Bug 1407891: Test navigation for right-click view-image on data:image/svg. r=bz

This commit is contained in:
Christoph Kerschbaumer 2017-11-08 17:43:26 +01:00
parent 6584da597b
commit 1ea20715d4
3 changed files with 45 additions and 0 deletions

View File

@ -9,3 +9,6 @@ support-files =
[browser_test_data_text_csv.js]
support-files =
file_data_text_csv.html
[browser_test_view_image_data_navigation.js]
support-files =
file_view_image_data_navigation.html

View File

@ -0,0 +1,30 @@
"use strict";
const TEST_PAGE = getRootDirectory(gTestPath) + "file_view_image_data_navigation.html";
add_task(async function test_principal_right_click_open_link_in_new_tab() {
await SpecialPowers.pushPrefEnv({
"set": [["security.data_uri.block_toplevel_data_uri_navigations", true]],
});
await BrowserTestUtils.withNewTab(TEST_PAGE, async function(browser) {
let loadPromise = BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser, true);
// simulate right-click->view-image
BrowserTestUtils.waitForEvent(document, "popupshown", false, event => {
// These are operations that must be executed synchronously with the event.
document.getElementById("context-viewimage").doCommand();
event.target.hidePopup();
return true;
});
BrowserTestUtils.synthesizeMouseAtCenter("#testimage",
{ type: "contextmenu", button: 2 },
gBrowser.selectedBrowser);
await loadPromise;
await ContentTask.spawn(gBrowser.selectedBrowser, {}, async function() {
ok(content.document.location.toString().startsWith("data:image/svg+xml;"),
"data:image/svg navigation allowed through right-click view-image")
});
});
});

View File

@ -0,0 +1,12 @@
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>Bug 1407891: Test navigation for right-click view-image on data:image/svg</title>
</head>
<body>
<img id="testimage" src="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxNiIgaGVpZ2h0PSIxNiIgdmlld0JveD0iMCAwIDE2IDE2Ij4KICA8cGF0aCBkPSJNOCwxMkwzLDcsNCw2bDQsNCw0LTQsMSwxWiIgZmlsbD0iIzZBNkE2QSIgLz4KPC9zdmc+Cg=="></img>
</body>
</html>