summaryrefslogtreecommitdiffstats
path: root/dom/base/test/browser_messagemanager_targetframeloader.js
blob: 32575d0738d6f53c619c5f2d3af45961a075ce2d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
function frameScript()
{
  sendSyncMessage("Test:Message");
  sendAsyncMessage("Test:Message");
  sendAsyncMessage("Test:Done");
}

function test() {
  waitForExplicitFinish();

  var newTab = gBrowser.addTab("about:blank");
  gBrowser.selectedTab = newTab;

  let browser = newTab.linkedBrowser;
  let frameLoader = browser.frameLoader;
  ok(frameLoader !== null, "frameLoader looks okay");

  browser.messageManager.loadFrameScript("data:,(" + frameScript.toString() + ")()", false);

  browser.messageManager.addMessageListener("Test:Message", (msg) => {
    ok(msg.target === browser, "<browser> is correct");
    ok(msg.targetFrameLoader === frameLoader, "frameLoader is correct");
    ok(browser.frameLoader === msg.targetFrameLoader, "browser frameloader is correct");
  });

  browser.messageManager.addMessageListener("Test:Done", () => {
    info("Finished");
    gBrowser.removeCurrentTab();
    finish();
  });
}