Bug 1190452 - Always import toolkit/devtools/server/main.js as CommonJS module. r=jryans
authorAlexandre Poirot <poirot.alex@gmail.com>
Mon, 10 Aug 2015 05:38:56 -0700
changeset 257023 2fcd73fa8a7e713719ae9ce2c04cc6a458d7735a
parent 257022 b4c366e105ff179bc57937ed823f08bc65dc8424
child 257055 86b3b49cae3712b44f0474d9acd8be0ecd85a9b5
push id14564
push userapoirot@mozilla.com
push dateMon, 10 Aug 2015 12:39:40 +0000
treeherderfx-team@2fcd73fa8a7e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjryans
bugs1190452
milestone42.0a1
Bug 1190452 - Always import toolkit/devtools/server/main.js as CommonJS module. r=jryans
addon-sdk/source/lib/dev/debuggee.js
addon-sdk/source/test/addons/page-mod-debugger-post/main.js
addon-sdk/source/test/addons/page-mod-debugger-pre/main.js
b2g/chrome/content/devtools/debugger.js
browser/devtools/app-manager/test/test_connection_store.html
browser/devtools/app-manager/test/test_device_store.html
browser/devtools/app-manager/test/test_remain_connected.html
browser/devtools/canvasdebugger/test/head.js
browser/devtools/debugger/test/head.js
browser/devtools/framework/gDevTools.jsm
browser/devtools/framework/target.js
browser/devtools/framework/test/browser_toolbox_tool_remote_reopen.js
browser/devtools/framework/test/browser_two_tabs.js
browser/devtools/framework/test/head.js
browser/devtools/inspector/test/doc_frame_script.js
browser/devtools/performance/test/head.js
browser/devtools/scratchpad/scratchpad.js
browser/devtools/scratchpad/test/browser_scratchpad_throw_output.js
browser/devtools/shadereditor/test/head.js
browser/devtools/webaudioeditor/test/head.js
browser/devtools/webconsole/hudservice.js
browser/devtools/webconsole/test/browser_output_longstring_expand.js
browser/devtools/webconsole/test/browser_webconsole_output_01.js
browser/devtools/webconsole/test/browser_webconsole_promise.js
browser/devtools/webide/modules/runtimes.js
browser/devtools/webide/test/browser_tabs.js
browser/devtools/webide/test/sidebars/browser_tabs.js
browser/devtools/webide/test/sidebars/test_autoconnect_runtime.html
browser/devtools/webide/test/sidebars/test_autoselect_project.html
browser/devtools/webide/test/sidebars/test_device_permissions.html
browser/devtools/webide/test/sidebars/test_device_preferences.html
browser/devtools/webide/test/sidebars/test_device_settings.html
browser/devtools/webide/test/sidebars/test_fullscreenToolbox.html
browser/devtools/webide/test/sidebars/test_runtime.html
browser/devtools/webide/test/sidebars/test_telemetry.html
browser/devtools/webide/test/test_autoconnect_runtime.html
browser/devtools/webide/test/test_autoselect_project.html
browser/devtools/webide/test/test_device_permissions.html
browser/devtools/webide/test/test_device_preferences.html
browser/devtools/webide/test/test_device_runtime.html
browser/devtools/webide/test/test_device_settings.html
browser/devtools/webide/test/test_fullscreenToolbox.html
browser/devtools/webide/test/test_runtime.html
browser/devtools/webide/test/test_telemetry.html
mobile/android/chrome/content/RemoteDebugger.js
testing/xpcshell/head.js
toolkit/devtools/apps/tests/debugger-protocol-helper.js
toolkit/devtools/apps/tests/unit/head_apps.js
toolkit/devtools/client/connection-manager.js
toolkit/devtools/security/tests/unit/head_dbg.js
toolkit/devtools/server/child.js
toolkit/devtools/server/tests/browser/head.js
toolkit/devtools/server/tests/mochitest/director-helpers.js
toolkit/devtools/server/tests/mochitest/inspector-helpers.js
toolkit/devtools/server/tests/mochitest/memory-helpers.js
toolkit/devtools/server/tests/mochitest/test_connectToChild.html
toolkit/devtools/server/tests/mochitest/test_connection-manager.html
toolkit/devtools/server/tests/mochitest/test_device.html
toolkit/devtools/server/tests/mochitest/test_framerate_01.html
toolkit/devtools/server/tests/mochitest/test_framerate_02.html
toolkit/devtools/server/tests/mochitest/test_framerate_03.html
toolkit/devtools/server/tests/mochitest/test_framerate_05.html
toolkit/devtools/server/tests/mochitest/test_getProcess.html
toolkit/devtools/server/tests/mochitest/test_preference.html
toolkit/devtools/server/tests/mochitest/test_registerActor.html
toolkit/devtools/server/tests/mochitest/test_settings.html
toolkit/devtools/server/tests/mochitest/test_setupInParentChild.html
toolkit/devtools/server/tests/unit/test_dbgactor.js
toolkit/devtools/server/tests/unit/test_dbgclient_debuggerstatement.js
toolkit/devtools/server/tests/unit/test_dbgglobal.js
toolkit/devtools/transport/tests/unit/head_dbg.js
toolkit/devtools/transport/tests/unit/test_bulk_error.js
toolkit/devtools/transport/tests/unit/test_client_server_bulk.js
toolkit/devtools/transport/tests/unit/test_dbgsocket.js
toolkit/devtools/transport/tests/unit/test_dbgsocket_connection_drop.js
toolkit/devtools/transport/tests/unit/test_no_bulk.js
toolkit/devtools/transport/tests/unit/test_queue.js
toolkit/devtools/transport/tests/unit/test_transport_bulk.js
toolkit/devtools/webconsole/test/common.js
webapprt/RemoteDebugger.jsm
webapprt/test/chrome/browser_debugger.js
--- a/addon-sdk/source/lib/dev/debuggee.js
+++ b/addon-sdk/source/lib/dev/debuggee.js
@@ -6,17 +6,18 @@
 
 module.metadata = {
   "stability": "experimental"
 };
 
 const { Cu } = require("chrome");
 const { Class } = require("../sdk/core/heritage");
 const { MessagePort, MessageChannel } = require("../sdk/messaging");
-const { DebuggerServer } = Cu.import("resource://gre/modules/devtools/dbg-server.jsm", {});
+const { require: devtoolsRequire } = Cu.import("resource://gre/modules/devtools/Loader.jsm", {});
+const { DebuggerServer } = devtoolsRequire("devtools/server/main");
 
 const outputs = new WeakMap();
 const inputs = new WeakMap();
 const targets = new WeakMap();
 const transports = new WeakMap();
 
 const inputFor = port => inputs.get(port);
 const outputFor = port => outputs.get(port);
--- a/addon-sdk/source/test/addons/page-mod-debugger-post/main.js
+++ b/addon-sdk/source/test/addons/page-mod-debugger-post/main.js
@@ -7,17 +7,18 @@ const { Cu } = require('chrome');
 const { PageMod } = require('sdk/page-mod');
 const tabs = require('sdk/tabs');
 const { closeTab } = require('sdk/tabs/utils');
 const promise = require('sdk/core/promise')
 const { getMostRecentBrowserWindow } = require('sdk/window/utils');
 const { data } = require('sdk/self');
 const { set } = require('sdk/preferences/service');
 
-const { DebuggerServer } = Cu.import('resource://gre/modules/devtools/dbg-server.jsm', {});
+const { require: devtoolsRequire } = Cu.import("resource://gre/modules/devtools/Loader.jsm", {});
+const { DebuggerServer } = devtoolsRequire("devtools/server/main");
 const { DebuggerClient } = Cu.import('resource://gre/modules/devtools/dbg-client.jsm', {});
 
 let gClient;
 let ok;
 let testName = 'testDebugger';
 let iframeURL = 'data:text/html;charset=utf-8,' + testName;
 let TAB_URL = 'data:text/html;charset=utf-8,' + encodeURIComponent('<iframe src="' + iframeURL + '" />');
 TAB_URL = data.url('index.html');
--- a/addon-sdk/source/test/addons/page-mod-debugger-pre/main.js
+++ b/addon-sdk/source/test/addons/page-mod-debugger-pre/main.js
@@ -7,17 +7,18 @@ const { Cu } = require('chrome');
 const { PageMod } = require('sdk/page-mod');
 const tabs = require('sdk/tabs');
 const { closeTab } = require('sdk/tabs/utils');
 const promise = require('sdk/core/promise')
 const { getMostRecentBrowserWindow } = require('sdk/window/utils');
 const { data } = require('sdk/self');
 const { set } = require('sdk/preferences/service');
 
-const { DebuggerServer } = Cu.import('resource://gre/modules/devtools/dbg-server.jsm', {});
+const { require: devtoolsRequire } = Cu.import("resource://gre/modules/devtools/Loader.jsm", {});
+const { DebuggerServer } = devtoolsRequire("devtools/server/main");
 const { DebuggerClient } = Cu.import('resource://gre/modules/devtools/dbg-client.jsm', {});
 
 let gClient;
 let ok;
 let testName = 'testDebugger';
 let iframeURL = 'data:text/html;charset=utf-8,' + testName;
 let TAB_URL = 'data:text/html;charset=utf-8,' + encodeURIComponent('<iframe src="' + iframeURL + '" />');
 TAB_URL = data.url('index.html');
