diff --git a/toolkit/devtools/Loader.jsm b/toolkit/devtools/Loader.jsm index 49fce5c5324e..f2d1b2ca662d 100644 --- a/toolkit/devtools/Loader.jsm +++ b/toolkit/devtools/Loader.jsm @@ -49,6 +49,7 @@ BuiltinProvider.prototype = { load: function() { this.loader = new loader.Loader({ modules: { + "Services": Object.create(Services), "toolkit/loader": loader, "source-map": SourceMap, }, @@ -123,6 +124,7 @@ SrcdirProvider.prototype = { let acornWalkURI = OS.Path.join(acornURI, "walk.js"); this.loader = new loader.Loader({ modules: { + "Services": Object.create(Services), "toolkit/loader": loader, "source-map": SourceMap, }, diff --git a/toolkit/devtools/server/actors/device.js b/toolkit/devtools/server/actors/device.js index 9863104ee3f3..b8199929d9fd 100644 --- a/toolkit/devtools/server/actors/device.js +++ b/toolkit/devtools/server/actors/device.js @@ -3,12 +3,12 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ const {Cc, Ci, Cu, CC} = require("chrome"); +const Services = require("Services"); const protocol = require("devtools/server/protocol"); const {method, RetVal} = protocol; const promise = require("sdk/core/promise"); const {LongStringActor} = require("devtools/server/actors/string"); -Cu.import("resource://gre/modules/Services.jsm"); Cu.import("resource://gre/modules/PermissionsTable.jsm") Cu.import('resource://gre/modules/devtools/dbg-server.jsm'); diff --git a/toolkit/devtools/server/actors/eventlooplag.js b/toolkit/devtools/server/actors/eventlooplag.js index 4133fc84473b..3fb61075d268 100644 --- a/toolkit/devtools/server/actors/eventlooplag.js +++ b/toolkit/devtools/server/actors/eventlooplag.js @@ -9,13 +9,12 @@ */ const {Ci, Cu} = require("chrome"); +const Services = require("Services"); Cu.import("resource://gre/modules/XPCOMUtils.jsm"); const protocol = require("devtools/server/protocol"); const {method, Arg, RetVal} = protocol; const events = require("sdk/event/core"); -Cu.import("resource://gre/modules/Services.jsm"); - exports.register = function(handle) { handle.addGlobalActor(EventLoopLagActor, "eventLoopLagActor"); handle.addTabActor(EventLoopLagActor, "eventLoopLagActor"); diff --git a/toolkit/devtools/server/actors/gcli.js b/toolkit/devtools/server/actors/gcli.js index a2e48fff5314..6c2018da2616 100644 --- a/toolkit/devtools/server/actors/gcli.js +++ b/toolkit/devtools/server/actors/gcli.js @@ -11,8 +11,6 @@ XPCOMUtils.defineLazyModuleGetter(this, "console", "resource://gre/modules/devtools/Console.jsm"); XPCOMUtils.defineLazyModuleGetter(this, "CommandUtils", "resource:///modules/devtools/DeveloperToolbar.jsm"); -XPCOMUtils.defineLazyModuleGetter(this, "Services", - "resource://gre/modules/Services.jsm"); XPCOMUtils.defineLazyGetter(this, "Requisition", function() { return require("gcli/cli").Requisition; diff --git a/toolkit/devtools/server/actors/highlighter.js b/toolkit/devtools/server/actors/highlighter.js index 23f8419d60aa..53bcbfd6376d 100644 --- a/toolkit/devtools/server/actors/highlighter.js +++ b/toolkit/devtools/server/actors/highlighter.js @@ -5,6 +5,7 @@ "use strict"; const {Cu, Cc, Ci} = require("chrome"); +const Services = require("Services"); const protocol = require("devtools/server/protocol"); const {Arg, Option, method} = protocol; const events = require("sdk/event/core"); @@ -13,7 +14,6 @@ require("devtools/server/actors/inspector"); Cu.import("resource://gre/modules/devtools/LayoutHelpers.jsm"); Cu.import("resource://gre/modules/XPCOMUtils.jsm"); -Cu.import("resource://gre/modules/Services.jsm"); // FIXME: add ":visited" and ":link" after bug 713106 is fixed const PSEUDO_CLASSES = [":hover", ":active", ":focus"]; diff --git a/toolkit/devtools/server/actors/inspector.js b/toolkit/devtools/server/actors/inspector.js index c0df9c66df21..4c347c7ebfaa 100644 --- a/toolkit/devtools/server/actors/inspector.js +++ b/toolkit/devtools/server/actors/inspector.js @@ -51,7 +51,7 @@ */ const {Cc, Ci, Cu, Cr} = require("chrome"); - +const Services = require("Services"); const protocol = require("devtools/server/protocol"); const {Arg, Option, method, RetVal, types} = protocol; const {LongStringActor, ShortLongString} = require("devtools/server/actors/string"); @@ -103,7 +103,6 @@ const PSEUDO_SELECTORS = [ let HELPER_SHEET = ".__fx-devtools-hide-shortcut__ { visibility: hidden !important } "; HELPER_SHEET += ":-moz-devtools-highlighted { outline: 2px dashed #F06!important; outline-offset: -2px!important } "; -Cu.import("resource://gre/modules/Services.jsm"); Cu.import("resource://gre/modules/devtools/LayoutHelpers.jsm"); loader.lazyGetter(this, "DOMParser", function() { diff --git a/toolkit/devtools/server/actors/root.js b/toolkit/devtools/server/actors/root.js index 9daee9c73810..4be5bbdbabe9 100644 --- a/toolkit/devtools/server/actors/root.js +++ b/toolkit/devtools/server/actors/root.js @@ -8,8 +8,6 @@ /* Root actor for the remote debugging protocol. */ -Cu.import("resource://gre/modules/Services.jsm"); - /** * Methods shared between RootActor and BrowserTabActor. */ diff --git a/toolkit/devtools/server/actors/styleeditor.js b/toolkit/devtools/server/actors/styleeditor.js index d377912137cb..4a2df008ddab 100644 --- a/toolkit/devtools/server/actors/styleeditor.js +++ b/toolkit/devtools/server/actors/styleeditor.js @@ -4,10 +4,10 @@ "use strict"; -let { components, Cc, Ci, Cu } = require('chrome'); +let { components, Cc, Ci, Cu } = require("chrome"); +let Services = require("Services"); Cu.import("resource://gre/modules/XPCOMUtils.jsm"); -Cu.import("resource://gre/modules/Services.jsm"); Cu.import("resource://gre/modules/NetUtil.jsm"); Cu.import("resource://gre/modules/FileUtils.jsm"); Cu.import("resource://gre/modules/devtools/SourceMap.jsm"); diff --git a/toolkit/devtools/server/actors/styles.js b/toolkit/devtools/server/actors/styles.js index db396cf51cb2..68e7b97b8a91 100644 --- a/toolkit/devtools/server/actors/styles.js +++ b/toolkit/devtools/server/actors/styles.js @@ -5,6 +5,7 @@ "use strict"; const {Cc, Ci} = require("chrome"); +const Services = require("Services"); const promise = require("sdk/core/promise"); const protocol = require("devtools/server/protocol"); const {Arg, Option, method, RetVal, types} = protocol; @@ -13,7 +14,6 @@ const object = require("sdk/util/object"); const { Class } = require("sdk/core/heritage"); const { StyleSheetActor } = require("devtools/server/actors/stylesheets"); -loader.lazyImporter(this, "Services", "resource://gre/modules/Services.jsm"); loader.lazyGetter(this, "CssLogic", () => require("devtools/styleinspector/css-logic").CssLogic); loader.lazyGetter(this, "DOMUtils", () => Cc["@mozilla.org/inspector/dom-utils;1"].getService(Ci.inIDOMUtils)); diff --git a/toolkit/devtools/server/actors/stylesheets.js b/toolkit/devtools/server/actors/stylesheets.js index 80dc2c81b1f6..33b19b42871c 100644 --- a/toolkit/devtools/server/actors/stylesheets.js +++ b/toolkit/devtools/server/actors/stylesheets.js @@ -4,10 +4,10 @@ "use strict"; -let { components, Cc, Ci, Cu } = require('chrome'); +let { components, Cc, Ci, Cu } = require("chrome"); +let Services = require("Services"); Cu.import("resource://gre/modules/XPCOMUtils.jsm"); -Cu.import("resource://gre/modules/Services.jsm"); Cu.import("resource://gre/modules/NetUtil.jsm"); Cu.import("resource://gre/modules/FileUtils.jsm"); Cu.import("resource://gre/modules/devtools/SourceMap.jsm"); diff --git a/toolkit/devtools/server/actors/webapps.js b/toolkit/devtools/server/actors/webapps.js index dc771c247bba..50fb084e4deb 100644 --- a/toolkit/devtools/server/actors/webapps.js +++ b/toolkit/devtools/server/actors/webapps.js @@ -124,7 +124,6 @@ function WebappsActor(aConnection) { Cu.import("resource://gre/modules/Webapps.jsm"); Cu.import("resource://gre/modules/AppsUtils.jsm"); Cu.import("resource://gre/modules/FileUtils.jsm"); - Cu.import('resource://gre/modules/Services.jsm'); promise = Cu.import("resource://gre/modules/commonjs/sdk/core/promise.js").Promise; // Keep reference of already created app actors. diff --git a/toolkit/devtools/server/actors/webbrowser.js b/toolkit/devtools/server/actors/webbrowser.js index 1ead3b8ac37d..b2be3ddff2c1 100644 --- a/toolkit/devtools/server/actors/webbrowser.js +++ b/toolkit/devtools/server/actors/webbrowser.js @@ -7,7 +7,6 @@ "use strict"; let promise = Cu.import("resource://gre/modules/commonjs/sdk/core/promise.js", {}).Promise; -XPCOMUtils.defineLazyModuleGetter(this, "Services", "resource://gre/modules/Services.jsm"); XPCOMUtils.defineLazyModuleGetter(this, "AddonManager", "resource://gre/modules/AddonManager.jsm"); /** diff --git a/toolkit/devtools/server/actors/webgl.js b/toolkit/devtools/server/actors/webgl.js index b22b18f70524..9df1ce75e821 100644 --- a/toolkit/devtools/server/actors/webgl.js +++ b/toolkit/devtools/server/actors/webgl.js @@ -4,9 +4,7 @@ "use strict"; const {Cc, Ci, Cu, Cr} = require("chrome"); - -Cu.import("resource://gre/modules/Services.jsm"); - +const Services = require("Services"); const events = require("sdk/event/core"); const protocol = require("devtools/server/protocol"); diff --git a/toolkit/devtools/server/main.js b/toolkit/devtools/server/main.js index fb72bc6d0fe5..53f7eea38765 100644 --- a/toolkit/devtools/server/main.js +++ b/toolkit/devtools/server/main.js @@ -10,6 +10,7 @@ * debugging global. */ let DevToolsUtils = require("devtools/toolkit/DevToolsUtils.js"); +let Services = require("Services"); // Until all Debugger server code is converted to SDK modules, // imports Components.* alias from chrome module. @@ -23,6 +24,7 @@ this.CC = CC; this.Cu = Cu; this.Cr = Cr; this.DevToolsUtils = DevToolsUtils; +this.Services = Services; // Overload `Components` to prevent SDK loader exception on Components // object usage @@ -34,7 +36,6 @@ const DBG_STRINGS_URI = "chrome://global/locale/devtools/debugger.properties"; const nsFile = CC("@mozilla.org/file/local;1", "nsIFile", "initWithPath"); Cu.import("resource://gre/modules/reflect.jsm"); -Cu.import("resource://gre/modules/Services.jsm"); Cu.import("resource://gre/modules/XPCOMUtils.jsm"); let wantLogging = Services.prefs.getBoolPref("devtools.debugger.log"); diff --git a/toolkit/devtools/server/protocol.js b/toolkit/devtools/server/protocol.js index 9632e75ec846..68cb7cd6ec53 100644 --- a/toolkit/devtools/server/protocol.js +++ b/toolkit/devtools/server/protocol.js @@ -5,16 +5,13 @@ "use strict"; let {Cu} = require("chrome"); - +let Services = require("Services"); let promise = require("sdk/core/promise"); let {Class} = require("sdk/core/heritage"); let {EventTarget} = require("sdk/event/target"); let events = require("sdk/event/core"); let object = require("sdk/util/object"); -// For telemetry -Cu.import("resource://gre/modules/Services.jsm"); - // Waiting for promise.done() to be added, see bug 851321 function promiseDone(err) { console.error(err); diff --git a/toolkit/devtools/server/tests/mochitest/inspector-helpers.js b/toolkit/devtools/server/tests/mochitest/inspector-helpers.js index 99f88cf1061a..f85d7e0db9fd 100644 --- a/toolkit/devtools/server/tests/mochitest/inspector-helpers.js +++ b/toolkit/devtools/server/tests/mochitest/inspector-helpers.js @@ -1,6 +1,11 @@ var Cu = Components.utils; -Cu.import("resource://gre/modules/Services.jsm"); +Cu.import("resource://gre/modules/devtools/Loader.jsm"); +Cu.import("resource://gre/modules/devtools/dbg-client.jsm"); +Cu.import("resource://gre/modules/devtools/dbg-server.jsm"); + +const Services = devtools.require("Services"); +const {_documentWalker} = devtools.require("devtools/server/actors/inspector"); // Always log packets when running tests. Services.prefs.setBoolPref("devtools.debugger.log", true); @@ -8,11 +13,6 @@ SimpleTest.registerCleanupFunction(function() { Services.prefs.clearUserPref("devtools.debugger.log"); }); -Cu.import("resource://gre/modules/devtools/Loader.jsm"); -Cu.import("resource://gre/modules/devtools/dbg-client.jsm"); -Cu.import("resource://gre/modules/devtools/dbg-server.jsm"); - -const {_documentWalker} = devtools.require("devtools/server/actors/inspector"); if (!DebuggerServer.initialized) { DebuggerServer.init(() => true); diff --git a/toolkit/devtools/server/tests/unit/head_dbg.js b/toolkit/devtools/server/tests/unit/head_dbg.js index b3fc49524a20..fa1f4e7707c9 100644 --- a/toolkit/devtools/server/tests/unit/head_dbg.js +++ b/toolkit/devtools/server/tests/unit/head_dbg.js @@ -7,7 +7,9 @@ const Ci = Components.interfaces; const Cu = Components.utils; const Cr = Components.results; -Cu.import("resource://gre/modules/Services.jsm"); +const { devtools } = Cu.import("resource://gre/modules/devtools/Loader.jsm", {}); +const DevToolsUtils = devtools.require("devtools/toolkit/DevToolsUtils.js"); +const Services = devtools.require("Services"); // Always log packets when running tests. runxpcshelltests.py will throw // the output away anyway, unless you give it the --verbose flag. @@ -15,9 +17,6 @@ Services.prefs.setBoolPref("devtools.debugger.log", true); // Enable remote debugging for the relevant tests. Services.prefs.setBoolPref("devtools.debugger.remote-enabled", true); -const { devtools } = Cu.import("resource://gre/modules/devtools/Loader.jsm", {}); -const DevToolsUtils = devtools.require("devtools/toolkit/DevToolsUtils.js"); - function tryImport(url) { try { Cu.import(url);