layout/tools/reftest/bootstrap.js

Fri, 16 Jan 2015 04:50:19 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Fri, 16 Jan 2015 04:50:19 +0100
branch
TOR_BUG_9701
changeset 13
44a2da4a2ab2
permissions
-rw-r--r--

Replace accessor implementation with direct member state manipulation, by
request https://trac.torproject.org/projects/tor/ticket/9701#comment:32

     1 Components.utils.import("resource://gre/modules/FileUtils.jsm");        
     3 function loadIntoWindow(window) {}
     4 function unloadFromWindow(window) {}
     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("");
    12 #include reftest-preferences.js
    13 }
    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);
    21             let wm = Components.classes["@mozilla.org/appshell/window-mediator;1"].getService(Components.interfaces.nsIWindowMediator);
    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 };
    42 function startup(aData, aReason) {
    43     let wm = Components.classes["@mozilla.org/appshell/window-mediator;1"].
    44              getService (Components.interfaces.nsIWindowMediator);
    46     Components.manager.addBootstrappedManifestLocation(aData.installPath);
    48     // Load into any new windows
    49     wm.addListener(windowListener);
    50 }
    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;
    57     let wm = Components.classes["@mozilla.org/appshell/window-mediator;1"].
    58              getService(Components.interfaces.nsIWindowMediator);
    60     // Stop watching for new windows
    61     wm.removeListener(windowListener);
    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 }
    71 function install(aData, aReason) { }
    72 function uninstall(aData, aReason) { }

mercurial