1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/toolkit/mozapps/extensions/test/browser/browser_bug557943.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,80 @@ 1.4 +/* Any copyright is dedicated to the Public Domain. 1.5 + * http://creativecommons.org/publicdomain/zero/1.0/ 1.6 + */ 1.7 + 1.8 +// Bug 557943 - Searching for addons can result in wrong results 1.9 + 1.10 +var gManagerWindow; 1.11 +var gProvider; 1.12 + 1.13 +function test() { 1.14 + waitForExplicitFinish(); 1.15 + 1.16 + gProvider = new MockProvider(); 1.17 + 1.18 + gProvider.createAddons([{ 1.19 + id: "addon1@tests.mozilla.org", 1.20 + name: "Microsoft .NET Framework Assistant", 1.21 + description: "", 1.22 + version: "6.66" 1.23 + }, { 1.24 + id: "addon2@tests.mozilla.org", 1.25 + name: "AwesomeNet Addon", 1.26 + description: "" 1.27 + }, { 1.28 + id: "addon3@tests.mozilla.org", 1.29 + name: "Dictionnaire MySpell en Francais (réforme 1990)", 1.30 + description: "" 1.31 + }]); 1.32 + 1.33 + open_manager("addons://list/extension", function(aWindow) { 1.34 + gManagerWindow = aWindow; 1.35 + run_next_test(); 1.36 + }); 1.37 +} 1.38 + 1.39 +function end_test() { 1.40 + close_manager(gManagerWindow, function() { 1.41 + finish(); 1.42 + }); 1.43 +} 1.44 + 1.45 + 1.46 +function perform_search(aQuery, aCallback) { 1.47 + waitForFocus(function() { 1.48 + var searchBox = gManagerWindow.document.getElementById("header-search"); 1.49 + searchBox.value = aQuery; 1.50 + 1.51 + EventUtils.synthesizeMouseAtCenter(searchBox, { }, gManagerWindow); 1.52 + EventUtils.synthesizeKey("VK_RETURN", { }, gManagerWindow); 1.53 + wait_for_view_load(gManagerWindow, function() { 1.54 + var list = gManagerWindow.document.getElementById("search-list"); 1.55 + var rows = list.getElementsByTagName("richlistitem"); 1.56 + aCallback(rows); 1.57 + }); 1.58 + }, gManagerWindow); 1.59 +} 1.60 + 1.61 + 1.62 +add_test(function() { 1.63 + perform_search(".net", function(aRows) { 1.64 + is(aRows.length, 1, "Should only get one result"); 1.65 + is(aRows[0].mAddon.id, "addon1@tests.mozilla.org", "Should get expected addon as only result"); 1.66 + run_next_test(); 1.67 + }); 1.68 +}); 1.69 + 1.70 +add_test(function() { 1.71 + perform_search("réf", function(aRows) { 1.72 + is(aRows.length, 1, "Should only get one result"); 1.73 + is(aRows[0].mAddon.id, "addon3@tests.mozilla.org", "Should get expected addon as only result"); 1.74 + run_next_test(); 1.75 + }); 1.76 +}); 1.77 + 1.78 +add_test(function() { 1.79 + perform_search("javascript:void()", function(aRows) { 1.80 + is(aRows.length, 0, "Should not get any results"); 1.81 + run_next_test(); 1.82 + }); 1.83 +});