fune/browser/components/originattributes/test/browser/file_windowOpenerRestrictionTarget.html
Tim Huang 1338dd1674 Bug 1339336 - Add a test case for pref "privacy.firstparty.isolate.restrict_opener_access". r=baku
MozReview-Commit-ID: GmnsHt2dumI

--HG--
extra : rebase_source : 202d66aec9e1cf91de37db28de2122c30db2916a
2017-02-16 10:15:54 +08:00

33 lines
986 B
HTML

<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title>title not set</title>
<script>
// If the query string is given, we are expecting the window.opener can be accessed
// across different first party domains, so we will match the cookie value.
// Otherwise, the access of window.opener should be treated as cross-origin.
// Therefore, it should fail at this setting.
let openerRestriction = true;
let cookieValue;
if (window.location.search.length > 0) {
cookieValue = window.location.search.substr(1);
openerRestriction = false;
}
try {
let openerFrame = window.opener.frames["child"];
let result = openerFrame.document.cookie === cookieValue;
if (result && !openerRestriction) {
document.title = "pass";
}
} catch (e) {
if (openerRestriction) {
document.title = "pass";
}
}
</script>
</head>
<body>
</body>
</html>