summaryrefslogtreecommitdiffstats
path: root/toolkit/mozapps/extensions/test/browser/browser_bug523784.js
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-28 14:29:10 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-28 14:29:10 +0000
commit2aa4a82499d4becd2284cdb482213d541b8804dd (patch)
treeb80bf8bf13c3766139fbacc530efd0dd9d54394c /toolkit/mozapps/extensions/test/browser/browser_bug523784.js
parentInitial commit. (diff)
downloadfirefox-upstream.tar.xz
firefox-upstream.zip
Adding upstream version 86.0.1.upstream/86.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'toolkit/mozapps/extensions/test/browser/browser_bug523784.js')
-rw-r--r--toolkit/mozapps/extensions/test/browser/browser_bug523784.js153
1 files changed, 153 insertions, 0 deletions
diff --git a/toolkit/mozapps/extensions/test/browser/browser_bug523784.js b/toolkit/mozapps/extensions/test/browser/browser_bug523784.js
new file mode 100644
index 0000000000..d0fac12d71
--- /dev/null
+++ b/toolkit/mozapps/extensions/test/browser/browser_bug523784.js
@@ -0,0 +1,153 @@
+/* Any copyright is dedicated to the Public Domain.
+ http://creativecommons.org/publicdomain/zero/1.0/ */
+
+const URI_BLOCKLIST_DIALOG =
+ "chrome://mozapps/content/extensions/blocklist.xhtml";
+
+// This tests that the blocklist dialog still affects soft-blocked add-ons
+// if the user clicks the "Restart Later" button. It also ensures that the
+// "Cancel" button is correctly renamed (to "Restart Later").
+var args = {
+ restart: false,
+ list: [
+ {
+ name: "Bug 523784 softblocked addon",
+ version: "1",
+ icon: "chrome://global/skin/plugins/plugin.svg",
+ disable: false,
+ blocked: false,
+ url: "http://example.com/bug523784_1",
+ },
+ ],
+};
+
+function test() {
+ waitForExplicitFinish();
+
+ let windowObserver = function(win, aTopic, aData) {
+ if (aTopic != "domwindowopened") {
+ return;
+ }
+
+ Services.ww.unregisterNotification(windowObserver);
+
+ win.addEventListener(
+ "load",
+ function() {
+ executeSoon(() => bug523784_test1(win));
+ },
+ { once: true }
+ );
+ };
+ Services.ww.registerNotification(windowObserver);
+
+ args.wrappedJSObject = args;
+ Services.ww.openWindow(
+ null,
+ URI_BLOCKLIST_DIALOG,
+ "",
+ "chrome,centerscreen,dialog,titlebar",
+ args
+ );
+}
+
+function bug523784_test1(win) {
+ let bundle = Services.strings.createBundle(
+ "chrome://mozapps/locale/update/updates.properties"
+ );
+ let cancelButton = win.document
+ .getElementById("BlocklistDialog")
+ .getButton("cancel");
+ let moreInfoLink = win.document.getElementById("moreInfo");
+
+ is(
+ cancelButton.getAttribute("label"),
+ bundle.GetStringFromName("restartLaterButton"),
+ "Text should be changed on Cancel button"
+ );
+ is(
+ cancelButton.getAttribute("accesskey"),
+ bundle.GetStringFromName("restartLaterButton.accesskey"),
+ "Accesskey should also be changed on Cancel button"
+ );
+ is(
+ moreInfoLink.getAttribute("href"),
+ "http://example.com/bug523784_1",
+ "More Info link should link to a detailed blocklist page."
+ );
+ let windowObserver = function(aSubject, aTopic, aData) {
+ if (aTopic != "domwindowclosed") {
+ return;
+ }
+
+ Services.ww.unregisterNotification(windowObserver);
+
+ ok(args.list[0].disable, "Should be blocking add-on");
+ ok(!args.restart, "Should not restart browser immediately");
+
+ executeSoon(bug523784_test2);
+ };
+ Services.ww.registerNotification(windowObserver);
+
+ cancelButton.doCommand();
+}
+
+function bug523784_test2(win) {
+ let windowObserver = function(win, aTopic, aData) {
+ if (aTopic != "domwindowopened") {
+ return;
+ }
+
+ Services.ww.unregisterNotification(windowObserver);
+ win.addEventListener(
+ "load",
+ function() {
+ executeSoon(function() {
+ let moreInfoLink = win.document.getElementById("moreInfo");
+ let cancelButton = win.document
+ .getElementById("BlocklistDialog")
+ .getButton("cancel");
+ is(
+ moreInfoLink.getAttribute("href"),
+ Services.urlFormatter.formatURLPref(
+ "extensions.blocklist.detailsURL"
+ ),
+ "More Info link should link to the general blocklist page."
+ );
+ cancelButton.doCommand();
+ executeSoon(finish);
+ });
+ },
+ { once: true }
+ );
+ };
+ Services.ww.registerNotification(windowObserver);
+
+ // Add 2 more addons to the blocked list to check that the more info link
+ // points to the general blocked list page.
+ args.list.push({
+ name: "Bug 523784 softblocked addon 2",
+ version: "2",
+ icon: "chrome://global/skin/plugins/plugin.svg",
+ disable: false,
+ blocked: false,
+ url: "http://example.com/bug523784_2",
+ });
+ args.list.push({
+ name: "Bug 523784 softblocked addon 3",
+ version: "4",
+ icon: "chrome://global/skin/plugins/plugin.svg",
+ disable: false,
+ blocked: false,
+ url: "http://example.com/bug523784_3",
+ });
+
+ args.wrappedJSObject = args;
+ Services.ww.openWindow(
+ null,
+ URI_BLOCKLIST_DIALOG,
+ "",
+ "chrome,centerscreen,dialog,titlebar",
+ args
+ );
+}