1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/toolkit/mozapps/extensions/test/browser/browser_bug572561.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,98 @@ 1.4 +/* Any copyright is dedicated to the Public Domain. 1.5 + * http://creativecommons.org/publicdomain/zero/1.0/ 1.6 + */ 1.7 + 1.8 +// Tests that the locale category is shown if there are no locale packs 1.9 +// installed but some are pending install 1.10 + 1.11 +var gManagerWindow; 1.12 +var gCategoryUtilities; 1.13 +var gProvider; 1.14 +var gInstallProperties = [{ 1.15 + name: "Locale Category Test", 1.16 + type: "locale" 1.17 +}]; 1.18 +var gInstall; 1.19 +var gExpectedCancel = false; 1.20 +var gTestInstallListener = { 1.21 + onInstallStarted: function(aInstall) { 1.22 + check_hidden(false); 1.23 + }, 1.24 + 1.25 + onInstallEnded: function(aInstall) { 1.26 + check_hidden(false); 1.27 + run_next_test(); 1.28 + }, 1.29 + 1.30 + onInstallCancelled: function(aInstall) { 1.31 + ok(gExpectedCancel, "Should expect install cancel"); 1.32 + check_hidden(false); 1.33 + run_next_test(); 1.34 + }, 1.35 + 1.36 + onInstallFailed: function(aInstall) { 1.37 + ok(false, "Did not expect onInstallFailed"); 1.38 + } 1.39 +}; 1.40 + 1.41 +function test() { 1.42 + waitForExplicitFinish(); 1.43 + 1.44 + gProvider = new MockProvider(); 1.45 + 1.46 + open_manager("addons://list/extension", function(aWindow) { 1.47 + gManagerWindow = aWindow; 1.48 + gCategoryUtilities = new CategoryUtilities(gManagerWindow); 1.49 + run_next_test(); 1.50 + }); 1.51 +} 1.52 + 1.53 +function end_test() { 1.54 + close_manager(gManagerWindow, function() { 1.55 + finish(); 1.56 + }); 1.57 +} 1.58 + 1.59 +function check_hidden(aExpectedHidden) { 1.60 + var hidden = !gCategoryUtilities.isTypeVisible("locale"); 1.61 + is(hidden, aExpectedHidden, "Should have correct hidden state"); 1.62 +} 1.63 + 1.64 +// Tests that a non-active install does not make the locale category show 1.65 +add_test(function() { 1.66 + check_hidden(true); 1.67 + gInstall = gProvider.createInstalls(gInstallProperties)[0]; 1.68 + gInstall.addTestListener(gTestInstallListener); 1.69 + check_hidden(true); 1.70 + run_next_test(); 1.71 +}); 1.72 + 1.73 +// Test that restarting the add-on manager with a non-active install 1.74 +// does not cause the locale category to show 1.75 +add_test(function() { 1.76 + restart_manager(gManagerWindow, null, function(aWindow) { 1.77 + gManagerWindow = aWindow; 1.78 + gCategoryUtilities = new CategoryUtilities(gManagerWindow); 1.79 + check_hidden(true); 1.80 + run_next_test(); 1.81 + }); 1.82 +}); 1.83 + 1.84 +// Test that installing the install shows the locale category 1.85 +add_test(function() { 1.86 + gInstall.install(); 1.87 +}); 1.88 + 1.89 +// Test that restarting the add-on manager does not cause the locale category 1.90 +// to become hidden 1.91 +add_test(function() { 1.92 + restart_manager(gManagerWindow, null, function(aWindow) { 1.93 + gManagerWindow = aWindow; 1.94 + gCategoryUtilities = new CategoryUtilities(gManagerWindow); 1.95 + check_hidden(false); 1.96 + 1.97 + gExpectedCancel = true; 1.98 + gInstall.cancel(); 1.99 + }); 1.100 +}); 1.101 +