michael@0: /* Any copyright is dedicated to the Public Domain. michael@0: * http://creativecommons.org/publicdomain/zero/1.0/ michael@0: */ michael@0: michael@0: // Bug 590347 michael@0: // Tests if softblock notifications are exposed in preference to incompatible michael@0: // notifications when compatibility checking is disabled michael@0: michael@0: var gProvider; michael@0: var gManagerWindow; michael@0: var gCategoryUtilities; michael@0: michael@0: var gApp = document.getElementById("bundle_brand").getString("brandShortName"); michael@0: var gVersion = Services.appinfo.version; michael@0: michael@0: // Opens the details view of an add-on michael@0: function open_details(aId, aType, aCallback) { michael@0: requestLongerTimeout(2); michael@0: michael@0: gCategoryUtilities.openType(aType, function() { michael@0: var list = gManagerWindow.document.getElementById("addon-list"); michael@0: var item = list.firstChild; michael@0: while (item) { michael@0: if ("mAddon" in item && item.mAddon.id == aId) { michael@0: list.ensureElementIsVisible(item); michael@0: EventUtils.synthesizeMouseAtCenter(item, { clickCount: 1 }, gManagerWindow); michael@0: EventUtils.synthesizeMouseAtCenter(item, { clickCount: 2 }, gManagerWindow); michael@0: wait_for_view_load(gManagerWindow, aCallback); michael@0: return; michael@0: } michael@0: item = item.nextSibling; michael@0: } michael@0: ok(false, "Should have found the add-on in the list"); michael@0: }); michael@0: } michael@0: michael@0: function get_list_view_warning_node() { michael@0: let item = gManagerWindow.document.getElementById("addon-list").firstChild; michael@0: let found = false; michael@0: while (item) { michael@0: if (item.mAddon.name == "Test add-on") { michael@0: found = true; michael@0: break; michael@0: } michael@0: item = item.nextSibling; michael@0: } michael@0: ok(found, "Test add-on node should have been found."); michael@0: return item.ownerDocument.getAnonymousElementByAttribute(item, "anonid", "warning"); michael@0: } michael@0: michael@0: function get_detail_view_warning_node(aManagerWindow) { michael@0: if(aManagerWindow) michael@0: return aManagerWindow.document.getElementById("detail-warning"); michael@0: } michael@0: michael@0: function test() { michael@0: waitForExplicitFinish(); michael@0: michael@0: gProvider = new MockProvider(); michael@0: michael@0: gProvider.createAddons([{ michael@0: id: "addon1@tests.mozilla.org", michael@0: name: "Test add-on", michael@0: description: "A test add-on", michael@0: isCompatible: false, michael@0: blocklistState: Ci.nsIBlocklistService.STATE_SOFTBLOCKED, michael@0: }]); michael@0: michael@0: open_manager(null, function(aWindow) { michael@0: gManagerWindow = aWindow; michael@0: gCategoryUtilities = new CategoryUtilities(gManagerWindow); michael@0: run_next_test(); michael@0: }); michael@0: } michael@0: michael@0: function end_test() { michael@0: close_manager(gManagerWindow, function() { michael@0: finish(); michael@0: }); michael@0: } michael@0: michael@0: // Check with compatibility checking enabled michael@0: add_test(function() { michael@0: gCategoryUtilities.openType("extension", function() { michael@0: Services.prefs.setBoolPref(PREF_CHECK_COMPATIBILITY, true); michael@0: let warning_node = get_list_view_warning_node(); michael@0: is_element_visible(warning_node, "Warning message should be visible"); michael@0: is(warning_node.textContent, "Test add-on is incompatible with " + gApp + " " + gVersion + ".", "Warning message should be correct"); michael@0: run_next_test(); michael@0: }); michael@0: }); michael@0: michael@0: add_test(function() { michael@0: open_details("addon1@tests.mozilla.org", "extension", function() { michael@0: let warning_node = get_detail_view_warning_node(gManagerWindow); michael@0: is_element_visible(warning_node, "Warning message should be visible"); michael@0: is(warning_node.textContent, "Test add-on is incompatible with " + gApp + " " + gVersion + ".", "Warning message should be correct"); michael@0: Services.prefs.setBoolPref(PREF_CHECK_COMPATIBILITY, false); michael@0: run_next_test(); michael@0: }); michael@0: }); michael@0: michael@0: // Check with compatibility checking disabled michael@0: add_test(function() { michael@0: gCategoryUtilities.openType("extension", function() { michael@0: let warning_node = get_list_view_warning_node(); michael@0: is_element_visible(warning_node, "Warning message should be visible"); michael@0: is(warning_node.textContent, "Test add-on is known to cause security or stability issues.", "Warning message should be correct"); michael@0: run_next_test(); michael@0: }); michael@0: }); michael@0: michael@0: add_test(function() { michael@0: open_details("addon1@tests.mozilla.org", "extension", function() { michael@0: let warning_node = get_detail_view_warning_node(gManagerWindow); michael@0: is_element_visible(warning_node, "Warning message should be visible"); michael@0: is(warning_node.textContent, "Test add-on is known to cause security or stability issues.", "Warning message should be correct"); michael@0: run_next_test(); michael@0: }); michael@0: });