Bug 1572895 - Update some XPConnect mochitests to work under Fission. r=mccr8
authorKris Maglione <maglione.k@gmail.com>
Fri, 09 Aug 2019 17:44:48 -0700
changeset 488072 4477d849b72a0cf15159b1f99a8530a250575365
parent 488071 0fae715f6c26e75f825c7c6cbd694d19522ebf27
child 488073 4546e42005a04b3cb98bbf315bd8a986f772f543
push id36435
push usercbrindusan@mozilla.com
push dateThu, 15 Aug 2019 09:46:49 +0000
treeherdermozilla-central@0db07ff50ab5 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmccr8
bugs1572895
milestone70.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 1572895 - Update some XPConnect mochitests to work under Fission. r=mccr8 Differential Revision: https://phabricator.services.mozilla.com/D41469
js/xpconnect/tests/mochitest/mochitest.ini
js/xpconnect/tests/mochitest/test_bug396851.html
js/xpconnect/tests/mochitest/test_bug505915.html
js/xpconnect/tests/mochitest/test_bug829872.html
js/xpconnect/tests/mochitest/test_bug916945.html
testing/specialpowers/content/SpecialPowersAPI.jsm
--- a/js/xpconnect/tests/mochitest/mochitest.ini
+++ b/js/xpconnect/tests/mochitest/mochitest.ini
@@ -38,72 +38,69 @@ support-files =
   inner.html
   test1_bug629331.html
   test2_bug629331.html
 
 [test_bug384632.html]
 [test_bug390488.html]
 [test_bug393269.html]
 [test_bug396851.html]
-fail-if = fission
 [test_bug428021.html]
 [test_bug446584.html]
 [test_bug462428.html]
 [test_bug478438.html]
 fail-if = fission
 [test_bug500691.html]
 [test_bug504877.html]
 fail-if = fission
 [test_bug505915.html]
-fail-if = fission
 [test_bug560351.html]
 [test_bug585745.html]
 [test_bug589028.html]
 [test_bug601299.html]
 [test_bug605167.html]
 [test_bug618017.html]
 [test_bug623437.html]
 [test_bug628410.html]
 [test_bug628794.html]
 [test_bug629227.html]
-fail-if = fission
+skip-if = fission # Times out.
 [test_bug629331.html]
 [test_bug636097.html]
-fail-if = fission
+fail-if = fission # Bug 1573621: window.location access after cross-origin navigation.
 [test_bug650273.html]
 [test_bug655297-1.html]
 [test_bug655297-2.html]
 [test_bug661980.html]
 [test_bug691059.html]
 [test_bug720619.html]
 [test_bug731471.html]
 skip-if = toolkit == "android" && debug && !is_fennec
 [test_bug764389.html]
 [test_bug772288.html]
 [test_bug781476.html]
 [test_bug789713.html]
 [test_bug790732.html]
 [test_bug793969.html]
 [test_bug800864.html]
-fail-if = fission
+fail-if = fission # Bug 1573621: window.location access after cross-origin navigation.
 [test_bug802557.html]
 skip-if = fission # Crashes: @ mozilla::dom::ContentParent::RecvDetachBrowsingContext(unsigned long, std::function<void (bool const&)>&&)
-fail-if = fission
+fail-if = fission # Bug 1573621: window.location access after cross-origin navigation.
 [test_bug803730.html]
 [test_bug809547.html]
 [test_bug829872.html]
-fail-if = fission
 [test_bug862380.html]
 [test_bug865260.html]
 [test_bug870423.html]
-fail-if = fission
+fail-if = fission # isinstance hooks for remote object proxies.
 [test_bug871887.html]
 [test_bug912322.html]
 [test_bug916945.html]
-fail-if = fission
+fail-if = fission # "name" attribute on cross-origin frames
 [test_bug92773.html]
 [test_bug940783.html]
 fail-if = fission
 [test_bug965082.html]
 fail-if = fission
 skip-if = fission && webrender && debug # Crashes intermittently: @ nsDocShell::SetParentWidget(nsIWidget*)
 [test_bug960820.html]
 [test_bug986542.html]
