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

Wed, 31 Dec 2014 13:27:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 13:27:57 +0100
branch
TOR_BUG_3246
changeset 6
8bccb770b82d
permissions
-rw-r--r--

Ignore runtime configuration files generated during quality assurance.

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

mercurial