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

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

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

mercurial