michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: let gSS = Services.search; michael@0: michael@0: function test() { michael@0: waitForExplicitFinish(); michael@0: michael@0: function observer(aSubject, aTopic, aData) { michael@0: switch (aData) { michael@0: case "engine-added": michael@0: let engine = gSS.getEngineByName("483086a"); michael@0: ok(engine, "Test engine 1 installed"); michael@0: isnot(engine.searchForm, "foo://example.com", michael@0: "Invalid SearchForm URL dropped"); michael@0: gSS.removeEngine(engine); michael@0: break; michael@0: case "engine-removed": michael@0: Services.obs.removeObserver(observer, "browser-search-engine-modified"); michael@0: test2(); michael@0: break; michael@0: } michael@0: } michael@0: michael@0: Services.obs.addObserver(observer, "browser-search-engine-modified", false); michael@0: gSS.addEngine("http://mochi.test:8888/browser/browser/components/search/test/483086-1.xml", michael@0: Ci.nsISearchEngine.DATA_XML, "data:image/x-icon;%00", michael@0: false); michael@0: } michael@0: michael@0: function test2() { michael@0: function observer(aSubject, aTopic, aData) { michael@0: switch (aData) { michael@0: case "engine-added": michael@0: let engine = gSS.getEngineByName("483086b"); michael@0: ok(engine, "Test engine 2 installed"); michael@0: is(engine.searchForm, "http://example.com", "SearchForm is correct"); michael@0: gSS.removeEngine(engine); michael@0: break; michael@0: case "engine-removed": michael@0: Services.obs.removeObserver(observer, "browser-search-engine-modified"); michael@0: finish(); michael@0: break; michael@0: } michael@0: } michael@0: michael@0: Services.obs.addObserver(observer, "browser-search-engine-modified", false); michael@0: gSS.addEngine("http://mochi.test:8888/browser/browser/components/search/test/483086-2.xml", michael@0: Ci.nsISearchEngine.DATA_XML, "data:image/x-icon;%00", michael@0: false); michael@0: }