--- a/caps/tests/mochitest/test_principal_jarprefix_origin_appid_appstatus.html
+++ b/caps/tests/mochitest/test_principal_jarprefix_origin_appid_appstatus.html
@@ -28,16 +28,18 @@ SimpleTest.waitForExplicitFinish();
* - app: gives the app manifest URL, will set mozapp to it on the iframe;
* - origin: gives the origin of the iframe. This is the URL thas is going to
* to be passed as iframe.src but also the expected principal's
* origin.
* - isapp: tells if the iframe is really a mozapp. If the manifest url isn't
* valid, the iframe will not be considered as a mozapp.
* - browser: say if the iframe should be a mozbrowser. This is implicit when
* app is set.
+ * - isolated: if origin isolation is enabled with browser frames. Defaults to
+ * true if unset.
* - test: an array of tests to run for this test case:
* - eo-unique: the extendedOrigin of the prinicpal must be unique in the
* current list.
* - eo-as-last: the extendedOrigin of the principal must be the same as the
* last added to the list.
*/
var gData = [
{
@@ -225,28 +227,71 @@ var gData = [
browser: false,
child: {
src: "http://example.org/chrome/",
isapp: false,
browser: true,
},
test: [ "child-has-different-eo", "child-has-same-appstatus", "child-has-same-appid" ],
},
- // browser containing an iframe is part of the browser
+ // browser containing an iframe that is part of the browser
{
src: "http://example.org/",
isapp: false,
browser: true,
child: {
src: "http://example.org/chrome/",
isapp: false,
inIsolatedMozBrowser: true,
},
test: [ "child-has-same-eo" ],
},
+ // iframe containing a browser with isolation disabled
+ // (only chrome documents can disable isolation)
+ {
+ src: "http://example.org/",
+ isapp: false,
+ browser: false,
+ child: {
+ src: "http://example.org/chrome/",
+ isapp: false,
+ browser: true,
+ isolated: false,
+ inIsolatedMozBrowser: true,
+ },
+ test: [ "child-has-different-eo" ],
+ },
+ // browser with isolation disabled containing an iframe that is part of the browser
+ {
+ src: "http://example.org/",
+ isapp: false,
+ browser: true,
+ isolated: false,
+ child: {
+ src: "http://example.org/chrome/",
+ isapp: false,
+ inIsolatedMozBrowser: false,
+ },
+ test: [ "child-has-same-eo" ],
+ },
+ // iframe with isolation enabled containing an iframe with isolation disabled
+ // (isolated only has an effect on browsers)
+ {
+ src: "http://example.org/",
+ isapp: false,
+ browser: false,
+ isolated: true,
+ child: {
+ src: "http://example.org/chrome/",
+ isapp: false,
+ browser: false,
+ isolated: false,
+ },
+ test: [ "child-has-same-eo" ],
+ },
];
// The list of all data ids generated by this test.
var eoList = [];
var content = document.getElementById('content');
var checkedCount = 0;
var checksTodo = gData.length;
@@ -275,45 +320,59 @@ function checkIFrame(aFrame, data) {
}
} else {
is(principal.appStatus, Ci.nsIPrincipal.APP_STATUS_NOT_INSTALLED,
'this should not be an installed app');
is(principal.appId, Ci.nsIScriptSecurityManager.NO_APP_ID,
"principals from non-installed app should have NO_APP_ID");
}
- if (!data.isapp && !data.browser) {
+ if (!data.isapp && !data.browser ||
+ (data.browser && data.isolated === false)) {
is(principal.jarPrefix, "",
- 'jarPrefix should return an empty string for non-app and non-browsers principals');
+ "jarPrefix should return an empty string for non-app, non-browsers, " +
+ "and browsers with isolation disabled");
} else {
isnot(principal.jarPrefix, "",
- 'jarPrefix should not return an empty string for apps or mozbrowsers');
+ "jarPrefix should not return an empty string for apps or browsers " +
+ "with isolation enabled");
}
if (data.test.indexOf("eo-unique") != -1) {
is(eoList.indexOf(principal.jarPrefix + principal.origin), -1,
"extended origin should be unique");
}
if (data.test.indexOf("eo-as-last") != -1) {
is(principal.jarPrefix + principal.origin, eoList[eoList.length-1],
"extended origin should be the same as the last inserted one");
}
- is(principal.isInIsolatedMozBrowserElement, !!data.browser,
+ let isolationExpected = false;
+ if (data.isolated !== false) {
+ isolationExpected = !!data.browser;
+ }
+ is(principal.isInIsolatedMozBrowserElement, isolationExpected,
"check principal.isInIsolatedMozBrowserElement");
if (data.child) {
let childPrincipal = aFrame.contentWindow.frames[0].document.nodePrincipal;
if (data.child.isapp) {
is(childPrincipal.appStatus, Ci.nsIPrincipal.APP_STATUS_INSTALLED,
"child should be an installed app");
}
- is(childPrincipal.isInIsolatedMozBrowserElement, !!data.child.browser || !!data.child.inIsolatedMozBrowser,
+ let childIsolationExpected = false;
+ if (data.child.isolated !== false) {
+ childIsolationExpected = !!data.child.browser;
+ }
+ if (data.child.inIsolatedMozBrowser !== undefined) {
+ childIsolationExpected = data.child.inIsolatedMozBrowser;
+ }
+ is(childPrincipal.isInIsolatedMozBrowserElement, childIsolationExpected,
"check childPrincipal.isInIsolatedMozBrowserElement");
if (data.test.indexOf("child-has-same-eo") != -1) {
is(childPrincipal.jarPrefix + childPrincipal.origin,
principal.jarPrefix + principal.origin,
"child should have the same extended origin as parent");
is(childPrincipal.appStatus, principal.appStatus,
"child should have the same appStatus if it has the same extended origin");
@@ -387,46 +446,55 @@ function runTest() {
if (data.child.app) {
childFrame.setAttribute('mozapp', data.child.app)
childFrame.setAttribute('mozbrowser', '');
} else if (data.child.browser) {
childFrame.setAttribute('mozbrowser', '');
}
+ if (data.child.isolated === false) {
+ childFrame.setAttribute("noisolation", "");
+ }
+
childFrame.src = data.child.src;
this.removeEventListener('load', this.addChild.bind(this));
childFrame.addEventListener('load', this.check.bind(this));
this.contentDocument.body.appendChild(childFrame);
};
if (data.app) {
iframe.setAttribute('mozapp', data.app);
iframe.setAttribute('mozbrowser', '');
} else if (data.browser) {
iframe.setAttribute('mozbrowser', '');
}
+ if (data.isolated === false) {
+ iframe.setAttribute("noisolation", "");
+ }
+
iframe.src = data.src;
if (data.child) {
iframe.addEventListener('load', iframe.addChild.bind(iframe));
} else {
iframe.addEventListener('load', iframe.check.bind(iframe));
}
content.appendChild(iframe);
yield;
}
}
var gTestRunner = runTest();
-SpecialPowers.pushPrefEnv({'set':[["dom.mozBrowserFramesEnabled", true]]},
- function() { gTestRunner.next(); });
+SpecialPowers.pushPrefEnv({"set": [
+ ["dom.mozBrowserFramesEnabled", true],
+]}, function() { gTestRunner.next(); });
</script>
</pre>
</body>
</html>