--- a/b2g/chrome/content/devtools/debugger.js
+++ b/b2g/chrome/content/devtools/debugger.js
@@ -1,27 +1,27 @@
 /* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- /
 /* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */
 /* 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";
 
-XPCOMUtils.defineLazyGetter(this, "DebuggerServer", function() {
-  Cu.import("resource://gre/modules/devtools/dbg-server.jsm");
-  return DebuggerServer;
-});
-
 XPCOMUtils.defineLazyGetter(this, "devtools", function() {
   const { devtools } =
     Cu.import("resource://gre/modules/devtools/Loader.jsm", {});
   return devtools;
 });
 
+XPCOMUtils.defineLazyGetter(this, "DebuggerServer", function() {
+  const { DebuggerServer } = devtools.require("devtools/server/main");
+  return DebuggerServer;
+});
+
 XPCOMUtils.defineLazyGetter(this, "B2GTabList", function() {
   const { B2GTabList } =
     devtools.require("resource://gre/modules/DebuggerActors.js");
   return B2GTabList;
 });
 
 // Load the discovery module eagerly, so that it can set a device name at
 // startup.  This does not cause discovery to start listening for packets, as
--- a/browser/devtools/app-manager/test/test_connection_store.html
+++ b/browser/devtools/app-manager/test/test_connection_store.html
@@ -20,31 +20,30 @@ Bug 901519 - [app manager] data store fo
       <span id="status" template='{"type":"textContent","path":"status"}'></span>
       <span id="host" template='{"type":"textContent","path":"host"}'></span>
       <span id="port" template='{"type":"textContent","path":"port"}'></span>
     </div>
 
     <script type="application/javascript;version=1.8" src="chrome://browser/content/devtools/app-manager/template.js"></script>
     <script type="application/javascript;version=1.8">
       const Cu = Components.utils;
-      Cu.import("resource://gre/modules/devtools/dbg-server.jsm");
+      const {require} = Cu.import("resource://gre/modules/devtools/Loader.jsm");
+      const {DebuggerServer} = require("devtools/server/main");
 
       if (!DebuggerServer.initialized) {
         DebuggerServer.init();
         DebuggerServer.addBrowserActors();
       }
 
       window.onload = function() {
         SimpleTest.waitForExplicitFinish();
 
         Cu.import("resource://gre/modules/Services.jsm");
         Cu.import("resource:///modules/devtools/gDevTools.jsm");
 
-        const {require} = Cu.import("resource://gre/modules/devtools/Loader.jsm", {});
-
         const {ConnectionManager} = require("devtools/client/connection-manager");
         const ConnectionStore = require("devtools/app-manager/connection-store");
 
         let connection = ConnectionManager.createConnection();
         let store = new ConnectionStore(connection);
 
         let root = document.querySelector("#root");
         let status = root.querySelector("#status");
--- a/browser/devtools/app-manager/test/test_device_store.html
+++ b/browser/devtools/app-manager/test/test_device_store.html
@@ -14,36 +14,34 @@ Bug 901520 - [app manager] data store fo
     <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css">
   </head>
 
   <body>
 
     <script type="application/javascript;version=1.8" src="chrome://browser/content/devtools/app-manager/template.js"></script>
     <script type="application/javascript;version=1.8">
       const Cu = Components.utils;
-      Cu.import("resource://gre/modules/devtools/dbg-server.jsm");
+      const {require} = Cu.import("resource://gre/modules/devtools/Loader.jsm");
+      const {DebuggerServer} = require("devtools/server/main");
 
       if (!DebuggerServer.initialized) {
         DebuggerServer.init();
         DebuggerServer.addBrowserActors();
       }
 
       function compare(o1, o2, msg) {
         is(JSON.stringify(o1), JSON.stringify(o2), msg);
       }
 
       window.onload = function() {
         SimpleTest.waitForExplicitFinish();
 
         Cu.import("resource://gre/modules/Services.jsm");
         Cu.import("resource:///modules/devtools/gDevTools.jsm");
 
-
-        const {require} = Cu.import("resource://gre/modules/devtools/Loader.jsm", {});
-
         const {ConnectionManager} = require("devtools/client/connection-manager");
         const DeviceStore = require("devtools/app-manager/device-store");
 
         let {getDeviceFront} = require("devtools/server/actors/device");
 
         let connection = ConnectionManager.createConnection();
         let store = new DeviceStore(connection);
 
--- a/browser/devtools/app-manager/test/test_remain_connected.html
+++ b/browser/devtools/app-manager/test/test_remain_connected.html
@@ -13,31 +13,29 @@ Bug 912646 - Closing app toolbox causes 
     <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">
   </head>
 
   <body>
 
     <script type="application/javascript;version=1.8">
       const Cu = Components.utils;
-
-      Cu.import("resource://gre/modules/devtools/dbg-server.jsm");
+      const {require} = Cu.import("resource://gre/modules/devtools/Loader.jsm");
+      const {DebuggerServer} = require("devtools/server/main");
 
       if (!DebuggerServer.initialized) {
         DebuggerServer.init();
         DebuggerServer.addBrowserActors();
       }
 
       window.onload = function() {
         SimpleTest.waitForExplicitFinish();
 
         Cu.import("resource:///modules/devtools/gDevTools.jsm");
 
-        const {require} =
-          Cu.import("resource://gre/modules/devtools/Loader.jsm", {});
         const {TargetFactory} = require("devtools/framework/target");
         const {Toolbox} = require("devtools/framework/toolbox");
 
         const {Connection, ConnectionManager} =
           require("devtools/client/connection-manager");
         const ConnectionStore =
           require("devtools/app-manager/connection-store");
 
--- a/browser/devtools/canvasdebugger/test/head.js
+++ b/browser/devtools/canvasdebugger/test/head.js
@@ -11,18 +11,19 @@ let { Services } = Cu.import("resource:/
 let gEnableLogging = Services.prefs.getBoolPref("devtools.debugger.log");
 Services.prefs.setBoolPref("devtools.debugger.log", false);
 
 let { generateUUID } = Cc['@mozilla.org/uuid-generator;1'].getService(Ci.nsIUUIDGenerator);
 let { Task } = Cu.import("resource://gre/modules/Task.jsm", {});
 let { Promise: promise } = Cu.import("resource://gre/modules/Promise.jsm", {});
 let { gDevTools } = Cu.import("resource:///modules/devtools/gDevTools.jsm", {});
 let { require } = Cu.import("resource://gre/modules/devtools/Loader.jsm", {});
-let { DebuggerServer } = Cu.import("resource://gre/modules/devtools/dbg-server.jsm", {});
 let { DebuggerClient } = Cu.import("resource://gre/modules/devtools/dbg-client.jsm", {});
+
+let { DebuggerServer } = require("devtools/server/main");
 let { CallWatcherFront } = require("devtools/server/actors/call-watcher");
 let { CanvasFront } = require("devtools/server/actors/canvas");
 let { setTimeout } = require("sdk/timers");
 let DevToolsUtils = require("devtools/toolkit/DevToolsUtils");
 let TiltGL = require("devtools/tilt/tilt-gl");
 let { TargetFactory } = require("devtools/framework/target");
 let { Toolbox } = require("devtools/framework/toolbox");
 let mm = null
--- a/browser/devtools/debugger/test/head.js
+++ b/browser/devtools/debugger/test/head.js
@@ -13,17 +13,17 @@ let gEnableLogging = Services.prefs.getB
 Services.prefs.setBoolPref("devtools.debugger.log", false);
 
 let { Task } = Cu.import("resource://gre/modules/Task.jsm", {});
 let { Promise: promise } = Cu.import("resource://gre/modules/devtools/deprecated-sync-thenables.js", {});
 let { gDevTools } = Cu.import("resource:///modules/devtools/gDevTools.jsm", {});
 let { require } = Cu.import("resource://gre/modules/devtools/Loader.jsm", {});
 let DevToolsUtils = require("devtools/toolkit/DevToolsUtils");
 let { BrowserToolboxProcess } = Cu.import("resource:///modules/devtools/ToolboxProcess.jsm", {});
-let { DebuggerServer } = Cu.import("resource://gre/modules/devtools/dbg-server.jsm", {});
+let { DebuggerServer } = require("devtools/server/main");
 let { DebuggerClient, ObjectClient } =
   Cu.import("resource://gre/modules/devtools/dbg-client.jsm", {});
 let { AddonManager } = Cu.import("resource://gre/modules/AddonManager.jsm", {});
 let EventEmitter = require("devtools/toolkit/event-emitter");
 const { promiseInvoke } = require("devtools/async-utils");
 let { TargetFactory } = require("devtools/framework/target");
 let { Toolbox } = require("devtools/framework/toolbox")
 
--- a/browser/devtools/framework/gDevTools.jsm
+++ b/browser/devtools/framework/gDevTools.jsm
@@ -16,20 +16,19 @@ loader.lazyRequireGetter(this, "TargetFa
 loader.lazyRequireGetter(this, "Toolbox", "devtools/framework/toolbox", true);
 
 XPCOMUtils.defineLazyModuleGetter(this, "promise",
                                   "resource://gre/modules/Promise.jsm", "Promise");
 XPCOMUtils.defineLazyModuleGetter(this, "console",
                                   "resource://gre/modules/devtools/Console.jsm");
 XPCOMUtils.defineLazyModuleGetter(this, "CustomizableUI",
                                   "resource:///modules/CustomizableUI.jsm");
-XPCOMUtils.defineLazyModuleGetter(this, "DebuggerServer",
-                                  "resource://gre/modules/devtools/dbg-server.jsm");
 XPCOMUtils.defineLazyModuleGetter(this, "DebuggerClient",
                                   "resource://gre/modules/devtools/dbg-client.jsm");
+loader.lazyRequireGetter(this, "DebuggerServer", "devtools/server/main", true);
 
 const DefaultTools = require("definitions").defaultTools;
 const EventEmitter = require("devtools/toolkit/event-emitter");
 const Telemetry = require("devtools/shared/telemetry");
 
 const TABS_OPEN_PEAK_HISTOGRAM = "DEVTOOLS_TABS_OPEN_PEAK_LINEAR";
 const TABS_OPEN_AVG_HISTOGRAM = "DEVTOOLS_TABS_OPEN_AVERAGE_LINEAR";
 const TABS_PINNED_PEAK_HISTOGRAM = "DEVTOOLS_TABS_PINNED_PEAK_LINEAR";
--- a/browser/devtools/framework/target.js
+++ b/browser/devtools/framework/target.js
@@ -4,18 +4,17 @@
 
 "use strict";
 
 const {Cc, Ci, Cu} = require("chrome");
 const {Promise: promise} = require("resource://gre/modules/Promise.jsm");
 const EventEmitter = require("devtools/toolkit/event-emitter");
 
 Cu.import("resource://gre/modules/XPCOMUtils.jsm");
-XPCOMUtils.defineLazyModuleGetter(this, "DebuggerServer",
-  "resource://gre/modules/devtools/dbg-server.jsm");
+loader.lazyRequireGetter(this, "DebuggerServer", "devtools/server/main", true);
 XPCOMUtils.defineLazyModuleGetter(this, "DebuggerClient",
   "resource://gre/modules/devtools/dbg-client.jsm");
 
 const targets = new WeakMap();
 const promiseTargets = new WeakMap();
 
 /**
  * Functions for creating Targets
--- a/browser/devtools/framework/test/browser_toolbox_tool_remote_reopen.js
+++ b/browser/devtools/framework/test/browser_toolbox_tool_remote_reopen.js
@@ -3,18 +3,17 @@
 
 ///////////////////
 //
 // Whitelisting this test.
 // As part of bug 1077403, the leaking uncaught rejection should be fixed.
 //
 thisTestLeaksUncaughtRejectionsAndShouldBeFixed("Error: Shader Editor is still waiting for a WebGL context to be created.");
 
-const { DebuggerServer } =
-  Cu.import("resource://gre/modules/devtools/dbg-server.jsm", {});
+const { DebuggerServer } = require("devtools/server/main");
 const { DebuggerClient } =
   Cu.import("resource://gre/modules/devtools/dbg-client.jsm", {});
 
 /**
  * Bug 979536: Ensure fronts are destroyed after toolbox close.
  *
  * The fronts need to be destroyed manually to unbind their onPacket handlers.
  *
--- a/browser/devtools/framework/test/browser_two_tabs.js
+++ b/browser/devtools/framework/test/browser_two_tabs.js
@@ -1,17 +1,16 @@
 /* Any copyright is dedicated to the Public Domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
 /**
  * Check regression when opening two tabs
  */
 
-let { DebuggerServer } =
-  Cu.import("resource://gre/modules/devtools/dbg-server.jsm", {});
+let { DebuggerServer } = require("devtools/server/main");
 let { DebuggerClient } =
   Cu.import("resource://gre/modules/devtools/dbg-client.jsm", {});
 
 const TAB_URL_1 = "data:text/html;charset=utf-8,foo";
 const TAB_URL_2 = "data:text/html;charset=utf-8,bar";
 
 let gClient;
 let gTab1, gTab2;
