Bug 1531837 - Part 2: Add testcase with allFrames and includeChrome for JS Window Actors, r=nika
authorJohn Dai <jdai@mozilla.com>
Thu, 07 Mar 2019 15:13:44 +0000
changeset 520835 5fdc6018b45ba5b8dfd202d3b2ffb46aa20d06f7
parent 520834 dc0a6a6383984ea1b60fe9dde982620e3869be1a
child 520836 636611b6dfee1f0caa6374fc3b331b19ea8cc2de
push id10862
push userffxbld-merge
push dateMon, 11 Mar 2019 13:01:11 +0000
treeherdermozilla-beta@a2e7f5c935da [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnika
bugs1531837
milestone67.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1531837 - Part 2: Add testcase with allFrames and includeChrome for JS Window Actors, r=nika Depends on D22472 Differential Revision: https://phabricator.services.mozilla.com/D22473
dom/ipc/tests/browser_JSWindowActor.js
--- a/dom/ipc/tests/browser_JSWindowActor.js
+++ b/dom/ipc/tests/browser_JSWindowActor.js
@@ -47,16 +47,73 @@ add_task(async function test_getActor() 
           let actorChild = child.getActor("Test");
           is(actorChild.show(), "TestChild", "actor show should have vaule.");
           is(actorChild.manager, child, "manager should match WindowGlobalChild.");
         });
       ChromeUtils.unregisterWindowActor("Test");
     });
 });
 
+add_task(async function test_getActor_without_allFrames() {
+  windowActorOptions.allFrames = false;
+  await BrowserTestUtils.withNewTab({gBrowser, url: URL},
+    async function(browser) {
+      ChromeUtils.registerWindowActor("Test", windowActorOptions);
+      await ContentTask.spawn(
+        browser, {}, async function() {
+          // Create and append an iframe into the window's document.
+          let frame = content.document.createElement("iframe");
+          content.document.body.appendChild(frame);
+          is(content.window.frames.length, 1, "There should be an iframe.");
+          let child = frame.contentWindow.window.getWindowGlobalChild();
+          Assert.throws(() => child.getActor("Test"),
+            /NS_ERROR_NOT_AVAILABLE/, "Should throw if allFrames is false.");
+        });
+      ChromeUtils.unregisterWindowActor("Test");
+    });
+});
+
+add_task(async function test_getActor_with_allFrames() {
+  windowActorOptions.allFrames = true;
+  ChromeUtils.registerWindowActor("Test", windowActorOptions);
+  await BrowserTestUtils.withNewTab({gBrowser, url: URL},
+    async function(browser) {
+      await ContentTask.spawn(
+        browser, {}, async function() {
+          // Create and append an iframe into the window's document.
+          let frame = content.document.createElement("iframe");
+          content.document.body.appendChild(frame);
+          is(content.window.frames.length, 1, "There should be an iframe.");
+          let child = frame.contentWindow.window.getWindowGlobalChild();
+          let actorChild = child.getActor("Test");
+          ok(actorChild, "JSWindowActorChild should have value.");
+        });
+    });
+    ChromeUtils.unregisterWindowActor("Test");
+});
+
+add_task(async function test_getActor_without_includeChrome() {
+  windowActorOptions.includeChrome = false;
+  let parent = window.docShell.browsingContext.currentWindowGlobal;
+  ChromeUtils.registerWindowActor("Test", windowActorOptions);
+  SimpleTest.doesThrow(() =>
+    parent.getActor("Test"),
+    "Should throw if includeChrome is false.");
+  ChromeUtils.unregisterWindowActor("Test");
+});
+
+add_task(async function test_getActor_with_includeChrome() {
+  windowActorOptions.includeChrome = true;
+  ChromeUtils.registerWindowActor("Test", windowActorOptions);
+  let parent = window.docShell.browsingContext.currentWindowGlobal;
+  let actorParent = parent.getActor("Test");
+  ok(actorParent, "JSWindowActorParent should have value.");
+  ChromeUtils.unregisterWindowActor("Test");
+});
+
 add_task(async function test_asyncMessage() {
   await BrowserTestUtils.withNewTab({gBrowser, url: URL},
     async function(browser) {
       ChromeUtils.registerWindowActor("Test", windowActorOptions);
       let parent = browser.browsingContext.currentWindowGlobal;
       let actorParent = parent.getActor("Test");
       ok(actorParent, "JSWindowActorParent should have value.");