@@ -117,14 +114,12 @@ skip-if = fission && webrender && debug 
 # The JS test component we use below is only available in debug builds.
 [test_getWebIDLCaller.html]
 skip-if = (debug == false)
 [test_getweakmapkeys.html]
 [test_paris_weakmap_keys.html]
 skip-if = (debug == false)
 [test_nukeContentWindow.html]
 [test_sameOriginPolicy.html]
-skip-if = fission # Crashes: @ nsOuterWindowProxy::GetSubframeWindow(JSContext*, JS::Handle<JSObject*>, JS::Handle<JS::PropertyKey>) const
-fail-if = fission
 [test_sandbox_fetch.html]
   support-files =
     ../../../../dom/tests/mochitest/fetch/test_fetch_basic.js
 [test_weakmaps.html]
--- a/js/xpconnect/tests/mochitest/test_bug396851.html
+++ b/js/xpconnect/tests/mochitest/test_bug396851.html
@@ -4,28 +4,40 @@
 https://bugzilla.mozilla.org/show_bug.cgi?id=396851
 -->
 <head>
   <title>Test for Bug 396851</title>
   <script src="/tests/SimpleTest/SimpleTest.js"></script>
   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
 
   <script type="text/javascript">
+  function throws(func, pattern, msg) {
+    try {
+      func();
+      ok(false, msg);
+    } catch (e) {
+      ok(pattern.test(e), `${msg}: Expect exception mathing ${pattern}`);
+    }
+  }
+
   function go() {
     var iframe = $("ifr");
     var win = iframe.contentWindow;
-    try {
-      var doc = win.document;
-      fail("Allowed cross-origin access to the document");
-    } catch (e) {
-      ok(e.toString().match("Permission denied") != null, "Weird exception thrown");
+    throws(() => win.document,
+           /Permission denied/,
+           "Unprivileged code should not be able to access cross-origin document");
+
+    if (SpecialPowers.useRemoteSubframes) {
+      throws(() => win.document,
+             /Permission denied/,
+             "Privileged code should not be able to access cross-process document");
+    } else {
+      ok(SpecialPowers.wrap(win).document != null,
+         "Able to access the cross-origin document");
     }
-
-    doc = SpecialPowers.wrap(win).document;
-    ok(doc != null, "Able to access the cross-origin document");
     SimpleTest.finish();
   }
   </script>
 </head>
 <body>
 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=396851">Mozilla Bug 396851</a>
 <p id="display"></p>
 <div id="content" style="display: none">
--- a/js/xpconnect/tests/mochitest/test_bug505915.html
+++ b/js/xpconnect/tests/mochitest/test_bug505915.html
@@ -40,12 +40,12 @@ function go() {
     SimpleTest.finish();
 }
 
 SimpleTest.waitForExplicitFinish();
 
 </script>
 </pre>
 
-<iframe id="ifr" onload="go();" src="http://example.org/"></iframe>
+<iframe id="ifr" onload="go();" src="http://test1.mochi.test:8888/"></iframe>
 
 </body>
 </html>
--- a/js/xpconnect/tests/mochitest/test_bug829872.html
+++ b/js/xpconnect/tests/mochitest/test_bug829872.html
@@ -14,29 +14,29 @@ https://bugzilla.mozilla.org/show_bug.cg
   SimpleTest.waitForExplicitFinish();
 
   var gLoadCount = 0;
   function loaded() {
     if (++gLoadCount == 3)
       go();
   }
 
-  function check(elem, desc) {
+  async function check(elem, desc) {
     is(elem.contentDocument, null, "null cross-origin contentDocument for " + desc);
-    ok(SpecialPowers.wrap(elem).contentWindow.eval('frameElement === null;'),
+    ok(await SpecialPowers.spawn(elem, [], () => this.content.eval('frameElement === null;')),
        "null cross-origin frameElement for " + desc);
     if (!(elem instanceof HTMLFrameElement))
       is(elem.getSVGDocument(), null, "null cross-origin getSVGDocument() for " + desc);
   }
 
-  function go() {
+  async function go() {
     ok(true, "Starting test");
-    check($('ifr'), "iframe element");
-    check($('obj'), "object element");
-    check($('framesetholder').contentDocument.getElementById('fr'), "frameset frame");
+    await check($('ifr'), "iframe element");
+    await check($('obj'), "object element");
+    await check($('framesetholder').contentDocument.getElementById('fr'), "frameset frame");
     SimpleTest.finish();
   }
 
   </script>
 </head>
 <body>
 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=829872">Mozilla Bug 829872</a>
 <p id="display"></p>
--- a/js/xpconnect/tests/mochitest/test_bug916945.html
+++ b/js/xpconnect/tests/mochitest/test_bug916945.html
@@ -13,35 +13,40 @@ https://bugzilla.mozilla.org/show_bug.cg
   /** Test for Bug 916945 **/
   SimpleTest.waitForExplicitFinish();
 
   var gLoadCount = 0;
   function loaded() {
     if (++gLoadCount == 2)
       go();
   }
-  function go() {
+  async function go() {
     // Both same-origin and cross-origin names should be visible if they're set
     // on the iframe element.
     ok('winA' in window, "same-origin named access works");
     ok(winA instanceof Window, "same-origin named access works");
     ok('winB' in window, "cross-origin named access works when iframe name matches");
     // XXXbholley - flip me when Window moves to new bindings.
     todo_is(winB instanceof Window, "cross-origin named access works when iframe name matches");
 
     // Setting the 'name' attribute should propagate to the docshell.
     var ifrB = document.getElementById('ifrB');
     ifrB.setAttribute('name', 'foo');
-    is(SpecialPowers.wrap(ifrB).contentWindow.name, 'foo', 'attribute sets propagate to the docshell');
+    await SpecialPowers.spawn(ifrB, [], () => {
+      Assert.equal(this.content.name, 'foo',
+                   'attribute sets propagate to the docshell');
+    });
     ok('foo' in window, "names are dynamic if updated via setAttribute");
     // XXXbholley - flip me when Window moves to new bindings.
     todo('foo' instanceof Window, "names are dynamic if updated via setAttribute");
 
     // Setting window.name on the subframe should not propagate to the attribute.
-    SpecialPowers.wrap(ifrB).contentWindow.name = 'bar';
+    await SpecialPowers.spawn(ifrB, [], () => {
+      this.content.name = "bar";
+    });
     is(ifrB.getAttribute('name'), 'foo', 'docshell updates dont propagate to the attribute');
 
     // When the frame element attribute and docshell name don't match, nothing is returned.
     ok(!('foo' in window), "frame element name not resolved if it doesn't match the docshell");
     ok(!('bar' in window), "docshell name not resolved if it doesn't match the frame element");
 
     SimpleTest.finish();
   }
--- a/testing/specialpowers/content/SpecialPowersAPI.jsm
+++ b/testing/specialpowers/content/SpecialPowersAPI.jsm
@@ -1291,16 +1291,20 @@ class SpecialPowersAPI extends JSWindowA
     if (this._os != null) {
       return this._os;
     }
 
     this._os = Services.appinfo.OS;
     return this._os;
   }
 
+  get useRemoteSubframes() {
+    return this.docShell.nsILoadContext.useRemoteSubframes;
+  }
+
   addSystemEventListener(target, type, listener, useCapture) {
     Services.els.addSystemEventListener(target, type, listener, useCapture);
   }
   removeSystemEventListener(target, type, listener, useCapture) {
     Services.els.removeSystemEventListener(target, type, listener, useCapture);
   }
 
   // helper method to check if the event is consumed by either default group's