Bug 1572895 - Update some XPConnect mochitests to work under Fission. r=mccr8

Differential Revision: https://phabricator.services.mozilla.com/D41469

--HG--
extra : rebase_source : 7a0f5bc5ff17b3c7a0fd1b72239546b894089983
This commit is contained in:
Kris Maglione 2019-08-09 17:44:48 -07:00
parent 722b4d5a57
commit e0f52079d4
6 changed files with 45 additions and 29 deletions

View File

@ -43,7 +43,6 @@ support-files =
[test_bug390488.html]
[test_bug393269.html]
[test_bug396851.html]
fail-if = fission
[test_bug428021.html]
[test_bug446584.html]
[test_bug462428.html]
@ -53,7 +52,6 @@ fail-if = fission
[test_bug504877.html]
fail-if = fission
[test_bug505915.html]
fail-if = fission
[test_bug560351.html]
[test_bug585745.html]
[test_bug589028.html]
@ -64,10 +62,10 @@ fail-if = fission
[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]
@ -83,22 +81,21 @@ skip-if = toolkit == "android" && debug && !is_fennec
[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
@ -122,8 +119,6 @@ skip-if = (debug == false)
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

View File

@ -9,18 +9,30 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=396851
<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");
doc = SpecialPowers.wrap(win).document;
ok(doc != null, "Able to access the 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");
}
SimpleTest.finish();
}
</script>

View File

@ -45,7 +45,7 @@ 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>

View File

@ -19,19 +19,19 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=829872
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();
}

View File

@ -18,7 +18,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=916945
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");
@ -30,13 +30,18 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=916945
// 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.

View File

@ -1296,6 +1296,10 @@ class SpecialPowersAPI extends JSWindowActorChild {
return this._os;
}
get useRemoteSubframes() {
return this.docShell.nsILoadContext.useRemoteSubframes;
}
addSystemEventListener(target, type, listener, useCapture) {
Services.els.addSystemEventListener(target, type, listener, useCapture);
}