From c28a0c2d53dbd67b79c7f53e631c06f301b852f8 Mon Sep 17 00:00:00 2001 From: vinoth Date: Wed, 21 Mar 2018 17:18:00 -0400 Subject: [PATCH] Bug 1414541 - Intermittent failure fixed for toplevel data: URI. r=ckerschb --- .../file_block_toplevel_data_navigation.html | 5 +++- .../file_block_toplevel_data_navigation3.html | 5 +++- .../test_block_toplevel_data_navigation.html | 25 +++++++++++++++++-- 3 files changed, 31 insertions(+), 4 deletions(-) diff --git a/dom/security/test/general/file_block_toplevel_data_navigation.html b/dom/security/test/general/file_block_toplevel_data_navigation.html index 5fbfdfdef4d6..3d83b7ff6342 100644 --- a/dom/security/test/general/file_block_toplevel_data_navigation.html +++ b/dom/security/test/general/file_block_toplevel_data_navigation.html @@ -6,7 +6,10 @@ test1: clicking data: URI tries to navigate window
-click me + +click me diff --git a/dom/security/test/general/file_block_toplevel_data_navigation3.html b/dom/security/test/general/file_block_toplevel_data_navigation3.html index 34aeddab3650..3743a72034dc 100644 --- a/dom/security/test/general/file_block_toplevel_data_navigation3.html +++ b/dom/security/test/general/file_block_toplevel_data_navigation3.html @@ -7,7 +7,10 @@ test3: performing data: URI navigation through win.loc.href
diff --git a/dom/security/test/general/test_block_toplevel_data_navigation.html b/dom/security/test/general/test_block_toplevel_data_navigation.html index 1b57d78ead08..a405d4e3ee58 100644 --- a/dom/security/test/general/test_block_toplevel_data_navigation.html +++ b/dom/security/test/general/test_block_toplevel_data_navigation.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();