toolkit/mozapps/extensions/test/browser/browser_select_compatoverrides.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 /* Any copyright is dedicated to the Public Domain.
     2  * http://creativecommons.org/publicdomain/zero/1.0/
     3  */
     5 // Tests that compatibility overrides are refreshed when showing the addon
     6 // selection UI.
     8 const PREF_GETADDONS_BYIDS            = "extensions.getAddons.get.url";
     9 const PREF_MIN_PLATFORM_COMPAT        = "extensions.minCompatiblePlatformVersion";
    11 var gTestAddon = null;
    12 var gWin;
    14 function waitForView(aView, aCallback) {
    15   var view = gWin.document.getElementById(aView);
    16   if (view.parentNode.selectedPanel == view) {
    17     aCallback();
    18     return;
    19   }
    21   view.addEventListener("ViewChanged", function() {
    22     view.removeEventListener("ViewChanged", arguments.callee, false);
    23     aCallback();
    24   }, false);
    25 }
    27 function install_test_addon(aCallback) {
    28   AddonManager.getInstallForURL(TESTROOT + "addons/browser_select_compatoverrides_1.xpi", function(aInstall) {
    29     var listener = {
    30       onInstallEnded: function() {
    31         AddonManager.getAddonByID("addon1@tests.mozilla.org", function(addon) {
    32           gTestAddon = addon;
    33           aCallback();
    34         });
    35       }
    36     };
    37     aInstall.addListener(listener);
    38     aInstall.install();
    39   }, "application/x-xpinstall");
    40 }
    42 registerCleanupFunction(function() {
    43   if (gWin)
    44     gWin.close();
    45   if (gTestAddon)
    46     gTestAddon.uninstall();
    48   Services.prefs.clearUserPref(PREF_MIN_PLATFORM_COMPAT);
    49 });
    51 function end_test() {
    52   finish();
    53 }
    56 function test() {
    57   waitForExplicitFinish();
    58   Services.prefs.setCharPref(PREF_UPDATEURL, TESTROOT + "missing.rdf");
    59   Services.prefs.setBoolPref(PREF_STRICT_COMPAT, false);
    60   Services.prefs.setCharPref(PREF_MIN_PLATFORM_COMPAT, "0");
    62   install_test_addon(run_next_test);
    63 }
    65 add_test(function() {
    66   gWin = Services.ww.openWindow(null,
    67                               "chrome://mozapps/content/extensions/selectAddons.xul",
    68                               "",
    69                               "chrome,centerscreen,dialog,titlebar",
    70                               null);
    71   waitForFocus(function() {
    72     waitForView("select", run_next_test);
    73   }, gWin);
    74 });
    76 add_test(function() {
    77   for (var row = gWin.document.getElementById("select-rows").firstChild; row; row = row.nextSibling) {
    78     if (row.localName == "separator")
    79       continue;
    80     if (row.id.substr(-18) != "@tests.mozilla.org")
    81       continue;
    83     is(row.id, "addon1@tests.mozilla.org", "Should get expected addon");
    84     isnot(row.action, "incompatible", "Addon should not be incompatible");
    86     gWin.close();
    87     gWin = null;
    88     run_next_test();
    89   }
    90 });
    92 add_test(function() {
    93   Services.prefs.setCharPref(PREF_GETADDONS_BYIDS, TESTROOT + "browser_select_compatoverrides.xml");
    94   Services.prefs.setBoolPref(PREF_GETADDONS_CACHE_ENABLED, true);
    96   gWin = Services.ww.openWindow(null,
    97                               "chrome://mozapps/content/extensions/selectAddons.xul",
    98                               "",
    99                               "chrome,centerscreen,dialog,titlebar",
   100                               null);
   101   waitForFocus(function() {
   102     waitForView("select", run_next_test);
   103   }, gWin);
   104 });
   106 add_test(function() {
   107   for (var row = gWin.document.getElementById("select-rows").firstChild; row; row = row.nextSibling) {
   108     if (row.localName == "separator")
   109       continue;
   110     if (row.id.substr(-18) != "@tests.mozilla.org")
   111       continue;
   112     is(row.id, "addon1@tests.mozilla.org", "Should get expected addon");
   113     is(row.action, "incompatible", "Addon should be incompatible");
   114     run_next_test();
   115   }
   116 });

mercurial