|
1 /* Any copyright is dedicated to the Public Domain. |
|
2 * http://creativecommons.org/publicdomain/zero/1.0/ |
|
3 */ |
|
4 |
|
5 // Simulates quickly switching between different list views to verify that only |
|
6 // the last selected is displayed |
|
7 |
|
8 let tempScope = {}; |
|
9 Components.utils.import("resource://gre/modules/LightweightThemeManager.jsm", tempScope); |
|
10 let LightweightThemeManager = tempScope.LightweightThemeManager; |
|
11 |
|
12 const xpi = "browser/toolkit/mozapps/extensions/test/browser/browser_installssl.xpi"; |
|
13 |
|
14 var gManagerWindow; |
|
15 var gCategoryUtilities; |
|
16 |
|
17 function test() { |
|
18 waitForExplicitFinish(); |
|
19 |
|
20 // Add a lightweight theme so at least one theme exists |
|
21 LightweightThemeManager.currentTheme = { |
|
22 id: "test", |
|
23 name: "Test lightweight theme", |
|
24 headerURL: "http://example.com/header.png" |
|
25 }; |
|
26 |
|
27 open_manager(null, function(aWindow) { |
|
28 gManagerWindow = aWindow; |
|
29 gCategoryUtilities = new CategoryUtilities(gManagerWindow); |
|
30 run_next_test(); |
|
31 }); |
|
32 } |
|
33 |
|
34 function end_test() { |
|
35 close_manager(gManagerWindow, function() { |
|
36 LightweightThemeManager.forgetUsedTheme("test"); |
|
37 finish(); |
|
38 }); |
|
39 } |
|
40 |
|
41 // Tests that loading a second view before the first has not finished loading |
|
42 // does not merge the results |
|
43 add_test(function() { |
|
44 var themeCount = null; |
|
45 var pluginCount = null; |
|
46 var themeItem = gCategoryUtilities.get("theme"); |
|
47 var pluginItem = gCategoryUtilities.get("plugin"); |
|
48 var list = gManagerWindow.document.getElementById("addon-list"); |
|
49 |
|
50 gCategoryUtilities.open(themeItem, function() { |
|
51 themeCount = list.childNodes.length; |
|
52 ok(themeCount > 0, "Test is useless if there are no themes"); |
|
53 |
|
54 gCategoryUtilities.open(pluginItem, function() { |
|
55 pluginCount = list.childNodes.length; |
|
56 ok(pluginCount > 0, "Test is useless if there are no plugins"); |
|
57 |
|
58 gCategoryUtilities.open(themeItem); |
|
59 |
|
60 gCategoryUtilities.open(pluginItem, function() { |
|
61 is(list.childNodes.length, pluginCount, "Should only see the plugins"); |
|
62 |
|
63 var item = list.firstChild; |
|
64 while (item) { |
|
65 is(item.getAttribute("type"), "plugin", "All items should be plugins"); |
|
66 item = item.nextSibling; |
|
67 } |
|
68 |
|
69 // Tests that switching to, from, to the same pane in quick succession |
|
70 // still only shows the right number of results |
|
71 |
|
72 gCategoryUtilities.open(themeItem); |
|
73 gCategoryUtilities.open(pluginItem); |
|
74 gCategoryUtilities.open(themeItem, function() { |
|
75 is(list.childNodes.length, themeCount, "Should only see the theme"); |
|
76 |
|
77 var item = list.firstChild; |
|
78 while (item) { |
|
79 is(item.getAttribute("type"), "theme", "All items should be theme"); |
|
80 item = item.nextSibling; |
|
81 } |
|
82 |
|
83 run_next_test(); |
|
84 }); |
|
85 }); |
|
86 }); |
|
87 }); |
|
88 }); |