summaryrefslogtreecommitdiffstats
path: root/browser/base/content/test/contextMenu
diff options
context:
space:
mode:
Diffstat (limited to 'browser/base/content/test/contextMenu')
-rw-r--r--browser/base/content/test/contextMenu/browser.toml4
-rw-r--r--browser/base/content/test/contextMenu/browser_contextmenu.js2
-rw-r--r--browser/base/content/test/contextMenu/browser_contextmenu_badiframe.js2
-rw-r--r--browser/base/content/test/contextMenu/browser_contextmenu_save_blocked.js2
-rw-r--r--browser/base/content/test/contextMenu/browser_strip_on_share_nested_link.js162
-rw-r--r--browser/base/content/test/contextMenu/contextmenu_common.js4
-rw-r--r--browser/base/content/test/contextMenu/subtst_contextmenu.html4
-rw-r--r--browser/base/content/test/contextMenu/subtst_contextmenu_webext.html2
8 files changed, 173 insertions, 9 deletions
diff --git a/browser/base/content/test/contextMenu/browser.toml b/browser/base/content/test/contextMenu/browser.toml
index 3eb6a1d606..660f6a955b 100644
--- a/browser/base/content/test/contextMenu/browser.toml
+++ b/browser/base/content/test/contextMenu/browser.toml
@@ -8,7 +8,6 @@ support-files = [
"subtst_contextmenu_xul.xhtml",
"ctxmenu-image.png",
"../general/head.js",
- "../general/video.ogg",
"../general/audio.ogg",
"../../../../../toolkit/components/pdfjs/test/file_pdfjs_test.pdf",
"contextmenu_common.js",
@@ -19,6 +18,7 @@ support-files = [
["browser_bug1798178.js"]
["browser_contextmenu.js"]
+support-files = [ "../general/video.webm" ]
tags = "fullscreen"
skip-if = [
"os == 'linux'",
@@ -86,6 +86,8 @@ skip-if = ["os == 'linux' && socketprocess_networking"]
["browser_strip_on_share_link.js"]
+["browser_strip_on_share_nested_link.js"]
+
["browser_utilityOverlay.js"]
https_first_disabled = true
skip-if = ["os == 'linux' && socketprocess_networking"]
diff --git a/browser/base/content/test/contextMenu/browser_contextmenu.js b/browser/base/content/test/contextMenu/browser_contextmenu.js
index ebeb4bdb04..00da3113c6 100644
--- a/browser/base/content/test/contextMenu/browser_contextmenu.js
+++ b/browser/base/content/test/contextMenu/browser_contextmenu.js
@@ -137,7 +137,7 @@ add_task(async function test_setup_html() {
audio.loop = true;
audio.src = "audio.ogg";
video.loop = true;
- video.src = "video.ogg";
+ video.src = "video.webm";
let awaitPause = ContentTaskUtils.waitForEvent(audio, "pause");
await ContentTaskUtils.waitForCondition(
diff --git a/browser/base/content/test/contextMenu/browser_contextmenu_badiframe.js b/browser/base/content/test/contextMenu/browser_contextmenu_badiframe.js
index 991a55af70..57d9808f5d 100644
--- a/browser/base/content/test/contextMenu/browser_contextmenu_badiframe.js
+++ b/browser/base/content/test/contextMenu/browser_contextmenu_badiframe.js
@@ -30,7 +30,7 @@ async function openTestPage() {
let pageAndIframesLoaded = BrowserTestUtils.browserLoaded(
browser,
true /* includeSubFrames */,
- url => {
+ () => {
expectedLoads--;
return !expectedLoads;
},
diff --git a/browser/base/content/test/contextMenu/browser_contextmenu_save_blocked.js b/browser/base/content/test/contextMenu/browser_contextmenu_save_blocked.js
index 062fbeac08..7e6b71e8e4 100644
--- a/browser/base/content/test/contextMenu/browser_contextmenu_save_blocked.js
+++ b/browser/base/content/test/contextMenu/browser_contextmenu_save_blocked.js
@@ -64,7 +64,7 @@ add_task(async function test_save_link_blocked_by_extension() {
setTimeout(resolve, 0);
};
- MockFilePicker.showCallback = function (fp) {
+ MockFilePicker.showCallback = function () {
ok(false, "filepicker should never been shown");
setTimeout(resolve, 0);
return Ci.nsIFilePicker.returnCancel;
diff --git a/browser/base/content/test/contextMenu/browser_strip_on_share_nested_link.js b/browser/base/content/test/contextMenu/browser_strip_on_share_nested_link.js
new file mode 100644
index 0000000000..d11649e648
--- /dev/null
+++ b/browser/base/content/test/contextMenu/browser_strip_on_share_nested_link.js
@@ -0,0 +1,162 @@
+/* Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/ */
+
+"use strict";
+
+let listService;
+
+const TEST_URL =
+ "https://example.com/browser/browser/base/content/test/general/dummy_page.html";
+
+add_setup(async function () {
+ await SpecialPowers.pushPrefEnv({
+ set: [["privacy.query_stripping.strip_list", "stripParam"]],
+ });
+
+ // Get the list service so we can wait for it to be fully initialized before running tests.
+ listService = Cc["@mozilla.org/query-stripping-list-service;1"].getService(
+ Ci.nsIURLQueryStrippingListService
+ );
+
+ await listService.testWaitForInit();
+});
+
+/*
+Tests the strip-on-share feature for in-content links with nested urls
+*/
+
+// Testing nested stripping with global params
+add_task(async function testNestedStrippingGlobalParam() {
+ let validUrl =
+ "https://www.example.com/?test=https%3A%2F%2Fwww.example.net%2F%3Futm_ad%3D1234";
+ let shortenedUrl =
+ "https://www.example.com/?test=https%3A%2F%2Fwww.example.net%2F";
+ await testStripOnShare({
+ originalURI: validUrl,
+ strippedURI: shortenedUrl,
+ });
+});
+
+// Testing nested stripping with site specific params
+add_task(async function testNestedStrippingSiteSpecific() {
+ let validUrl =
+ "https://www.example.com/?test=https%3A%2F%2Fwww.example.net%2F%3Ftest_3%3D1234";
+ let shortenedUrl =
+ "https://www.example.com/?test=https%3A%2F%2Fwww.example.net%2F";
+ await testStripOnShare({
+ originalURI: validUrl,
+ strippedURI: shortenedUrl,
+ });
+});
+
+// Testing nested stripping with incorrect site specific params
+add_task(async function testNoStrippedNestedParam() {
+ let validUrl =
+ "https://www.example.com/?test=https%3A%2F%2Fwww.example.com%2F%3Ftest_3%3D1234";
+ let shortenedUrl =
+ "https://www.example.com/?test=https%3A%2F%2Fwww.example.com%2F%3Ftest_3%3D1234";
+ await testStripOnShare({
+ originalURI: validUrl,
+ strippedURI: shortenedUrl,
+ });
+});
+
+// Testing order of stripping for nested stripping
+add_task(async function testOrderOfStripping() {
+ let validUrl =
+ "https://www.example.com/?test_1=https%3A%2F%2Fwww.example.net%2F%3Ftest_3%3D1234";
+ let shortenedUrl = "https://www.example.com/";
+ await testStripOnShare({
+ originalURI: validUrl,
+ strippedURI: shortenedUrl,
+ });
+});
+
+// Testing correct scoping of site specific params for nested stripping
+add_task(async function testMultipleQueryParamsWithNestedStripping() {
+ let validUrl =
+ "https://www.example.com/?test_3=1234&test=https%3A%2F%2Fwww.example.net%2F%3Ftest_3%3D1234";
+ let shortenedUrl =
+ "https://www.example.com/?test_3=1234&test=https%3A%2F%2Fwww.example.net%2F";
+ await testStripOnShare({
+ originalURI: validUrl,
+ strippedURI: shortenedUrl,
+ });
+});
+
+// Testing functionality with no https pages
+add_task(async function testNonHTTPsPages() {
+ let validUrl = "https://www.example.com/?test_2=1234&test=about%3A%3Aconfig";
+ let shortenedUrl = "https://www.example.com/?test=about%3A%3Aconfig";
+ await testStripOnShare({
+ originalURI: validUrl,
+ strippedURI: shortenedUrl,
+ });
+});
+
+/**
+ * Opens a new tab, opens the context menu and checks that the strip-on-share menu item is visible.
+ * Checks that the stripped version of the url is copied to the clipboard.
+ *
+ * @param {string} originalURI - The orginal url before the stripping occurs
+ * @param {string} strippedURI - The expected url after stripping occurs
+ */
+async function testStripOnShare({ originalURI, strippedURI }) {
+ await SpecialPowers.pushPrefEnv({
+ set: [
+ ["privacy.query_stripping.strip_on_share.enabled", true],
+ ["privacy.query_stripping.strip_on_share.enableTestMode", true],
+ ],
+ });
+
+ let testJson = {
+ global: {
+ queryParams: ["utm_ad"],
+ topLevelSites: ["*"],
+ },
+ example: {
+ queryParams: ["test_2", "test_1"],
+ topLevelSites: ["www.example.com"],
+ },
+ exampleNet: {
+ queryParams: ["test_3", "test_4"],
+ topLevelSites: ["www.example.net"],
+ },
+ };
+
+ await listService.testSetList(testJson);
+
+ await BrowserTestUtils.withNewTab(TEST_URL, async function (browser) {
+ // Prepare a link
+ await SpecialPowers.spawn(browser, [originalURI], function (startingURI) {
+ let link = content.document.createElement("a");
+ link.href = startingURI;
+ link.textContent = "link with query param";
+ link.id = "link";
+ content.document.body.appendChild(link);
+ });
+ let contextMenu = document.getElementById("contentAreaContextMenu");
+ // Open the context menu
+ let awaitPopupShown = BrowserTestUtils.waitForEvent(
+ contextMenu,
+ "popupshown"
+ );
+ await BrowserTestUtils.synthesizeMouseAtCenter(
+ "#link",
+ { type: "contextmenu", button: 2 },
+ browser
+ );
+ await awaitPopupShown;
+ let awaitPopupHidden = BrowserTestUtils.waitForEvent(
+ contextMenu,
+ "popuphidden"
+ );
+ let stripOnShare = contextMenu.querySelector("#context-stripOnShareLink");
+ Assert.ok(BrowserTestUtils.isVisible(stripOnShare), "Menu item is visible");
+ // Make sure the stripped link will be copied to the clipboard
+ await SimpleTest.promiseClipboardChange(strippedURI, () => {
+ contextMenu.activateItem(stripOnShare);
+ });
+ await awaitPopupHidden;
+ });
+}
diff --git a/browser/base/content/test/contextMenu/contextmenu_common.js b/browser/base/content/test/contextMenu/contextmenu_common.js
index ac61aa2a3a..2c9a1967f6 100644
--- a/browser/base/content/test/contextMenu/contextmenu_common.js
+++ b/browser/base/content/test/contextMenu/contextmenu_common.js
@@ -39,7 +39,7 @@ function closeContextMenu() {
contextMenu.hidePopup();
}
-function getVisibleMenuItems(aMenu, aData) {
+function getVisibleMenuItems(aMenu) {
var items = [];
var accessKeys = {};
for (var i = 0; i < aMenu.children.length; i++) {
@@ -65,7 +65,7 @@ function getVisibleMenuItems(aMenu, aData) {
var label = item.getAttribute("label");
ok(label.length, "menuitem " + item.id + " has a label");
if (isGenerated) {
- is(key, "", "Generated items shouldn't have an access key");
+ is(key, null, "Generated items shouldn't have an access key");
items.push("*" + label);
} else if (
item.id.indexOf("spell-check-dictionary-") != 0 &&
diff --git a/browser/base/content/test/contextMenu/subtst_contextmenu.html b/browser/base/content/test/contextMenu/subtst_contextmenu.html
index 2c263fbce4..2facd9fecc 100644
--- a/browser/base/content/test/contextMenu/subtst_contextmenu.html
+++ b/browser/base/content/test/contextMenu/subtst_contextmenu.html
@@ -26,14 +26,14 @@ document.getElementById("shadow-host-in-link").attachShadow({ mode: "closed" }).
<image id="test-svg-image" href="ctxmenu-image.png"/>
</svg>
<canvas id="test-canvas" width="100" height="100" style="background-color: blue"></canvas>
-<video controls id="test-video-ok" src="video.ogg" width="100" height="100" style="background-color: green"></video>
+<video controls id="test-video-ok" src="video.webm" width="100" height="100" style="background-color: green"></video>
<video id="test-audio-in-video" src="audio.ogg" width="100" height="100" style="background-color: red"></video>
<video controls id="test-video-bad" src="bogus.duh" width="100" height="100" style="background-color: orange"></video>
<video controls id="test-video-bad2" width="100" height="100" style="background-color: yellow">
<source src="bogus.duh" type="video/durrrr;">
</video>
<iframe id="test-iframe" width="98" height="98" style="border: 1px solid black"></iframe>
-<iframe id="test-video-in-iframe" src="video.ogg" width="98" height="98" style="border: 1px solid black"></iframe>
+<iframe id="test-video-in-iframe" src="video.webm" width="98" height="98" style="border: 1px solid black"></iframe>
<iframe id="test-audio-in-iframe" src="audio.ogg" width="98" height="98" style="border: 1px solid black"></iframe>
<iframe id="test-image-in-iframe" src="ctxmenu-image.png" width="98" height="98" style="border: 1px solid black"></iframe>
<iframe id="test-pdf-viewer-in-frame" src="file_pdfjs_test.pdf" width="100" height="100" style="border: 1px solid black"></iframe>
diff --git a/browser/base/content/test/contextMenu/subtst_contextmenu_webext.html b/browser/base/content/test/contextMenu/subtst_contextmenu_webext.html
index ac3b5415dd..be45c2ddd0 100644
--- a/browser/base/content/test/contextMenu/subtst_contextmenu_webext.html
+++ b/browser/base/content/test/contextMenu/subtst_contextmenu_webext.html
@@ -7,6 +7,6 @@
<body>
Browser context menu subtest.
<a href="moz-extension://foo-bar/tab.html" id="link">Link to an extension resource</a>
- <video src="moz-extension://foo-bar/video.ogg" id="video"></video>
+ <video src="moz-extension://foo-bar/video.webm" id="video"></video>
</body>
</html>