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