1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/components/search/test/browser_483086.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,51 @@ 1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.6 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.7 +let gSS = Services.search; 1.8 + 1.9 +function test() { 1.10 + waitForExplicitFinish(); 1.11 + 1.12 + function observer(aSubject, aTopic, aData) { 1.13 + switch (aData) { 1.14 + case "engine-added": 1.15 + let engine = gSS.getEngineByName("483086a"); 1.16 + ok(engine, "Test engine 1 installed"); 1.17 + isnot(engine.searchForm, "foo://example.com", 1.18 + "Invalid SearchForm URL dropped"); 1.19 + gSS.removeEngine(engine); 1.20 + break; 1.21 + case "engine-removed": 1.22 + Services.obs.removeObserver(observer, "browser-search-engine-modified"); 1.23 + test2(); 1.24 + break; 1.25 + } 1.26 + } 1.27 + 1.28 + Services.obs.addObserver(observer, "browser-search-engine-modified", false); 1.29 + gSS.addEngine("http://mochi.test:8888/browser/browser/components/search/test/483086-1.xml", 1.30 + Ci.nsISearchEngine.DATA_XML, "data:image/x-icon;%00", 1.31 + false); 1.32 +} 1.33 + 1.34 +function test2() { 1.35 + function observer(aSubject, aTopic, aData) { 1.36 + switch (aData) { 1.37 + case "engine-added": 1.38 + let engine = gSS.getEngineByName("483086b"); 1.39 + ok(engine, "Test engine 2 installed"); 1.40 + is(engine.searchForm, "http://example.com", "SearchForm is correct"); 1.41 + gSS.removeEngine(engine); 1.42 + break; 1.43 + case "engine-removed": 1.44 + Services.obs.removeObserver(observer, "browser-search-engine-modified"); 1.45 + finish(); 1.46 + break; 1.47 + } 1.48 + } 1.49 + 1.50 + Services.obs.addObserver(observer, "browser-search-engine-modified", false); 1.51 + gSS.addEngine("http://mochi.test:8888/browser/browser/components/search/test/483086-2.xml", 1.52 + Ci.nsISearchEngine.DATA_XML, "data:image/x-icon;%00", 1.53 + false); 1.54 +}