--- a/browser/devtools/framework/test/head.js
+++ b/browser/devtools/framework/test/head.js
@@ -14,17 +14,17 @@ function toggleAllTools(state) {
     } else {
       Services.prefs.clearUserPref(tool.visibilityswitch);
     }
   }
 }
 
 function getChromeActors(callback)
 {
-  let { DebuggerServer } = Cu.import("resource://gre/modules/devtools/dbg-server.jsm", {});
+  let { DebuggerServer } = require("devtools/server/main");
   let { DebuggerClient } = Cu.import("resource://gre/modules/devtools/dbg-client.jsm", {});
 
   if (!DebuggerServer.initialized) {
     DebuggerServer.init();
     DebuggerServer.addBrowserActors();
   }
   DebuggerServer.allowChromeProcess = true;
 
--- a/browser/devtools/inspector/test/doc_frame_script.js
+++ b/browser/devtools/inspector/test/doc_frame_script.js
@@ -34,17 +34,18 @@ addEventListener("DOMWindowCreated", () 
 
 /**
  * Given an actorID and connection prefix, get the corresponding actor from the
  * debugger-server connection.
  * @param {String} actorID
  * @param {String} connPrefix
  */
 function getHighlighterActor(actorID, connPrefix) {
-  let {DebuggerServer} = Cu.import("resource://gre/modules/devtools/dbg-server.jsm");
+  let {require} = Cu.import("resource://gre/modules/devtools/Loader.jsm");
+  let {DebuggerServer} = require("devtools/server/main");
   if (!DebuggerServer.initialized) {
     return;
   }
 
   let conn = DebuggerServer._connections[connPrefix];
   if (!conn) {
     return;
   }
--- a/browser/devtools/performance/test/head.js
+++ b/browser/devtools/performance/test/head.js
@@ -7,17 +7,17 @@ const { classes: Cc, interfaces: Ci, uti
 let { Services } = Cu.import("resource://gre/modules/Services.jsm", {});
 let { Preferences } = Cu.import("resource://gre/modules/Preferences.jsm", {});
 let { Task } = Cu.import("resource://gre/modules/Task.jsm", {});
 let { Promise } = Cu.import("resource://gre/modules/Promise.jsm", {});
 let { require } = Cu.import("resource://gre/modules/devtools/Loader.jsm", {});
 let { TargetFactory } = require("devtools/framework/target");
 let { gDevTools } = Cu.import("resource:///modules/devtools/gDevTools.jsm", {});
 const DevToolsUtils = require("devtools/toolkit/DevToolsUtils");
-let { DebuggerServer } = Cu.import("resource://gre/modules/devtools/dbg-server.jsm", {});
+let { DebuggerServer } = require("devtools/server/main");
 let { console } = require("resource://gre/modules/devtools/Console.jsm");
 let { merge } = require("sdk/util/object");
 let { generateUUID } = Cc["@mozilla.org/uuid-generator;1"].getService(Ci.nsIUUIDGenerator);
 let { getPerformanceFront, PerformanceFront } = require("devtools/performance/front");
 
 let mm = null;
 
 const FRAME_SCRIPT_UTILS_URL = "chrome://browser/content/devtools/frame-script-utils.js"
--- a/browser/devtools/scratchpad/scratchpad.js
+++ b/browser/devtools/scratchpad/scratchpad.js
@@ -38,17 +38,17 @@ const WRAP_TEXT = "devtools.scratchpad.w
 const SHOW_TRAILING_SPACE = "devtools.scratchpad.showTrailingSpace";
 const EDITOR_FONT_SIZE = "devtools.scratchpad.editorFontSize";
 const ENABLE_AUTOCOMPLETION = "devtools.scratchpad.enableAutocompletion";
 const TAB_SIZE = "devtools.editor.tabsize";
 const FALLBACK_CHARSET_LIST = "intl.fallbackCharsetList.ISO-8859-1";
 
 const VARIABLES_VIEW_URL = "chrome://browser/content/devtools/widgets/VariablesView.xul";
 
-const {require} = Cu.import("resource://gre/modules/devtools/Loader.jsm", {});
+const {require, devtools: loader} = Cu.import("resource://gre/modules/devtools/Loader.jsm", {});
 
 const Telemetry = require("devtools/shared/telemetry");
 const Editor    = require("devtools/sourceeditor/editor");
 const TargetFactory = require("devtools/framework/target").TargetFactory;
 const EventEmitter = require("devtools/toolkit/event-emitter");
 const {DevToolsWorker} = require("devtools/toolkit/shared/worker");
 const DevToolsUtils = require("devtools/toolkit/DevToolsUtils");
 
@@ -70,18 +70,17 @@ XPCOMUtils.defineLazyModuleGetter(this, 
   "resource:///modules/devtools/VariablesViewController.jsm");
 
 XPCOMUtils.defineLazyModuleGetter(this, "EnvironmentClient",
   "resource://gre/modules/devtools/dbg-client.jsm");
 
 XPCOMUtils.defineLazyModuleGetter(this, "ObjectClient",
   "resource://gre/modules/devtools/dbg-client.jsm");
 
-XPCOMUtils.defineLazyModuleGetter(this, "DebuggerServer",
-  "resource://gre/modules/devtools/dbg-server.jsm");
+loader.lazyRequireGetter(this, "DebuggerServer", "devtools/server/main", true);
 
 XPCOMUtils.defineLazyModuleGetter(this, "DebuggerClient",
   "resource://gre/modules/devtools/dbg-client.jsm");
 
 XPCOMUtils.defineLazyGetter(this, "REMOTE_TIMEOUT", () =>
   Services.prefs.getIntPref("devtools.debugger.remote-timeout"));
 
 XPCOMUtils.defineLazyModuleGetter(this, "ShortcutUtils",
--- a/browser/devtools/scratchpad/test/browser_scratchpad_throw_output.js
+++ b/browser/devtools/scratchpad/test/browser_scratchpad_throw_output.js
@@ -26,23 +26,22 @@ function testThrowOutput()
     tests.push({
       method: "display",
       code: "throw " + value + ";",
       result: "throw " + value + ";\n/*\nException: " + value + "\n*/",
       label: "Correct exception message for '" + value + "' is shown"
     });
   });
 
-  let server = Cu.import("resource://gre/modules/devtools/dbg-server.jsm", {})
-               .DebuggerServer;
+  let { DebuggerServer } = require("devtools/server/main");
 
-  let longLength = server.LONG_STRING_LENGTH + 1;
+  let longLength = DebuggerServer.LONG_STRING_LENGTH + 1;
   let longString = new Array(longLength).join("a");
-  let shortedString = longString.substring(0, server.LONG_STRING_INITIAL_LENGTH) +
-                      "\u2026";
+  let shortedString = longString.substring(0,
+    DebuggerServer.LONG_STRING_INITIAL_LENGTH) + "\u2026";
 
   tests.push({
     method: "display",
     code: "throw (new Array(" + longLength + ").join('a'));",
     result: "throw (new Array(" + longLength + ").join('a'));\n" +
             "/*\nException: " + shortedString + "\n*/",
     label: "Correct exception message for a longString is shown"
   });
--- a/browser/devtools/shadereditor/test/head.js
+++ b/browser/devtools/shadereditor/test/head.js
@@ -9,19 +9,19 @@ let { Services } = Cu.import("resource:/
 let gEnableLogging = Services.prefs.getBoolPref("devtools.debugger.log");
 // To enable logging for try runs, just set the pref to true.
 Services.prefs.setBoolPref("devtools.debugger.log", false);
 
 let { Task } = Cu.import("resource://gre/modules/Task.jsm", {});
 let { Promise: promise } = Cu.import("resource://gre/modules/Promise.jsm", {});
 let { gDevTools } = Cu.import("resource:///modules/devtools/gDevTools.jsm", {});
 let { require } = Cu.import("resource://gre/modules/devtools/Loader.jsm", {});
-let { DebuggerServer } = Cu.import("resource://gre/modules/devtools/dbg-server.jsm", {});
 let { DebuggerClient } = Cu.import("resource://gre/modules/devtools/dbg-client.jsm", {});
 
+let { DebuggerServer } = require("devtools/server/main");
 let { WebGLFront } = require("devtools/server/actors/webgl");
 let DevToolsUtils = require("devtools/toolkit/DevToolsUtils");
 let TiltGL = require("devtools/tilt/tilt-gl");
 let {TargetFactory} = require("devtools/framework/target");
 let {Toolbox} = require("devtools/framework/toolbox");
 let mm = null;
 
 const FRAME_SCRIPT_UTILS_URL = "chrome://browser/content/devtools/frame-script-utils.js"
--- a/browser/devtools/webaudioeditor/test/head.js
+++ b/browser/devtools/webaudioeditor/test/head.js
@@ -11,17 +11,17 @@ let { Services } = Cu.import("resource:/
 let gEnableLogging = Services.prefs.getBoolPref("devtools.debugger.log");
 Services.prefs.setBoolPref("devtools.debugger.log", false);
 
 let { Task } = Cu.import("resource://gre/modules/Task.jsm", {});
 let { Promise } = Cu.import("resource://gre/modules/Promise.jsm", {});
 let { gDevTools } = Cu.import("resource:///modules/devtools/gDevTools.jsm", {});
 let { require } = Cu.import("resource://gre/modules/devtools/Loader.jsm", {});
 let { TargetFactory } = require("devtools/framework/target");
-let { DebuggerServer } = Cu.import("resource://gre/modules/devtools/dbg-server.jsm", {});
+let { DebuggerServer } = require("devtools/server/main");
 let { generateUUID } = Cc["@mozilla.org/uuid-generator;1"].getService(Ci.nsIUUIDGenerator);
 
 let { WebAudioFront } = require("devtools/server/actors/webaudio");
 let DevToolsUtils = require("devtools/toolkit/DevToolsUtils");
 let audioNodes = require("devtools/server/actors/utils/audionodes.json");
 let mm = null;
 
 const FRAME_SCRIPT_UTILS_URL = "chrome://browser/content/devtools/frame-script-utils.js";
--- a/browser/devtools/webconsole/hudservice.js
+++ b/browser/devtools/webconsole/hudservice.js
@@ -13,17 +13,17 @@ let Heritage = require("sdk/core/heritag
 let {TargetFactory} = require("devtools/framework/target");
 let {Tools} = require("definitions");
 
 loader.lazyGetter(this, "Telemetry", () => require("devtools/shared/telemetry"));
 loader.lazyGetter(this, "WebConsoleFrame", () => require("devtools/webconsole/webconsole").WebConsoleFrame);
 loader.lazyImporter(this, "promise", "resource://gre/modules/Promise.jsm", "Promise");
 loader.lazyImporter(this, "gDevTools", "resource:///modules/devtools/gDevTools.jsm");
 loader.lazyImporter(this, "Services", "resource://gre/modules/Services.jsm");
-loader.lazyImporter(this, "DebuggerServer", "resource://gre/modules/devtools/dbg-server.jsm");
+loader.lazyRequireGetter(this, "DebuggerServer", "devtools/server/main", true);
 loader.lazyImporter(this, "DebuggerClient", "resource://gre/modules/devtools/dbg-client.jsm");
 loader.lazyGetter(this, "showDoorhanger", () => require("devtools/shared/doorhanger").showDoorhanger);
 loader.lazyRequireGetter(this, "sourceUtils", "devtools/shared/source-utils");
 
 const STRINGS_URI = "chrome://browser/locale/devtools/webconsole.properties";
 let l10n = new WebConsoleUtils.l10n(STRINGS_URI);
 
 const BROWSER_CONSOLE_WINDOW_FEATURES = "chrome,titlebar,toolbar,centerscreen,resizable,dialog=no";
--- a/browser/devtools/webconsole/test/browser_output_longstring_expand.js
+++ b/browser/devtools/webconsole/test/browser_output_longstring_expand.js
@@ -5,19 +5,17 @@
 // Test that long strings can be expanded in the console output.
 
 "use strict";
 
 const TEST_URI = "data:text/html;charset=utf8,test for bug 787981 - check " +
                  "that long strings can be expanded in the output.";
 
 let test = asyncTest(function* () {
-  let tempScope = {};
-  Cu.import("resource://gre/modules/devtools/dbg-server.jsm", tempScope);
-  let DebuggerServer = tempScope.DebuggerServer;
+  let { DebuggerServer } = require("devtools/server/main");
 
   let longString = (new Array(DebuggerServer.LONG_STRING_LENGTH + 4))
                     .join("a") + "foobar";
   let initialString =
     longString.substring(0, DebuggerServer.LONG_STRING_INITIAL_LENGTH);
 
   yield loadTab(TEST_URI);
 
--- a/browser/devtools/webconsole/test/browser_webconsole_output_01.js
+++ b/browser/devtools/webconsole/test/browser_webconsole_output_01.js
@@ -10,17 +10,17 @@
 "use strict";
 
 thisTestLeaksUncaughtRejectionsAndShouldBeFixed("null");
 
 // Test the webconsole output for various types of objects.
 
 const TEST_URI = "data:text/html;charset=utf8,test for console output - 01";
 
-let {DebuggerServer} = Cu.import("resource://gre/modules/devtools/dbg-server.jsm", {});
+let {DebuggerServer} = require("devtools/server/main");
 
 let LONG_STRING_LENGTH = DebuggerServer.LONG_STRING_LENGTH;
 let LONG_STRING_INITIAL_LENGTH = DebuggerServer.LONG_STRING_INITIAL_LENGTH;
 DebuggerServer.LONG_STRING_LENGTH = 100;
 DebuggerServer.LONG_STRING_INITIAL_LENGTH = 50;
 
 let longString = (new Array(DebuggerServer.LONG_STRING_LENGTH + 4)).join("a");
 let initialString = longString.substring(0, DebuggerServer.LONG_STRING_INITIAL_LENGTH);
--- a/browser/devtools/webconsole/test/browser_webconsole_promise.js
+++ b/browser/devtools/webconsole/test/browser_webconsole_promise.js
@@ -4,18 +4,17 @@
  */
 
 // Bug 1148759 - Test the webconsole can display promises inside objects.
 
 "use strict";
 
 const TEST_URI = "data:text/html;charset=utf8,test for console and promises";
 
-let {DebuggerServer} =
-  Cu.import("resource://gre/modules/devtools/dbg-server.jsm", {});
+let {DebuggerServer} = require("devtools/server/main");
 
 let LONG_STRING_LENGTH = DebuggerServer.LONG_STRING_LENGTH;
 let LONG_STRING_INITIAL_LENGTH = DebuggerServer.LONG_STRING_INITIAL_LENGTH;
 DebuggerServer.LONG_STRING_LENGTH = 100;
 DebuggerServer.LONG_STRING_INITIAL_LENGTH = 50;
 
 let longString = (new Array(DebuggerServer.LONG_STRING_LENGTH + 4)).join("a");
 let initialString = longString.substring(0,
--- a/browser/devtools/webide/modules/runtimes.js
+++ b/browser/devtools/webide/modules/runtimes.js
@@ -1,17 +1,17 @@
 /* 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/. */
 
 const {Cu, Ci} = require("chrome");
 const {Devices} = Cu.import("resource://gre/modules/devtools/Devices.jsm");
 const {Services} = Cu.import("resource://gre/modules/Services.jsm");
 const {Connection} = require("devtools/client/connection-manager");
-const {DebuggerServer} = require("resource://gre/modules/devtools/dbg-server.jsm");
+const {DebuggerServer} = require("devtools/server/main");
 const {Simulators} = require("devtools/webide/simulators");
 const discovery = require("devtools/toolkit/discovery/discovery");
 const EventEmitter = require("devtools/toolkit/event-emitter");
 const promise = require("promise");
 loader.lazyRequireGetter(this, "AuthenticationResult",
   "devtools/toolkit/security/auth", true);
 loader.lazyRequireGetter(this, "DevToolsUtils",
   "devtools/toolkit/DevToolsUtils");
--- a/browser/devtools/webide/test/browser_tabs.js
+++ b/browser/devtools/webide/test/browser_tabs.js
@@ -4,18 +4,17 @@
 
 const TEST_URI = "http://example.com/browser/browser/devtools/webide/test/doc_tabs.html";
 
 function test() {
   waitForExplicitFinish();
   requestCompleteLog();
 
   Task.spawn(function*() {
-    const { DebuggerServer } =
-      Cu.import("resource://gre/modules/devtools/dbg-server.jsm", {});
+    const { DebuggerServer } = require("devtools/server/main");
 
     // Since we test the connections set below, destroy the server in case it
     // was left open.
     DebuggerServer.destroy();
     DebuggerServer.init();
     DebuggerServer.addBrowserActors();
 
     let tab = yield addTab(TEST_URI);
--- a/browser/devtools/webide/test/sidebars/browser_tabs.js
+++ b/browser/devtools/webide/test/sidebars/browser_tabs.js
@@ -4,18 +4,17 @@
 
 const TEST_URI = "http://example.com/browser/browser/devtools/webide/test/doc_tabs.html";
 
 function test() {
   waitForExplicitFinish();
   requestCompleteLog();
 
   Task.spawn(function*() {
-    const { DebuggerServer } =
-      Cu.import("resource://gre/modules/devtools/dbg-server.jsm", {});
+    const { DebuggerServer } = require("devtools/server/main");
 
     Services.prefs.setBoolPref("devtools.webide.sidebars", true);
 
     // Since we test the connections set below, destroy the server in case it
     // was left open.
     DebuggerServer.destroy();
     DebuggerServer.init();
     DebuggerServer.addBrowserActors();
--- a/browser/devtools/webide/test/sidebars/test_autoconnect_runtime.html
+++ b/browser/devtools/webide/test/sidebars/test_autoconnect_runtime.html
@@ -14,17 +14,17 @@
 
   <body>
 
     <script type="application/javascript;version=1.8">
       window.onload = function() {
         SimpleTest.waitForExplicitFinish();
 
         Task.spawn(function*() {
-          Cu.import("resource://gre/modules/devtools/dbg-server.jsm");
+          const { DebuggerServer } = require("devtools/server/main");
           Services.prefs.setBoolPref("devtools.webide.sidebars", true);
 
           if (!DebuggerServer.initialized) {
             DebuggerServer.init();
             DebuggerServer.addBrowserActors();
           }
 
           let win = yield openWebIDE();
--- a/browser/devtools/webide/test/sidebars/test_autoselect_project.html
+++ b/browser/devtools/webide/test/sidebars/test_autoselect_project.html
@@ -14,17 +14,17 @@
 
   <body>
 
     <script type="application/javascript;version=1.8">
       window.onload = function() {
         SimpleTest.waitForExplicitFinish();
 
         Task.spawn(function* () {
-          Cu.import("resource://gre/modules/devtools/dbg-server.jsm");
+          const { DebuggerServer } = require("devtools/server/main");
           Services.prefs.setBoolPref("devtools.webide.sidebars", true);
 
           if (!DebuggerServer.initialized) {
             DebuggerServer.init();
             DebuggerServer.addBrowserActors();
           }
 
           let win = yield openWebIDE();
--- a/browser/devtools/webide/test/sidebars/test_device_permissions.html
+++ b/browser/devtools/webide/test/sidebars/test_device_permissions.html
@@ -14,17 +14,17 @@
 
   <body>
 
     <script type="application/javascript;version=1.8">
       window.onload = function() {
         SimpleTest.waitForExplicitFinish();
 
         Task.spawn(function* () {
-          Cu.import("resource://gre/modules/devtools/dbg-server.jsm");
+          const { DebuggerServer } = require("devtools/server/main");
           Services.prefs.setBoolPref("devtools.webide.sidebars", true);
 
           if (!DebuggerServer.initialized) {
             DebuggerServer.init();
             DebuggerServer.addBrowserActors();
           }
 
           let win = yield openWebIDE();
--- a/browser/devtools/webide/test/sidebars/test_device_preferences.html
+++ b/browser/devtools/webide/test/sidebars/test_device_preferences.html
@@ -14,17 +14,17 @@
 
   <body>
 
     <script type="application/javascript;version=1.8">
       window.onload = function() {
         SimpleTest.waitForExplicitFinish();
 
         Task.spawn(function* () {
-          Cu.import("resource://gre/modules/devtools/dbg-server.jsm");
+          const { DebuggerServer } = require("devtools/server/main");
           Services.prefs.setBoolPref("devtools.webide.sidebars", true);
 
           if (!DebuggerServer.initialized) {
             DebuggerServer.init();
             DebuggerServer.addBrowserActors();
           }
 
           let win = yield openWebIDE();
--- a/browser/devtools/webide/test/sidebars/test_device_settings.html
+++ b/browser/devtools/webide/test/sidebars/test_device_settings.html
@@ -14,17 +14,17 @@
 
   <body>
 
     <script type="application/javascript;version=1.8">
       window.onload = function() {
         SimpleTest.waitForExplicitFinish();
 
         Task.spawn(function*() {
-          Cu.import("resource://gre/modules/devtools/dbg-server.jsm");
+          const { DebuggerServer } = require("devtools/server/main");
 
           if (SpecialPowers.isMainProcess()) {
             Cu.import("resource://gre/modules/SettingsRequestManager.jsm");
           }
 
           Services.prefs.setBoolPref("devtools.webide.sidebars", true);
 
           if (!DebuggerServer.initialized) {
--- a/browser/devtools/webide/test/sidebars/test_fullscreenToolbox.html
+++ b/browser/devtools/webide/test/sidebars/test_fullscreenToolbox.html
@@ -23,17 +23,17 @@
         docRuntime.querySelectorAll(".runtime-panel-item-other")[1].click();
         return deferred.promise;
       }
 
       window.onload = function() {
         SimpleTest.waitForExplicitFinish();
 
         Task.spawn(function* () {
-          Cu.import("resource://gre/modules/devtools/dbg-server.jsm");
+          const { DebuggerServer } = require("devtools/server/main");
           Services.prefs.setBoolPref("devtools.webide.sidebars", true);
           let win = yield openWebIDE();
           let docProject = getProjectDocument(win);
           let docRuntime = getRuntimeDocument(win);
           win.AppManager.update("runtime-list");
 
           yield connectToLocal(win, docRuntime);
 
@@ -56,17 +56,16 @@
           win.Cmds.showRuntimeDetails();
 
           ok(!nbox.hasAttribute("toolboxfullscreen"), "Toolbox is not fullscreen");
 
           yield win.Cmds.disconnectRuntime();
 
           yield closeWebIDE(win);
 
-          const { DebuggerServer } = Cu.import("resource://gre/modules/devtools/dbg-server.jsm", {});
           DebuggerServer.destroy();
 
           SimpleTest.finish();
         });
       }
     </script>
   </body>
 </html>
--- a/browser/devtools/webide/test/sidebars/test_runtime.html
+++ b/browser/devtools/webide/test/sidebars/test_runtime.html
@@ -36,17 +36,17 @@
           function isPlayActive() {
             return !win.document.querySelector("#cmd_play").hasAttribute("disabled");
           }
 
           function isStopActive() {
             return !win.document.querySelector("#cmd_stop").hasAttribute("disabled");
           }
 
-          Cu.import("resource://gre/modules/devtools/dbg-server.jsm");
+          const { DebuggerServer } = require("devtools/server/main");
 
           if (!DebuggerServer.initialized) {
             DebuggerServer.init();
             DebuggerServer.addBrowserActors();
           }
 
           win = yield openWebIDE();
           let docRuntime = getRuntimeDocument(win);
--- a/browser/devtools/webide/test/sidebars/test_telemetry.html
+++ b/browser/devtools/webide/test/sidebars/test_telemetry.html
@@ -14,16 +14,17 @@
 
   <body>
 
     <script type="application/javascript;version=1.8">
       const Telemetry = require("devtools/shared/telemetry");
       const { _DeprecatedUSBRuntime, _WiFiRuntime, _SimulatorRuntime,
               _gRemoteRuntime, _gLocalRuntime, RuntimeTypes }
             = require("devtools/webide/runtimes");
+      const { DebuggerServer } = require("devtools/server/main");
 
       // Because we need to gather stats for the period of time that a tool has
       // been opened we make use of setTimeout() to create tool active times.
       const TOOL_DELAY = 200;
 
       function patchTelemetry() {
         Telemetry.prototype.telemetryInfo = {};
         Telemetry.prototype._oldlog = Telemetry.prototype.log;
@@ -270,17 +271,16 @@
             }
             DebuggerServer.destroy();
             yield removeAllProjects();
             resetTelemetry();
           });
         });
 
         Task.spawn(function*() {
-          Cu.import("resource://gre/modules/devtools/dbg-server.jsm");
           Services.prefs.setBoolPref("devtools.webide.sidebars", true);
 
           if (!DebuggerServer.initialized) {
             DebuggerServer.init();
             DebuggerServer.addBrowserActors();
           }
 
           patchTelemetry();
--- a/browser/devtools/webide/test/test_autoconnect_runtime.html
+++ b/browser/devtools/webide/test/test_autoconnect_runtime.html
@@ -14,18 +14,17 @@
 
   <body>
 
     <script type="application/javascript;version=1.8">
       window.onload = function() {
         SimpleTest.waitForExplicitFinish();
 
         Task.spawn(function* () {
-
-          Cu.import("resource://gre/modules/devtools/dbg-server.jsm");
+          const { DebuggerServer } = require("devtools/server/main");
 
           if (!DebuggerServer.initialized) {
             DebuggerServer.init();
             DebuggerServer.addBrowserActors();
           }
 
           let win = yield openWebIDE();
 
--- a/browser/devtools/webide/test/test_autoselect_project.html
+++ b/browser/devtools/webide/test/test_autoselect_project.html
@@ -14,18 +14,17 @@
 
   <body>
 
     <script type="application/javascript;version=1.8">
       window.onload = function() {
         SimpleTest.waitForExplicitFinish();
 
         Task.spawn(function* () {
-
-          Cu.import("resource://gre/modules/devtools/dbg-server.jsm");
+          const { DebuggerServer } = require("devtools/server/main");
 
           if (!DebuggerServer.initialized) {
             DebuggerServer.init();
             DebuggerServer.addBrowserActors();
           }
 
           let win = yield openWebIDE();
 
--- a/browser/devtools/webide/test/test_device_permissions.html
+++ b/browser/devtools/webide/test/test_device_permissions.html
@@ -14,17 +14,17 @@
 
   <body>
 
     <script type="application/javascript;version=1.8">
       window.onload = function() {
         SimpleTest.waitForExplicitFinish();
 
         Task.spawn(function* () {
-          Cu.import("resource://gre/modules/devtools/dbg-server.jsm");
+          const { DebuggerServer } = require("devtools/server/main");
 
           if (!DebuggerServer.initialized) {
             DebuggerServer.init();
             DebuggerServer.addBrowserActors();
           }
 
           let win = yield openWebIDE();
 
--- a/browser/devtools/webide/test/test_device_preferences.html
+++ b/browser/devtools/webide/test/test_device_preferences.html
@@ -14,17 +14,17 @@
 
   <body>
 
     <script type="application/javascript;version=1.8">
       window.onload = function() {
         SimpleTest.waitForExplicitFinish();
 
         Task.spawn(function* () {
-          Cu.import("resource://gre/modules/devtools/dbg-server.jsm");
+          const { DebuggerServer } = require("devtools/server/main");
 
           if (!DebuggerServer.initialized) {
             DebuggerServer.init();
             DebuggerServer.addBrowserActors();
           }
 
           let win = yield openWebIDE();
 
--- a/browser/devtools/webide/test/test_device_runtime.html
+++ b/browser/devtools/webide/test/test_device_runtime.html
@@ -14,17 +14,17 @@
 
   <body>
 
     <script type="application/javascript;version=1.8">
       window.onload = function() {
         SimpleTest.waitForExplicitFinish();
 
         Task.spawn(function* () {
-          Cu.import("resource://gre/modules/devtools/dbg-server.jsm");
+          const { DebuggerServer } = require("devtools/server/main");
 
           if (!DebuggerServer.initialized) {
             DebuggerServer.init();
             DebuggerServer.addBrowserActors();
           }
 
           let win = yield openWebIDE();
 
--- a/browser/devtools/webide/test/test_device_settings.html
+++ b/browser/devtools/webide/test/test_device_settings.html
@@ -14,17 +14,17 @@
 
   <body>
 
     <script type="application/javascript;version=1.8">
       window.onload = function() {
         SimpleTest.waitForExplicitFinish();
 
         Task.spawn(function*() {
-          Cu.import("resource://gre/modules/devtools/dbg-server.jsm");
+          const { DebuggerServer } = require("devtools/server/main");
 
           if (SpecialPowers.isMainProcess()) {
             Cu.import("resource://gre/modules/SettingsRequestManager.jsm");
           }
 
           if (!DebuggerServer.initialized) {
             DebuggerServer.init();
             DebuggerServer.addBrowserActors();
--- a/browser/devtools/webide/test/test_fullscreenToolbox.html
+++ b/browser/devtools/webide/test/test_fullscreenToolbox.html
@@ -24,17 +24,17 @@
         win.document.querySelectorAll(".runtime-panel-item-other")[1].click();
         return deferred.promise;
       }
 
       window.onload = function() {
         SimpleTest.waitForExplicitFinish();
 
         Task.spawn(function* () {
-          Cu.import("resource://gre/modules/devtools/dbg-server.jsm");
+          const { DebuggerServer } = require("devtools/server/main");
           win = yield openWebIDE();
           win.AppManager.update("runtime-list");
 
           yield connectToLocal(win);
 
           // Select main process
           yield win.Cmds.showProjectPanel();
           yield waitForUpdate(win, "runtime-targets");
@@ -55,17 +55,16 @@
           win.Cmds.showRuntimeDetails();
 
           ok(!nbox.hasAttribute("toolboxfullscreen"), "Toolbox is not fullscreen");
 
           yield win.Cmds.disconnectRuntime();
 
           yield closeWebIDE(win);
 
-          const { DebuggerServer } = Cu.import("resource://gre/modules/devtools/dbg-server.jsm", {});
           DebuggerServer.destroy();
 
           SimpleTest.finish();
         });
       }
 
 
     </script>
--- a/browser/devtools/webide/test/test_runtime.html
+++ b/browser/devtools/webide/test/test_runtime.html
@@ -35,17 +35,17 @@
           function isPlayActive() {
             return !win.document.querySelector("#cmd_play").hasAttribute("disabled");
           }
 
           function isStopActive() {
             return !win.document.querySelector("#cmd_stop").hasAttribute("disabled");
           }
 
-          Cu.import("resource://gre/modules/devtools/dbg-server.jsm");
+          const { DebuggerServer } = require("devtools/server/main");
 
           if (!DebuggerServer.initialized) {
             DebuggerServer.init();
             DebuggerServer.addBrowserActors();
           }
 
           win = yield openWebIDE();
 
--- a/browser/devtools/webide/test/test_telemetry.html
+++ b/browser/devtools/webide/test/test_telemetry.html
@@ -14,16 +14,17 @@
 
   <body>
 
     <script type="application/javascript;version=1.8">
       const Telemetry = require("devtools/shared/telemetry");
       const { _DeprecatedUSBRuntime, _WiFiRuntime, _SimulatorRuntime,
               _gRemoteRuntime, _gLocalRuntime, RuntimeTypes }
             = require("devtools/webide/runtimes");
+      const { DebuggerServer } = require("devtools/server/main");
 
       // Because we need to gather stats for the period of time that a tool has
       // been opened we make use of setTimeout() to create tool active times.
       const TOOL_DELAY = 200;
 
       function patchTelemetry() {
         Telemetry.prototype.telemetryInfo = {};
         Telemetry.prototype._oldlog = Telemetry.prototype.log;
@@ -270,18 +271,16 @@
             }
             DebuggerServer.destroy();
             yield removeAllProjects();
             resetTelemetry();
           });
         });
 
         Task.spawn(function*() {
-          Cu.import("resource://gre/modules/devtools/dbg-server.jsm");
-
           if (!DebuggerServer.initialized) {
             DebuggerServer.init();
             DebuggerServer.addBrowserActors();
           }
 
           patchTelemetry();
 
           // Cycle once, so we can test for multiple opens
--- a/mobile/android/chrome/content/RemoteDebugger.js
+++ b/mobile/android/chrome/content/RemoteDebugger.js
@@ -1,17 +1,20 @@
 // -*- Mode: js; tab-width: 2; indent-tabs-mode: nil; js2-basic-offset: 2; js2-skip-preprocessor-directives: t; -*-
 /* 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/. */
 /* globals DebuggerServer */
 "use strict";
 
-XPCOMUtils.defineLazyModuleGetter(this, "DebuggerServer",
-                                  "resource://gre/modules/devtools/dbg-server.jsm");
+XPCOMUtils.defineLazyGetter(this, "DebuggerServer", () => {
+  let { require } = Cu.import("resource://gre/modules/devtools/Loader.jsm", {});
+  let { DebuggerServer } = require("devtools/server/main");
+  return DebuggerServer;
+});
 
 let RemoteDebugger = {
   init() {
     USBRemoteDebugger.init();
     WiFiRemoteDebugger.init();
   },
 
   get isAnyEnabled() {
--- a/testing/xpcshell/head.js
+++ b/testing/xpcshell/head.js
@@ -373,18 +373,19 @@ function _setupDebuggerServer(breakpoint
                       .getService(Components.interfaces.nsIEnvironment);
   if (env.get("DEVTOOLS_DEBUGGER_LOG")) {
     prefs.setBoolPref("devtools.debugger.log", true);
   }
   if (env.get("DEVTOOLS_DEBUGGER_LOG_VERBOSE")) {
     prefs.setBoolPref("devtools.debugger.log.verbose", true);
   }
 
-  let {DebuggerServer, OriginalLocation} =
-    Components.utils.import('resource://gre/modules/devtools/dbg-server.jsm', {});
+  let { require } = Cu.import("resource://gre/modules/devtools/Loader.jsm", {});
+  let { DebuggerServer } = require("devtools/server/main");
+  let { OriginalLocation } = require("devtools/server/actors/common");
   DebuggerServer.init();
   DebuggerServer.addBrowserActors();
   DebuggerServer.addActors("resource://testing-common/dbg-actors.js");
   DebuggerServer.allowChromeProcess = true;
 
   // An observer notification that tells us when we can "resume" script
   // execution.
   let obsSvc = Components.classes["@mozilla.org/observer-service;1"].
--- a/toolkit/devtools/apps/tests/debugger-protocol-helper.js
+++ b/toolkit/devtools/apps/tests/debugger-protocol-helper.js
@@ -1,18 +1,18 @@
 /* Any copyright is dedicated to the Public Domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
 const Cc = Components.classes;
 const Ci = Components.interfaces;
 const Cu = Components.utils;
 
-const { DebuggerServer } = Cu.import("resource://gre/modules/devtools/dbg-server.jsm");
 const { DebuggerClient } = Cu.import("resource://gre/modules/devtools/dbg-client.jsm");
 const { require } = Cu.import("resource://gre/modules/devtools/Loader.jsm", {});
+const { DebuggerServer } = require("devtools/server/main");
 const { FileUtils } = Cu.import("resource://gre/modules/FileUtils.jsm");
 const { Services } = Cu.import("resource://gre/modules/Services.jsm");
 
 let gClient, gActor;
 
 function connect(onDone) {
 
   if (Services.appinfo.name == "B2G") {
--- a/toolkit/devtools/apps/tests/unit/head_apps.js
+++ b/toolkit/devtools/apps/tests/unit/head_apps.js
@@ -2,23 +2,23 @@
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
 const Cc = Components.classes;
 const Ci = Components.interfaces;
 const Cu = Components.utils;
 const Cr = Components.results;
 const CC = Components.Constructor;
 
-Cu.import("resource://gre/modules/devtools/dbg-server.jsm");
 Cu.import("resource://gre/modules/devtools/dbg-client.jsm");
 
 Cu.import("resource://gre/modules/Services.jsm");
 Cu.import("resource://gre/modules/XPCOMUtils.jsm");
 Cu.import("resource://gre/modules/FileUtils.jsm");
 const {require} = Cu.import("resource://gre/modules/devtools/Loader.jsm", {});
+const {DebuggerServer} = require("devtools/server/main");
 const {AppActorFront} = require("devtools/app-actor-front");
 
 let gClient, gActor, gActorFront;
 
 function connect(onDone) {
   // Initialize a loopback remote protocol connection
   DebuggerServer.init();
   // We need to register browser actors to have `listTabs` working
--- a/toolkit/devtools/client/connection-manager.js
+++ b/toolkit/devtools/client/connection-manager.js
@@ -5,20 +5,20 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 "use strict";
 
 const {Cc, Ci, Cu, Cr} = require("chrome");
 const {setTimeout, clearTimeout} = require('sdk/timers');
 const EventEmitter = require("devtools/toolkit/event-emitter");
 const DevToolsUtils = require("devtools/toolkit/DevToolsUtils");
+const { DebuggerServer } = require("devtools/server/main");
 
 Cu.import("resource://gre/modules/Services.jsm");
 Cu.import("resource://gre/modules/devtools/dbg-client.jsm");
-Cu.import("resource://gre/modules/devtools/dbg-server.jsm");
 DevToolsUtils.defineLazyModuleGetter(this, "Task",
   "resource://gre/modules/Task.jsm");
 
 const REMOTE_TIMEOUT = "devtools.debugger.remote-timeout";
 
 /**
  * Connection Manager.
  *
--- a/toolkit/devtools/security/tests/unit/head_dbg.js
+++ b/toolkit/devtools/security/tests/unit/head_dbg.js
@@ -12,16 +12,17 @@ const { require } =
   Cu.import("resource://gre/modules/devtools/Loader.jsm", {});
 const { Promise: promise } =
   Cu.import("resource://gre/modules/Promise.jsm", {});
 const { Task } = Cu.import("resource://gre/modules/Task.jsm", {});
 
 const Services = require("Services");
 const DevToolsUtils = require("devtools/toolkit/DevToolsUtils.js");
 const xpcInspector = require("xpcInspector");
+const { DebuggerServer } = require("devtools/server/main");
 
 // We do not want to log packets by default, because in some tests,
 // we can be sending large amounts of data. The test harness has
 // trouble dealing with logging all the data, and we end up with
 // intermittent time outs (e.g. bug 775924).
 // Services.prefs.setBoolPref("devtools.debugger.log", true);
 // Services.prefs.setBoolPref("devtools.debugger.log.verbose", true);
 // Enable remote debugging for the relevant tests.
@@ -34,17 +35,16 @@ function tryImport(url) {
     Cu.import(url);
   } catch (e) {
     dump("Error importing " + url + "\n");
     dump(DevToolsUtils.safeErrorString(e) + "\n");
     throw e;
   }
 }
 
-tryImport("resource://gre/modules/devtools/dbg-server.jsm");
 tryImport("resource://gre/modules/devtools/dbg-client.jsm");
 
 // Convert an nsIScriptError 'aFlags' value into an appropriate string.
 function scriptErrorFlagsToKind(aFlags) {
   var kind;
   if (aFlags & Ci.nsIScriptError.warningFlag)
     kind = "warning";
   if (aFlags & Ci.nsIScriptError.exceptionFlag)
--- a/toolkit/devtools/server/child.js
+++ b/toolkit/devtools/server/child.js
@@ -10,17 +10,17 @@ let chromeGlobal = this;
 
 // Encapsulate in its own scope to allows loading this frame script
 // more than once.
 (function () {
   let Cu = Components.utils;
   let { require } = Cu.import("resource://gre/modules/devtools/Loader.jsm", {});
   const DevToolsUtils = require("devtools/toolkit/DevToolsUtils.js");
   const { dumpn } = DevToolsUtils;
-  const { DebuggerServer, ActorPool } = Cu.import("resource://gre/modules/devtools/dbg-server.jsm", {});
+  const { DebuggerServer, ActorPool } = require("devtools/server/main");
 
   // Note that this frame script may be evaluated in non-e10s build
   // In such case, DebuggerServer is already going to be initialized.
   if (!DebuggerServer.initialized) {
     DebuggerServer.init();
     DebuggerServer.isInChildProcess = true;
   }
 
--- a/toolkit/devtools/server/tests/browser/head.js
+++ b/toolkit/devtools/server/tests/browser/head.js
@@ -5,17 +5,17 @@
 const Cc = Components.classes;
 const Ci = Components.interfaces;
 const Cu = Components.utils;
 
 Cu.import("resource://gre/modules/Services.jsm");
 const {console} = Cu.import("resource://gre/modules/devtools/Console.jsm", {});
 const {require} = Cu.import("resource://gre/modules/devtools/Loader.jsm", {});
 const {DebuggerClient} = Cu.import("resource://gre/modules/devtools/dbg-client.jsm", {});
-const {DebuggerServer} = Cu.import("resource://gre/modules/devtools/dbg-server.jsm", {});
+const {DebuggerServer} = require("devtools/server/main");
 
 const PATH = "browser/toolkit/devtools/server/tests/browser/";
 const MAIN_DOMAIN = "http://test1.example.org/" + PATH;
 const ALT_DOMAIN = "http://sectest1.example.org/" + PATH;
 const ALT_DOMAIN_SECURED = "https://sectest1.example.org:443/" + PATH;
 
 // All tests are asynchronous.
 waitForExplicitFinish();
--- a/toolkit/devtools/server/tests/mochitest/director-helpers.js
+++ b/toolkit/devtools/server/tests/mochitest/director-helpers.js
@@ -1,13 +1,12 @@
 var Cu = Components.utils;
 Cu.import("resource://gre/modules/devtools/dbg-client.jsm");
-Cu.import("resource://gre/modules/devtools/dbg-server.jsm");
 const {require} = Cu.import("resource://gre/modules/devtools/Loader.jsm", {});
-
+const {DebuggerServer} = require("devtools/server/main");
 const Services = require("Services");
 
 // Always log packets when running tests.
 Services.prefs.setBoolPref("devtools.debugger.log", true);
 Services.prefs.setBoolPref("dom.mozBrowserFramesEnabled", true);
 
 SimpleTest.registerCleanupFunction(function() {
   Services.prefs.clearUserPref("devtools.debugger.log");
--- a/toolkit/devtools/server/tests/mochitest/inspector-helpers.js
+++ b/toolkit/devtools/server/tests/mochitest/inspector-helpers.js
@@ -1,13 +1,13 @@
 var Cu = Components.utils;
 
 const {require} = 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 {DebuggerServer} = require("devtools/server/main");
 Cu.import("resource://gre/modules/Task.jsm");
 
 const Services = require("Services");
 const {_documentWalker} = require("devtools/server/actors/inspector");
 
 // Always log packets when running tests.
 Services.prefs.setBoolPref("devtools.debugger.log", true);
 SimpleTest.registerCleanupFunction(function() {
--- a/toolkit/devtools/server/tests/mochitest/memory-helpers.js
+++ b/toolkit/devtools/server/tests/mochitest/memory-helpers.js
@@ -6,20 +6,20 @@ Cu.import("resource://gre/modules/Servic
 
 // Always log packets when running tests.
 Services.prefs.setBoolPref("devtools.debugger.log", true);
 SimpleTest.registerCleanupFunction(function() {
   Services.prefs.clearUserPref("devtools.debugger.log");
 });
 
 Cu.import("resource://gre/modules/devtools/dbg-client.jsm");
-Cu.import("resource://gre/modules/devtools/dbg-server.jsm");
 
 Cu.import("resource://gre/modules/Task.jsm");
 let { require } = Cu.import("resource://gre/modules/devtools/Loader.jsm", {});
+let { DebuggerServer } = require("devtools/server/main");
 
 let { MemoryFront } = require("devtools/server/actors/memory");
 
 function startServerAndGetSelectedTabMemory() {
   DebuggerServer.init();
   DebuggerServer.addBrowserActors();
   var client = new DebuggerClient(DebuggerServer.connectPipe());
 
--- a/toolkit/devtools/server/tests/mochitest/test_connectToChild.html
+++ b/toolkit/devtools/server/tests/mochitest/test_connectToChild.html
@@ -13,17 +13,18 @@ Bug 966991 - Test DebuggerServer.connect
 <pre id="test">
 <script type="application/javascript;version=1.8">
 
 let Cu = Components.utils;
 let Cc = Components.classes;
 let Ci = Components.interfaces;
 
 Cu.import("resource://gre/modules/devtools/dbg-client.jsm");
-Cu.import("resource://gre/modules/devtools/dbg-server.jsm");
+let { require } = Cu.import("resource://gre/modules/devtools/Loader.jsm");
+let { DebuggerServer } = require("devtools/server/main");
 
 window.onload = function() {
   SimpleTest.waitForExplicitFinish();
 
   SpecialPowers.pushPrefEnv({
     "set": [
       // Always log packets when running tests.
       ["devtools.debugger.log", true],
@@ -38,17 +39,18 @@ function runTests() {
   iframe.mozbrowser = true;
   document.body.appendChild(iframe);
 
   let mm = iframe.QueryInterface(Ci.nsIFrameLoaderOwner).frameLoader.messageManager;
 
   // Register a test actor in the child process so that we can know if and when
   // this fake actor is disconnected.
   mm.loadFrameScript("data:text/javascript,new " + function FrameScriptScope() {
-    const {DebuggerServer} = Cu.import("resource://gre/modules/devtools/dbg-server.jsm", {});
+    const { require } = Cu.import("resource://gre/modules/devtools/Loader.jsm");
+    const { DebuggerServer } = require("devtools/server/main");
 
     if (!DebuggerServer.initialized) {
       DebuggerServer.init();
     }
 
     function TestActor() {dump("instanciate test actor\n");}
     TestActor.prototype = {
       actorPrefix: "test",
--- a/toolkit/devtools/server/tests/mochitest/test_connection-manager.html
+++ b/toolkit/devtools/server/tests/mochitest/test_connection-manager.html
@@ -13,18 +13,18 @@ Bug 898485 - [app manager] Implement an 
 <pre id="test">
 <script>
 
 window.onload = function() {
   SimpleTest.waitForExplicitFinish();
 
   var Cu = Components.utils;
 
-  Cu.import("resource://gre/modules/devtools/dbg-server.jsm");
   var {require} = Cu.import("resource://gre/modules/devtools/Loader.jsm", {});
+  var {DebuggerServer} = require("devtools/server/main");
   Cu.import("resource://gre/modules/Services.jsm");
 
   if (!DebuggerServer.initialized) {
     DebuggerServer.init();
     DebuggerServer.addBrowserActors();
   }
 
   var {ConnectionManager, Connection} = require("devtools/client/connection-manager");
--- a/toolkit/devtools/server/tests/mochitest/test_device.html
+++ b/toolkit/devtools/server/tests/mochitest/test_device.html
@@ -16,17 +16,17 @@ Bug 895360 - [app manager] Device meta d
 window.onload = function() {
   var Cu = Components.utils;
   var Cc = Components.classes;
   var Ci = Components.interfaces;
 
   Cu.import("resource://gre/modules/PermissionsTable.jsm");
   var {require} = 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");
+  var {DebuggerServer} = require("devtools/server/main");
   Cu.import("resource://gre/modules/Services.jsm");
 
   SimpleTest.waitForExplicitFinish();
 
   var {getDeviceFront} = require("devtools/server/actors/device");
 
   if (!DebuggerServer.initialized) {
     DebuggerServer.init();
--- a/toolkit/devtools/server/tests/mochitest/test_framerate_01.html
+++ b/toolkit/devtools/server/tests/mochitest/test_framerate_01.html
@@ -23,17 +23,17 @@ window.onload = function() {
   // Always log packets when running tests.
   Services.prefs.setBoolPref("devtools.debugger.log", true);
   SimpleTest.registerCleanupFunction(function() {
     Services.prefs.clearUserPref("devtools.debugger.log");
   });
 
   var { require } = 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");
+  var { DebuggerServer } = require("devtools/server/main");
 
   SimpleTest.waitForExplicitFinish();
 
   var {FramerateFront} = require("devtools/server/actors/framerate");
 
   function plotFPS(ticks, interval = 100, clamp = 60) {
     var timeline = [];
     var totalTicks = ticks.length;
--- a/toolkit/devtools/server/tests/mochitest/test_framerate_02.html
+++ b/toolkit/devtools/server/tests/mochitest/test_framerate_02.html
@@ -23,17 +23,17 @@ window.onload = function() {
   // Always log packets when running tests.
   Services.prefs.setBoolPref("devtools.debugger.log", true);
   SimpleTest.registerCleanupFunction(function() {
     Services.prefs.clearUserPref("devtools.debugger.log");
   });
 
   var {require} = 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");
+  var {DebuggerServer} = require("devtools/server/main");
 
   SimpleTest.waitForExplicitFinish();
 
   var {FramerateFront} = require("devtools/server/actors/framerate");
 
   function plotFPS(ticks, interval = 100, clamp = 60) {
     var timeline = [];
     var totalTicks = ticks.length;
--- a/toolkit/devtools/server/tests/mochitest/test_framerate_03.html
+++ b/toolkit/devtools/server/tests/mochitest/test_framerate_03.html
@@ -23,17 +23,17 @@ window.onload = function() {
   // Always log packets when running tests.
   Services.prefs.setBoolPref("devtools.debugger.log", true);
   SimpleTest.registerCleanupFunction(function() {
     Services.prefs.clearUserPref("devtools.debugger.log");
   });
 
   var {require} = 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");
+  var {DebuggerServer} = require("devtools/server/main");
 
   SimpleTest.waitForExplicitFinish();
 
   var {FramerateFront} = require("devtools/server/actors/framerate");
   var START_TICK = 2000;
   var STOP_TICK = 3000;
   var TOTAL_TIME = 5000;
 
--- a/toolkit/devtools/server/tests/mochitest/test_framerate_05.html
+++ b/toolkit/devtools/server/tests/mochitest/test_framerate_05.html
@@ -23,17 +23,17 @@ window.onload = function() {
   // Always log packets when running tests.
   Services.prefs.setBoolPref("devtools.debugger.log", true);
   SimpleTest.registerCleanupFunction(function() {
     Services.prefs.clearUserPref("devtools.debugger.log");
   });
 
   var {require} = 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");
+  var {DebuggerServer} = require("devtools/server/main");
 
   SimpleTest.waitForExplicitFinish();
 
   var {FramerateFront} = require("devtools/server/actors/framerate");
 
   DebuggerServer.init();
   DebuggerServer.addBrowserActors();
 
--- a/toolkit/devtools/server/tests/mochitest/test_getProcess.html
+++ b/toolkit/devtools/server/tests/mochitest/test_getProcess.html
@@ -12,18 +12,19 @@ Bug 1060093 - Test DebuggerServer.getPro
 <body>
 <pre id="test">
 <script type="application/javascript;version=1.8">
 
 let Cu = Components.utils;
 let Cc = Components.classes;
 let Ci = Components.interfaces;
 
+let {require} = 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");
+let {DebuggerServer} = require("devtools/server/main");
 
 window.onload = function() {
   SimpleTest.waitForExplicitFinish();
 
   SpecialPowers.pushPrefEnv({
     "set": [
       // Always log packets when running tests.
       ["devtools.debugger.log", true],
--- a/toolkit/devtools/server/tests/mochitest/test_preference.html
+++ b/toolkit/devtools/server/tests/mochitest/test_preference.html
@@ -15,17 +15,17 @@ Bug 943251 - Allow accessing about:confi
 
 function runTests() {
   var Cu = Components.utils;
   var Cc = Components.classes;
   var Ci = Components.interfaces;
 
   var {require} = 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");
+  var {DebuggerServer} = require("devtools/server/main");
   Cu.import("resource://gre/modules/Services.jsm");
 
   SimpleTest.waitForExplicitFinish();
 
   var {getPreferenceFront} = require("devtools/server/actors/preference");
 
   DebuggerServer.init();
   DebuggerServer.addBrowserActors();
--- a/toolkit/devtools/server/tests/mochitest/test_registerActor.html
+++ b/toolkit/devtools/server/tests/mochitest/test_registerActor.html
@@ -15,17 +15,17 @@ Bug 895360 - [app manager] Device meta d
 var gClient;
 window.onload = function() {
   var Cu = Components.utils;
   var Cc = Components.classes;
   var Ci = Components.interfaces;
 
   var {require} = 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");
+  var {DebuggerServer} = require("devtools/server/main");
   Cu.import("resource://gre/modules/Services.jsm");
 
   SimpleTest.waitForExplicitFinish();
 
   var {ActorRegistryFront} = require("devtools/server/actors/actor-registry");
   var actorURL = "chrome://mochitests/content/chrome/toolkit/devtools/server/tests/mochitest/hello-actor.js";
 
   if (!DebuggerServer.initialized) {
--- a/toolkit/devtools/server/tests/mochitest/test_settings.html
+++ b/toolkit/devtools/server/tests/mochitest/test_settings.html
@@ -16,17 +16,17 @@ Bug 1022797 - Settings support from WebI
 
 function runTests() {
   var Cu = Components.utils;
   var Cc = Components.classes;
   var Ci = Components.interfaces;
 
   var {require} = 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");
+  var {DebuggerServer} = require("devtools/server/main");
 
   if (SpecialPowers.isMainProcess()) {
     Cu.import("resource://gre/modules/SettingsRequestManager.jsm");
   }
 
   SimpleTest.waitForExplicitFinish();
 
   var {getSettingsFront, _setDefaultSettings} = require("devtools/server/actors/settings");
--- a/toolkit/devtools/server/tests/mochitest/test_setupInParentChild.html
+++ b/toolkit/devtools/server/tests/mochitest/test_setupInParentChild.html
@@ -13,18 +13,19 @@ Bug 1181100 - Test DebuggerServerConnect
 <pre id="test">
 <script type="application/javascript;version=1.8">
 
 let Cu = Components.utils;
 let Cc = Components.classes;
 let Ci = Components.interfaces;
 
 Cu.import("resource://gre/modules/Services.jsm");
+let {require} = 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");
+let {DebuggerServer} = require("devtools/server/main");
 
 window.onload = function() {
   SimpleTest.waitForExplicitFinish();
 
   SpecialPowers.pushPrefEnv({
     "set": [
       // Always log packets when running tests.
       ["devtools.debugger.log", true],
--- a/toolkit/devtools/server/tests/unit/test_dbgactor.js
+++ b/toolkit/devtools/server/tests/unit/test_dbgactor.js
@@ -1,14 +1,11 @@
 /* Any copyright is dedicated to the Public Domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
-Cu.import("resource://gre/modules/devtools/dbg-server.jsm");
-Cu.import("resource://gre/modules/devtools/dbg-client.jsm");
-
 var gClient;
 var gDebuggee;
 
 const xpcInspector = Cc["@mozilla.org/jsinspector;1"].getService(Ci.nsIJSInspector);
 
 function run_test()
 {
   initTestDebuggerServer();
--- a/toolkit/devtools/server/tests/unit/test_dbgclient_debuggerstatement.js
+++ b/toolkit/devtools/server/tests/unit/test_dbgclient_debuggerstatement.js
@@ -1,14 +1,11 @@
 /* Any copyright is dedicated to the Public Domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
-Cu.import("resource://gre/modules/devtools/dbg-server.jsm");
-Cu.import("resource://gre/modules/devtools/dbg-client.jsm");
-
 var gClient;
 var gTabClient;
 var gDebuggee;
 
 function run_test()
 {
   initTestDebuggerServer();
   gDebuggee = testGlobal("test-1");
--- a/toolkit/devtools/server/tests/unit/test_dbgglobal.js
+++ b/toolkit/devtools/server/tests/unit/test_dbgglobal.js
@@ -1,14 +1,11 @@
 /* Any copyright is dedicated to the Public Domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
-Cu.import("resource://gre/modules/devtools/dbg-server.jsm");
-Cu.import("resource://gre/modules/devtools/dbg-client.jsm");
-
 function run_test()
 {
   // Should get an exception if we try to interact with DebuggerServer
   // before we initialize it...
   check_except(function() {
     DebuggerServer.createListener();
   });
   check_except(DebuggerServer.closeAllListeners);
--- a/toolkit/devtools/transport/tests/unit/head_dbg.js
+++ b/toolkit/devtools/transport/tests/unit/head_dbg.js
@@ -21,29 +21,18 @@ const DevToolsUtils = require("devtools/
 // we can be sending large amounts of data. The test harness has
 // trouble dealing with logging all the data, and we end up with
 // intermittent time outs (e.g. bug 775924).
 // Services.prefs.setBoolPref("devtools.debugger.log", true);
 // Services.prefs.setBoolPref("devtools.debugger.log.verbose", true);
 // Enable remote debugging for the relevant tests.
 Services.prefs.setBoolPref("devtools.debugger.remote-enabled", true);
 
-function tryImport(url) {
-  try {
-    Cu.import(url);
-  } catch (e) {
-    dump("Error importing " + url + "\n");
-    dump(DevToolsUtils.safeErrorString(e) + "\n");
-    throw e;
-  }
-}
-
-tryImport("resource://gre/modules/devtools/dbg-server.jsm");
-tryImport("resource://gre/modules/devtools/dbg-client.jsm");
-tryImport("resource://gre/modules/devtools/Loader.jsm");
+const { DebuggerServer } = require("devtools/server/main");
+Cu.import("resource://gre/modules/devtools/dbg-client.jsm");
 
 function testExceptionHook(ex) {
   try {
     do_report_unexpected_exception(ex);
   } catch(ex) {
     return {throw: ex}
   }
   return undefined;
--- a/toolkit/devtools/transport/tests/unit/test_bulk_error.js
+++ b/toolkit/devtools/transport/tests/unit/test_bulk_error.js
@@ -1,19 +1,14 @@
 /* Any copyright is dedicated to the Public Domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
-let { DebuggerServer } =
-  Cu.import("resource://gre/modules/devtools/dbg-server.jsm", {});
-let { DebuggerClient } =
-  Cu.import("resource://gre/modules/devtools/dbg-client.jsm", {});
 let { FileUtils } = Cu.import("resource://gre/modules/FileUtils.jsm", {});
 let { NetUtil } = Cu.import("resource://gre/modules/NetUtil.jsm", {});
 let Pipe = CC("@mozilla.org/pipe;1", "nsIPipe", "init");
-let { Promise: promise } = Cu.import("resource://gre/modules/Promise.jsm", {});
 
 function run_test() {
   initTestDebuggerServer();
   add_test_bulk_actor();
 
   add_task(function*() {
     yield test_string_error(socket_transport, json_reply);
     yield test_string_error(local_transport, json_reply);
--- a/toolkit/devtools/transport/tests/unit/test_client_server_bulk.js
+++ b/toolkit/devtools/transport/tests/unit/test_client_server_bulk.js
@@ -1,20 +1,14 @@
 /* Any copyright is dedicated to the Public Domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
-let { DebuggerServer } =
-  Cu.import("resource://gre/modules/devtools/dbg-server.jsm", {});
-let { DebuggerClient } =
-  Cu.import("resource://gre/modules/devtools/dbg-client.jsm", {});
 let { FileUtils } = Cu.import("resource://gre/modules/FileUtils.jsm", {});
 let { NetUtil } = Cu.import("resource://gre/modules/NetUtil.jsm", {});
-let { Services } = Cu.import("resource://gre/modules/Services.jsm", {});
 let Pipe = CC("@mozilla.org/pipe;1", "nsIPipe", "init");
-let { Promise: promise } = Cu.import("resource://gre/modules/Promise.jsm", {});
 
 function run_test() {
   initTestDebuggerServer();
   add_test_bulk_actor();
 
   add_task(function*() {
     yield test_bulk_request_cs(socket_transport, "jsonReply", "json");
     yield test_bulk_request_cs(local_transport, "jsonReply", "json");
--- a/toolkit/devtools/transport/tests/unit/test_dbgsocket.js
+++ b/toolkit/devtools/transport/tests/unit/test_dbgsocket.js
@@ -1,14 +1,11 @@
 /* Any copyright is dedicated to the Public Domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
-Cu.import("resource://gre/modules/devtools/dbg-server.jsm");
-Cu.import("resource://gre/modules/devtools/dbg-client.jsm");
-
 let gPort;
 let gExtraListener;
 
 function run_test()
 {
   do_print("Starting test at " + new Date().toTimeString());
   initTestDebuggerServer();
 
--- a/toolkit/devtools/transport/tests/unit/test_dbgsocket_connection_drop.js
+++ b/toolkit/devtools/transport/tests/unit/test_dbgsocket_connection_drop.js
@@ -3,19 +3,16 @@
  * http://creativecommons.org/publicdomain/zero/1.0/
  */
 
 /**
  * Bug 755412 - checks if the server drops the connection on an improperly
  * framed packet, i.e. when the length header is invalid.
  */
 
-Cu.import("resource://gre/modules/devtools/dbg-server.jsm");
-Cu.import("resource://gre/modules/devtools/dbg-client.jsm");
-
 const { RawPacket } = require("devtools/toolkit/transport/packets");
 
 function run_test() {
   do_print("Starting test at " + new Date().toTimeString());
   initTestDebuggerServer();
 
   add_task(test_socket_conn_drops_after_invalid_header);
   add_task(test_socket_conn_drops_after_invalid_header_2);
--- a/toolkit/devtools/transport/tests/unit/test_no_bulk.js
+++ b/toolkit/devtools/transport/tests/unit/test_no_bulk.js
@@ -1,19 +1,14 @@
 /* Any copyright is dedicated to the Public Domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
-let { DebuggerServer } =
-  Cu.import("resource://gre/modules/devtools/dbg-server.jsm", {});
-let { DebuggerClient } =
-  Cu.import("resource://gre/modules/devtools/dbg-client.jsm", {});
 let { FileUtils } = Cu.import("resource://gre/modules/FileUtils.jsm", {});
 let { NetUtil } = Cu.import("resource://gre/modules/NetUtil.jsm", {});
 let Pipe = CC("@mozilla.org/pipe;1", "nsIPipe", "init");
-let { Promise: promise } = Cu.import("resource://gre/modules/Promise.jsm", {});
 
 function run_test() {
   DebuggerServer.registerModule("xpcshell-test/testactors-no-bulk");
   // Allow incoming connections.
   DebuggerServer.init();
 
   add_task(function*() {
     yield test_bulk_send_error(socket_transport);
--- a/toolkit/devtools/transport/tests/unit/test_queue.js
+++ b/toolkit/devtools/transport/tests/unit/test_queue.js
@@ -1,18 +1,16 @@
 /* Any copyright is dedicated to the Public Domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
 /**
  * This test verifies that the transport's queue operates correctly when various
  * packets are scheduled simultaneously.
  */
 
-let { DebuggerServer } =
-  Cu.import("resource://gre/modules/devtools/dbg-server.jsm", {});
 let { FileUtils } = Cu.import("resource://gre/modules/FileUtils.jsm", {});
 let { NetUtil } = Cu.import("resource://gre/modules/NetUtil.jsm", {});
 
 function run_test() {
   initTestDebuggerServer();
 
   add_task(function*() {
     yield test_transport(socket_transport);
--- a/toolkit/devtools/transport/tests/unit/test_transport_bulk.js
+++ b/toolkit/devtools/transport/tests/unit/test_transport_bulk.js
@@ -1,16 +1,13 @@
 /* Any copyright is dedicated to the Public Domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
-let { DebuggerServer } =
-  Cu.import("resource://gre/modules/devtools/dbg-server.jsm", {});
 let { FileUtils } = Cu.import("resource://gre/modules/FileUtils.jsm", {});
 let { NetUtil } = Cu.import("resource://gre/modules/NetUtil.jsm", {});
-let { Services } = Cu.import("resource://gre/modules/Services.jsm", {});
 
 function run_test() {
   initTestDebuggerServer();
 
   add_task(function*() {
     yield test_bulk_transfer_transport(socket_transport);
     yield test_bulk_transfer_transport(local_transport);
     DebuggerServer.destroy();
--- a/toolkit/devtools/webconsole/test/common.js
+++ b/toolkit/devtools/webconsole/test/common.js
@@ -13,25 +13,25 @@ const {Task} = Cu.import("resource://gre
 // This gives logging to stdout for tests
 var {console} = Cu.import("resource://gre/modules/devtools/Console.jsm", {});
 
 let {require} = Cu.import("resource://gre/modules/devtools/Loader.jsm", {});
 let WebConsoleUtils = require("devtools/toolkit/webconsole/utils").Utils;
 
 let ConsoleAPIStorage = Cc["@mozilla.org/consoleAPI-storage;1"]
                           .getService(Ci.nsIConsoleAPIStorage);
+let {DebuggerServer} = require("devtools/server/main");
 
 let {ConsoleServiceListener, ConsoleAPIListener} =
   require("devtools/toolkit/webconsole/utils");
 
 function initCommon()
 {
   //Services.prefs.setBoolPref("devtools.debugger.log", true);
 
-  Cu.import("resource://gre/modules/devtools/dbg-server.jsm");
   Cu.import("resource://gre/modules/devtools/dbg-client.jsm");
 }
 
 function initDebuggerServer()
 {
   if (!DebuggerServer.initialized) {
     DebuggerServer.init();
     DebuggerServer.addBrowserActors();
--- a/webapprt/RemoteDebugger.jsm
+++ b/webapprt/RemoteDebugger.jsm
@@ -7,17 +7,18 @@
 this.EXPORTED_SYMBOLS = ["RemoteDebugger"];
 
 let Cc = Components.classes;
 let Ci = Components.interfaces;
 let Cu = Components.utils;
 
 Cu.import("resource://gre/modules/Services.jsm");
 Cu.import("resource://gre/modules/XPCOMUtils.jsm");
-Cu.import('resource://gre/modules/devtools/dbg-server.jsm');
+let { require } = Cu.import("resource://gre/modules/devtools/Loader.jsm", {});
+let { DebuggerServer } = require("devtools/server/main");
 
 this.RemoteDebugger = {
   init: function(port) {
     if (!DebuggerServer.initialized) {
       DebuggerServer.init();
       DebuggerServer.addBrowserActors("webapprt:webapp");
       DebuggerServer.addActors("chrome://webapprt/content/dbg-webapp-actors.js");
     }
--- a/webapprt/test/chrome/browser_debugger.js
+++ b/webapprt/test/chrome/browser_debugger.js
@@ -1,10 +1,11 @@
 Cu.import("resource://gre/modules/Services.jsm");
-let { DebuggerServer } = Cu.import("resource://gre/modules/devtools/dbg-server.jsm", {});
+let { require } = Cu.import("resource://gre/modules/devtools/Loader.jsm", {});
+let { DebuggerServer } = require("devtools/server/main");
 let { DebuggerClient } = Cu.import("resource://gre/modules/devtools/dbg-client.jsm", {});
 let { RemoteDebugger } = Cu.import("resource://webapprt/modules/RemoteDebugger.jsm", {});
 
 function test() {
   waitForExplicitFinish();
 
   loadWebapp("debugger.webapp", undefined, () => {
     RemoteDebugger.init(Services.prefs.getIntPref('devtools.debugger.remote-port'));