Bug 1359085 - remove unused devtools util content-globals.js;r=ochameau
MozReview-Commit-ID: K8Knz9B0Gav
--- a/addon-sdk/source/lib/sdk/loader/sandbox.js
+++ b/addon-sdk/source/lib/sdk/loader/sandbox.js
@@ -10,39 +10,28 @@ module.metadata = {
const { Cc, Ci, CC, Cu } = require('chrome');
const systemPrincipal = CC('@mozilla.org/systemprincipal;1', 'nsIPrincipal')();
const scriptLoader = Cc['@mozilla.org/moz/jssubscript-loader;1'].
getService(Ci.mozIJSSubScriptLoader);
const self = require('sdk/self');
const { getTabId } = require('../tabs/utils');
const { getInnerId } = require('../window/utils');
-const { devtools } = Cu.import("resource://devtools/shared/Loader.jsm", {});
-const { require: devtoolsRequire } = devtools;
-const { addContentGlobal, removeContentGlobal } = devtoolsRequire("devtools/server/content-globals");
-
/**
* Make a new sandbox that inherits given `source`'s principals. Source can be
* URI string, DOMWindow or `null` for system principals.
*/
function sandbox(target, options) {
options = options || {};
options.metadata = options.metadata ? options.metadata : {};
options.metadata.addonID = options.metadata.addonID ?
options.metadata.addonID : self.id;
let sandbox = Cu.Sandbox(target || systemPrincipal, options);
Cu.setSandboxMetadata(sandbox, options.metadata);
- let innerWindowID = options.metadata['inner-window-id']
- if (innerWindowID) {
- addContentGlobal({
- global: sandbox,
- 'inner-window-id': innerWindowID
- });
- }
return sandbox;
}
exports.sandbox = sandbox;
/**
* Evaluates given `source` in a given `sandbox` and returns result.
*/
function evaluate(sandbox, code, uri, line, version) {
--- a/addon-sdk/source/test/test-page-mod-debug.js
+++ b/addon-sdk/source/test/test-page-mod-debug.js
@@ -5,20 +5,16 @@
const { Cc, Ci, Cu } = require("chrome");
const { PageMod } = require("sdk/page-mod");
const { testPageMod, handleReadyState, openNewTab,
contentScriptWhenServer, createLoader } = require("./page-mod/helpers");
const { cleanUI, after } = require("sdk/test/utils");
const { open, getFrames, getMostRecentBrowserWindow, getInnerId } = require("sdk/window/utils");
-const { devtools } = Cu.import("resource://devtools/shared/Loader.jsm", {});
-const { require: devtoolsRequire } = devtools;
-const contentGlobals = devtoolsRequire("devtools/server/content-globals");
-
// The following adds Debugger constructor to the global namespace.
const { addDebuggerToGlobal } = require('resource://gre/modules/jsdebugger.jsm');
addDebuggerToGlobal(this);
exports.testDebugMetadata = function(assert, done) {
let dbg = new Debugger;
let globalDebuggees = [];
dbg.onNewGlobalObject = function(global) {
@@ -41,26 +37,14 @@ exports.testDebugMetadata = function(ass
return false;
}
}), "one of the globals is a content script");
done();
}
);
};
-exports.testDevToolsExtensionsGetContentGlobals = function(assert, done) {
- let mods = testPageMod(assert, done, "about:", [{
- include: "about:",
- contentScriptWhen: "start",
- contentScript: "null;",
- }], function(win, done) {
- assert.equal(contentGlobals.getContentGlobals({ 'inner-window-id': getInnerId(win) }).length, 1);
- done();
- }
- );
-};
-
after(exports, function*(name, assert) {
assert.pass("cleaning ui.");
yield cleanUI();
});
require('sdk/test').run(exports);
deleted file mode 100644
--- a/devtools/server/content-globals.js
+++ /dev/null
@@ -1,48 +0,0 @@
-/* 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");
-
-var 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(innerWindowID) {
- globalsCache[innerWindowID] = globalsCache[innerWindowID] || [];
- return globalsCache[innerWindowID];
-}
-
-// when the window is destroyed, eliminate the associated globals cache
-if (!isWorker) {
- Services.obs.addObserver(function observer(subject, topic, data) {
- let id = subject.QueryInterface(Ci.nsISupportsPRUint64).data;
- delete globalsCache[id];
- }, "inner-window-destroyed");
-}
--- a/devtools/server/moz.build
+++ b/devtools/server/moz.build
@@ -25,21 +25,20 @@ XPIDL_MODULE = 'jsinspector'
SOURCES += [
'nsJSInspector.cpp',
]
FINAL_LIBRARY = 'xul'
DevToolsModules(
'child.js',
- 'content-globals.js',
'content-server.jsm',
'css-logic.js',
'event-parsers.js',
'main.js',
'primitive.js',
'service-worker-child.js',
'websocket-server.js',
'worker.js'
)
-with Files('**'):
- BUG_COMPONENT = ('Firefox', 'Developer Tools')
+with Files('**'):
+ BUG_COMPONENT = ('Firefox', 'Developer Tools')
--- a/devtools/shared/tests/mochitest/chrome.ini
+++ b/devtools/shared/tests/mochitest/chrome.ini
@@ -1,9 +1,8 @@
[DEFAULT]
tags = devtools
skip-if = os == 'android'
[test_css-logic-getCssPath.html]
-[test_devtools_extensions.html]
[test_dom_matrix_2d.html]
[test_eventemitter_basic.html]
skip-if = os == 'linux' && debug # Bug 1205739
deleted file mode 100644
--- a/devtools/shared/tests/mochitest/test_devtools_extensions.html
+++ /dev/null
@@ -1,117 +0,0 @@
-<!DOCTYPE html>
-<!--
- Any copyright is dedicated to the Public Domain.
- http://creativecommons.org/publicdomain/zero/1.0/
--->
-
-<html>
-
- <head>
- <meta charset="utf8">
- <title></title>
-
- <script type="application/javascript"
- src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
- <link rel="stylesheet" type="text/css"
- href="chrome://mochikit/content/tests/SimpleTest/test.css">
-
- <script type="application/javascript">
- const { classes: Cc, interfaces: Ci, utils: Cu } = Components;
-
- let { require } = Cu.import("resource://devtools/shared/Loader.jsm", {});
- const contentGlobals = require("devtools/server/content-globals");
- const Services = require("Services");
- const tabs = require('sdk/tabs');
- const { getMostRecentBrowserWindow, getInnerId } = require('sdk/window/utils');
- const { PageMod } = require('sdk/page-mod');
-
- var _tests = [];
- function addTest(test) {
- _tests.push(test);
- }
-
- function runNextTest() {
- if (_tests.length == 0) {
- SimpleTest.finish()
- return;
- }
- _tests.shift()();
- }
-
- window.onload = function() {
- SimpleTest.waitForExplicitFinish();
- runNextTest();
- }
-
- addTest(function () {
- let TEST_URL = 'data:text/html;charset=utf-8,test';
-
- let mod = PageMod({
- include: TEST_URL,
- contentScriptWhen: 'ready',
- contentScript: 'null;'
- });
-
- tabs.open({
- url: TEST_URL,
- onLoad: function(tab) {
- let id = getInnerId(getMostRecentBrowserWindow().gBrowser.selectedBrowser.contentWindow);
-
- // getting
- is(contentGlobals.getContentGlobals({
- 'inner-window-id': id
- }).length, 1, 'found a global for inner-id = ' + id);
-
- Services.obs.addObserver(function observer(subject, topic, data) {
- if (id == subject.QueryInterface(Components.interfaces.nsISupportsPRUint64).data) {
- Services.obs.removeObserver(observer, 'inner-window-destroyed');
- setTimeout(function() {
- // closing the tab window should have removed the global
- is(contentGlobals.getContentGlobals({
- 'inner-window-id': id
- }).length, 0, 'did not find a global for inner-id = ' + id);
-
- mod.destroy();
- runNextTest();
- })
- }
- }, 'inner-window-destroyed');
-
- tab.close();
- }
- });
- })
-
- addTest(function testAddRemoveGlobal() {
- let global = {};
- let globalDetails = {
- global: global,
- 'inner-window-id': 5
- };
-
- // adding
- contentGlobals.addContentGlobal(globalDetails);
-
- // getting
- is(contentGlobals.getContentGlobals({
- 'inner-window-id': 5
- }).length, 1, 'found a global for inner-id = 5');
- is(contentGlobals.getContentGlobals({
- 'inner-window-id': 4
- }).length, 0, 'did not find a global for inner-id = 4');
-
- // remove
- contentGlobals.removeContentGlobal(globalDetails);
-
- // getting again
- is(contentGlobals.getContentGlobals({
- 'inner-window-id': 5
- }).length, 0, 'did not find a global for inner-id = 5');
-
- runNextTest();
- });
-
- </script>
- </head>
- <body></body>
-</html>