Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
1 /* Any copyright is dedicated to the Public Domain.
2 * http://creativecommons.org/publicdomain/zero/1.0/
3 */
5 // Bug 590347
6 // Tests if softblock notifications are exposed in preference to incompatible
7 // notifications when compatibility checking is disabled
9 var gProvider;
10 var gManagerWindow;
11 var gCategoryUtilities;
13 var gApp = document.getElementById("bundle_brand").getString("brandShortName");
14 var gVersion = Services.appinfo.version;
16 // Opens the details view of an add-on
17 function open_details(aId, aType, aCallback) {
18 requestLongerTimeout(2);
20 gCategoryUtilities.openType(aType, function() {
21 var list = gManagerWindow.document.getElementById("addon-list");
22 var item = list.firstChild;
23 while (item) {
24 if ("mAddon" in item && item.mAddon.id == aId) {
25 list.ensureElementIsVisible(item);
26 EventUtils.synthesizeMouseAtCenter(item, { clickCount: 1 }, gManagerWindow);
27 EventUtils.synthesizeMouseAtCenter(item, { clickCount: 2 }, gManagerWindow);
28 wait_for_view_load(gManagerWindow, aCallback);
29 return;
30 }
31 item = item.nextSibling;
32 }
33 ok(false, "Should have found the add-on in the list");
34 });
35 }
37 function get_list_view_warning_node() {
38 let item = gManagerWindow.document.getElementById("addon-list").firstChild;
39 let found = false;
40 while (item) {
41 if (item.mAddon.name == "Test add-on") {
42 found = true;
43 break;
44 }
45 item = item.nextSibling;
46 }
47 ok(found, "Test add-on node should have been found.");
48 return item.ownerDocument.getAnonymousElementByAttribute(item, "anonid", "warning");
49 }
51 function get_detail_view_warning_node(aManagerWindow) {
52 if(aManagerWindow)
53 return aManagerWindow.document.getElementById("detail-warning");
54 }
56 function test() {
57 waitForExplicitFinish();
59 gProvider = new MockProvider();
61 gProvider.createAddons([{
62 id: "addon1@tests.mozilla.org",
63 name: "Test add-on",
64 description: "A test add-on",
65 isCompatible: false,
66 blocklistState: Ci.nsIBlocklistService.STATE_SOFTBLOCKED,
67 }]);
69 open_manager(null, function(aWindow) {
70 gManagerWindow = aWindow;
71 gCategoryUtilities = new CategoryUtilities(gManagerWindow);
72 run_next_test();
73 });
74 }
76 function end_test() {
77 close_manager(gManagerWindow, function() {
78 finish();
79 });
80 }
82 // Check with compatibility checking enabled
83 add_test(function() {
84 gCategoryUtilities.openType("extension", function() {
85 Services.prefs.setBoolPref(PREF_CHECK_COMPATIBILITY, true);
86 let warning_node = get_list_view_warning_node();
87 is_element_visible(warning_node, "Warning message should be visible");
88 is(warning_node.textContent, "Test add-on is incompatible with " + gApp + " " + gVersion + ".", "Warning message should be correct");
89 run_next_test();
90 });
91 });
93 add_test(function() {
94 open_details("addon1@tests.mozilla.org", "extension", function() {
95 let warning_node = get_detail_view_warning_node(gManagerWindow);
96 is_element_visible(warning_node, "Warning message should be visible");
97 is(warning_node.textContent, "Test add-on is incompatible with " + gApp + " " + gVersion + ".", "Warning message should be correct");
98 Services.prefs.setBoolPref(PREF_CHECK_COMPATIBILITY, false);
99 run_next_test();
100 });
101 });
103 // Check with compatibility checking disabled
104 add_test(function() {
105 gCategoryUtilities.openType("extension", function() {
106 let warning_node = get_list_view_warning_node();
107 is_element_visible(warning_node, "Warning message should be visible");
108 is(warning_node.textContent, "Test add-on is known to cause security or stability issues.", "Warning message should be correct");
109 run_next_test();
110 });
111 });
113 add_test(function() {
114 open_details("addon1@tests.mozilla.org", "extension", function() {
115 let warning_node = get_detail_view_warning_node(gManagerWindow);
116 is_element_visible(warning_node, "Warning message should be visible");
117 is(warning_node.textContent, "Test add-on is known to cause security or stability issues.", "Warning message should be correct");
118 run_next_test();
119 });
120 });