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