tools/quitter/contentscript.js

Thu, 15 Jan 2015 21:03:48 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 15 Jan 2015 21:03:48 +0100
branch
TOR_BUG_9701
changeset 11
deefc01c0e14
permissions
-rw-r--r--

Integrate friendly tips from Tor colleagues to make (or not) 4.5 alpha 3;
This includes removal of overloaded (but unused) methods, and addition of
a overlooked call to DataStruct::SetData(nsISupports, uint32_t, bool.)

     1 /* This Source Code Form is subject to the terms of the Mozilla Public
     2  * License, v. 2.0. If a copy of the MPL was not distributed with this
     3  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     5 var Ci = Components.interfaces;
     6 var Cc = Components.classes;
     8 function Quitter() {
     9 }
    11 Quitter.prototype = {
    12   toString: function() { return "[Quitter]"; },
    13   quit: function() {
    14     sendSyncMessage('Quitter.Quit', {});
    15   },
    16   __exposedProps__: {
    17     'toString': 'r',
    18     'quit': 'r'
    19   }
    20 };
    22 // This is a frame script, so it may be running in a content process.
    23 // In any event, it is targeted at a specific "tab", so we listen for
    24 // the DOMWindowCreated event to be notified about content windows
    25 // being created in this context.
    27 function QuitterManager() {
    28   addEventListener("DOMWindowCreated", this, false);
    29 }
    31 QuitterManager.prototype = {
    32   handleEvent: function handleEvent(aEvent) {
    33     var window = aEvent.target.defaultView;
    34     window.wrappedJSObject.Quitter = new Quitter(window);
    35   }
    36 };
    38 var quittermanager = new QuitterManager();

mercurial