browser_415700.js
Go to the documentation of this file.
1 /* ***** BEGIN LICENSE BLOCK *****
2  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
3  *
4  * The contents of this file are subject to the Mozilla Public License Version
5  * 1.1 (the "License"); you may not use this file except in compliance with
6  * the License. You may obtain a copy of the License at
7  * http://www.mozilla.org/MPL/
8  *
9  * Software distributed under the License is distributed on an "AS IS" basis,
10  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
11  * for the specific language governing rights and limitations under the
12  * License.
13  *
14  * The Original Code is mozilla.org code.
15  *
16  * The Initial Developer of the Original Code is Mozilla Foundation.
17  * Portions created by the Initial Developer are Copyright (C) 2008
18  * the Initial Developer. All Rights Reserved.
19  *
20  * Contributor(s):
21  * Ryan Flint <rflint@dslr.net> (Original Author)
22  *
23  * Alternatively, the contents of this file may be used under the terms of
24  * either the GNU General Public License Version 2 or later (the "GPL"), or
25  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
26  * in which case the provisions of the GPL or the LGPL are applicable instead
27  * of those above. If you wish to allow use of your version of this file only
28  * under the terms of either the GPL or the LGPL, and not to allow others to
29  * use your version of this file under the terms of the MPL, indicate your
30  * decision by deleting the provisions above and replace them with the notice
31  * and other provisions required by the GPL or the LGPL. If you do not delete
32  * the provisions above, a recipient may use your version of this file under
33  * the terms of any one of the MPL, the GPL or the LGPL.
34  *
35  * ***** END LICENSE BLOCK ***** */
36 var gSS = Cc["@mozilla.org/browser/search-service;1"].
37  getService(Ci.nsIBrowserSearchService);
38 var gObs = Cc["@mozilla.org/observer-service;1"].
39  getService(Ci.nsIObserverService);
40 
41 var observers = {
42  observe: function(aSubject, aTopic, aData) {
43  switch (aData) {
44  case "engine-added":
45  test2();
46  break;
47  case "engine-current":
48  test3();
49  break;
50  case "engine-removed":
51  test4();
52  break;
53  }
54  }
55 };
56 
57 function test() {
59  gObs.addObserver(observers, "browser-search-engine-modified", false);
60 
61  gSS.addEngine("http://localhost:8888/browser/browser/components/search/test/testEngine.xml",
62  Ci.nsISearchEngine.DATA_XML, "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAIAAACQkWg2AAABGklEQVQoz2NgGB6AnZ1dUlJSXl4eSDIyMhLW4Ovr%2B%2Fr168uXL69Zs4YoG%2BLi4i5dusTExMTGxsbNzd3f37937976%2BnpmZmagbHR09J49e5YvX66kpATVEBYW9ubNm2nTphkbG7e2tp44cQLIuHfvXm5urpaWFlDKysqqu7v73LlzECMYIiIiHj58mJCQoKKicvXq1bS0NKBgW1vbjh074uPjgeqAXE1NzSdPnvDz84M0AEUvXLgAsW379u1z5swBen3jxo2zZ892cHB4%2BvQp0KlAfwI1cHJyghQFBwfv2rULokFXV%2FfixYu7d%2B8GGqGgoMDKyrpu3br9%2B%2FcDuXl5eVA%2FAEWBfoWHAdAYoNuAYQ0XAeoUERFhGDYAAPoUaT2dfWJuAAAAAElFTkSuQmCC",
63  false);
64 }
65 
66 function test2() {
67  var engine = gSS.getEngineByName("Foo");
68  ok(engine, "Engine was added.");
69 
70  var aEngine = gSS.getEngineByAlias("fooalias");
71  ok(!aEngine, "Alias was not parsed from engine description");
72 
73  gSS.currentEngine = engine;
74 }
75 
76 function test3() {
77  var engine = gSS.currentEngine;
78  is(engine.name, "Foo", "Current engine was changed successfully");
79 
80  gSS.removeEngine(engine);
81 }
82 
83 function test4() {
84  var engine = gSS.currentEngine;
85  ok(engine, "An engine is present.");
86  isnot(engine.name, "Foo", "Current engine reset after removal");
87 
88  gObs.removeObserver(observers, "browser-search-engine-modified");
89  finish();
90 }
const Cc
var observers
var gObs
var gSS
function test3()
getService(Ci.sbIFaceplateManager)
function test()
waitForExplicitFinish()
function test4()
function test2()
const Ci
_updateTextAndScrollDataForFrame aData
sbDeviceFirmwareAutoCheckForUpdate prototype observe