forked from mozilla/gecko-dev
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bug 1003095 - Convert DevToolsExtensions.jsm into an SDK module;r=pas…
…t;r=ZER0
- Loading branch information
Showing
6 changed files
with
62 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
"use strict"; | ||
|
||
const { Ci } = require("chrome"); | ||
const Services = require("Services"); | ||
|
||
let globalsCache = {}; | ||
|
||
exports.addContentGlobal = function(options) { | ||
if (!options || !options.global || !options['inner-window-id']) { | ||
throw Error('Invalid arguments'); | ||
} | ||
let cache = getGlobalCache(options['inner-window-id']); | ||
cache.push(options.global); | ||
return undefined; | ||
} | ||
|
||
exports.getContentGlobals = function(options) { | ||
if (!options || !options['inner-window-id']) { | ||
throw Error('Invalid arguments'); | ||
} | ||
return Array.slice(globalsCache[options['inner-window-id']] || []); | ||
} | ||
|
||
exports.removeContentGlobal = function(options) { | ||
if (!options || !options.global || !options['inner-window-id']) { | ||
throw Error('Invalid arguments'); | ||
} | ||
let cache = getGlobalCache(options['inner-window-id']); | ||
let index = cache.indexOf(options.global); | ||
cache.splice(index, 1); | ||
return undefined; | ||
} | ||
|
||
function getGlobalCache(aInnerWindowID) { | ||
return globalsCache[aInnerWindowID] = globalsCache[aInnerWindowID] || []; | ||
} | ||
|
||
// when the window is destroyed, eliminate the associated globals cache | ||
Services.obs.addObserver(function observer(subject, topic, data) { | ||
let id = subject.QueryInterface(Ci.nsISupportsPRUint64).data; | ||
delete globalsCache[id]; | ||
}, 'inner-window-destroyed', false); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters