|
1 /* Any copyright is dedicated to the Public Domain. |
|
2 * http://creativecommons.org/publicdomain/zero/1.0/ |
|
3 */ |
|
4 |
|
5 // Bug 557943 - Searching for addons can result in wrong results |
|
6 |
|
7 var gManagerWindow; |
|
8 var gProvider; |
|
9 |
|
10 function test() { |
|
11 waitForExplicitFinish(); |
|
12 |
|
13 gProvider = new MockProvider(); |
|
14 |
|
15 gProvider.createAddons([{ |
|
16 id: "addon1@tests.mozilla.org", |
|
17 name: "Microsoft .NET Framework Assistant", |
|
18 description: "", |
|
19 version: "6.66" |
|
20 }, { |
|
21 id: "addon2@tests.mozilla.org", |
|
22 name: "AwesomeNet Addon", |
|
23 description: "" |
|
24 }, { |
|
25 id: "addon3@tests.mozilla.org", |
|
26 name: "Dictionnaire MySpell en Francais (réforme 1990)", |
|
27 description: "" |
|
28 }]); |
|
29 |
|
30 open_manager("addons://list/extension", function(aWindow) { |
|
31 gManagerWindow = aWindow; |
|
32 run_next_test(); |
|
33 }); |
|
34 } |
|
35 |
|
36 function end_test() { |
|
37 close_manager(gManagerWindow, function() { |
|
38 finish(); |
|
39 }); |
|
40 } |
|
41 |
|
42 |
|
43 function perform_search(aQuery, aCallback) { |
|
44 waitForFocus(function() { |
|
45 var searchBox = gManagerWindow.document.getElementById("header-search"); |
|
46 searchBox.value = aQuery; |
|
47 |
|
48 EventUtils.synthesizeMouseAtCenter(searchBox, { }, gManagerWindow); |
|
49 EventUtils.synthesizeKey("VK_RETURN", { }, gManagerWindow); |
|
50 wait_for_view_load(gManagerWindow, function() { |
|
51 var list = gManagerWindow.document.getElementById("search-list"); |
|
52 var rows = list.getElementsByTagName("richlistitem"); |
|
53 aCallback(rows); |
|
54 }); |
|
55 }, gManagerWindow); |
|
56 } |
|
57 |
|
58 |
|
59 add_test(function() { |
|
60 perform_search(".net", function(aRows) { |
|
61 is(aRows.length, 1, "Should only get one result"); |
|
62 is(aRows[0].mAddon.id, "addon1@tests.mozilla.org", "Should get expected addon as only result"); |
|
63 run_next_test(); |
|
64 }); |
|
65 }); |
|
66 |
|
67 add_test(function() { |
|
68 perform_search("réf", function(aRows) { |
|
69 is(aRows.length, 1, "Should only get one result"); |
|
70 is(aRows[0].mAddon.id, "addon3@tests.mozilla.org", "Should get expected addon as only result"); |
|
71 run_next_test(); |
|
72 }); |
|
73 }); |
|
74 |
|
75 add_test(function() { |
|
76 perform_search("javascript:void()", function(aRows) { |
|
77 is(aRows.length, 0, "Should not get any results"); |
|
78 run_next_test(); |
|
79 }); |
|
80 }); |