Bug 1414541 - Intermittent failure fixed for toplevel data: URI. r=ckerschb

This commit is contained in:
vinoth 2018-03-21 17:18:00 -04:00
Родитель 06789a9851
Коммит c28a0c2d53
3 изменённых файлов: 31 добавлений и 4 удалений

Просмотреть файл

@ -6,7 +6,10 @@
</head>
<body>
test1: clicking data: URI tries to navigate window<br/>
<a id="testlink" href="data:text/html,<body>toplevel data: URI navigations should be blocked</body>">click me</a>
<!-- postMessage will not be sent if data: URI is blocked -->
<a id="testlink" href="data:text/html,<body><script
window.opener.postMessage('test1','*');</script>toplevel data: URI navigations
should be blocked</body>">click me</a>
<script>
document.getElementById('testlink').click();
</script>

Просмотреть файл

@ -7,7 +7,10 @@
<body>
test3: performing data: URI navigation through win.loc.href<br/>
<script>
window.location.href = "data:text/html,<body>toplevel data: URI navigations should be blocked</body>";
// postMessage will not be sent if data: URI is blocked
window.location.href = "data:text/html,<body><script>" +
"window.opener.postMessage('test3','*');<\/script>toplevel data: URI " +
"navigations should be blocked</body>";
</script>
</body>
</html>

Просмотреть файл

@ -17,12 +17,32 @@ SimpleTest.registerCleanupFunction(() => {
SimpleTest.waitForExplicitFinish();
SimpleTest.requestFlakyTimeout("have to test that top level data: URI navgiation is blocked");
var testsToRun = {
test1: false,
test3: false,
};
// test1 and test3 event messages will not be received if toplevel data: URI
// is blocked.
window.addEventListener("message", receiveMessage);
function receiveMessage(event) {
switch (event.data) {
case "test1":
testsToRun["test1"] = true;
break;
case "test3":
testsToRun["test3"] = true;
break;
}
}
function test1() {
// simple data: URI click navigation should be prevented
let TEST_FILE = "file_block_toplevel_data_navigation.html";
let win1 = window.open(TEST_FILE);
// testsToRun["test1"] will be false if toplevel data: URI is blocked
setTimeout(function () {
ok(SpecialPowers.wrap(win1).document.body.innerHTML.includes("test1:"),
is(testsToRun["test1"], false,
"toplevel data: URI navigation through click() should be blocked");
win1.close();
test2();
@ -45,8 +65,9 @@ function test2() {
function test3() {
// navigating to a data: URI using window.location.href should be blocked
let win3 = window.open("file_block_toplevel_data_navigation3.html");
// testsToRun["test3"] will be false if toplevel data: URI is blocked
setTimeout(function () {
ok(win3.document.body.innerHTML.includes("test3:"),
is(testsToRun["test3"], false,
"data: URI navigation through win.loc.href should be blocked");
win3.close();
test4();