toolkit/mozapps/extensions/test/browser/browser_bug523784.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 /* Any copyright is dedicated to the Public Domain.
michael@0 2 http://creativecommons.org/publicdomain/zero/1.0/ */
michael@0 3
michael@0 4 const URI_BLOCKLIST_DIALOG = "chrome://mozapps/content/extensions/blocklist.xul";
michael@0 5
michael@0 6 // This tests that the blocklist dialog still affects soft-blocked add-ons
michael@0 7 // if the user clicks the "Restart Later" button. It also ensures that the
michael@0 8 // "Cancel" button is correctly renamed (to "Restart Later").
michael@0 9 let args = {
michael@0 10 restart: false,
michael@0 11 list: [{
michael@0 12 name: "Bug 523784 softblocked addon",
michael@0 13 version: "1",
michael@0 14 icon: "chrome://mozapps/skin/plugins/pluginGeneric.png",
michael@0 15 disable: false,
michael@0 16 blocked: false,
michael@0 17 url: 'http://example.com/bug523784_1',
michael@0 18 }],
michael@0 19 };
michael@0 20
michael@0 21 function test() {
michael@0 22 waitForExplicitFinish();
michael@0 23
michael@0 24 let windowObserver = function(aSubject, aTopic, aData) {
michael@0 25 if (aTopic != "domwindowopened")
michael@0 26 return;
michael@0 27
michael@0 28 Services.ww.unregisterNotification(windowObserver);
michael@0 29
michael@0 30 let win = aSubject.QueryInterface(Ci.nsIDOMWindow);
michael@0 31 win.addEventListener("load", function() {
michael@0 32 win.removeEventListener("load", arguments.callee, false);
michael@0 33
michael@0 34 executeSoon(function() bug523784_test1(win));
michael@0 35 }, false);
michael@0 36 };
michael@0 37 Services.ww.registerNotification(windowObserver);
michael@0 38
michael@0 39 args.wrappedJSObject = args;
michael@0 40 Services.ww.openWindow(null, URI_BLOCKLIST_DIALOG, "",
michael@0 41 "chrome,centerscreen,dialog,titlebar", args);
michael@0 42 }
michael@0 43
michael@0 44 function bug523784_test1(win) {
michael@0 45 let bundle = Services.strings.
michael@0 46 createBundle("chrome://mozapps/locale/update/updates.properties");
michael@0 47 let cancelButton = win.document.documentElement.getButton("cancel");
michael@0 48 let moreInfoLink = win.document.getElementById("moreInfo");
michael@0 49
michael@0 50 is(cancelButton.getAttribute("label"),
michael@0 51 bundle.GetStringFromName("restartLaterButton"),
michael@0 52 "Text should be changed on Cancel button");
michael@0 53 is(cancelButton.getAttribute("accesskey"),
michael@0 54 bundle.GetStringFromName("restartLaterButton.accesskey"),
michael@0 55 "Accesskey should also be changed on Cancel button");
michael@0 56 is(moreInfoLink.getAttribute("href"),
michael@0 57 'http://example.com/bug523784_1',
michael@0 58 "More Info link should link to a detailed blocklist page.");
michael@0 59 let windowObserver = function(aSubject, aTopic, aData) {
michael@0 60 if (aTopic != "domwindowclosed")
michael@0 61 return;
michael@0 62
michael@0 63 Services.ww.unregisterNotification(windowObserver);
michael@0 64
michael@0 65 ok(args.list[0].disable, "Should be blocking add-on");
michael@0 66 ok(!args.restart, "Should not restart browser immediately");
michael@0 67
michael@0 68 executeSoon(bug523784_test2);
michael@0 69 };
michael@0 70 Services.ww.registerNotification(windowObserver);
michael@0 71
michael@0 72 cancelButton.doCommand();
michael@0 73 }
michael@0 74
michael@0 75 function bug523784_test2(win) {
michael@0 76 let windowObserver = function(aSubject, aTopic, aData) {
michael@0 77 if (aTopic != "domwindowopened")
michael@0 78 return;
michael@0 79
michael@0 80 Services.ww.unregisterNotification(windowObserver);
michael@0 81 let win = aSubject.QueryInterface(Ci.nsIDOMWindow);
michael@0 82 win.addEventListener("load", function() {
michael@0 83 win.removeEventListener("load", arguments.callee, false);
michael@0 84
michael@0 85 executeSoon(function(){
michael@0 86 let moreInfoLink = win.document.getElementById("moreInfo");
michael@0 87 let cancelButton = win.document.documentElement.getButton("cancel");
michael@0 88 is(moreInfoLink.getAttribute("href"),
michael@0 89 Services.urlFormatter.formatURLPref("extensions.blocklist.detailsURL"),
michael@0 90 "More Info link should link to the general blocklist page.");
michael@0 91 cancelButton.doCommand();
michael@0 92 executeSoon(finish);
michael@0 93 })
michael@0 94 }, false);
michael@0 95 };
michael@0 96 Services.ww.registerNotification(windowObserver);
michael@0 97
michael@0 98 // Add 2 more addons to the blocked list to check that the more info link
michael@0 99 // points to the general blocked list page.
michael@0 100 args.list.push({
michael@0 101 name: "Bug 523784 softblocked addon 2",
michael@0 102 version: "2",
michael@0 103 icon: "chrome://mozapps/skin/plugins/pluginGeneric.png",
michael@0 104 disable: false,
michael@0 105 blocked: false,
michael@0 106 url: 'http://example.com/bug523784_2'
michael@0 107 });
michael@0 108 args.list.push({
michael@0 109 name: "Bug 523784 softblocked addon 3",
michael@0 110 version: "4",
michael@0 111 icon: "chrome://mozapps/skin/plugins/pluginGeneric.png",
michael@0 112 disable: false,
michael@0 113 blocked: false,
michael@0 114 url: 'http://example.com/bug523784_3'
michael@0 115 });
michael@0 116
michael@0 117 args.wrappedJSObject = args;
michael@0 118 Services.ww.openWindow(null, URI_BLOCKLIST_DIALOG, "",
michael@0 119 "chrome,centerscreen,dialog,titlebar", args);
michael@0 120 }

mercurial