From 05bec231c0b2e8bef22a35248664d8a70a72b127 Mon Sep 17 00:00:00 2001 From: Mehdi Mulani Date: Wed, 16 Feb 2011 13:24:41 -0800 Subject: [PATCH] Bug 523784 - (Tests) Soft blocked items are not disabled if user clicks "Cancel". r=Unfocused a=blocking+beltzner --- .../extensions/test/browser/Makefile.in | 1 + .../test/browser/browser_bug523784.js | 74 +++++++++++++++++++ 2 files changed, 75 insertions(+) create mode 100644 toolkit/mozapps/extensions/test/browser/browser_bug523784.js diff --git a/toolkit/mozapps/extensions/test/browser/Makefile.in b/toolkit/mozapps/extensions/test/browser/Makefile.in index 1e1fecbede07..ef2c5c389ddb 100644 --- a/toolkit/mozapps/extensions/test/browser/Makefile.in +++ b/toolkit/mozapps/extensions/test/browser/Makefile.in @@ -48,6 +48,7 @@ include $(DEPTH)/config/autoconf.mk _MAIN_TEST_FILES = \ head.js \ browser_about.js \ + browser_bug523784.js \ browser_bug557943.js \ browser_bug562797.js \ browser_bug562854.js \ 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 000000000000..2cd9a471bb97 --- /dev/null +++ b/toolkit/mozapps/extensions/test/browser/browser_bug523784.js @@ -0,0 +1,74 @@ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ + +const Cc = Components.classes; +const Ci = Components.interfaces; + +const URI_BLOCKLIST_DIALOG = "chrome://mozapps/content/extensions/blocklist.xul"; + +Components.utils.import("resource://gre/modules/Services.jsm"); + +// 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"). +let args = { + restart: false, + list: [{ + name: "Bug 523784 softblocked addon", + version: "1", + icon: "chrome://mozapps/skin/plugins/pluginGeneric.png", + disable: false, + blocked: false, + }], +}; + +function test() { + waitForExplicitFinish(); + + let windowObserver = function(aSubject, aTopic, aData) { + if (aTopic != "domwindowopened") + return; + + Services.ww.unregisterNotification(windowObserver); + + let win = aSubject.QueryInterface(Ci.nsIDOMWindow); + win.addEventListener("load", function() { + win.removeEventListener("load", arguments.callee, false); + + executeSoon(function() bug523784_test1(win)); + }, false); + }; + 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.documentElement.getButton("cancel"); + + 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"); + + 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(finish); + }; + Services.ww.registerNotification(windowObserver); + + cancelButton.doCommand(); +}