Bug 1403814 - Update tests for toplevel data URI blocking because we know block after we have received the response. r=smaug

This commit is contained in:
Christoph Kerschbaumer 2017-11-03 13:22:57 +01:00
parent 8f13729a0f
commit 60bd93b916
2 changed files with 16 additions and 18 deletions

View File

@ -34,15 +34,17 @@ function test_toplevel_data_image_svg() {
const DATA_SVG =
"data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxNiIgaGVpZ2h0PSIxNiIgdmlld0JveD0iMCAwIDE2IDE2Ij4KICA8cGF0aCBkPSJNOCwxMkwzLDcsNCw2bDQsNCw0LTQsMSwxWiIgZmlsbD0iIzZBNkE2QSIgLz4KPC9zdmc+Cg==";
let win2 = window.open(DATA_SVG);
let wrappedWin2 = SpecialPowers.wrap(win2);
setTimeout(function () {
isnot(wrappedWin2.document.documentElement.localName, "svg",
"Loading data:image/svg+xml should be blocked");
wrappedWin2.close();
SimpleTest.finish();
}, 1000);
// Unfortunately we can't detect whether the window was closed using some event,
// hence we are constantly polling till we see that win == null.
// Test times out on failure.
var win2Closed = setInterval(function() {
if (win2 == null || win2.closed) {
clearInterval(win2Closed);
ok(true, "Loading data:image/svg+xml should be blocked");
SimpleTest.finish();
}
}, 200);
}
// fire up the tests
test_toplevel_data_image();

View File

@ -21,16 +21,12 @@ 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);
var readyStateCheckInterval = setInterval(function() {
let state = win1.document.readyState;
if (state === "interactive" || state === "complete") {
clearInterval(readyStateCheckInterval);
ok(win1.document.body.innerHTML.indexOf("test1:") !== -1,
"toplevel data: URI navigation through click() should be blocked");
win1.close();
test2();
}
}, 200);
setTimeout(function () {
ok(SpecialPowers.wrap(win1).document.body.innerHTML.indexOf("test1:") !== -1,
"toplevel data: URI navigation through click() should be blocked");
win1.close();
test2();
}, 1000);
}
function test2() {