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