layout/tools/reftest/bootstrap.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/layout/tools/reftest/bootstrap.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,73 @@
     1.4 +Components.utils.import("resource://gre/modules/FileUtils.jsm");        
     1.5 +
     1.6 +function loadIntoWindow(window) {}
     1.7 +function unloadFromWindow(window) {}
     1.8 +
     1.9 +function setDefaultPrefs() {
    1.10 +    // This code sets the preferences for extension-based reftest.
    1.11 +    var prefs = Components.classes["@mozilla.org/preferences-service;1"].
    1.12 +                getService(Components.interfaces.nsIPrefService);
    1.13 +    var branch = prefs.getDefaultBranch("");
    1.14 +
    1.15 +#include reftest-preferences.js
    1.16 +}
    1.17 +
    1.18 +var windowListener = {
    1.19 +    onOpenWindow: function(aWindow) {
    1.20 +        let domWindow = aWindow.QueryInterface(Components.interfaces.nsIInterfaceRequestor).getInterface(Components.interfaces.nsIDOMWindowInternal || Components.interfaces.nsIDOMWindow);
    1.21 +        domWindow.addEventListener("load", function() {
    1.22 +            domWindow.removeEventListener("load", arguments.callee, false);
    1.23 +
    1.24 +            let wm = Components.classes["@mozilla.org/appshell/window-mediator;1"].getService(Components.interfaces.nsIWindowMediator);
    1.25 +
    1.26 +            // Load into any existing windows
    1.27 +            let enumerator = wm.getEnumerator("navigator:browser");
    1.28 +            while (enumerator.hasMoreElements()) {
    1.29 +                let win = enumerator.getNext().QueryInterface(Components.interfaces.nsIDOMWindow);
    1.30 +                setDefaultPrefs();
    1.31 +                Components.utils.import("chrome://reftest/content/reftest.jsm");
    1.32 +                win.addEventListener("pageshow", function() {
    1.33 +                    win.removeEventListener("pageshow", arguments.callee); 
    1.34 +                    // We add a setTimeout here because windows.innerWidth/Height are not set yet;
    1.35 +                    win.setTimeout(function () {OnRefTestLoad(win);}, 0);
    1.36 +                });
    1.37 +                break;
    1.38 +            }
    1.39 +        }, false);
    1.40 +   },
    1.41 +   onCloseWindow: function(aWindow){ },
    1.42 +   onWindowTitleChange: function(){ },
    1.43 +};
    1.44 +
    1.45 +function startup(aData, aReason) {
    1.46 +    let wm = Components.classes["@mozilla.org/appshell/window-mediator;1"].
    1.47 +             getService (Components.interfaces.nsIWindowMediator);
    1.48 +
    1.49 +    Components.manager.addBootstrappedManifestLocation(aData.installPath);
    1.50 +
    1.51 +    // Load into any new windows
    1.52 +    wm.addListener(windowListener);
    1.53 +}
    1.54 +
    1.55 +function shutdown(aData, aReason) {
    1.56 +    // When the application is shutting down we normally don't have to clean up any UI changes
    1.57 +    if (aReason == APP_SHUTDOWN)
    1.58 +        return;
    1.59 +
    1.60 +    let wm = Components.classes["@mozilla.org/appshell/window-mediator;1"].
    1.61 +             getService(Components.interfaces.nsIWindowMediator);
    1.62 +
    1.63 +    // Stop watching for new windows
    1.64 +    wm.removeListener(windowListener);
    1.65 +
    1.66 +    // Unload from any existing windows
    1.67 +    let enumerator = wm.getEnumerator("navigator:browser");
    1.68 +    while (enumerator.hasMoreElements()) {
    1.69 +        let win = enumerator.getNext().QueryInterface(Components.interfaces.nsIDOMWindow);
    1.70 +        unloadFromWindow(win);
    1.71 +    }
    1.72 +}
    1.73 +
    1.74 +function install(aData, aReason) { }
    1.75 +function uninstall(aData, aReason) { }
    1.76 +

mercurial