toolkit/devtools/DevToolsExtensions.jsm

Wed, 31 Dec 2014 13:27:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 13:27:57 +0100
branch
TOR_BUG_3246
changeset 6
8bccb770b82d
permissions
-rw-r--r--

Ignore runtime configuration files generated during quality assurance.

     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/. */
     4 "use strict";
     6 this.EXPORTED_SYMBOLS = ["gDevToolsExtensions"];
     8 Components.utils.import("resource://gre/modules/Services.jsm");
    10 let globalsCache = {};
    12 this.gDevToolsExtensions = {
    13   addContentGlobal: function(options) {
    14     if (!options || !options.global || !options['inner-window-id']) {
    15       throw Error('Invalid arguments');
    16     }
    17     let cache = getGlobalCache(options['inner-window-id']);
    18     cache.push(options.global);
    19     return undefined;
    20   },
    21   getContentGlobals: function(options) {
    22     if (!options || !options['inner-window-id']) {
    23       throw Error('Invalid arguments');
    24     }
    25     return Array.slice(globalsCache[options['inner-window-id']] || []);
    26   },
    27   removeContentGlobal: function(options) {
    28     if (!options || !options.global || !options['inner-window-id']) {
    29       throw Error('Invalid arguments');
    30     }
    31     let cache = getGlobalCache(options['inner-window-id']);
    32     let index = cache.indexOf(options.global);
    33     cache.splice(index, 1);
    34     return undefined;
    35   }
    36 };
    38 function getGlobalCache(aInnerWindowID) {
    39   return globalsCache[aInnerWindowID] = globalsCache[aInnerWindowID] || [];
    40 }
    42 // when the window is destroyed, eliminate the associated globals cache
    43 Services.obs.addObserver(function observer(subject, topic, data) {
    44   let id = subject.QueryInterface(Components.interfaces.nsISupportsPRUint64).data;
    45   delete globalsCache[id];
    46 }, 'inner-window-destroyed', false);

mercurial