|
1 Components.utils.import("resource://gre/modules/FileUtils.jsm"); |
|
2 |
|
3 function loadIntoWindow(window) {} |
|
4 function unloadFromWindow(window) {} |
|
5 |
|
6 function setDefaultPrefs() { |
|
7 // This code sets the preferences for extension-based reftest. |
|
8 var prefs = Components.classes["@mozilla.org/preferences-service;1"]. |
|
9 getService(Components.interfaces.nsIPrefService); |
|
10 var branch = prefs.getDefaultBranch(""); |
|
11 |
|
12 #include reftest-preferences.js |
|
13 } |
|
14 |
|
15 var windowListener = { |
|
16 onOpenWindow: function(aWindow) { |
|
17 let domWindow = aWindow.QueryInterface(Components.interfaces.nsIInterfaceRequestor).getInterface(Components.interfaces.nsIDOMWindowInternal || Components.interfaces.nsIDOMWindow); |
|
18 domWindow.addEventListener("load", function() { |
|
19 domWindow.removeEventListener("load", arguments.callee, false); |
|
20 |
|
21 let wm = Components.classes["@mozilla.org/appshell/window-mediator;1"].getService(Components.interfaces.nsIWindowMediator); |
|
22 |
|
23 // Load into any existing windows |
|
24 let enumerator = wm.getEnumerator("navigator:browser"); |
|
25 while (enumerator.hasMoreElements()) { |
|
26 let win = enumerator.getNext().QueryInterface(Components.interfaces.nsIDOMWindow); |
|
27 setDefaultPrefs(); |
|
28 Components.utils.import("chrome://reftest/content/reftest.jsm"); |
|
29 win.addEventListener("pageshow", function() { |
|
30 win.removeEventListener("pageshow", arguments.callee); |
|
31 // We add a setTimeout here because windows.innerWidth/Height are not set yet; |
|
32 win.setTimeout(function () {OnRefTestLoad(win);}, 0); |
|
33 }); |
|
34 break; |
|
35 } |
|
36 }, false); |
|
37 }, |
|
38 onCloseWindow: function(aWindow){ }, |
|
39 onWindowTitleChange: function(){ }, |
|
40 }; |
|
41 |
|
42 function startup(aData, aReason) { |
|
43 let wm = Components.classes["@mozilla.org/appshell/window-mediator;1"]. |
|
44 getService (Components.interfaces.nsIWindowMediator); |
|
45 |
|
46 Components.manager.addBootstrappedManifestLocation(aData.installPath); |
|
47 |
|
48 // Load into any new windows |
|
49 wm.addListener(windowListener); |
|
50 } |
|
51 |
|
52 function shutdown(aData, aReason) { |
|
53 // When the application is shutting down we normally don't have to clean up any UI changes |
|
54 if (aReason == APP_SHUTDOWN) |
|
55 return; |
|
56 |
|
57 let wm = Components.classes["@mozilla.org/appshell/window-mediator;1"]. |
|
58 getService(Components.interfaces.nsIWindowMediator); |
|
59 |
|
60 // Stop watching for new windows |
|
61 wm.removeListener(windowListener); |
|
62 |
|
63 // Unload from any existing windows |
|
64 let enumerator = wm.getEnumerator("navigator:browser"); |
|
65 while (enumerator.hasMoreElements()) { |
|
66 let win = enumerator.getNext().QueryInterface(Components.interfaces.nsIDOMWindow); |
|
67 unloadFromWindow(win); |
|
68 } |
|
69 } |
|
70 |
|
71 function install(aData, aReason) { } |
|
72 function uninstall(aData, aReason) { } |
|
73 |