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 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 2 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 3 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 4 | let gSS = Services.search; |
michael@0 | 5 | |
michael@0 | 6 | function test() { |
michael@0 | 7 | waitForExplicitFinish(); |
michael@0 | 8 | |
michael@0 | 9 | function observer(aSubject, aTopic, aData) { |
michael@0 | 10 | switch (aData) { |
michael@0 | 11 | case "engine-added": |
michael@0 | 12 | let engine = gSS.getEngineByName("483086a"); |
michael@0 | 13 | ok(engine, "Test engine 1 installed"); |
michael@0 | 14 | isnot(engine.searchForm, "foo://example.com", |
michael@0 | 15 | "Invalid SearchForm URL dropped"); |
michael@0 | 16 | gSS.removeEngine(engine); |
michael@0 | 17 | break; |
michael@0 | 18 | case "engine-removed": |
michael@0 | 19 | Services.obs.removeObserver(observer, "browser-search-engine-modified"); |
michael@0 | 20 | test2(); |
michael@0 | 21 | break; |
michael@0 | 22 | } |
michael@0 | 23 | } |
michael@0 | 24 | |
michael@0 | 25 | Services.obs.addObserver(observer, "browser-search-engine-modified", false); |
michael@0 | 26 | gSS.addEngine("http://mochi.test:8888/browser/browser/components/search/test/483086-1.xml", |
michael@0 | 27 | Ci.nsISearchEngine.DATA_XML, "data:image/x-icon;%00", |
michael@0 | 28 | false); |
michael@0 | 29 | } |
michael@0 | 30 | |
michael@0 | 31 | function test2() { |
michael@0 | 32 | function observer(aSubject, aTopic, aData) { |
michael@0 | 33 | switch (aData) { |
michael@0 | 34 | case "engine-added": |
michael@0 | 35 | let engine = gSS.getEngineByName("483086b"); |
michael@0 | 36 | ok(engine, "Test engine 2 installed"); |
michael@0 | 37 | is(engine.searchForm, "http://example.com", "SearchForm is correct"); |
michael@0 | 38 | gSS.removeEngine(engine); |
michael@0 | 39 | break; |
michael@0 | 40 | case "engine-removed": |
michael@0 | 41 | Services.obs.removeObserver(observer, "browser-search-engine-modified"); |
michael@0 | 42 | finish(); |
michael@0 | 43 | break; |
michael@0 | 44 | } |
michael@0 | 45 | } |
michael@0 | 46 | |
michael@0 | 47 | Services.obs.addObserver(observer, "browser-search-engine-modified", false); |
michael@0 | 48 | gSS.addEngine("http://mochi.test:8888/browser/browser/components/search/test/483086-2.xml", |
michael@0 | 49 | Ci.nsISearchEngine.DATA_XML, "data:image/x-icon;%00", |
michael@0 | 50 | false); |
michael@0 | 51 | } |