toolkit/mozapps/extensions/test/xpcshell/test_bug596343.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.

     1 /* This Source Code Form is subject to the terms of the Mozilla Public
     2  * License, v. 2.0. If a copy of the MPL was not distributed with this
     3  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
     4  */
     6 const URI_EXTENSION_SELECT_DIALOG     = "chrome://mozapps/content/extensions/selectAddons.xul";
     7 const URI_EXTENSION_UPDATE_DIALOG     = "chrome://mozapps/content/extensions/update.xul";
     8 const PREF_EM_SHOW_MISMATCH_UI        = "extensions.showMismatchUI";
     9 const PREF_SHOWN_SELECTION_UI         = "extensions.shownSelectionUI";
    11 const profileDir = gProfD.clone();
    12 profileDir.append("extensions");
    14 var gExpectedURL = null;
    16 // This will be called to show the any update dialog.
    17 var WindowWatcher = {
    18   openWindow: function(parent, url, name, features, arguments) {
    19     do_check_eq(url, gExpectedURL);
    20     gExpectedURL = null;
    21   },
    23   QueryInterface: function(iid) {
    24     if (iid.equals(AM_Ci.nsIWindowWatcher)
    25      || iid.equals(AM_Ci.nsISupports))
    26       return this;
    28     throw Components.results.NS_ERROR_NO_INTERFACE;
    29   }
    30 }
    32 var WindowWatcherFactory = {
    33   createInstance: function createInstance(outer, iid) {
    34     if (outer != null)
    35       throw Components.results.NS_ERROR_NO_AGGREGATION;
    36     return WindowWatcher.QueryInterface(iid);
    37   }
    38 };
    40 var registrar = Components.manager.QueryInterface(Components.interfaces.nsIComponentRegistrar);
    41 registrar.registerFactory(Components.ID("{1dfeb90a-2193-45d5-9cb8-864928b2af55}"),
    42                           "Fake Window Watcher",
    43                           "@mozilla.org/embedcomp/window-watcher;1", WindowWatcherFactory);
    45 // Tests that the selection UI is displayed when upgrading an existing profile
    46 function run_test() {
    47   createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1");
    49   Services.prefs.setBoolPref(PREF_EM_SHOW_MISMATCH_UI, true);
    51   var dest = writeInstallRDFForExtension({
    52     id: "addon1@tests.mozilla.org",
    53     version: "1.0",
    54     targetApplications: [{
    55       id: "xpcshell@tests.mozilla.org",
    56       minVersion: "1",
    57       maxVersion: "1"
    58     }],
    59     name: "Test Addon 1",
    60   }, profileDir);
    62   startupManager();
    64   // For a new profile it should disable showing the selection UI in the future
    65   do_check_true(Services.prefs.getBoolPref(PREF_SHOWN_SELECTION_UI));
    66   Services.prefs.clearUserPref(PREF_SHOWN_SELECTION_UI);
    68   gExpectedURL = URI_EXTENSION_SELECT_DIALOG;
    69   restartManager("2");
    71   do_check_true(Services.prefs.getBoolPref(PREF_SHOWN_SELECTION_UI));
    72   do_check_eq(gExpectedURL, null);
    74   gExpectedURL = URI_EXTENSION_UPDATE_DIALOG;
    76   restartManager("3");
    78   do_check_eq(gExpectedURL, null);
    79 }

mercurial