summaryrefslogtreecommitdiffstats
path: root/toolkit
diff options
context:
space:
mode:
authorjanekptacijarabaci <janekptacijarabaci@seznam.cz>2018-05-06 14:31:20 +0200
committerjanekptacijarabaci <janekptacijarabaci@seznam.cz>2018-05-06 14:31:20 +0200
commit4b7a2c677a8bda717cbc21f8e06ee43c0d9f0005 (patch)
treeea479247696202858d088702ecd85b4163c4750a /toolkit
parent7d5f95a8e57de5255ad2767342c1f2392b6f261f (diff)
downloadUXP-4b7a2c677a8bda717cbc21f8e06ee43c0d9f0005.tar
UXP-4b7a2c677a8bda717cbc21f8e06ee43c0d9f0005.tar.gz
UXP-4b7a2c677a8bda717cbc21f8e06ee43c0d9f0005.tar.lz
UXP-4b7a2c677a8bda717cbc21f8e06ee43c0d9f0005.tar.xz
UXP-4b7a2c677a8bda717cbc21f8e06ee43c0d9f0005.zip
moebius#231: Consider blocking top level window data: URIs (tests)
https://github.com/MoonchildProductions/moebius/pull/231
Diffstat (limited to 'toolkit')
-rw-r--r--toolkit/components/printing/tests/browser.ini3
-rw-r--r--toolkit/components/printing/tests/browser_page_change_print_original.js13
-rw-r--r--toolkit/components/printing/tests/file_page_change_print_original_1.html8
-rw-r--r--toolkit/components/printing/tests/file_page_change_print_original_2.html1
-rw-r--r--toolkit/mozapps/extensions/test/xpinstall/browser_datauri.js8
5 files changed, 28 insertions, 5 deletions
diff --git a/toolkit/components/printing/tests/browser.ini b/toolkit/components/printing/tests/browser.ini
index 88d6bb454..5f2867189 100644
--- a/toolkit/components/printing/tests/browser.ini
+++ b/toolkit/components/printing/tests/browser.ini
@@ -1,2 +1,5 @@
[browser_page_change_print_original.js]
+support-files =
+ file_page_change_print_original_1.html
+ file_page_change_print_original_2.html
skip-if = os == "mac"
diff --git a/toolkit/components/printing/tests/browser_page_change_print_original.js b/toolkit/components/printing/tests/browser_page_change_print_original.js
index 5990a486b..864150451 100644
--- a/toolkit/components/printing/tests/browser_page_change_print_original.js
+++ b/toolkit/components/printing/tests/browser_page_change_print_original.js
@@ -3,8 +3,11 @@
* and we re-initialize print preview (e.g. by changing page orientation),
* we still show (and will therefore print) the original contents.
*/
+const TEST_PATH = getRootDirectory(gTestPath)
+ .replace("chrome://mochitests/content", "http://example.com");
+
add_task(function* pp_after_orientation_change() {
- const DATA_URI = `data:text/html,<script>window.onafterprint = function() { setTimeout("window.location = 'data:text/plain,REPLACED PAGE!'", 0); }</script><pre>INITIAL PAGE</pre>`;
+ const URI = TEST_PATH + "file_page_change_print_original_1.html";
// Can only do something if we have a print preview UI:
if (AppConstants.platform != "win" && AppConstants.platform != "linux") {
ok(true, "Can't test if there's no print preview.");
@@ -12,7 +15,7 @@ add_task(function* pp_after_orientation_change() {
}
// Ensure we get a browserStopped for this browser
- let tab = yield BrowserTestUtils.openNewForegroundTab(gBrowser, DATA_URI, false, true);
+ let tab = yield BrowserTestUtils.openNewForegroundTab(gBrowser, URI, false, true);
let browserToPrint = tab.linkedBrowser;
let ppBrowser = PrintPreviewListener.getPrintPreviewBrowser();
@@ -26,7 +29,7 @@ add_task(function* pp_after_orientation_change() {
// Assert that we are showing the original page
yield ContentTask.spawn(ppBrowser, null, function* () {
- is(content.document.body.textContent, "INITIAL PAGE", "Should have initial page print previewed.");
+ is(content.document.body.textContent.trim(), "INITIAL PAGE", "Should have initial page print previewed.");
});
yield originalTabNavigated;
@@ -43,12 +46,12 @@ add_task(function* pp_after_orientation_change() {
// Check that we're still showing the original page.
yield ContentTask.spawn(ppBrowser, null, function* () {
- is(content.document.body.textContent, "INITIAL PAGE", "Should still have initial page print previewed.");
+ is(content.document.body.textContent.trim(), "INITIAL PAGE", "Should still have initial page print previewed.");
});
// Check that the other tab is definitely showing the new page:
yield ContentTask.spawn(browserToPrint, null, function* () {
- is(content.document.body.textContent, "REPLACED PAGE!", "Original page should have changed.");
+ is(content.document.body.textContent.trim(), "REPLACED PAGE!", "Original page should have changed.");
});
PrintUtils.exitPrintPreview();
diff --git a/toolkit/components/printing/tests/file_page_change_print_original_1.html b/toolkit/components/printing/tests/file_page_change_print_original_1.html
new file mode 100644
index 000000000..76e3be137
--- /dev/null
+++ b/toolkit/components/printing/tests/file_page_change_print_original_1.html
@@ -0,0 +1,8 @@
+<script>
+window.onafterprint = function() {
+ setTimeout(function() {
+ window.location = "file_page_change_print_original_2.html"
+ }, 0);
+}
+</script>
+<pre>INITIAL PAGE</pre>
diff --git a/toolkit/components/printing/tests/file_page_change_print_original_2.html b/toolkit/components/printing/tests/file_page_change_print_original_2.html
new file mode 100644
index 000000000..44f33281c
--- /dev/null
+++ b/toolkit/components/printing/tests/file_page_change_print_original_2.html
@@ -0,0 +1 @@
+REPLACED PAGE!
diff --git a/toolkit/mozapps/extensions/test/xpinstall/browser_datauri.js b/toolkit/mozapps/extensions/test/xpinstall/browser_datauri.js
index 917f2465d..b24bce4b5 100644
--- a/toolkit/mozapps/extensions/test/xpinstall/browser_datauri.js
+++ b/toolkit/mozapps/extensions/test/xpinstall/browser_datauri.js
@@ -13,6 +13,13 @@ function setup_redirect(aSettings) {
}
function test() {
+ waitForExplicitFinish();
+ SpecialPowers.pushPrefEnv({
+ "set": [["security.data_uri.block_toplevel_data_uri_navigations", false]]
+ }, runTest);
+}
+
+function runTest() {
Harness.installOriginBlockedCallback = install_blocked;
Harness.installsCompletedCallback = finish_test;
Harness.setup();
@@ -33,4 +40,5 @@ function finish_test(count) {
gBrowser.removeCurrentTab();
Harness.finish();
+ finish();
}