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 | function run_test() { |
michael@0 | 5 | do_test_pending(); |
michael@0 | 6 | |
michael@0 | 7 | removeMetadata(); |
michael@0 | 8 | removeCacheFile(); |
michael@0 | 9 | |
michael@0 | 10 | do_load_manifest("data/chrome.manifest"); |
michael@0 | 11 | |
michael@0 | 12 | let url = "chrome://testsearchplugin/locale/searchplugins/"; |
michael@0 | 13 | Services.prefs.setCharPref("browser.search.jarURIs", url); |
michael@0 | 14 | Services.prefs.setBoolPref("browser.search.loadFromJars", true); |
michael@0 | 15 | |
michael@0 | 16 | do_check_false(Services.search.isInitialized); |
michael@0 | 17 | let fallback = false; |
michael@0 | 18 | |
michael@0 | 19 | Services.search.init(function search_initialized(aStatus) { |
michael@0 | 20 | do_check_true(fallback); |
michael@0 | 21 | do_check_true(Components.isSuccessCode(aStatus)); |
michael@0 | 22 | do_check_true(Services.search.isInitialized); |
michael@0 | 23 | |
michael@0 | 24 | // test engines from dir are loaded. |
michael@0 | 25 | let engines = Services.search.getEngines(); |
michael@0 | 26 | do_check_true(engines.length > 1); |
michael@0 | 27 | |
michael@0 | 28 | // test jar engine is loaded ok. |
michael@0 | 29 | let engine = Services.search.getEngineByName("bug645970"); |
michael@0 | 30 | do_check_neq(engine, null); |
michael@0 | 31 | |
michael@0 | 32 | Services.prefs.clearUserPref("browser.search.jarURIs"); |
michael@0 | 33 | Services.prefs.clearUserPref("browser.search.loadFromJars"); |
michael@0 | 34 | |
michael@0 | 35 | do_test_finished(); |
michael@0 | 36 | }); |
michael@0 | 37 | |
michael@0 | 38 | // Execute test for the sync fallback while the async code is being executed. |
michael@0 | 39 | Services.obs.addObserver(function searchServiceObserver(aResult, aTopic, aVerb) { |
michael@0 | 40 | if (aVerb == "find-jar-engines") { |
michael@0 | 41 | Services.obs.removeObserver(searchServiceObserver, aTopic); |
michael@0 | 42 | fallback = true; |
michael@0 | 43 | |
michael@0 | 44 | do_check_false(Services.search.isInitialized); |
michael@0 | 45 | |
michael@0 | 46 | // test engines from dir are loaded. |
michael@0 | 47 | let engines = Services.search.getEngines(); |
michael@0 | 48 | do_check_true(engines.length > 1); |
michael@0 | 49 | |
michael@0 | 50 | // test jar engine is loaded ok. |
michael@0 | 51 | let engine = Services.search.getEngineByName("bug645970"); |
michael@0 | 52 | do_check_neq(engine, null); |
michael@0 | 53 | |
michael@0 | 54 | do_check_true(Services.search.isInitialized); |
michael@0 | 55 | } |
michael@0 | 56 | }, "browser-search-service", false); |
michael@0 | 57 | } |