michael@0: /* Any copyright is dedicated to the Public Domain. michael@0: http://creativecommons.org/publicdomain/zero/1.0/ */ michael@0: michael@0: const URI_BLOCKLIST_DIALOG = "chrome://mozapps/content/extensions/blocklist.xul"; michael@0: michael@0: // This tests that the blocklist dialog still affects soft-blocked add-ons michael@0: // if the user clicks the "Restart Later" button. It also ensures that the michael@0: // "Cancel" button is correctly renamed (to "Restart Later"). michael@0: let args = { michael@0: restart: false, michael@0: list: [{ michael@0: name: "Bug 523784 softblocked addon", michael@0: version: "1", michael@0: icon: "chrome://mozapps/skin/plugins/pluginGeneric.png", michael@0: disable: false, michael@0: blocked: false, michael@0: url: 'http://example.com/bug523784_1', michael@0: }], michael@0: }; michael@0: michael@0: function test() { michael@0: waitForExplicitFinish(); michael@0: michael@0: let windowObserver = function(aSubject, aTopic, aData) { michael@0: if (aTopic != "domwindowopened") michael@0: return; michael@0: michael@0: Services.ww.unregisterNotification(windowObserver); michael@0: michael@0: let win = aSubject.QueryInterface(Ci.nsIDOMWindow); michael@0: win.addEventListener("load", function() { michael@0: win.removeEventListener("load", arguments.callee, false); michael@0: michael@0: executeSoon(function() bug523784_test1(win)); michael@0: }, false); michael@0: }; michael@0: Services.ww.registerNotification(windowObserver); michael@0: michael@0: args.wrappedJSObject = args; michael@0: Services.ww.openWindow(null, URI_BLOCKLIST_DIALOG, "", michael@0: "chrome,centerscreen,dialog,titlebar", args); michael@0: } michael@0: michael@0: function bug523784_test1(win) { michael@0: let bundle = Services.strings. michael@0: createBundle("chrome://mozapps/locale/update/updates.properties"); michael@0: let cancelButton = win.document.documentElement.getButton("cancel"); michael@0: let moreInfoLink = win.document.getElementById("moreInfo"); michael@0: michael@0: is(cancelButton.getAttribute("label"), michael@0: bundle.GetStringFromName("restartLaterButton"), michael@0: "Text should be changed on Cancel button"); michael@0: is(cancelButton.getAttribute("accesskey"), michael@0: bundle.GetStringFromName("restartLaterButton.accesskey"), michael@0: "Accesskey should also be changed on Cancel button"); michael@0: is(moreInfoLink.getAttribute("href"), michael@0: 'http://example.com/bug523784_1', michael@0: "More Info link should link to a detailed blocklist page."); michael@0: let windowObserver = function(aSubject, aTopic, aData) { michael@0: if (aTopic != "domwindowclosed") michael@0: return; michael@0: michael@0: Services.ww.unregisterNotification(windowObserver); michael@0: michael@0: ok(args.list[0].disable, "Should be blocking add-on"); michael@0: ok(!args.restart, "Should not restart browser immediately"); michael@0: michael@0: executeSoon(bug523784_test2); michael@0: }; michael@0: Services.ww.registerNotification(windowObserver); michael@0: michael@0: cancelButton.doCommand(); michael@0: } michael@0: michael@0: function bug523784_test2(win) { michael@0: let windowObserver = function(aSubject, aTopic, aData) { michael@0: if (aTopic != "domwindowopened") michael@0: return; michael@0: michael@0: Services.ww.unregisterNotification(windowObserver); michael@0: let win = aSubject.QueryInterface(Ci.nsIDOMWindow); michael@0: win.addEventListener("load", function() { michael@0: win.removeEventListener("load", arguments.callee, false); michael@0: michael@0: executeSoon(function(){ michael@0: let moreInfoLink = win.document.getElementById("moreInfo"); michael@0: let cancelButton = win.document.documentElement.getButton("cancel"); michael@0: is(moreInfoLink.getAttribute("href"), michael@0: Services.urlFormatter.formatURLPref("extensions.blocklist.detailsURL"), michael@0: "More Info link should link to the general blocklist page."); michael@0: cancelButton.doCommand(); michael@0: executeSoon(finish); michael@0: }) michael@0: }, false); michael@0: }; michael@0: Services.ww.registerNotification(windowObserver); michael@0: michael@0: // Add 2 more addons to the blocked list to check that the more info link michael@0: // points to the general blocked list page. michael@0: args.list.push({ michael@0: name: "Bug 523784 softblocked addon 2", michael@0: version: "2", michael@0: icon: "chrome://mozapps/skin/plugins/pluginGeneric.png", michael@0: disable: false, michael@0: blocked: false, michael@0: url: 'http://example.com/bug523784_2' michael@0: }); michael@0: args.list.push({ michael@0: name: "Bug 523784 softblocked addon 3", michael@0: version: "4", michael@0: icon: "chrome://mozapps/skin/plugins/pluginGeneric.png", michael@0: disable: false, michael@0: blocked: false, michael@0: url: 'http://example.com/bug523784_3' michael@0: }); michael@0: michael@0: args.wrappedJSObject = args; michael@0: Services.ww.openWindow(null, URI_BLOCKLIST_DIALOG, "", michael@0: "chrome,centerscreen,dialog,titlebar", args); michael@0: }