forked from mozilla/gecko-dev
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bug 1800279 - Add a test which checks document URI handling in sandbo…
…xed top level pages. r=aiunusov Differential Revision: https://phabricator.services.mozilla.com/D161936
- Loading branch information
Olli Pettay
authored and
Olli Pettay
committed
Nov 14, 2022
1 parent
eec3bcd
commit f2df7f5
Showing
3 changed files
with
67 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<!DOCTYPE HTML> | ||
<html> | ||
<head> | ||
<script src="/tests/SimpleTest/SimpleTest.js"></script> | ||
<script src="/tests/SimpleTest/ChromeTask.js"></script> | ||
<script> | ||
function test() { | ||
location.hash = "foobar" | ||
if (!document.documentURI.includes("#foobar")) { | ||
opener.postMessage("Wrong documentURI", "*"); | ||
window.close(); | ||
} else { | ||
ChromeTask.spawn(null, () => { | ||
return { | ||
documentURI: actorParent.documentURI.spec, | ||
principalURI: actorParent.documentPrincipal.URI.spec | ||
}; | ||
}).then((uriAndPrincipal) => { | ||
if (!uriAndPrincipal.documentURI.includes("#foobar")) { | ||
opener.postMessage("Wrong documentURI in the parent process", "*"); | ||
} else if (!uriAndPrincipal.principalURI.includes("moz-nullprincipal")) { | ||
opener.postMessage("Wrong document principal in the parent process", "*"); | ||
} else { | ||
opener.postMessage("done", "*"); | ||
} | ||
window.close(); | ||
}); | ||
} | ||
} | ||
</script> | ||
</head> | ||
<body onload="setTimeout(test)"> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<!DOCTYPE HTML> | ||
<html> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title>Test sandbox inheritance and document uri handling</title> | ||
<script src="/tests/SimpleTest/SimpleTest.js"></script> | ||
<link rel="stylesheet" href="/tests/SimpleTest/test.css"/> | ||
<script> | ||
add_task(async function() { | ||
await new Promise((resolve) => { | ||
window.onmessage = (event) => { | ||
is(event.data, "done"); | ||
resolve(); | ||
} | ||
}); | ||
}); | ||
</script> | ||
</head> | ||
<body> | ||
<p id="display"></p> | ||
<div id="content" style="display: none"></div> | ||
<pre id="test"></pre> | ||
<iframe sandbox="allow-popups allow-scripts" srcdoc= | ||
"<script> | ||
window.onmessage = function(event) { parent.postMessage(event.data, '*'); } | ||
/* Open a cross-origin page */ | ||
window.onload = function() { window.open('http://example.org/tests/dom/base/test/file_sandbox_and_document_uri.html'); } | ||
</script>" | ||
></iframe> | ||
</body> | ||
</html> |