1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
|
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/
*/
// Tests that sorting of plugins works correctly
// (this test checks that plugins with "ask to activate" state appear after those with
// "always activate" and before those with "never activate")
var gManagerWindow;
var gProvider;
function test() {
waitForExplicitFinish();
gProvider = new MockProvider();
gProvider.createAddons([{
// enabledInstalled group
// * Always activate
// * Ask to activate
// * Never activate
id: "test1@tests.mozilla.org",
name: "Java Applet Plug-in Java 7 Update 51",
description: "foo",
type: "plugin",
isActive: true,
userDisabled: AddonManager.STATE_ASK_TO_ACTIVATE
}, {
id: "test2@tests.mozilla.org",
name: "Quick Time Plug-in",
description: "foo",
type: "plugin",
isActive: true,
userDisabled: false
}, {
id: "test3@tests.mozilla.org",
name: "Shockwave Flash",
description: "foo",
type: "plugin",
isActive: false,
userDisabled: true
}, {
id: "test4@tests.mozilla.org",
name: "Adobe Reader Plug-in",
description: "foo",
type: "plugin",
isActive: true,
userDisabled: AddonManager.STATE_ASK_TO_ACTIVATE
}, {
id: "test5@tests.mozilla.org",
name: "3rd Party Plug-in",
description: "foo",
type: "plugin",
isActive: true,
userDisabled: false
}]);
open_manager("addons://list/plugin", function(aWindow) {
gManagerWindow = aWindow;
run_next_test();
});
}
function end_test() {
close_manager(gManagerWindow, function() {
finish();
});
}
function check_order(aExpectedOrder) {
var order = [];
var list = gManagerWindow.document.getElementById("addon-list");
var node = list.firstChild;
while (node) {
var id = node.getAttribute("value");
if (id && id.endsWith("@tests.mozilla.org"))
order.push(node.getAttribute("value"));
node = node.nextSibling;
}
is(order.toSource(), aExpectedOrder.toSource(), "Should have seen the right order");
}
// Tests that ascending name ordering was the default
add_test(function() {
check_order([
"test5@tests.mozilla.org",
"test2@tests.mozilla.org",
"test4@tests.mozilla.org",
"test1@tests.mozilla.org",
"test3@tests.mozilla.org"
]);
run_next_test();
});
|