testing/mochitest/roboextender/bootstrap.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     2 var Cc = Components.classes;
     3 var Ci = Components.interfaces;
     4 var Cu = Components.utils;
     6 Cu.import("resource://gre/modules/Services.jsm");
     8 function loadIntoWindow(window) {}
     9 function unloadFromWindow(window) {}
    11 function _sendMessageToJava (aMsg) {
    12   return Services.androidBridge.handleGeckoMessage(aMsg);
    13 };
    15 /*
    16  bootstrap.js API
    17 */
    18 var windowListener = {
    19   onOpenWindow: function(aWindow) {
    20     // Wait for the window to finish loading
    21     let domWindow = aWindow.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindowInternal || Ci.nsIDOMWindow);
    22     domWindow.addEventListener("load", function() {
    23       domWindow.removeEventListener("load", arguments.callee, false);
    24       if (domWindow) {
    25         domWindow.addEventListener("scroll", function(e) {
    26           let message = {
    27             type: 'robocop:scroll',
    28             y: XPCNativeWrapper.unwrap(e.target).documentElement.scrollTop,
    29             height: XPCNativeWrapper.unwrap(e.target).documentElement.scrollHeight,
    30             cheight: XPCNativeWrapper.unwrap(e.target).documentElement.clientHeight,
    31           };
    32           let retVal = _sendMessageToJava(message);
    33         });
    34       }
    35     }, false);
    36   },
    37   onCloseWindow: function(aWindow) { },
    38   onWindowTitleChange: function(aWindow, aTitle) { }
    39 };
    41 function startup(aData, aReason) {
    42   let wm = Cc["@mozilla.org/appshell/window-mediator;1"].getService(Ci.nsIWindowMediator);
    44   // Load into any new windows
    45   wm.addListener(windowListener);
    46   Services.obs.addObserver(function observe(aSubject, aTopic, aData) {
    47       dump("Robocop:Quit received -- requesting quit");
    48       let appStartup = Cc["@mozilla.org/toolkit/app-startup;1"].getService(Ci.nsIAppStartup);
    49       appStartup.quit(Ci.nsIAppStartup.eForceQuit);
    50   }, "Robocop:Quit", false);
    51 }
    53 function shutdown(aData, aReason) {
    54   // When the application is shutting down we normally don't have to clean up any UI changes
    55   if (aReason == APP_SHUTDOWN) return;
    57   let wm = Cc["@mozilla.org/appshell/window-mediator;1"].getService(Ci.nsIWindowMediator);
    59   // Stop watching for new windows
    60   wm.removeListener(windowListener);
    61 }
    63 function install(aData, aReason) { }
    64 function uninstall(aData, aReason) { }

mercurial