toolkit/mozapps/extensions/test/browser/browser_bug572561.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 the locale category is shown if there are no locale packs
     6 // installed but some are pending install
     8 var gManagerWindow;
     9 var gCategoryUtilities;
    10 var gProvider;
    11 var gInstallProperties = [{
    12   name: "Locale Category Test",
    13   type: "locale"
    14 }];
    15 var gInstall;
    16 var gExpectedCancel = false;
    17 var gTestInstallListener = {
    18   onInstallStarted: function(aInstall) {
    19     check_hidden(false);
    20   },
    22   onInstallEnded: function(aInstall) {
    23     check_hidden(false);
    24     run_next_test();
    25   },
    27   onInstallCancelled: function(aInstall) {
    28     ok(gExpectedCancel, "Should expect install cancel");
    29     check_hidden(false);
    30     run_next_test();
    31   },
    33   onInstallFailed: function(aInstall) {
    34     ok(false, "Did not expect onInstallFailed");
    35   }
    36 };
    38 function test() {
    39   waitForExplicitFinish();
    41   gProvider = new MockProvider();
    43   open_manager("addons://list/extension", function(aWindow) {
    44     gManagerWindow = aWindow;
    45     gCategoryUtilities = new CategoryUtilities(gManagerWindow);
    46     run_next_test();
    47   });
    48 }
    50 function end_test() {
    51   close_manager(gManagerWindow, function() {
    52     finish();
    53   });
    54 }
    56 function check_hidden(aExpectedHidden) {
    57   var hidden = !gCategoryUtilities.isTypeVisible("locale");
    58   is(hidden, aExpectedHidden, "Should have correct hidden state");
    59 }
    61 // Tests that a non-active install does not make the locale category show
    62 add_test(function() {
    63   check_hidden(true);
    64   gInstall = gProvider.createInstalls(gInstallProperties)[0];
    65   gInstall.addTestListener(gTestInstallListener);
    66   check_hidden(true);
    67   run_next_test();
    68 });
    70 // Test that restarting the add-on manager with a non-active install
    71 // does not cause the locale category to show
    72 add_test(function() {
    73   restart_manager(gManagerWindow, null, function(aWindow) {
    74     gManagerWindow = aWindow;
    75     gCategoryUtilities = new CategoryUtilities(gManagerWindow);
    76     check_hidden(true);
    77     run_next_test();
    78   });
    79 });
    81 // Test that installing the install shows the locale category
    82 add_test(function() {
    83   gInstall.install();
    84 });
    86 // Test that restarting the add-on manager does not cause the locale category
    87 // to become hidden
    88 add_test(function() {
    89   restart_manager(gManagerWindow, null, function(aWindow) {
    90     gManagerWindow = aWindow;
    91     gCategoryUtilities = new CategoryUtilities(gManagerWindow);
    92     check_hidden(false);
    94     gExpectedCancel = true;
    95     gInstall.cancel();
    96   });
    97 });

mercurial