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

changeset 0
6474c204b198
equal deleted inserted replaced
-1:000000000000 0:fd3f72c50018
1 /* Any copyright is dedicated to the Public Domain.
2 * http://creativecommons.org/publicdomain/zero/1.0/
3 */
4
5 // Tests that the locale category is shown if there are no locale packs
6 // installed but some are pending install
7
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 },
21
22 onInstallEnded: function(aInstall) {
23 check_hidden(false);
24 run_next_test();
25 },
26
27 onInstallCancelled: function(aInstall) {
28 ok(gExpectedCancel, "Should expect install cancel");
29 check_hidden(false);
30 run_next_test();
31 },
32
33 onInstallFailed: function(aInstall) {
34 ok(false, "Did not expect onInstallFailed");
35 }
36 };
37
38 function test() {
39 waitForExplicitFinish();
40
41 gProvider = new MockProvider();
42
43 open_manager("addons://list/extension", function(aWindow) {
44 gManagerWindow = aWindow;
45 gCategoryUtilities = new CategoryUtilities(gManagerWindow);
46 run_next_test();
47 });
48 }
49
50 function end_test() {
51 close_manager(gManagerWindow, function() {
52 finish();
53 });
54 }
55
56 function check_hidden(aExpectedHidden) {
57 var hidden = !gCategoryUtilities.isTypeVisible("locale");
58 is(hidden, aExpectedHidden, "Should have correct hidden state");
59 }
60
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 });
69
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 });
80
81 // Test that installing the install shows the locale category
82 add_test(function() {
83 gInstall.install();
84 });
85
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);
93
94 gExpectedCancel = true;
95 gInstall.cancel();
96 });
97 });
98

mercurial