Bug 1387123 - Replace all usages of require(promise).defer by require(devtools/shared/defer).defer. r=tromey
authorAlexandre Poirot <poirot.alex@gmail.com>
Tue, 08 Aug 2017 15:24:04 +0200
changeset 373409 a820e391d9002cc951fee85edcf40b3dbd3eaf60
parent 373408 40601ae660c6347cff6a1139c38c3d2c2fa25510
child 373410 84755985ba136a4afa2ea7d3e84626a3948417df
push id48257
push userapoirot@mozilla.com
push dateTue, 08 Aug 2017 15:58:07 +0000
treeherderautoland@84755985ba13 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstromey
bugs1387123
milestone57.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1387123 - Replace all usages of require(promise).defer by require(devtools/shared/defer).defer. r=tromey In prevision of Promise.jsm removal, use defer helper module instead of Promise.jsm as that's the only one feature that DOM Promise don't support. PART2: Substitutes promise.defer usages with defer $ sed -i 's/promise.defer/defer/gI' $(egrep -lir "promise.defer\(\)" devtools) Reset modification to the following files as they are using deprecated syncable promises as we don't want to touch them. http://searchfox.org/mozilla-central/search?q=deprecated-sync-thenables&case=true&regexp=false&path= $ git checkout devtools/client/debugger/test/mochitest/ $ git checkout devtools/shared/client/main.js $ git checkout devtools/client/debugger/ $ git checkout devtools/server/main.js MozReview-Commit-ID: DGN5ae68wtn
devtools/client/canvasdebugger/test/browser_canvas-frontend-slider-02.js
devtools/client/canvasdebugger/test/head.js
devtools/client/dom/dom-panel.js
devtools/client/jsonview/test/head.js
devtools/client/performance/modules/widgets/graphs.js
devtools/client/performance/panel.js
devtools/client/performance/performance-controller.js
devtools/client/performance/test/browser_perf-recordings-io-03.js
devtools/client/performance/test/browser_perf-recordings-io-04.js
devtools/client/performance/test/browser_perf-recordings-io-06.js
devtools/client/performance/test/browser_timeline-waterfall-workers.js
devtools/client/scratchpad/scratchpad-panel.js
devtools/client/scratchpad/scratchpad.js
devtools/client/scratchpad/test/browser_scratchpad_reload_and_run.js
devtools/client/scratchpad/test/head.js
devtools/client/shadereditor/shadereditor.js
devtools/client/shadereditor/test/browser_se_programs-blackbox-01.js
devtools/client/shadereditor/test/head.js
devtools/client/webconsole/console-output.js
devtools/client/webconsole/hudservice.js
devtools/client/webconsole/jsterm.js
devtools/client/webconsole/net/data-provider.js
devtools/client/webconsole/panel.js
devtools/client/webconsole/test/browser_bug_638949_copy_link_location.js
devtools/client/webconsole/test/browser_bug_871156_ctrlw_close_tab.js
devtools/client/webconsole/test/browser_console.js
devtools/client/webconsole/test/browser_console_addonsdk_loader_exception.js
devtools/client/webconsole/test/browser_console_consolejsm_output.js
devtools/client/webconsole/test/browser_console_copy_command.js
devtools/client/webconsole/test/browser_console_filters.js
devtools/client/webconsole/test/browser_console_hide_jsterm_when_devtools_chrome_enabled_false.js
devtools/client/webconsole/test/browser_console_optimized_out_vars.js
devtools/client/webconsole/test/browser_console_server_logging.js
devtools/client/webconsole/test/browser_console_variables_view_dom_nodes.js
devtools/client/webconsole/test/browser_console_variables_view_dont_sort_non_sortable_classes_properties.js
devtools/client/webconsole/test/browser_eval_in_debugger_stackframe2.js
devtools/client/webconsole/test/browser_netmonitor_shows_reqs_in_webconsole.js
devtools/client/webconsole/test/browser_output_longstring_expand.js
devtools/client/webconsole/test/browser_result_format_as_string.js
devtools/client/webconsole/test/browser_warn_user_about_replaced_api.js
devtools/client/webconsole/test/browser_webconsole_allow_mixedcontent_securityerrors.js
devtools/client/webconsole/test/browser_webconsole_autocomplete-properties-with-non-alphanumeric-names.js
devtools/client/webconsole/test/browser_webconsole_autocomplete_and_selfxss.js
devtools/client/webconsole/test/browser_webconsole_block_mixedcontent_securityerrors.js
devtools/client/webconsole/test/browser_webconsole_bug_580001_closing_after_completion.js
devtools/client/webconsole/test/browser_webconsole_bug_585991_autocomplete_keys.js
devtools/client/webconsole/test/browser_webconsole_bug_585991_autocomplete_popup.js
devtools/client/webconsole/test/browser_webconsole_bug_587617_output_copy.js
devtools/client/webconsole/test/browser_webconsole_bug_588730_text_node_insertion.js
devtools/client/webconsole/test/browser_webconsole_bug_597460_filter_scroll.js
devtools/client/webconsole/test/browser_webconsole_bug_599725_response_headers.js
devtools/client/webconsole/test/browser_webconsole_bug_600183_charset.js
devtools/client/webconsole/test/browser_webconsole_bug_613642_maintain_scroll.js
devtools/client/webconsole/test/browser_webconsole_bug_621644_jsterm_dollar.js
devtools/client/webconsole/test/browser_webconsole_bug_622303_persistent_filters.js
devtools/client/webconsole/test/browser_webconsole_bug_630733_response_redirect_headers.js
devtools/client/webconsole/test/browser_webconsole_bug_651501_document_body_autocomplete.js
devtools/client/webconsole/test/browser_webconsole_bug_660806_history_nav.js
devtools/client/webconsole/test/browser_webconsole_bug_764572_output_open_url.js
devtools/client/webconsole/test/browser_webconsole_bug_782653_CSS_links_in_Style_Editor.js
devtools/client/webconsole/test/browser_webconsole_bug_837351_securityerrors.js
devtools/client/webconsole/test/browser_webconsole_chrome.js
devtools/client/webconsole/test/browser_webconsole_closure_inspection.js
devtools/client/webconsole/test/browser_webconsole_dont_navigate_on_doubleclick.js
devtools/client/webconsole/test/browser_webconsole_filter_buttons_contextmenu.js
devtools/client/webconsole/test/browser_webconsole_for_of.js
devtools/client/webconsole/test/browser_webconsole_jsterm.js
devtools/client/webconsole/test/browser_webconsole_netlogging_reset_filter.js
devtools/client/webconsole/test/browser_webconsole_notifications.js
devtools/client/webconsole/test/browser_webconsole_output_dom_elements_04.js
devtools/client/webconsole/test/browser_webconsole_scratchpad_panel_link.js
devtools/client/webconsole/test/browser_webconsole_shows_reqs_in_netmonitor.js
devtools/client/webconsole/test/browser_webconsole_split.js
devtools/client/webconsole/test/browser_webconsole_split_escape_key.js
devtools/client/webconsole/test/head.js
devtools/client/webconsole/webconsole.js
devtools/server/actors/canvas.js
devtools/server/actors/device.js
devtools/server/actors/inspector.js
devtools/server/actors/storage.js
devtools/server/actors/stylesheets.js
devtools/server/actors/webbrowser.js
devtools/server/actors/webgl.js
devtools/server/main.js
devtools/server/tests/mochitest/inspector-helpers.js
devtools/server/tests/mochitest/test_inspector-dead-nodes.html
devtools/server/tests/unit/head_dbg.js
devtools/server/tests/unit/test_blackboxing-06.js
devtools/server/tests/unit/test_client_request.js
devtools/server/tests/unit/test_nesting-01.js
devtools/server/tests/unit/test_nesting-02.js
devtools/server/tests/unit/test_profiler_events-01.js
devtools/server/tests/unit/test_profiler_events-02.js
devtools/server/tests/unit/test_protocol_async.js
devtools/server/tests/unit/test_protocol_longstring.js
devtools/server/tests/unit/test_protocol_simple.js
devtools/server/tests/unit/test_sourcemaps-10.js
devtools/server/tests/unit/test_sourcemaps-11.js
devtools/server/worker.js
devtools/shared/webconsole/test/unit/test_throttle.js
--- a/devtools/client/canvasdebugger/test/browser_canvas-frontend-slider-02.js
+++ b/devtools/client/canvasdebugger/test/browser_canvas-frontend-slider-02.js
@@ -74,17 +74,17 @@ function* ifTestingSupported() {
   yield once(window, EVENTS.CALL_SCREENSHOT_DISPLAYED);
   ok(true, "The full-sized screenshot was displayed for the item at index 0.");
 
   yield teardown(panel);
   finish();
 }
 
 function waitForMozSetImageElement(panel) {
-  let deferred = promise.defer();
+  let deferred = defer();
   panel._onMozSetImageElement = deferred.resolve;
   return deferred.promise;
 }
 
 function sameArray(a, b) {
   if (a.length != b.length) {
     return false;
   }
--- a/devtools/client/canvasdebugger/test/head.js
+++ b/devtools/client/canvasdebugger/test/head.js
@@ -68,17 +68,17 @@ registerCleanupFunction(() => {
 function loadFrameScripts() {
   mm = gBrowser.selectedBrowser.messageManager;
   mm.loadFrameScript(FRAME_SCRIPT_UTILS_URL, false);
 }
 
 function addTab(aUrl, aWindow) {
   info("Adding tab: " + aUrl);
 
-  let deferred = promise.defer();
+  let deferred = defer();
   let targetWindow = aWindow || window;
   let targetBrowser = targetWindow.gBrowser;
 
   targetWindow.focus();
   let tab = targetBrowser.selectedTab = targetBrowser.addTab(aUrl);
   let linkedBrowser = tab.linkedBrowser;
 
   BrowserTestUtils.browserLoaded(linkedBrowser)
@@ -88,17 +88,17 @@ function addTab(aUrl, aWindow) {
     });
 
   return deferred.promise;
 }
 
 function removeTab(aTab, aWindow) {
   info("Removing tab.");
 
-  let deferred = promise.defer();
+  let deferred = defer();
   let targetWindow = aWindow || window;
   let targetBrowser = targetWindow.gBrowser;
   let tabContainer = targetBrowser.tabContainer;
 
   tabContainer.addEventListener("TabClose", function (aEvent) {
     info("Tab removed and finished closing.");
     deferred.resolve();
   }, {once: true});
@@ -144,17 +144,17 @@ function isTestingSupported() {
   info("This test requires WebGL support.");
   info("Apparently, WebGL is" + (supported ? "" : " not") + " supported.");
   return supported;
 }
 
 function once(aTarget, aEventName, aUseCapture = false) {
   info("Waiting for event: '" + aEventName + "' on " + aTarget + ".");
 
-  let deferred = promise.defer();
+  let deferred = defer();
 
   for (let [add, remove] of [
     ["on", "off"], // Use event emitter before DOM events for consistency
     ["addEventListener", "removeEventListener"],
     ["addListener", "removeListener"]
   ]) {
     if ((add in aTarget) && (remove in aTarget)) {
       aTarget[add](aEventName, function onEvent(...aArgs) {
@@ -165,17 +165,17 @@ function once(aTarget, aEventName, aUseC
       break;
     }
   }
 
   return deferred.promise;
 }
 
 function waitForTick() {
-  let deferred = promise.defer();
+  let deferred = defer();
   executeSoon(deferred.resolve);
   return deferred.promise;
 }
 
 function navigateInHistory(aTarget, aDirection, aWaitForTargetEvent = "navigate") {
   executeSoon(() => content.history[aDirection]());
   return once(aTarget, aWaitForTargetEvent);
 }
@@ -252,17 +252,17 @@ function teardown({target}) {
   });
 }
 
 /**
  * Takes a string `script` and evaluates it directly in the content
  * in potentially a different process.
  */
 function evalInDebuggee(script) {
-  let deferred = promise.defer();
+  let deferred = defer();
 
   if (!mm) {
     throw new Error("`loadFrameScripts()` must be called when using MessageManager.");
   }
 
   let id = generateUUID().toString();
   mm.sendAsyncMessage("devtools:test:eval", { script: script, id: id });
   mm.addMessageListener("devtools:test:eval:response", handler);
@@ -291,14 +291,14 @@ function getSourceActor(aSources, aURL) 
  *        Invoked once in a while until it returns true.
  * @param number interval [optional]
  *        How often the predicate is invoked, in milliseconds.
  */
 function* waitUntil(predicate, interval = 10) {
   if (yield predicate()) {
     return Promise.resolve(true);
   }
-  let deferred = Promise.defer();
+  let deferred = defer();
   setTimeout(function () {
     waitUntil(predicate).then(() => deferred.resolve(true));
   }, interval);
   return deferred.promise;
 }
--- a/devtools/client/dom/dom-panel.js
+++ b/devtools/client/dom/dom-panel.js
@@ -38,17 +38,17 @@ DomPanel.prototype = {
    * @return object
    *         A promise that is resolved when the DOM panel completes opening.
    */
   open: Task.async(function* () {
     if (this._opening) {
       return this._opening;
     }
 
-    let deferred = promise.defer();
+    let deferred = defer();
     this._opening = deferred.promise;
 
     // Local monitoring needs to make the target remote.
     if (!this.target.isRemote) {
       yield this.target.makeRemote();
     }
 
     this.initialize();
@@ -78,17 +78,17 @@ DomPanel.prototype = {
     this.shouldRefresh = true;
   },
 
   destroy: Task.async(function* () {
     if (this._destroying) {
       return this._destroying;
     }
 
-    let deferred = promise.defer();
+    let deferred = defer();
     this._destroying = deferred.promise;
 
     this.target.off("navigate", this.onTabNavigated);
     this._toolbox.off("select", this.onPanelVisibilityChange);
 
     this.emit("destroyed");
 
     deferred.resolve();
--- a/devtools/client/jsonview/test/head.js
+++ b/devtools/client/jsonview/test/head.js
@@ -30,17 +30,17 @@ registerCleanupFunction(() => {
  *   The maximum number of milliseconds allowed before the initialization of the
  *   JSON Viewer once the tab has been loaded. If exceeded, the initialization
  *   will be considered to have failed, and the returned promise will be rejected.
  *   If this parameter is not passed or is negative, it will be ignored.
  */
 function addJsonViewTab(url, timeout = -1) {
   info("Adding a new JSON tab with URL: '" + url + "'");
 
-  let deferred = promise.defer();
+  let deferred = defer();
   addTab(url).then(tab => {
     let browser = tab.linkedBrowser;
 
     // Load devtools/shared/frame-script-utils.js
     getFrameScript();
 
     // Load frame script with helpers for JSON View tests.
     let rootDir = getRootDirectory(gTestPath);
@@ -146,17 +146,17 @@ function sendString(str, selector) {
     selector: selector,
     str: str
   };
 
   return executeInContent("Test:JsonView:SendString", data);
 }
 
 function waitForTime(delay) {
-  let deferred = promise.defer();
+  let deferred = defer();
   setTimeout(deferred.resolve, delay);
   return deferred.promise;
 }
 
 function waitForFilter() {
   return executeInContent("Test:JsonView:WaitForFilter");
 }
 
--- a/devtools/client/performance/modules/widgets/graphs.js
+++ b/devtools/client/performance/modules/widgets/graphs.js
@@ -215,17 +215,17 @@ GraphsController.prototype = {
     yield (this._rendering && this._rendering.promise);
 
     // Check after yielding to ensure we're not tearing down,
     // as this can create a race condition in tests
     if (this._destroyed) {
       return;
     }
 
-    this._rendering = promise.defer();
+    this._rendering = defer();
     for (let graph of (yield this._getEnabled())) {
       yield graph.setPerformanceData(recordingData, resolution);
       this.emit("rendered", graph.graphName);
     }
     this._rendering.resolve();
   }),
 
   /**
--- a/devtools/client/performance/panel.js
+++ b/devtools/client/performance/panel.js
@@ -27,17 +27,17 @@ PerformancePanel.prototype = {
    * @return object
    *         A promise that is resolved when the Performance tool
    *         completes opening.
    */
   open: Task.async(function* () {
     if (this._opening) {
       return this._opening;
     }
-    let deferred = promise.defer();
+    let deferred = defer();
     this._opening = deferred.promise;
 
     this.panelWin.gToolbox = this.toolbox;
     this.panelWin.gTarget = this.target;
     this._checkRecordingStatus = this._checkRecordingStatus.bind(this);
 
     // Actor is already created in the toolbox; reuse
     // the same front, and the toolbox will also initialize the front,
--- a/devtools/client/performance/performance-controller.js
+++ b/devtools/client/performance/performance-controller.js
@@ -531,17 +531,17 @@ var PerformanceController = {
    * Takes a PerformanceRecording and a state, and waits for
    * the event to be emitted from the front for that recording.
    *
    * @param {PerformanceRecordingFront} recording
    * @param {string} expectedState
    * @return {Promise}
    */
   waitForStateChangeOnRecording: Task.async(function* (recording, expectedState) {
-    let deferred = promise.defer();
+    let deferred = defer();
     this.on(EVENTS.RECORDING_STATE_CHANGE, function handler(state, model) {
       if (state === expectedState && model === recording) {
         this.off(EVENTS.RECORDING_STATE_CHANGE, handler);
         deferred.resolve();
       }
     });
     yield deferred.promise;
   }),
--- a/devtools/client/performance/test/browser_perf-recordings-io-03.js
+++ b/devtools/client/performance/test/browser_perf-recordings-io-03.js
@@ -33,17 +33,17 @@ var test = Task.async(function* () {
 function getUnicodeConverter() {
   let className = "@mozilla.org/intl/scriptableunicodeconverter";
   let converter = Cc[className].createInstance(Ci.nsIScriptableUnicodeConverter);
   converter.charset = "UTF-8";
   return converter;
 }
 
 function asyncCopy(data, file) {
-  let deferred = Promise.defer();
+  let deferred = defer();
 
   let string = JSON.stringify(data);
   let inputStream = getUnicodeConverter().convertToInputStream(string);
   let outputStream = FileUtils.openSafeFileOutputStream(file);
 
   NetUtil.asyncCopy(inputStream, outputStream, status => {
     if (!Components.isSuccessCode(status)) {
       deferred.reject(new Error("Could not save data to file."));
--- a/devtools/client/performance/test/browser_perf-recordings-io-04.js
+++ b/devtools/client/performance/test/browser_perf-recordings-io-04.js
@@ -155,17 +155,17 @@ var test = Task.async(function* () {
 function getUnicodeConverter() {
   let className = "@mozilla.org/intl/scriptableunicodeconverter";
   let converter = Cc[className].createInstance(Ci.nsIScriptableUnicodeConverter);
   converter.charset = "UTF-8";
   return converter;
 }
 
 function asyncCopy(data, file) {
-  let deferred = Promise.defer();
+  let deferred = defer();
 
   let string = JSON.stringify(data);
   let inputStream = getUnicodeConverter().convertToInputStream(string);
   let outputStream = FileUtils.openSafeFileOutputStream(file);
 
   NetUtil.asyncCopy(inputStream, outputStream, status => {
     if (!Components.isSuccessCode(status)) {
       deferred.reject(new Error("Could not save data to file."));
--- a/devtools/client/performance/test/browser_perf-recordings-io-06.js
+++ b/devtools/client/performance/test/browser_perf-recordings-io-06.js
@@ -119,17 +119,17 @@ var test = Task.async(function* () {
 function getUnicodeConverter() {
   let className = "@mozilla.org/intl/scriptableunicodeconverter";
   let converter = Cc[className].createInstance(Ci.nsIScriptableUnicodeConverter);
   converter.charset = "UTF-8";
   return converter;
 }
 
 function asyncCopy(data, file) {
-  let deferred = Promise.defer();
+  let deferred = defer();
 
   let string = JSON.stringify(data);
   let inputStream = getUnicodeConverter().convertToInputStream(string);
   let outputStream = FileUtils.openSafeFileOutputStream(file);
 
   NetUtil.asyncCopy(inputStream, outputStream, status => {
     if (!Components.isSuccessCode(status)) {
       deferred.reject(new Error("Could not save data to file."));
--- a/devtools/client/performance/test/browser_timeline-waterfall-workers.js
+++ b/devtools/client/performance/test/browser_timeline-waterfall-workers.js
@@ -68,17 +68,17 @@ function testWorkerMarkerUI(node) {
 }
 
 /**
  * Takes a string `script` and evaluates it directly in the content
  * in potentially a different process.
  */
 function evalInDebuggee(script) {
   let { generateUUID } = Cc["@mozilla.org/uuid-generator;1"].getService(Ci.nsIUUIDGenerator);
-  let deferred = Promise.defer();
+  let deferred = defer();
 
   if (!mm) {
     throw new Error("`loadFrameScripts()` must be called when using MessageManager.");
   }
 
   let id = generateUUID().toString();
   mm.sendAsyncMessage("devtools:test:eval", { script: script, id: id });
   mm.addMessageListener("devtools:test:eval:response", handler);
--- a/devtools/client/scratchpad/scratchpad-panel.js
+++ b/devtools/client/scratchpad/scratchpad-panel.js
@@ -15,17 +15,17 @@ function ScratchpadPanel(iframeWindow, t
   let { Scratchpad } = iframeWindow;
   this._toolbox = toolbox;
   this.panelWin = iframeWindow;
   this.scratchpad = Scratchpad;
 
   Scratchpad.target = this.target;
   Scratchpad.hideMenu();
 
-  let deferred = promise.defer();
+  let deferred = defer();
   this._readyObserver = deferred.promise;
   Scratchpad.addObserver({
     onReady: function () {
       Scratchpad.removeObserver(this);
       deferred.resolve();
     }
   });
 
--- a/devtools/client/scratchpad/scratchpad.js
+++ b/devtools/client/scratchpad/scratchpad.js
@@ -502,17 +502,17 @@ var Scratchpad = {
     }
     else {
       connection = ScratchpadWindow.consoleFor(this.browserWindow);
     }
 
     let evalOptions = { url: this.uniqueName };
 
     return connection.then(({ debuggerClient, webConsoleClient }) => {
-      let deferred = promise.defer();
+      let deferred = defer();
 
       webConsoleClient.evaluateJSAsync(aString, aResponse => {
         this.debuggerClient = debuggerClient;
         this.webConsoleClient = webConsoleClient;
         if (aResponse.error) {
           deferred.reject(aResponse);
         }
         else if (aResponse.exception !== null) {
@@ -545,17 +545,17 @@ var Scratchpad = {
    * Execute the selected text (if any) or the entire editor content in the
    * current context.
    *
    * @return Promise
    *         The promise for the script evaluation result.
    */
   run: function SP_run()
   {
-    let deferred = promise.defer();
+    let deferred = defer();
     let reject = aReason => deferred.reject(aReason);
 
     this.execute().then(([aString, aError, aResult]) => {
       let resolve = () => deferred.resolve([aString, aError, aResult]);
 
       if (aError) {
         this.writeAsErrorComment(aError).then(resolve, reject);
       }
@@ -572,17 +572,17 @@ var Scratchpad = {
    * Execute the selected text (if any) or the entire editor content in the
    * current context. The resulting object is inspected up in the sidebar.
    *
    * @return Promise
    *         The promise for the script evaluation result.
    */
   inspect: function SP_inspect()
   {
-    let deferred = promise.defer();
+    let deferred = defer();
     let reject = aReason => deferred.reject(aReason);
 
     this.execute().then(([aString, aError, aResult]) => {
       let resolve = () => deferred.resolve([aString, aError, aResult]);
 
       if (aError) {
         this.writeAsErrorComment(aError).then(resolve, reject);
       }
@@ -600,17 +600,17 @@ var Scratchpad = {
    * the page finishes loading. Note that this operation should be available
    * only in the content context.
    *
    * @return Promise
    *         The promise for the script evaluation result.
    */
   reloadAndRun: function SP_reloadAndRun()
   {
-    let deferred = promise.defer();
+    let deferred = defer();
 
     if (this.executionContext !== SCRATCHPAD_CONTEXT_CONTENT) {
       console.error(this.strings.
                     GetStringFromName("scratchpadContext.invalid"));
       return;
     }
 
     let target = TargetFactory.forTab(this.gBrowser.selectedTab);
@@ -628,17 +628,17 @@ var Scratchpad = {
    * the selected text, or at the end of the editor content if there is no
    * selected text.
    *
    * @return Promise
    *         The promise for the script evaluation result.
    */
   display: function SP_display()
   {
-    let deferred = promise.defer();
+    let deferred = defer();
     let reject = aReason => deferred.reject(aReason);
 
     this.execute().then(([aString, aError, aResult]) => {
       let resolve = () => deferred.resolve([aString, aError, aResult]);
 
       if (aError) {
         this.writeAsErrorComment(aError).then(resolve, reject);
       }
@@ -871,17 +871,17 @@ var Scratchpad = {
    *
    * @param any aValue
    *        The value to print.
    * @return Promise
    *         The promise that resolves after the value has been printed.
    */
   _writePrimitiveAsComment: function SP__writePrimitiveAsComment(aValue)
   {
-    let deferred = promise.defer();
+    let deferred = defer();
 
     if (aValue.type == "longString") {
       let client = this.webConsoleClient;
       client.longString(aValue).substring(0, aValue.length, aResponse => {
         if (aResponse.error) {
           reportError("display", aResponse);
           deferred.reject(aResponse);
         }
@@ -930,17 +930,17 @@ var Scratchpad = {
    *        The error object to write out the message and stack trace. It must
    *        contain an |exception| property with the actual error thrown, but it
    *        will often be the entire response of an evaluateJS request.
    * @return Promise
    *         The promise that indicates when writing the comment completes.
    */
   writeAsErrorComment: function SP_writeAsErrorComment(aError)
   {
-    let deferred = promise.defer();
+    let deferred = defer();
 
     if (VariablesView.isPrimitive({ value: aError.exception })) {
       let error = aError.exception;
       let type = error.type;
       if (type == "undefined" ||
           type == "null" ||
           type == "Infinity" ||
           type == "-Infinity" ||
@@ -2107,17 +2107,17 @@ ScratchpadTab.prototype = {
    *         The promise for the result of connecting to this tab or window.
    */
   connect: function ST_connect(aSubject)
   {
     if (this._connector) {
       return this._connector;
     }
 
-    let deferred = promise.defer();
+    let deferred = defer();
     this._connector = deferred.promise;
 
     let connectTimer = setTimeout(() => {
       deferred.reject({
         error: "timeout",
         message: Scratchpad.strings.GetStringFromName("connectionTimeout"),
       });
     }, REMOTE_TIMEOUT);
@@ -2258,17 +2258,17 @@ ScratchpadSidebar.prototype = {
    *        The object to inspect, which is the aEvalString evaluation result.
    * @return Promise
    *         A promise that will resolve once the sidebar is open.
    */
   open: function SS_open(aEvalString, aObject)
   {
     this.show();
 
-    let deferred = promise.defer();
+    let deferred = defer();
 
     let onTabReady = () => {
       if (this.variablesView) {
         this.variablesView.controller.releaseActors();
       }
       else {
         let window = this._sidebar.getWindowForTab("variablesview");
         let container = window.document.querySelector("#variables");
--- a/devtools/client/scratchpad/test/browser_scratchpad_reload_and_run.js
+++ b/devtools/client/scratchpad/test/browser_scratchpad_reload_and_run.js
@@ -48,17 +48,17 @@ function runTests()
   // body to make sure that the page has been reloaded and Scratchpad
   // code has been executed.
 
   sp.setContentContext();
   sp.setText(EDITOR_TEXT);
 
   let browser = gBrowser.selectedBrowser;
 
-  let deferred = promise.defer();
+  let deferred = defer();
   browser.addEventListener("DOMWindowCreated", function () {
     browser.contentWindow.addEventListener("foo", function () {
       is(browser.contentWindow.document.body.innerHTML, "Modified text",
         "After reloading, HTML is different.");
 
       Services.prefs.clearUserPref(DEVTOOLS_CHROME_ENABLED);
       deferred.resolve();
     }, {capture: true, once: true});
--- a/devtools/client/scratchpad/test/head.js
+++ b/devtools/client/scratchpad/test/head.js
@@ -149,17 +149,17 @@ function createTempFile(aName, aContent,
  *          Expected code that will be in the scratchpad upon completion.
  *        - label
  *          The tests label which will be logged in the test runner output.
  * @return Promise
  *         The promise that will be resolved when all tests are finished.
  */
 function runAsyncTests(aScratchpad, aTests)
 {
-  let deferred = promise.defer();
+  let deferred = defer();
 
   (function runTest() {
     if (aTests.length) {
       let test = aTests.shift();
       aScratchpad.setText(test.code);
       aScratchpad[test.method]().then(function success() {
         is(aScratchpad.getText(), test.result, test.label);
         runTest();
--- a/devtools/client/shadereditor/shadereditor.js
+++ b/devtools/client/shadereditor/shadereditor.js
@@ -421,17 +421,17 @@ var ShadersEditorsView = {
    * @return object
    *        Returns a promise that resolves to an editor instance
    */
   _getEditor: function (type) {
     if (this._editorPromises.has(type)) {
       return this._editorPromises.get(type);
     }
 
-    let deferred = promise.defer();
+    let deferred = defer();
     this._editorPromises.set(type, deferred.promise);
 
     // Initialize the source editor and store the newly created instance
     // in the ether of a resolved promise's value.
     let parent = $("#" + type + "-editor");
     let editor = new Editor(DEFAULT_EDITOR_CONFIG);
     editor.config.mode = Editor.modes[type];
 
--- a/devtools/client/shadereditor/test/browser_se_programs-blackbox-01.js
+++ b/devtools/client/shadereditor/test/browser_se_programs-blackbox-01.js
@@ -158,12 +158,12 @@ function getItemLabel(aPanel, aIndex) {
 }
 
 function getBlackBoxCheckbox(aPanel, aIndex) {
   return aPanel.panelWin.document.querySelectorAll(
     ".side-menu-widget-item-checkbox")[aIndex];
 }
 
 function once(aTarget, aEvent) {
-  let deferred = promise.defer();
+  let deferred = defer();
   aTarget.once(aEvent, deferred.resolve);
   return deferred.promise;
 }
--- a/devtools/client/shadereditor/test/head.js
+++ b/devtools/client/shadereditor/test/head.js
@@ -64,17 +64,17 @@ function loadFrameScripts() {
     mm = gBrowser.selectedBrowser.messageManager;
     mm.loadFrameScript(FRAME_SCRIPT_UTILS_URL, false);
   }
 }
 
 function addTab(aUrl, aWindow) {
   info("Adding tab: " + aUrl);
 
-  let deferred = promise.defer();
+  let deferred = defer();
   let targetWindow = aWindow || window;
   let targetBrowser = targetWindow.gBrowser;
 
   targetWindow.focus();
   let tab = targetBrowser.selectedTab = targetBrowser.addTab(aUrl);
   let linkedBrowser = tab.linkedBrowser;
 
   BrowserTestUtils.browserLoaded(linkedBrowser).then(function () {
@@ -83,17 +83,17 @@ function addTab(aUrl, aWindow) {
   });
 
   return deferred.promise;
 }
 
 function removeTab(aTab, aWindow) {
   info("Removing tab.");
 
-  let deferred = promise.defer();
+  let deferred = defer();
   let targetWindow = aWindow || window;
   let targetBrowser = targetWindow.gBrowser;
   let tabContainer = targetBrowser.tabContainer;
 
   tabContainer.addEventListener("TabClose", function (aEvent) {
     info("Tab removed and finished closing.");
     deferred.resolve();
   }, {once: true});
@@ -124,17 +124,17 @@ function test() {
 
 function createCanvas() {
   return document.createElementNS("http://www.w3.org/1999/xhtml", "canvas");
 }
 
 function once(aTarget, aEventName, aUseCapture = false) {
   info("Waiting for event: '" + aEventName + "' on " + aTarget + ".");
 
-  let deferred = promise.defer();
+  let deferred = defer();
 
   for (let [add, remove] of [
     ["on", "off"], // Use event emitter before DOM events for consistency
     ["addEventListener", "removeEventListener"],
     ["addListener", "removeListener"]
   ]) {
     if ((add in aTarget) && (remove in aTarget)) {
       aTarget[add](aEventName, function onEvent(...aArgs) {
@@ -148,25 +148,25 @@ function once(aTarget, aEventName, aUseC
   return deferred.promise;
 }
 
 // Hack around `once`, as that only resolves to a single (first) argument
 // and discards the rest. `onceSpread` is similar, except resolves to an
 // array of all of the arguments in the handler. These should be consolidated
 // into the same function, but many tests will need to be changed.
 function onceSpread(aTarget, aEvent) {
-  let deferred = promise.defer();
+  let deferred = defer();
   aTarget.once(aEvent, (...args) => deferred.resolve(args));
   return deferred.promise;
 }
 
 function observe(aNotificationName, aOwnsWeak = false) {
   info("Waiting for observer notification: '" + aNotificationName + ".");
 
-  let deferred = promise.defer();
+  let deferred = defer();
 
   Services.obs.addObserver(function onNotification(...aArgs) {
     Services.obs.removeObserver(onNotification, aNotificationName);
     deferred.resolve.apply(deferred, aArgs);
   }, aNotificationName, aOwnsWeak);
 
   return deferred.promise;
 }
@@ -272,17 +272,17 @@ function teardown(aPanel) {
 // first event since they're fired consecutively. This allows us to capture
 // all actors and returns an array containing them.
 //
 // Takes a `front` object that is an event emitter, the number of
 // programs that should be listened to and waited on, and an optional
 // `onAdd` function that calls with the entire actors array on program link
 function getPrograms(front, count, onAdd) {
   let actors = [];
-  let deferred = promise.defer();
+  let deferred = defer();
   front.on("program-linked", function onLink(actor) {
     if (actors.length !== count) {
       actors.push(actor);
       if (typeof onAdd === "function") onAdd(actors);
     }
     if (actors.length === count) {
       front.off("program-linked", onLink);
       deferred.resolve(actors);
--- a/devtools/client/webconsole/console-output.js
+++ b/devtools/client/webconsole/console-output.js
@@ -1719,17 +1719,17 @@ Messages.ConsoleTable.prototype = extend
    * Retrieves the table data and columns from the arguments received from the
    * server.
    *
    * @return Promise|null
    *         Returns a promise that resolves when the table data is ready or
    *         null if the arguments are invalid.
    */
   _populateTableData: function () {
-    let deferred = promise.defer();
+    let deferred = defer();
 
     if (this._arguments.length <= 0) {
       return deferred.reject();
     }
 
     let data = this._arguments[0];
     if (data.class != "Array" && data.class != "Object" &&
         data.class != "Map" && data.class != "Set" &&
@@ -3171,17 +3171,17 @@ Widgets.ObjectRenderers.add({
    * be switched to.
    */
   openNodeInInspector: Task.async(function* () {
     yield this.linkToInspector();
     yield this.toolbox.selectTool("inspector");
 
     let isAttached = yield this.toolbox.walker.isInDOMTree(this._nodeFront);
     if (isAttached) {
-      let onReady = promise.defer();
+      let onReady = defer();
       this.toolbox.inspector.once("inspector-updated", onReady.resolve);
       yield this.toolbox.selection.setNodeFront(this._nodeFront, "console");
       yield onReady.promise;
     } else {
       throw new Error("Node is not attached.");
     }
   }),
 
--- a/devtools/client/webconsole/hudservice.js
+++ b/devtools/client/webconsole/hudservice.js
@@ -169,21 +169,21 @@ HUD_SERVICE.prototype =
       let hud = this.getHudReferenceById(this._browserConsoleID);
       return hud.destroy();
     }
 
     if (this._browserConsoleDefer) {
       return this._browserConsoleDefer.promise;
     }
 
-    this._browserConsoleDefer = promise.defer();
+    this._browserConsoleDefer = defer();
 
     function connect()
     {
-      let deferred = promise.defer();
+      let deferred = defer();
 
       if (!DebuggerServer.initialized) {
         DebuggerServer.init();
         DebuggerServer.addBrowserActors();
       }
       DebuggerServer.allowChromeProcess = true;
 
       let client = new DebuggerClient(DebuggerServer.connectPipe());
@@ -198,17 +198,17 @@ HUD_SERVICE.prototype =
     let target;
     function getTarget(aConnection)
     {
       return TargetFactory.forRemoteTab(aConnection);
     }
     function openWindow(aTarget)
     {
       target = aTarget;
-      let deferred = promise.defer();
+      let deferred = defer();
       // Using the old frontend for now in the browser console.  This can be switched to
       // Tools.webConsole.url to use whatever is preffed on.
       let url = Tools.webConsole.oldWebConsoleURL;
       let win = Services.ww.openWindow(null, url, "_blank",
                                        BROWSER_CONSOLE_WINDOW_FEATURES, null);
       win.addEventListener("DOMContentLoaded", function () {
           win.document.title = l10n.getStr("browserConsole.title");
         deferred.resolve(win);
@@ -553,17 +553,17 @@ WebConsole.prototype = {
   destroy: function WC_destroy()
   {
     if (this._destroyer) {
       return this._destroyer.promise;
     }
 
     HUDService.consoles.delete(this.hudId);
 
-    this._destroyer = promise.defer();
+    this._destroyer = defer();
 
     // The document may already be removed
     if (this.chromeUtilsWindow && this.mainPopupSet) {
       let popupset = this.mainPopupSet;
       let panels = popupset.querySelectorAll("panel[hudId=" + this.hudId + "]");
       for (let panel of panels) {
         panel.hidePopup();
       }
@@ -673,17 +673,17 @@ BrowserConsole.prototype = extend(WebCon
   destroy: function BC_destroy()
   {
     if (this._bc_destroyer) {
       return this._bc_destroyer.promise;
     }
 
     this._telemetry.toolClosed("browserconsole");
 
-    this._bc_destroyer = promise.defer();
+    this._bc_destroyer = defer();
 
     let chromeWindow = this.chromeWindow;
     this.$destroy().then(() =>
       this.target.client.close().then(() => {
         HUDService._browserConsoleID = null;
         chromeWindow.close();
         this._bc_destroyer.resolve(null);
       }));
--- a/devtools/client/webconsole/jsterm.js
+++ b/devtools/client/webconsole/jsterm.js
@@ -429,17 +429,17 @@ JSTerm.prototype = {
    *        user input is used - taken from |this.getInputValue()|.
    * @param function [callback]
    *        Optional function to invoke when the result is displayed.
    *        This is deprecated - please use the promise return value instead.
    * @returns Promise
    *          Resolves with the message once the result is displayed.
    */
   execute: function (executeString, callback) {
-    let deferred = promise.defer();
+    let deferred = defer();
     let resultCallback;
     if (this.hud.NEW_CONSOLE_OUTPUT_ENABLED) {
       resultCallback = (msg) => deferred.resolve(msg);
     } else {
       resultCallback = (msg) => {
         deferred.resolve(msg);
         if (callback) {
           callback(msg);
@@ -518,17 +518,17 @@ JSTerm.prototype = {
    *        - selectedNodeActor: tells the NodeActor ID of the current selection
    *        in the Inspector, if such a selection exists. This is used by
    *        helper functions that can evaluate on the current selection.
    * @return object
    *         A promise object that is resolved when the server response is
    *         received.
    */
   requestEvaluation: function (str, options = {}) {
-    let deferred = promise.defer();
+    let deferred = defer();
 
     function onResult(response) {
       if (!response.error) {
         deferred.resolve(response);
       } else {
         deferred.reject(response);
       }
     }
@@ -622,17 +622,17 @@ JSTerm.prototype = {
       }
 
       this.emit("variablesview-open", view, options);
       return view;
     };
 
     let openPromise;
     if (options.targetElement) {
-      let deferred = promise.defer();
+      let deferred = defer();
       openPromise = deferred.promise;
       let document = options.targetElement.ownerDocument;
       let iframe = document.createElementNS(XHTML_NS, "iframe");
 
       iframe.addEventListener("load", function () {
         iframe.style.visibility = "visible";
         deferred.resolve(iframe.contentWindow);
       }, {capture: true, once: true});
@@ -667,17 +667,17 @@ JSTerm.prototype = {
   /**
    * Add the variables view tab to the sidebar.
    *
    * @private
    * @return object
    *         A promise object for the adding of the new tab.
    */
   _addVariablesViewSidebarTab: function () {
-    let deferred = promise.defer();
+    let deferred = defer();
 
     let onTabReady = () => {
       let window = this.sidebar.getWindowForTab("variablesview");
       deferred.resolve(window);
     };
 
     let tabPanel = this.sidebar.getTabPanel("variablesview");
     if (tabPanel) {
--- a/devtools/client/webconsole/net/data-provider.js
+++ b/devtools/client/webconsole/net/data-provider.js
@@ -24,17 +24,17 @@ var DataProvider = {
 
   requestData: function (client, actor, method) {
     let key = actor + ":" + method;
     let p = promises.get(key);
     if (p) {
       return p;
     }
 
-    let deferred = promise.defer();
+    let deferred = defer();
     let realMethodName = "get" + method.charAt(0).toUpperCase() +
       method.slice(1);
 
     if (!client[realMethodName]) {
       return null;
     }
 
     client[realMethodName](actor, response => {
--- a/devtools/client/webconsole/panel.js
+++ b/devtools/client/webconsole/panel.js
@@ -41,17 +41,17 @@ WebConsolePanel.prototype = {
    * @return object
    *         A promise that is resolved when the Web Console completes opening.
    */
   open: function () {
     let parentDoc = this._toolbox.doc;
     let iframe = parentDoc.getElementById("toolbox-panel-iframe-webconsole");
 
     // Make sure the iframe content window is ready.
-    let deferredIframe = promise.defer();
+    let deferredIframe = defer();
     let win, doc;
     if ((win = iframe.contentWindow) &&
         (doc = win.document) &&
         doc.readyState == "complete") {
       deferredIframe.resolve(null);
     } else {
       iframe.addEventListener("load", function () {
         deferredIframe.resolve(null);
--- a/devtools/client/webconsole/test/browser_bug_638949_copy_link_location.js
+++ b/devtools/client/webconsole/test/browser_bug_638949_copy_link_location.js
@@ -72,17 +72,17 @@ add_task(function* () {
   message = [...result.matched][0];
   hud.ui.output.selectMessage(message);
 
   goUpdateCommand(COMMAND_NAME);
   ok(isEnabled(), COMMAND_NAME + " is enabled");
 
   info("expected clipboard value: " + message.url);
 
-  let deferred = promise.defer();
+  let deferred = defer();
 
   waitForClipboard((aData) => {
     return aData.trim() == message.url;
   }, () => {
     goDoCommand(COMMAND_NAME);
   }, () => {
     deferred.resolve(null);
   }, () => {
--- a/devtools/client/webconsole/test/browser_bug_871156_ctrlw_close_tab.js
+++ b/devtools/client/webconsole/test/browser_bug_871156_ctrlw_close_tab.js
@@ -18,19 +18,19 @@ add_task(function* () {
     Services.prefs.clearUserPref("toolkit.cosmeticAnimations.enabled");
   });
 
   yield loadTab(TEST_URI);
 
   let hud = yield openConsole();
   ok(hud, "Web Console opened");
 
-  let tabClosed = promise.defer();
-  let toolboxDestroyed = promise.defer();
-  let tabSelected = promise.defer();
+  let tabClosed = defer();
+  let toolboxDestroyed = defer();
+  let tabSelected = defer();
 
   let target = TargetFactory.forTab(gBrowser.selectedTab);
   let toolbox = gDevTools.getToolbox(target);
 
   gBrowser.tabContainer.addEventListener("TabClose", function () {
     info("tab closed");
     tabClosed.resolve(null);
   }, {once: true});
@@ -54,17 +54,17 @@ add_task(function* () {
 
   yield promise.all([tabClosed.promise, toolboxDestroyed.promise,
                      tabSelected.promise]);
   info("promise.all resolved. start testing the Browser Console");
 
   hud = yield HUDService.toggleBrowserConsole();
   ok(hud, "Browser Console opened");
 
-  let deferred = promise.defer();
+  let deferred = defer();
 
   Services.obs.addObserver(function onDestroy() {
     Services.obs.removeObserver(onDestroy, "web-console-destroyed");
     ok(true, "the Browser Console closed");
 
     deferred.resolve(null);
   }, "web-console-destroyed");
 
--- a/devtools/client/webconsole/test/browser_console.js
+++ b/devtools/client/webconsole/test/browser_console.js
@@ -195,17 +195,17 @@ function* testCPOWInspection(hud) {
   let prototypeAndProperties = yield objectClient.getPrototypeAndProperties();
 
   // Just a sanity check to make sure a valid packet came back
   is(prototypeAndProperties.prototype.class, "XBL prototype JSClass",
     "Looks like a valid response");
 }
 
 function waitForConsole() {
-  let deferred = promise.defer();
+  let deferred = defer();
 
   Services.obs.addObserver(function observer(aSubject) {
     Services.obs.removeObserver(observer, "web-console-created");
     aSubject.QueryInterface(Ci.nsISupportsString);
 
     let hud = HUDService.getBrowserConsole();
     ok(hud, "browser console is open");
     is(aSubject.data, hud.hudId, "notification hudId is correct");
--- a/devtools/client/webconsole/test/browser_console_addonsdk_loader_exception.js
+++ b/devtools/client/webconsole/test/browser_console_addonsdk_loader_exception.js
@@ -62,17 +62,17 @@ function test() {
     ok(locationNode, "message location element found");
 
     let url = locationNode.getAttribute("data-url");
     info("location node url: " + url);
     ok(url.indexOf("resource://") === 0, "error comes from a subscript");
 
     let viewSource = browserconsole.viewSource;
     let URL = null;
-    let clickPromise = promise.defer();
+    let clickPromise = defer();
     browserconsole.viewSourceInDebugger = (sourceURL) => {
       info("browserconsole.viewSourceInDebugger() was invoked: " + sourceURL);
       URL = sourceURL;
       clickPromise.resolve(null);
     };
 
     msg.scrollIntoView();
     EventUtils.synthesizeMouse(locationNode, 2, 2, {},
--- a/devtools/client/webconsole/test/browser_console_consolejsm_output.js
+++ b/devtools/client/webconsole/test/browser_console_consolejsm_output.js
@@ -112,17 +112,17 @@ add_task(function* () {
     ],
   });
 
   let consoleErrorMsg = results[3];
   ok(consoleErrorMsg, "console.error message element found");
   let clickable = consoleErrorMsg.clickableElements[0];
   ok(clickable, "clickable object found for console.error");
 
-  let deferred = promise.defer();
+  let deferred = defer();
 
   let onFetch = (aEvent, aVar) => {
     // Skip the notification from console.dir variablesview-fetched.
     if (aVar._variablesView != hud.jsterm._variablesView) {
       return;
     }
     hud.jsterm.off("variablesview-fetched", onFetch);
 
--- a/devtools/client/webconsole/test/browser_console_copy_command.js
+++ b/devtools/client/webconsole/test/browser_console_copy_command.js
@@ -45,17 +45,17 @@ add_task(function* testCopy() {
                   [JSON.stringify(string), string],
                   [obj.toSource(), JSON.stringify(obj, null, "  ")],
     [
       "$('#" + ID + "')",
       content.document.getElementById(ID).outerHTML
     ]
   ];
   for (let [source, reference] of samples) {
-    let deferredResult = promise.defer();
+    let deferredResult = defer();
 
     SimpleTest.waitForClipboard(
       "" + reference,
       () => {
         let command = "copy(" + source + ")";
         info("Attempting to copy: " + source);
         info("Executing command: " + command);
         gJSTerm.execute(command, msg => {
--- a/devtools/client/webconsole/test/browser_console_filters.js
+++ b/devtools/client/webconsole/test/browser_console_filters.js
@@ -30,17 +30,17 @@ add_task(function* () {
   is(Services.prefs.getBoolPref(BROWSER_CONSOLE_PREFIX + "exception"), true,
      "'exception' filter is enabled (browser console)");
   is(Services.prefs.getBoolPref(WEB_CONSOLE_PREFIX + "exception"), false,
      "'exception' filter is disabled (web console)");
 
   hud.setFilterState("exception", true);
 
   // We need to let the console opening event loop to finish.
-  let deferred = promise.defer();
+  let deferred = defer();
   executeSoon(() => closeConsole().then(() => deferred.resolve(null)));
   yield deferred.promise;
 
   info("web console closed");
   hud = yield HUDService.toggleBrowserConsole();
   ok(hud, "browser console opened");
 
   is(Services.prefs.getBoolPref(BROWSER_CONSOLE_PREFIX + "exception"), true,
--- a/devtools/client/webconsole/test/browser_console_hide_jsterm_when_devtools_chrome_enabled_false.js
+++ b/devtools/client/webconsole/test/browser_console_hide_jsterm_when_devtools_chrome_enabled_false.js
@@ -27,17 +27,17 @@ function testObjectInspectorPropertiesAr
   is(variablesView.delete, null, "vview.delete is null");
 }
 
 function* getVariablesView(hud) {
   function openVariablesView(event, vview) {
     deferred.resolve(vview._variablesView);
   }
 
-  let deferred = promise.defer();
+  let deferred = defer();
 
   // Filter out other messages to ensure ours stays visible.
   hud.ui.filterBox.value = "browser_console_hide_jsterm_test";
 
   hud.jsterm.clearOutput();
   hud.jsterm.execute("new Object({ browser_console_hide_jsterm_test: true })");
 
   let [message] = yield waitForMessages({
--- a/devtools/client/webconsole/test/browser_console_optimized_out_vars.js
+++ b/devtools/client/webconsole/test/browser_console_optimized_out_vars.js
@@ -68,17 +68,17 @@ function ensureThreadClientState(aPanel,
   }
   return waitForThreadEvents(aPanel, aState);
 }
 
 function waitForThreadEvents(aPanel, aEventName, aEventRepeat = 1) {
   info("Waiting for thread event: '" + aEventName + "' to fire: " +
        aEventRepeat + " time(s).");
 
-  let deferred = promise.defer();
+  let deferred = defer();
   let thread = aPanel.panelWin.gThreadClient;
   let count = 0;
 
   thread.addListener(aEventName, function onEvent(eventName, ...args) {
     info("Thread event '" + eventName + "' fired: " + (++count) + " time(s).");
 
     if (count == aEventRepeat) {
       ok(true, "Enough '" + eventName + "' thread events have been fired.");
--- a/devtools/client/webconsole/test/browser_console_server_logging.js
+++ b/devtools/client/webconsole/test/browser_console_server_logging.js
@@ -104,14 +104,14 @@ add_task(function* () {
     }],
   });
   // Clean up filter
   hud.setFilterState("serverlog", false);
   yield updateServerLoggingListener(hud);
 });
 
 function updateServerLoggingListener(hud) {
-  let deferred = promise.defer();
+  let deferred = defer();
   hud.ui._updateServerLoggingListener(response => {
     deferred.resolve(response);
   });
   return deferred.promise;
 }
--- a/devtools/client/webconsole/test/browser_console_variables_view_dom_nodes.js
+++ b/devtools/client/webconsole/test/browser_console_variables_view_dom_nodes.js
@@ -31,17 +31,17 @@ function test() {
 
   Task.spawn(runner).then(finishTest);
 
   function* runner() {
     const {tab} = yield loadTab(TEST_URI);
     const hud = yield openConsole(tab);
     const jsterm = hud.jsterm;
 
-    let deferred = promise.defer();
+    let deferred = defer();
     jsterm.once("variablesview-fetched", (_, val) => deferred.resolve(val));
     jsterm.execute("inspect(document.querySelectorAll('div'))");
 
     let variableScope = yield deferred.promise;
     ok(variableScope, "Variables view opened");
 
     yield findVariableViewProperties(variableScope, [
       { name: "0", value: "<div>"},
--- a/devtools/client/webconsole/test/browser_console_variables_view_dont_sort_non_sortable_classes_properties.js
+++ b/devtools/client/webconsole/test/browser_console_variables_view_dont_sort_non_sortable_classes_properties.js
@@ -78,17 +78,17 @@ function test() {
    * specified by aObject is inspected.
    *
    * @param string aObject
    *        A string that, once executed, creates and returns the object to
    *        inspect.
    */
   function* testNotSorted(aObject) {
     info("Testing " + aObject);
-    let deferred = promise.defer();
+    let deferred = defer();
     jsterm.once("variablesview-fetched", (_, aVar) => deferred.resolve(aVar));
     jsterm.execute("inspect(" + aObject + ")");
 
     let variableScope = yield deferred.promise;
     ok(variableScope, "Variables view opened");
 
     // If the properties are sorted: keys = ["0", "1", "10",...] <- incorrect
     // If the properties are not sorted: keys = ["0", "1", "2",...] <- correct
@@ -104,17 +104,17 @@ function test() {
    * specified by aObject is inspected.
    *
    * @param string aObject
    *        A string that, once executed, creates and returns the object to
    *        inspect.
    */
   function* testSorted(aObject) {
     info("Testing " + aObject);
-    let deferred = promise.defer();
+    let deferred = defer();
     jsterm.once("variablesview-fetched", (_, aVar) => deferred.resolve(aVar));
     jsterm.execute("inspect(" + aObject + ")");
 
     let variableScope = yield deferred.promise;
     ok(variableScope, "Variables view opened");
 
     // If the properties are sorted:
     // keys = ["1", "4", "10",..., "abc", "hello"] <- correct
--- a/devtools/client/webconsole/test/browser_eval_in_debugger_stackframe2.js
+++ b/devtools/client/webconsole/test/browser_eval_in_debugger_stackframe2.js
@@ -25,18 +25,18 @@ add_task(function* () {
   let hud = yield openConsole();
   let {jsterm} = hud;
 
   info("open the debugger");
   let {panelWin} = yield openDebugger();
   let {DebuggerController} = panelWin;
   let {activeThread} = DebuggerController;
 
-  let firstCall = promise.defer();
-  let frameAdded = promise.defer();
+  let firstCall = defer();
+  let frameAdded = defer();
   executeSoon(() => {
     info("Executing firstCall");
     activeThread.addOneTimeListener("framesadded", () => {
       executeSoon(frameAdded.resolve);
     });
     jsterm.execute("firstCall()").then(firstCall.resolve);
   });
 
--- a/devtools/client/webconsole/test/browser_netmonitor_shows_reqs_in_webconsole.js
+++ b/devtools/client/webconsole/test/browser_netmonitor_shows_reqs_in_webconsole.js
@@ -45,17 +45,17 @@ add_task(function* () {
   let target = TargetFactory.forTab(tab);
   let toolbox = yield gDevTools.showToolbox(target, "netmonitor");
   info("Network panel is open.");
 
   yield testNetmonitor(toolbox);
 });
 
 function loadDocument(browser) {
-  let deferred = promise.defer();
+  let deferred = defer();
 
   browser.addEventListener("load", function () {
     deferred.resolve();
   }, {capture: true, once: true});
   BrowserTestUtils.loadURI(gBrowser.selectedBrowser, TEST_PATH);
 
   return deferred.promise;
 }
--- a/devtools/client/webconsole/test/browser_output_longstring_expand.js
+++ b/devtools/client/webconsole/test/browser_output_longstring_expand.js
@@ -74,12 +74,12 @@ add_task(function* () {
       text: longString,
       category: CATEGORY_OUTPUT,
       longString: false,
     }],
   });
 });
 
 function execute(hud, str) {
-  let deferred = promise.defer();
+  let deferred = defer();
   hud.jsterm.execute(str, deferred.resolve);
   return deferred.promise;
 }
--- a/devtools/client/webconsole/test/browser_result_format_as_string.js
+++ b/devtools/client/webconsole/test/browser_result_format_as_string.js
@@ -29,12 +29,12 @@ add_task(function* () {
   isnot(msg.textContent.indexOf("<p>"), -1,
         "<p> string is displayed");
 
   EventUtils.synthesizeMouseAtCenter(msg, {type: "mousemove"});
   ok(!gBrowser._bug772506, "no content variable");
 });
 
 function execute(hud, str) {
-  let deferred = promise.defer();
+  let deferred = defer();
   hud.jsterm.execute(str, deferred.resolve);
   return deferred.promise;
 }
--- a/devtools/client/webconsole/test/browser_warn_user_about_replaced_api.js
+++ b/devtools/client/webconsole/test/browser_warn_user_about_replaced_api.js
@@ -26,17 +26,17 @@ add_task(function* () {
   let hud2 = yield openConsole();
 
   yield testWarningPresent(hud2);
 
   Services.prefs.clearUserPref(PREF);
 });
 
 function testWarningNotPresent(hud) {
-  let deferred = promise.defer();
+  let deferred = defer();
 
   is(hud.outputNode.textContent.indexOf("logging API"), -1,
      "no warning displayed");
 
   // Bug 862024: make sure the warning doesn't show after page reload.
   info("reload " + TEST_URI);
   executeSoon(function () {
     let browser = gBrowser.selectedBrowser;
@@ -55,17 +55,17 @@ function testWarningNotPresent(hud) {
     closeConsole().then(deferred.resolve);
   }));
 
   return deferred.promise;
 }
 
 function testWarningPresent(hud) {
   info("wait for the warning to show");
-  let deferred = promise.defer();
+  let deferred = defer();
 
   let warning = {
     webconsole: hud,
     messages: [{
       text: /logging API .+ disabled by a script/,
       category: CATEGORY_JS,
       severity: SEVERITY_WARNING,
     }],
--- a/devtools/client/webconsole/test/browser_webconsole_allow_mixedcontent_securityerrors.js
+++ b/devtools/client/webconsole/test/browser_webconsole_allow_mixedcontent_securityerrors.js
@@ -47,17 +47,17 @@ add_task(function* () {
       },
     ],
   });
 
   yield testClickOpenNewTab(hud, results);
 });
 
 function pushPrefEnv() {
-  let deferred = promise.defer();
+  let deferred = defer();
   let options = {"set":
       [["security.mixed_content.block_active_content", false],
        ["security.mixed_content.block_display_content", false]
   ]};
   SpecialPowers.pushPrefEnv(options, deferred.resolve);
   return deferred.promise;
 }
 
--- a/devtools/client/webconsole/test/browser_webconsole_autocomplete-properties-with-non-alphanumeric-names.js
+++ b/devtools/client/webconsole/test/browser_webconsole_autocomplete-properties-with-non-alphanumeric-names.js
@@ -9,17 +9,17 @@
 // autocompleted (bug 967468).
 
 add_task(function* () {
   const TEST_URI = "data:text/html;charset=utf8,test autocompletion with " +
                    "$ or _";
   yield loadTab(TEST_URI);
 
   function* autocomplete(term) {
-    let deferred = promise.defer();
+    let deferred = defer();
 
     jsterm.setInputValue(term);
     jsterm.complete(jsterm.COMPLETE_HINT_ONLY, deferred.resolve);
 
     yield deferred.promise;
 
     ok(popup.itemCount > 0,
        "There's " + popup.itemCount + " suggestions for '" + term + "'");
--- a/devtools/client/webconsole/test/browser_webconsole_autocomplete_and_selfxss.js
+++ b/devtools/client/webconsole/test/browser_webconsole_autocomplete_and_selfxss.js
@@ -16,17 +16,17 @@ add_task(function* () {
   yield loadTab(TEST_URI);
 
   let hud = yield openConsole();
 
   yield consoleOpened(hud);
 });
 
 function consoleOpened(HUD) {
-  let deferred = promise.defer();
+  let deferred = defer();
 
   let jsterm = HUD.jsterm;
   let stringToCopy = "foobazbarBug642615";
 
   jsterm.clearOutput();
 
   ok(!jsterm.completeNode.value, "no completeNode.value");
 
--- a/devtools/client/webconsole/test/browser_webconsole_block_mixedcontent_securityerrors.js
+++ b/devtools/client/webconsole/test/browser_webconsole_block_mixedcontent_securityerrors.js
@@ -51,31 +51,31 @@ add_task(function* () {
   yield testClickOpenNewTab(hud, results[0]);
 
   let results2 = yield mixedContentOverrideTest2(hud, browser);
 
   yield testClickOpenNewTab(hud, results2[0]);
 });
 
 function pushPrefEnv() {
-  let deferred = promise.defer();
+  let deferred = defer();
   let options = {
     "set": [
       ["security.mixed_content.block_active_content", true],
       ["security.mixed_content.block_display_content", true],
       ["security.mixed_content.use_hsts", false],
       ["security.mixed_content.send_hsts_priming", false],
     ]
   };
   SpecialPowers.pushPrefEnv(options, deferred.resolve);
   return deferred.promise;
 }
 
 function mixedContentOverrideTest2(hud, browser) {
-  let deferred = promise.defer();
+  let deferred = defer();
   let {gIdentityHandler} = browser.ownerGlobal;
   ok(gIdentityHandler._identityBox.classList.contains("mixedActiveBlocked"),
     "Mixed Active Content state appeared on identity box");
   gIdentityHandler.disableMixedContentProtection();
 
   waitForMessages({
     webconsole: hud,
     messages: [
--- a/devtools/client/webconsole/test/browser_webconsole_bug_580001_closing_after_completion.js
+++ b/devtools/client/webconsole/test/browser_webconsole_bug_580001_closing_after_completion.js
@@ -14,17 +14,17 @@ const TEST_URI = "http://example.com/bro
 add_task(function* () {
   let { browser } = yield loadTab(TEST_URI);
 
   let hud = yield openConsole();
   yield testClosingAfterCompletion(hud, browser);
 });
 
 function testClosingAfterCompletion(hud, browser) {
-  let deferred = promise.defer();
+  let deferred = defer();
 
   let errorWhileClosing = false;
   function errorListener() {
     errorWhileClosing = true;
   }
 
   browser.addEventListener("error", errorListener);
 
--- a/devtools/client/webconsole/test/browser_webconsole_bug_585991_autocomplete_keys.js
+++ b/devtools/client/webconsole/test/browser_webconsole_bug_585991_autocomplete_keys.js
@@ -26,17 +26,17 @@ add_task(function* () {
   yield testCompletionInText();
   yield popupHideAfterCompletionInText();
 
   HUD = popup = jsterm = inputNode = completeNode = null;
   Services.prefs.setBoolPref(PREF_AUTO_MULTILINE, true);
 });
 
 var consoleOpened = Task.async(function* (hud) {
-  let deferred = promise.defer();
+  let deferred = defer();
   HUD = hud;
   info("web console opened");
 
   jsterm = HUD.jsterm;
 
   yield jsterm.execute("window.foobarBug585991={" +
     "'item0': 'value0'," +
     "'item1': 'value1'," +
@@ -141,17 +141,17 @@ var consoleOpened = Task.async(function*
 
   jsterm.setInputValue("window.foobarBug585991");
   EventUtils.synthesizeKey(".", {});
 
   return deferred.promise;
 });
 
 function popupHideAfterTab() {
-  let deferred = promise.defer();
+  let deferred = defer();
 
   // At this point the completion suggestion should be accepted.
   ok(!popup.isOpen, "popup is not open");
 
   is(jsterm.getInputValue(), "window.foobarBug585991.watch",
      "completion was successful after VK_TAB");
 
   ok(!completeNode.value, "completeNode is empty");
@@ -193,17 +193,17 @@ function popupHideAfterTab() {
     jsterm.setInputValue("window.foobarBug585991");
     EventUtils.synthesizeKey(".", {});
   });
 
   return deferred.promise;
 }
 
 function testReturnKey() {
-  let deferred = promise.defer();
+  let deferred = defer();
 
   popup.once("popup-opened", function onShown() {
     ok(popup.isOpen, "popup is open");
 
     is(popup.itemCount, 19, "popup.itemCount is correct");
 
     is(popup.selectedIndex, 18, "First index from bottom is selected");
     EventUtils.synthesizeKey("VK_DOWN", {});
@@ -245,17 +245,17 @@ function testReturnKey() {
     EventUtils.synthesizeKey("1", {});
     EventUtils.synthesizeKey(".", {});
   });
 
   return deferred.promise;
 }
 
 function* dontShowArrayNumbers() {
-  let deferred = promise.defer();
+  let deferred = defer();
 
   info("dontShowArrayNumbers");
   yield ContentTask.spawn(gBrowser.selectedBrowser, {}, function* () {
     content.wrappedJSObject.foobarBug585991 = ["Sherlock Holmes"];
   });
 
   jsterm = HUD.jsterm;
   popup = jsterm.autocompletePopup;
@@ -281,17 +281,17 @@ function* dontShowArrayNumbers() {
     jsterm.setInputValue("window.foobarBug585991");
     EventUtils.synthesizeKey(".", {});
   });
 
   return deferred.promise;
 }
 
 function testReturnWithNoSelection() {
-  let deferred = promise.defer();
+  let deferred = defer();
 
   info("test pressing return with open popup, but no selection, see bug 873250");
 
   popup.once("popup-opened", function onShown() {
     ok(popup.isOpen, "popup is open");
     is(popup.itemCount, 2, "popup.itemCount is correct");
     isnot(popup.selectedIndex, -1, "popup.selectedIndex is correct");
 
@@ -320,17 +320,17 @@ function popupHideAfterReturnWithNoSelec
      "jsterm history is correct");
 
   return promise.resolve();
 }
 
 function testCompletionInText() {
   info("test that completion works inside text, see bug 812618");
 
-  let deferred = promise.defer();
+  let deferred = defer();
 
   popup.once("popup-opened", function onShown() {
     ok(popup.isOpen, "popup is open");
     is(popup.itemCount, 2, "popup.itemCount is correct");
 
     EventUtils.synthesizeKey("VK_DOWN", {});
     is(popup.selectedIndex, 0, "popup.selectedIndex is correct");
     ok(!completeNode.value, "completeNode.value is empty");
--- a/devtools/client/webconsole/test/browser_webconsole_bug_585991_autocomplete_popup.js
+++ b/devtools/client/webconsole/test/browser_webconsole_bug_585991_autocomplete_popup.js
@@ -11,17 +11,17 @@ const TEST_URI = "data:text/html;charset
 add_task(function* () {
   yield loadTab(TEST_URI);
   let hud = yield openConsole();
 
   yield consoleOpened(hud);
 });
 
 function consoleOpened(HUD) {
-  let deferred = promise.defer();
+  let deferred = defer();
 
   let items = [
     {label: "item0", value: "value0"},
     {label: "item1", value: "value1"},
     {label: "item2", value: "value2"},
   ];
 
   let popup = HUD.jsterm.autocompletePopup;
--- a/devtools/client/webconsole/test/browser_webconsole_bug_587617_output_copy.js
+++ b/devtools/client/webconsole/test/browser_webconsole_bug_587617_output_copy.js
@@ -19,17 +19,17 @@ add_task(function* () {
   yield testContextMenuCopy();
 
   HUD = outputNode = null;
 });
 
 function consoleOpened(hud) {
   HUD = hud;
 
-  let deferred = promise.defer();
+  let deferred = defer();
 
   // See bugs 574036, 586386 and 587617.
   outputNode = HUD.outputNode;
 
   HUD.jsterm.clearOutput();
 
   let controller = top.document.commandDispatcher
                                .getControllerForCommand("cmd_copy");
@@ -72,17 +72,17 @@ function consoleOpened(hud) {
     }, deferred.resolve, deferred.resolve);
   });
   return deferred.promise;
 }
 
 // Test that the context menu "Copy" (which has a different code path) works
 // properly as well.
 function testContextMenuCopy() {
-  let deferred = promise.defer();
+  let deferred = defer();
 
   let contextMenuId = HUD.ui.outputWrapper.getAttribute("context");
   let contextMenu = HUD.ui.document.getElementById(contextMenuId);
   ok(contextMenu, "the output node has a context menu");
 
   let copyItem = contextMenu.querySelector("*[command='cmd_copy']");
   ok(copyItem, "the context menu on the output node has a \"Copy\" item");
 
--- a/devtools/client/webconsole/test/browser_webconsole_bug_588730_text_node_insertion.js
+++ b/devtools/client/webconsole/test/browser_webconsole_bug_588730_text_node_insertion.js
@@ -16,17 +16,17 @@ add_task(function* () {
   let hud = yield openConsole();
 
   yield testTextNodeInsertion(hud);
 });
 
 // Test for bug 588730: Adding a text node to an existing label element causes
 // warnings
 function testTextNodeInsertion(hud) {
-  let deferred = promise.defer();
+  let deferred = defer();
   let outputNode = hud.outputNode;
 
   let label = document.createElementNS(
     "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul", "label");
   outputNode.appendChild(label);
 
   let error = false;
   let listener = {
--- a/devtools/client/webconsole/test/browser_webconsole_bug_597460_filter_scroll.js
+++ b/devtools/client/webconsole/test/browser_webconsole_bug_597460_filter_scroll.js
@@ -18,17 +18,17 @@ add_task(function* () {
   let results = yield consoleOpened(hud);
 
   testScroll(results, hud);
 
   Services.prefs.clearUserPref(PREF);
 });
 
 function consoleOpened(hud) {
-  let deferred = promise.defer();
+  let deferred = defer();
 
   for (let i = 0; i < 200; i++) {
     content.console.log("test message " + i);
   }
 
   hud.setFilterState("network", false);
   hud.setFilterState("networkinfo", false);
 
--- a/devtools/client/webconsole/test/browser_webconsole_bug_599725_response_headers.js
+++ b/devtools/client/webconsole/test/browser_webconsole_bug_599725_response_headers.js
@@ -5,17 +5,17 @@
 
 "use strict";
 
 const INIT_URI = "data:text/plain;charset=utf8,hello world";
 const TEST_URI = "http://example.com/browser/devtools/client/webconsole/" +
                  "test/test-bug-599725-response-headers.sjs";
 
 function performTest(request, hud) {
-  let deferred = promise.defer();
+  let deferred = defer();
 
   let headers = null;
 
   function readHeader(name) {
     for (let header of headers) {
       if (header.name == name) {
         return header.value;
       }
--- a/devtools/client/webconsole/test/browser_webconsole_bug_600183_charset.js
+++ b/devtools/client/webconsole/test/browser_webconsole_bug_600183_charset.js
@@ -5,17 +5,17 @@
 
 "use strict";
 
 const INIT_URI = "data:text/html;charset=utf-8,Web Console - bug 600183 test";
 const TEST_URI = "http://example.com/browser/devtools/client/webconsole/" +
                  "test/test-bug-600183-charset.html";
 
 function performTest(lastFinishedRequest, console) {
-  let deferred = promise.defer();
+  let deferred = defer();
 
   ok(lastFinishedRequest, "charset test page was loaded and logged");
   HUDService.lastFinishedRequest.callback = null;
 
   executeSoon(() => {
     console.webConsoleClient.getResponseContent(lastFinishedRequest.actor,
       (response) => {
         ok(!response.contentDiscarded, "response body was not discarded");
@@ -32,17 +32,17 @@ function performTest(lastFinishedRequest
         executeSoon(deferred.resolve);
       });
   });
 
   return deferred.promise;
 }
 
 function waitForRequest() {
-  let deferred = promise.defer();
+  let deferred = defer();
   HUDService.lastFinishedRequest.callback = (req, console) => {
     performTest(req, console).then(deferred.resolve);
   };
   return deferred.promise;
 }
 
 add_task(function* () {
   let { browser } = yield loadTab(INIT_URI);
--- a/devtools/client/webconsole/test/browser_webconsole_bug_613642_maintain_scroll.js
+++ b/devtools/client/webconsole/test/browser_webconsole_bug_613642_maintain_scroll.js
@@ -32,17 +32,17 @@ add_task(function* () {
     }],
   });
 
   ok(scrollBox.scrollTop > 0, "scroll location is not at the top");
 
   // scroll to the first node
   outputNode.focus();
 
-  let scrolled = promise.defer();
+  let scrolled = defer();
 
   scrollBox.onscroll = () => {
     info("onscroll top " + scrollBox.scrollTop);
     if (scrollBox.scrollTop != 0) {
       // Wait for scroll to 0.
       return;
     }
     scrollBox.onscroll = null;
@@ -61,17 +61,17 @@ add_task(function* () {
     webconsole: hud,
     messages: [{
       text: "test message 150",
       category: CATEGORY_WEBDEV,
       severity: SEVERITY_LOG,
     }],
   });
 
-  scrolled = promise.defer();
+  scrolled = defer();
   scrollBox.onscroll = () => {
     if (scrollBox.scrollTop != 0) {
       // Wait for scroll to stabilize at the top.
       return;
     }
     scrollBox.onscroll = null;
     is(scrollBox.scrollTop, 0, "scroll location is still at the top");
     scrolled.resolve();
@@ -81,17 +81,17 @@ add_task(function* () {
   // the yield to work.
   executeSoon(scrollBox.onscroll);
 
   yield scrolled.promise;
 
   // scroll back to the bottom
   outputNode.lastChild.focus();
 
-  scrolled = promise.defer();
+  scrolled = defer();
   scrollBox.onscroll = () => {
     if (scrollBox.scrollTop == 0) {
       // Wait for scroll to bottom.
       return;
     }
     scrollBox.onscroll = null;
     isnot(scrollBox.scrollTop, 0, "scroll location updated (moved to bottom)");
     scrolled.resolve();
@@ -99,17 +99,17 @@ add_task(function* () {
   EventUtils.synthesizeKey("VK_END", {});
   yield scrolled.promise;
 
   let oldScrollTop = scrollBox.scrollTop;
 
   ContentTask.spawn(gBrowser.selectedBrowser, null,
     "() => content.console.log('test message 151')");
 
-  scrolled = promise.defer();
+  scrolled = defer();
   scrollBox.onscroll = () => {
     if (scrollBox.scrollTop == oldScrollTop) {
       // Wait for scroll to change.
       return;
     }
     scrollBox.onscroll = null;
     isnot(scrollBox.scrollTop, oldScrollTop,
           "scroll location updated (moved to bottom again)");
--- a/devtools/client/webconsole/test/browser_webconsole_bug_621644_jsterm_dollar.js
+++ b/devtools/client/webconsole/test/browser_webconsole_bug_621644_jsterm_dollar.js
@@ -13,31 +13,31 @@ add_task(function* () {
 
   let hud = yield openConsole();
 
   yield test$(hud);
   yield test$$(hud);
 });
 
 function* test$(HUD) {
-  let deferred = promise.defer();
+  let deferred = defer();
 
   HUD.jsterm.clearOutput();
 
   HUD.jsterm.execute("$(document.body)", (msg) => {
     ok(msg.textContent.indexOf("<p>") > -1,
        "jsterm output is correct for $()");
     deferred.resolve();
   });
 
   return deferred.promise;
 }
 
 function test$$(HUD) {
-  let deferred = promise.defer();
+  let deferred = defer();
 
   HUD.jsterm.clearOutput();
 
   HUD.jsterm.setInputValue();
   HUD.jsterm.execute("$$(document)", (msg) => {
     ok(msg.textContent.indexOf("621644") > -1,
        "jsterm output is correct for $$()");
     deferred.resolve();
--- a/devtools/client/webconsole/test/browser_webconsole_bug_622303_persistent_filters.js
+++ b/devtools/client/webconsole/test/browser_webconsole_bug_622303_persistent_filters.js
@@ -53,17 +53,17 @@ add_task(function* () {
   for (let category in prefs) {
     prefs[category].forEach(function (pref) {
       Services.prefs.clearUserPref("devtools.webconsole.filter." + pref);
     });
   }
 });
 
 function onConsoleOpen(hud) {
-  let deferred = promise.defer();
+  let deferred = defer();
 
   let hudBox = hud.ui.rootElement;
 
   // Check if the filters menuitems exists and are checked
   for (let category in prefs) {
     let button = hudBox.querySelector(".webconsole-filter-button[category=\""
                                       + category + "\"]");
     ok(isChecked(button), "main button for " + category +
@@ -87,17 +87,17 @@ function onConsoleOpen(hud) {
     openConsole().then(deferred.resolve);
   });
 
   return deferred.promise;
 }
 
 function onConsoleReopen1(hud) {
   info("testing after reopening once");
-  let deferred = promise.defer();
+  let deferred = defer();
 
   let hudBox = hud.ui.rootElement;
 
   // Check if the filter button and menuitems are unchecked
   for (let category in prefs) {
     let button = hudBox.querySelector(".webconsole-filter-button[category=\""
                                            + category + "\"]");
     ok(isUnchecked(button), "main button for " + category +
--- a/devtools/client/webconsole/test/browser_webconsole_bug_630733_response_redirect_headers.js
+++ b/devtools/client/webconsole/test/browser_webconsole_bug_630733_response_redirect_headers.js
@@ -21,34 +21,34 @@ add_task(function* () {
   yield consoleOpened(hud);
   yield getHeaders();
   yield getContent();
 
   performTest();
 });
 
 function consoleOpened(hud) {
-  let deferred = promise.defer();
+  let deferred = defer();
 
   webConsoleClient = hud.ui.webConsoleClient;
   HUDService.lastFinishedRequest.callback = (aHttpRequest) => {
     let status = aHttpRequest.response.status;
     lastFinishedRequests[status] = aHttpRequest;
     if ("301" in lastFinishedRequests &&
         "404" in lastFinishedRequests) {
       deferred.resolve();
     }
   };
   BrowserTestUtils.loadURI(gBrowser.selectedBrowser, TEST_URI2);
 
   return deferred.promise;
 }
 
 function getHeaders() {
-  let deferred = promise.defer();
+  let deferred = defer();
 
   HUDService.lastFinishedRequest.callback = null;
 
   ok("301" in lastFinishedRequests, "request 1: 301 Moved Permanently");
   ok("404" in lastFinishedRequests, "request 2: 404 Not found");
 
   webConsoleClient.getResponseHeaders(lastFinishedRequests["301"].actor,
     function (response) {
@@ -59,17 +59,17 @@ function getHeaders() {
           lastFinishedRequests["404"].response.headers = resp.headers;
           executeSoon(deferred.resolve);
         });
     });
   return deferred.promise;
 }
 
 function getContent() {
-  let deferred = promise.defer();
+  let deferred = defer();
 
   webConsoleClient.getResponseContent(lastFinishedRequests["301"].actor,
     function (response) {
       lastFinishedRequests["301"].response.content = response.content;
       lastFinishedRequests["301"].discardResponseBody = response.contentDiscarded;
 
       webConsoleClient.getResponseContent(lastFinishedRequests["404"].actor,
         function (resp) {
--- a/devtools/client/webconsole/test/browser_webconsole_bug_651501_document_body_autocomplete.js
+++ b/devtools/client/webconsole/test/browser_webconsole_bug_651501_document_body_autocomplete.js
@@ -21,17 +21,17 @@ add_task(function* () {
   yield autocompletePopupHidden();
   let view = yield testPropertyPanel();
   yield onVariablesViewReady(view);
 
   gHUD = null;
 });
 
 function consoleOpened() {
-  let deferred = promise.defer();
+  let deferred = defer();
 
   let jsterm = gHUD.jsterm;
   let popup = jsterm.autocompletePopup;
 
   ok(!popup.isOpen, "popup is not open");
 
   popup.once("popup-opened", () => {
     ok(popup.isOpen, "popup is open");
@@ -53,17 +53,17 @@ function consoleOpened() {
 
   jsterm.setInputValue("document.body");
   EventUtils.synthesizeKey(".", {});
 
   return deferred.promise;
 }
 
 function autocompletePopupHidden() {
-  let deferred = promise.defer();
+  let deferred = defer();
 
   let jsterm = gHUD.jsterm;
   let popup = jsterm.autocompletePopup;
   let completeNode = jsterm.completeNode;
 
   ok(!popup.isOpen, "popup is not open");
 
   jsterm.once("autocomplete-updated", function () {
@@ -75,17 +75,17 @@ function autocompletePopupHidden() {
   jsterm.setInputValue(inputStr);
   EventUtils.synthesizeKey("o", {});
   let testStr = inputStr.replace(/./g, " ") + " ";
 
   return deferred.promise;
 }
 
 function testPropertyPanel() {
-  let deferred = promise.defer();
+  let deferred = defer();
 
   let jsterm = gHUD.jsterm;
   jsterm.clearOutput();
   jsterm.execute("document", (msg) => {
     jsterm.once("variablesview-fetched", (evt, view) => {
       deferred.resolve(view);
     });
     let anchor = msg.querySelector(".message-body a");
--- a/devtools/client/webconsole/test/browser_webconsole_bug_660806_history_nav.js
+++ b/devtools/client/webconsole/test/browser_webconsole_bug_660806_history_nav.js
@@ -12,17 +12,17 @@ add_task(function* () {
   yield loadTab(TEST_URI);
 
   let hud = yield openConsole();
 
   yield consoleOpened(hud);
 });
 
 function consoleOpened(HUD) {
-  let deferred = promise.defer();
+  let deferred = defer();
 
   let jsterm = HUD.jsterm;
   let popup = jsterm.autocompletePopup;
   let onShown = function () {
     ok(false, "popup shown");
   };
 
   jsterm.execute(`window.foobarBug660806 = {
--- a/devtools/client/webconsole/test/browser_webconsole_bug_764572_output_open_url.js
+++ b/devtools/client/webconsole/test/browser_webconsole_bug_764572_output_open_url.js
@@ -84,17 +84,17 @@ function testOnNetActivity() {
       text: "test-console.html",
       category: CATEGORY_NETWORK,
       severity: SEVERITY_LOG,
     }],
   });
 }
 
 function onNetworkMessage(results) {
-  let deferred = promise.defer();
+  let deferred = defer();
 
   outputNode.focus();
   let msg = [...results[0].matched][0];
   ok(msg, "network message");
   HUD.ui.output.selectMessage(msg);
 
   let currentTab = gBrowser.selectedTab;
   let newTab = null;
@@ -120,17 +120,17 @@ function onNetworkMessage(results) {
 
   // Try to open the URL.
   goDoCommand(COMMAND_NAME);
 
   return deferred.promise;
 }
 
 function testOnNetActivityContextMenu(msg) {
-  let deferred = promise.defer();
+  let deferred = defer();
 
   outputNode.focus();
   HUD.ui.output.selectMessage(msg);
 
   info("net activity context menu");
 
   waitForContextMenu(contextMenu, msg, () => {
     let isShown = !contextMenu.querySelector(CONTEXT_MENU_ID).hidden;
--- a/devtools/client/webconsole/test/browser_webconsole_bug_782653_CSS_links_in_Style_Editor.js
+++ b/devtools/client/webconsole/test/browser_webconsole_bug_782653_CSS_links_in_Style_Editor.js
@@ -17,17 +17,17 @@ add_task(function* () {
 
   let styleEditor = yield testViewSource();
   yield onStyleEditorReady(styleEditor);
 
   nodes = hud = StyleEditorUI = null;
 });
 
 function testViewSource() {
-  let deferred = promise.defer();
+  let deferred = defer();
 
   waitForMessages({
     webconsole: hud,
     messages: [{
       text: "\u2018font-weight\u2019",
       category: CATEGORY_CSS,
       severity: SEVERITY_WARNING,
     },
@@ -53,17 +53,17 @@ function testViewSource() {
 
     EventUtils.sendMouseEvent({ type: "click" }, nodes[0].querySelector(".frame-link-filename"));
   });
 
   return deferred.promise;
 }
 
 function onStyleEditorReady(panel) {
-  let deferred = promise.defer();
+  let deferred = defer();
 
   let win = panel.panelWindow;
   ok(win, "Style Editor Window is defined");
   ok(StyleEditorUI, "Style Editor UI is defined");
 
   function fireEvent(toolbox, href, line) {
     toolbox.once("styleeditor-selected", function (evt) {
       info(evt + " event fired");
@@ -110,17 +110,17 @@ function checkStyleEditorForSheetAndLine
     }
   }
 
   ok(foundEditor, "found style editor for " + href);
   return performLineCheck(foundEditor, line);
 }
 
 function performLineCheck(editor, line) {
-  let deferred = promise.defer();
+  let deferred = defer();
 
   function checkForCorrectState() {
     is(editor.sourceEditor.getCursor().line, line,
        "correct line is selected");
     is(StyleEditorUI.selectedStyleSheetIndex, editor.styleSheet.styleSheetIndex,
        "correct stylesheet is selected in the editor");
 
     executeSoon(deferred.resolve);
--- a/devtools/client/webconsole/test/browser_webconsole_bug_837351_securityerrors.js
+++ b/devtools/client/webconsole/test/browser_webconsole_bug_837351_securityerrors.js
@@ -27,16 +27,16 @@ add_task(function* () {
         category: CATEGORY_SECURITY,
         severity: SEVERITY_ERROR
       },
     ],
   });
 });
 
 function pushPrefEnv() {
-  let deferred = promise.defer();
+  let deferred = defer();
   let options = {
     set: [["security.mixed_content.block_active_content", true]]
   };
   SpecialPowers.pushPrefEnv(options, deferred.resolve);
   return deferred.promise;
 }
 
--- a/devtools/client/webconsole/test/browser_webconsole_chrome.js
+++ b/devtools/client/webconsole/test/browser_webconsole_chrome.js
@@ -21,17 +21,17 @@ function test() {
 
     let input = jsterm.inputNode;
     ok(hud.outputNode, "we have an output node");
 
     // Test typing 'docu'.
     input.value = "docu";
     input.setSelectionRange(4, 4);
 
-    let deferred = promise.defer();
+    let deferred = defer();
 
     jsterm.complete(jsterm.COMPLETE_HINT_ONLY, function () {
       is(jsterm.completeNode.value, "    ment", "'docu' completion");
       deferred.resolve(null);
     });
 
     yield deferred.promise;
   }).then(finishTest);
--- a/devtools/client/webconsole/test/browser_webconsole_closure_inspection.js
+++ b/devtools/client/webconsole/test/browser_webconsole_closure_inspection.js
@@ -30,17 +30,17 @@ function test() {
       toolbox.selectTool("webconsole").then(() => consoleOpened(hud));
       deferred.resolve();
     });
   }
 
   loadTab(TEST_URI).then(() => {
     openConsole().then((hud) => {
       openDebugger().then(({ toolbox, panelWin }) => {
-        let deferred = promise.defer();
+        let deferred = defer();
         fetchScopes(hud, toolbox, panelWin, deferred);
 
         ContentTask.spawn(gBrowser.selectedBrowser, {}, function* () {
           let button = content.document.querySelector("button");
           ok(button, "button element found");
           button.click();
         });
 
--- a/devtools/client/webconsole/test/browser_webconsole_dont_navigate_on_doubleclick.js
+++ b/devtools/client/webconsole/test/browser_webconsole_dont_navigate_on_doubleclick.js
@@ -35,17 +35,17 @@ function test() {
         url: TEST_PAGE_URI,
         category: CATEGORY_NETWORK
       }]
     });
 
     let networkEventMessage = messages[0].matched.values().next().value;
     let urlNode = networkEventMessage.querySelector(".url");
 
-    let deferred = promise.defer();
+    let deferred = defer();
     urlNode.addEventListener("click", function (event) {
       ok(event.defaultPrevented, "The default action was prevented.");
 
       deferred.resolve();
     }, {once: true});
 
     EventUtils.synthesizeMouseAtCenter(urlNode, {clickCount: 2},
                                        hud.iframeWindow);
--- a/devtools/client/webconsole/test/browser_webconsole_filter_buttons_contextmenu.js
+++ b/devtools/client/webconsole/test/browser_webconsole_filter_buttons_contextmenu.js
@@ -22,17 +22,17 @@ function testFilterButtons(aHud) {
     .then(() => testRightClick("css", hudBox, aHud))
     .then(() => testRightClick("js", hudBox, aHud))
     .then(() => testRightClick("logging", hudBox, aHud))
     .then(() => testRightClick("security", hudBox, aHud))
     .then(finishTest);
 }
 
 function testRightClick(aCategory, hudBox, aHud) {
-  let deferred = promise.defer();
+  let deferred = defer();
   let selector = ".webconsole-filter-button[category=\"" + aCategory + "\"]";
   let button = hudBox.querySelector(selector);
   let mainButton = getMainButton(button, aHud);
   let origCheckedState = button.getAttribute("aria-pressed");
   let contextMenu = aHud.iframeWindow.document.getElementById(aCategory + "-contextmenu");
 
   function verifyContextMenuIsClosed() {
     info("verify the context menu is closed");
--- a/devtools/client/webconsole/test/browser_webconsole_for_of.js
+++ b/devtools/client/webconsole/test/browser_webconsole_for_of.js
@@ -13,17 +13,17 @@ const TEST_URI = "http://example.com/bro
 add_task(function* () {
   yield loadTab(TEST_URI);
 
   let hud = yield openConsole();
   yield testForOf(hud);
 });
 
 function testForOf(hud) {
-  let deferred = promise.defer();
+  let deferred = defer();
 
   let jsterm = hud.jsterm;
   jsterm.execute("{ let _nodes = []; for (let x of document.body.childNodes) { if (x.nodeType === 1) { _nodes.push(x.tagName); } } _nodes.join(' '); }",
     (node) => {
       ok(/H1 DIV H2 P/.test(node.textContent),
         "for-of loop should find all top-level nodes");
       deferred.resolve();
     });
--- a/devtools/client/webconsole/test/browser_webconsole_jsterm.js
+++ b/devtools/client/webconsole/test/browser_webconsole_jsterm.js
@@ -14,17 +14,17 @@ add_task(function* () {
   yield loadTab(TEST_URI);
   let hud = yield openConsole();
   jsterm = hud.jsterm;
   yield testJSTerm(hud);
   jsterm = null;
 });
 
 function checkResult(msg, desc) {
-  let def = promise.defer();
+  let def = defer();
   waitForMessages({
     webconsole: jsterm.hud.owner,
     messages: [{
       name: desc,
       category: CATEGORY_OUTPUT,
     }],
   }).then(([result]) => {
     let node = [...result.matched][0].querySelector(".message-body");
--- a/devtools/client/webconsole/test/browser_webconsole_netlogging_reset_filter.js
+++ b/devtools/client/webconsole/test/browser_webconsole_netlogging_reset_filter.js
@@ -83,15 +83,15 @@ function testMessages() {
       text: "testscript.js",
       category: CATEGORY_NETWORK,
       severity: SEVERITY_LOG,
     }],
   });
 }
 
 function pushPrefEnv() {
-  let deferred = promise.defer();
+  let deferred = defer();
   let options = {
     set: [["devtools.webconsole.filter.networkinfo", true]]
   };
   SpecialPowers.pushPrefEnv(options, deferred.resolve);
   return deferred.promise;
 }
--- a/devtools/client/webconsole/test/browser_webconsole_notifications.js
+++ b/devtools/client/webconsole/test/browser_webconsole_notifications.js
@@ -6,27 +6,27 @@
 "use strict";
 
 const TEST_URI = "data:text/html;charset=utf-8,<p>Web Console test for " +
                  "notifications";
 
 add_task(function* () {
   yield loadTab(TEST_URI);
 
-  let consoleOpened = promise.defer();
+  let consoleOpened = defer();
   let gotEvents = waitForEvents(consoleOpened.promise);
   yield openConsole().then(() => {
     consoleOpened.resolve();
   });
 
   yield gotEvents;
 });
 
 function waitForEvents(onConsoleOpened) {
-  let deferred = promise.defer();
+  let deferred = defer();
 
   function webConsoleCreated(id) {
     Services.obs.removeObserver(observer, "web-console-created");
     ok(HUDService.getHudReferenceById(id), "We have a hud reference");
     content.wrappedJSObject.console.log("adding a log message");
   }
 
   function webConsoleDestroyed(id) {
--- a/devtools/client/webconsole/test/browser_webconsole_output_dom_elements_04.js
+++ b/devtools/client/webconsole/test/browser_webconsole_output_dom_elements_04.js
@@ -98,15 +98,15 @@ function* getWidgetAndMessage(result) {
 
   info("Waiting for the ElementNode widget to be linked to the inspector");
   yield widget.linkToInspector();
 
   return {widget: widget, msg: msg};
 }
 
 function reloadPage() {
-  let def = promise.defer();
+  let def = defer();
   gBrowser.selectedBrowser.addEventListener("load", function () {
     def.resolve();
   }, {capture: true, once: true});
   content.location.reload();
   return def.promise;
 }
--- a/devtools/client/webconsole/test/browser_webconsole_scratchpad_panel_link.js
+++ b/devtools/client/webconsole/test/browser_webconsole_scratchpad_panel_link.js
@@ -7,17 +7,17 @@
 
 const TEST_URI = "data:text/html;charset=utf8,<p>test Scratchpad panel " +
                  "linking</p>";
 
 var { Tools } = require("devtools/client/definitions");
 var { isTargetSupported } = Tools.scratchpad;
 
 function pushPrefEnv() {
-  let deferred = promise.defer();
+  let deferred = defer();
   let options = {"set":
       [["devtools.scratchpad.enabled", true]
   ]};
   SpecialPowers.pushPrefEnv(options, deferred.resolve);
   return deferred.promise;
 }
 
 add_task(function* () {
--- a/devtools/client/webconsole/test/browser_webconsole_shows_reqs_in_netmonitor.js
+++ b/devtools/client/webconsole/test/browser_webconsole_shows_reqs_in_netmonitor.js
@@ -45,17 +45,17 @@ add_task(function* () {
         category: CATEGORY_NETWORK,
         severity: SEVERITY_LOG
       }
     ]
   });
 });
 
 function loadDocument(browser) {
-  let deferred = promise.defer();
+  let deferred = defer();
 
   browser.addEventListener("load", function () {
     deferred.resolve();
   }, {capture: true, once: true});
   BrowserTestUtils.loadURI(gBrowser.selectedBrowser, TEST_PATH);
 
   return deferred.promise;
 }
--- a/devtools/client/webconsole/test/browser_webconsole_split.js
+++ b/devtools/client/webconsole/test/browser_webconsole_split.js
@@ -189,17 +189,17 @@ function test() {
     is(currentUIState.webconsoleHeight, 0,
        "Web console is collapsed after toggling");
     ok(!currentUIState.openedConsolePanel,
        "The console panel is not the current tool");
     ok(!currentUIState.buttonSelected, "The command button is not selected.");
   });
 
   function openPanel(toolId) {
-    let deferred = promise.defer();
+    let deferred = defer();
     let target = TargetFactory.forTab(gBrowser.selectedTab);
     gDevTools.showToolbox(target, toolId).then(function (box) {
       toolbox = box;
       deferred.resolve();
     }).catch(console.error);
     return deferred.promise;
   }
 
--- a/devtools/client/webconsole/test/browser_webconsole_split_escape_key.js
+++ b/devtools/client/webconsole/test/browser_webconsole_split_escape_key.js
@@ -73,17 +73,17 @@
         "Split console is open after hiding the variables view.");
      });
      EventUtils.sendKey("ESCAPE", toolbox.win);
 
      return result;
    }
 
    function testHideAutoCompletePopupAfterEscape() {
-     let deferred = promise.defer();
+     let deferred = defer();
      let popup = jsterm.autocompletePopup;
 
      popup.once("popup-closed", () => {
        ok(!popup.isOpen,
         "Auto complete popup is hidden.");
        ok(toolbox.splitConsole,
         "Split console is open after hiding the autocomplete popup.");
 
--- a/devtools/client/webconsole/test/head.js
+++ b/devtools/client/webconsole/test/head.js
@@ -182,17 +182,17 @@ function findLogEntry(str) {
  *        default tab is taken from the global variable |tab|.
  * @param function [callback]
  *        Optional function to invoke after the Web Console completes
  *        initialization (web-console-created).
  * @return object
  *         A promise that is resolved once the web console is open.
  */
 var openConsole = function (tab) {
-  let webconsoleOpened = promise.defer();
+  let webconsoleOpened = defer();
   let target = TargetFactory.forTab(tab || gBrowser.selectedTab);
   gDevTools.showToolbox(target, "webconsole").then(toolbox => {
     let hud = toolbox.getCurrentPanel().hud;
     hud.jsterm._lazyVariablesView = false;
     webconsoleOpened.resolve(hud);
   });
   return webconsoleOpened.promise;
 };
@@ -341,17 +341,17 @@ waitForExplicitFinish();
  *        Name of test. This is used to generate the success and failure
  *        messages.
  *        - timeout
  *        Timeout for validator function, in milliseconds. Default is 5000.
  * @return object
  *         A Promise object that is resolved based on the validator function.
  */
 function waitForSuccess(options) {
-  let deferred = promise.defer();
+  let deferred = defer();
   let start = Date.now();
   let timeout = options.timeout || 5000;
   let {validator} = options;
 
   function wait() {
     if ((Date.now() - start) > timeout) {
       // Log the failure.
       ok(false, "Timed out while waiting for: " + options.name);
@@ -447,17 +447,17 @@ function findVariableViewProperties(view
   }
 
   function processExpandRules(rules) {
     let rule = rules.shift();
     if (!rule) {
       return promise.resolve(null);
     }
 
-    let deferred = promise.defer();
+    let deferred = defer();
     let expandOptions = {
       rootVariable: view,
       expandTo: rule.name,
       webconsole: options.webconsole,
     };
 
     variablesViewExpandTo(expandOptions).then(function onSuccess(prop) {
       let name = rule.name;
@@ -589,17 +589,17 @@ function matchVariablesViewProperty(prop
  *         callback is given a boolean: true if the property is an iterator, or
  *         false otherwise.
  */
 function isVariableViewPropertyIterator(prop, webConsole) {
   if (prop.displayValue == "Iterator") {
     return promise.resolve(true);
   }
 
-  let deferred = promise.defer();
+  let deferred = defer();
 
   variablesViewExpandTo({
     rootVariable: prop,
     expandTo: "__proto__.__iterator__",
     webconsole: webConsole,
   }).then(function onSuccess() {
     deferred.resolve(true);
   }, function onFailure() {
@@ -625,25 +625,25 @@ function isVariableViewPropertyIterator(
  *         is found, and rejected otherwise. Resolution reason is always the
  *         last property - |nextSibling| in the example above. Rejection is
  *         always the last property that was found.
  */
 function variablesViewExpandTo(options) {
   let root = options.rootVariable;
   let expandTo = options.expandTo.split(".");
   let jsterm = (options.webconsole || {}).jsterm;
-  let lastDeferred = promise.defer();
+  let lastDeferred = defer();
 
   function fetch(prop) {
     if (!prop.onexpand) {
       ok(false, "property " + prop.name + " cannot be expanded: !onexpand");
       return promise.reject(prop);
     }
 
-    let deferred = promise.defer();
+    let deferred = defer();
 
     if (prop._fetched || !jsterm) {
       executeSoon(function () {
         deferred.resolve(prop);
       });
     } else {
       jsterm.once("variablesview-fetched", function _onFetchProp() {
         executeSoon(() => deferred.resolve(prop));
@@ -711,17 +711,17 @@ var updateVariablesViewProperty = Task.a
       break;
     case "value":
       EventUtils.synthesizeKey("VK_RETURN", {}, view.window);
       break;
     default:
       throw new Error("options.field is incorrect");
   }
 
-  let deferred = promise.defer();
+  let deferred = defer();
 
   executeSoon(() => {
     EventUtils.synthesizeKey("A", { accelKey: true }, view.window);
 
     for (let c of options.string) {
       EventUtils.synthesizeKey(c, {}, view.window);
     }
 
@@ -757,17 +757,17 @@ var updateVariablesViewProperty = Task.a
  *         - panel: the jsdebugger panel instance.
  *         - panelWin: the window object of the panel iframe.
  */
 function openDebugger(options = {}) {
   if (!options.tab) {
     options.tab = gBrowser.selectedTab;
   }
 
-  let deferred = promise.defer();
+  let deferred = defer();
 
   let target = TargetFactory.forTab(options.tab);
   let toolbox = gDevTools.getToolbox(target);
   let dbgPanelAlreadyOpen = toolbox && toolbox.getPanel("jsdebugger");
 
   gDevTools.showToolbox(target, "jsdebugger").then(function onSuccess(tool) {
     let panel = tool.getCurrentPanel();
     let panelWin = panel.panelWin;
@@ -887,17 +887,17 @@ function isDebuggerCaretPos(panel, line,
 function waitForMessages(options) {
   info("Waiting for messages...");
 
   gPendingOutputTest++;
   let webconsole = options.webconsole;
   let rules = WebConsoleUtils.cloneObject(options.messages, true);
   let rulesMatched = 0;
   let listenerAdded = false;
-  let deferred = promise.defer();
+  let deferred = defer();
   options.matchCondition = options.matchCondition || "all";
 
   function checkText(rule, text) {
     let result = false;
     if (Array.isArray(rule)) {
       result = rule.every((s) => checkText(s, text));
     } else if (typeof rule == "string") {
       result = text.indexOf(rule) > -1;
@@ -1490,22 +1490,22 @@ function checkOutputForInputs(hud, input
     if (entry.getClickableNode) {
       body = entry.getClickableNode(msg);
     } else {
       body = msg.querySelector(".message-body a") ||
              msg.querySelector(".message-body");
     }
     ok(body, "the message body");
 
-    let deferredVariablesView = promise.defer();
+    let deferredVariablesView = defer();
     entry._onVariablesViewOpen = onVariablesViewOpen.bind(null, entry,
                                                           deferredVariablesView);
     hud.jsterm.on("variablesview-open", entry._onVariablesViewOpen);
 
-    let deferredTab = promise.defer();
+    let deferredTab = defer();
     entry._onTabOpen = onTabOpen.bind(null, entry, deferredTab);
     container.addEventListener("TabOpen", entry._onTabOpen, true);
 
     body.scrollIntoView();
 
     if (!entry.suppressClick) {
       EventUtils.synthesizeMouse(body, 2, 2, {}, hud.iframeWindow);
     }
@@ -1711,17 +1711,17 @@ function waitForFinishedRequest(predicat
  * addEventListener/removeEventListener
  * @param {String} eventName
  * @param {Boolean} useCapture Optional for addEventListener/removeEventListener
  * @return A promise that resolves when the event has been handled
  */
 function once(target, eventName, useCapture = false) {
   info("Waiting for event: '" + eventName + "' on " + target + ".");
 
-  let deferred = promise.defer();
+  let deferred = defer();
 
   for (let [add, remove] of [
     ["addEventListener", "removeEventListener"],
     ["addListener", "removeListener"],
     ["on", "off"]
   ]) {
     if ((add in target) && (remove in target)) {
       target[add](eventName, function onEvent(...aArgs) {
@@ -1770,17 +1770,17 @@ function getSourceActor(sources, URL) {
   return item && item.value;
 }
 
 /**
  * Verify that clicking on a link from a popup notification message tries to
  * open the expected URL.
  */
 function simulateMessageLinkClick(element, expectedLink) {
-  let deferred = promise.defer();
+  let deferred = defer();
 
   // Invoke the click event and check if a new tab would
   // open to the correct page.
   let oldOpenUILinkIn = window.openUILinkIn;
   window.openUILinkIn = function (link) {
     if (link == expectedLink) {
       ok(true, "Clicking the message link opens the desired page");
       window.openUILinkIn = oldOpenUILinkIn;
--- a/devtools/client/webconsole/webconsole.js
+++ b/devtools/client/webconsole/webconsole.js
@@ -401,17 +401,17 @@ WebConsoleFrame.prototype = {
    *        The new value you want to set.
    */
   setSaveRequestAndResponseBodies: function (value) {
     if (!this.webConsoleClient) {
       // Don't continue if the webconsole disconnected.
       return promise.resolve(null);
     }
 
-    let deferred = promise.defer();
+    let deferred = defer();
     let newValue = !!value;
     let toSet = {
       "NetworkMonitor.saveRequestAndResponseBodies": newValue,
     };
 
     // Make sure the web console client connection is established first.
     this.webConsoleClient.setPreferences(toSet, response => {
       if (!response.error) {
@@ -432,17 +432,17 @@ WebConsoleFrame.prototype = {
    *        The new value you want to set; @see NetworkThrottleManager.
    */
   setThrottleData: function(value) {
     if (!this.webConsoleClient) {
       // Don't continue if the webconsole disconnected.
       return promise.resolve(null);
     }
 
-    let deferred = promise.defer();
+    let deferred = defer();
     let toSet = {
       "NetworkMonitor.throttleData": value,
     };
 
     // Make sure the web console client connection is established first.
     this.webConsoleClient.setPreferences(toSet, response => {
       if (!response.error) {
         this._throttleData = value;
@@ -501,17 +501,17 @@ WebConsoleFrame.prototype = {
    *         A promise object that is resolved/reject based on the connection
    *         result.
    */
   _initConnection: function () {
     if (this._initDefer) {
       return this._initDefer.promise;
     }
 
-    this._initDefer = promise.defer();
+    this._initDefer = defer();
     this.proxy = new WebConsoleConnectionProxy(this, this.owner.target);
 
     this.proxy.connect().then(() => {
       // on success
       this._initDefer.resolve(this);
     }, (reason) => {
       // on failure
       let node = this.createMessageNode(CATEGORY_JS, SEVERITY_ERROR,
@@ -2706,17 +2706,17 @@ WebConsoleFrame.prototype = {
    *         A promise that is resolved when the WebConsoleFrame instance is
    *         destroyed.
    */
   destroy: function () {
     if (this._destroyer) {
       return this._destroyer.promise;
     }
 
-    this._destroyer = promise.defer();
+    this._destroyer = defer();
 
     let toolbox = gDevTools.getToolbox(this.owner.target);
     if (toolbox) {
       toolbox.off("webconsole-selected", this._onPanelSelected);
     }
 
     this._prefObserver.off(PREF_MESSAGE_TIMESTAMP, this._onToolboxPrefChanged);
     this._prefObserver.destroy();
--- a/devtools/server/actors/canvas.js
+++ b/devtools/server/actors/canvas.js
@@ -199,17 +199,17 @@ exports.CanvasActor = protocol.ActorClas
     }
 
     this._recordingContainsDrawCall = false;
     this._callWatcher.eraseRecording();
     this._callWatcher.initTimestampEpoch();
     this._webGLPrimitiveCounter.resetCounts();
     this._callWatcher.resumeRecording();
 
-    let deferred = this._currentAnimationFrameSnapshot = promise.defer();
+    let deferred = this._currentAnimationFrameSnapshot = defer();
     return deferred.promise;
   },
 
   /**
    * Cease attempts to record an animation frame.
    */
   stopRecordingAnimationFrame: function () {
     if (!this._callWatcher.isRecording()) {
--- a/devtools/server/actors/device.js
+++ b/devtools/server/actors/device.js
@@ -17,17 +17,17 @@ const FileReader = require("FileReader")
 exports.DeviceActor = protocol.ActorClassWithSpec(deviceSpec, {
   _desc: null,
 
   getDescription: function () {
     return getSystemInfo();
   },
 
   getWallpaper: function () {
-    let deferred = promise.defer();
+    let deferred = defer();
     getSetting("wallpaper.image").then((blob) => {
       let reader = new FileReader();
       let conn = this.conn;
       reader.addEventListener("load", function () {
         let str = new LongStringActor(conn, reader.result);
         deferred.resolve(str);
       });
       reader.addEventListener("error", function () {
--- a/devtools/server/actors/inspector.js
+++ b/devtools/server/actors/inspector.js
@@ -2746,17 +2746,17 @@ exports.InspectorActor = protocol.ActorC
     return this.tabActor.window;
   },
 
   getWalker: function (options = {}) {
     if (this._walkerPromise) {
       return this._walkerPromise;
     }
 
-    let deferred = promise.defer();
+    let deferred = defer();
     this._walkerPromise = deferred.promise;
 
     let window = this.window;
     let domReady = () => {
       let tabActor = this.tabActor;
       window.removeEventListener("DOMContentLoaded", domReady, true);
       this.walker = WalkerActor(this.conn, tabActor, options);
       this.manage(this.walker);
--- a/devtools/server/actors/storage.js
+++ b/devtools/server/actors/storage.js
@@ -73,17 +73,17 @@ var storageTypePool = new Map();
 
 /**
  * An async method equivalent to setTimeout but using Promises
  *
  * @param {number} time
  *        The wait time in milliseconds.
  */
 function sleep(time) {
-  let deferred = promise.defer();
+  let deferred = defer();
 
   setTimeout(() => {
     deferred.resolve(null);
   }, time);
 
   return deferred.promise;
 }
 
@@ -1847,17 +1847,17 @@ StorageActors.createActor({
           let [action, host, path] = msg.json.args;
           this.onItemUpdated(action, host, path);
         }
       }
     });
 
     let unresolvedPromises = new Map();
     function callParentProcessAsync(methodName, ...args) {
-      let deferred = promise.defer();
+      let deferred = defer();
 
       unresolvedPromises.set(methodName, deferred);
 
       sendAsyncMessage("debug:storage-indexedDB-request-parent", {
         method: methodName,
         args: args
       });
 
@@ -1920,17 +1920,17 @@ var indexedDBHelpers = {
 
   /**
    * Fetches and stores all the metadata information for the given database
    * `name` for the given `host` with its `principal`. The stored metadata
    * information is of `DatabaseMetadata` type.
    */
   getDBMetaData: Task.async(function* (host, principal, name, storage) {
     let request = this.openWithPrincipal(principal, name, storage);
-    let success = promise.defer();
+    let success = defer();
 
     request.onsuccess = event => {
       let db = event.target.result;
       let dbData = new DatabaseMetadata(host, db, storage);
       db.close();
 
       success.resolve(this.backToChild("getDBMetaData", dbData));
     };
@@ -2282,17 +2282,17 @@ var indexedDBHelpers = {
    *                       iterated,
    *          offset:      offset of the entries to be fetched,
    *          size:        The intended size of the entries to be fetched
    *        }
    */
   getObjectStoreData(host, principal, dbName, storage, requestOptions) {
     let {name} = this.splitNameAndStorage(dbName);
     let request = this.openWithPrincipal(principal, name, storage);
-    let success = promise.defer();
+    let success = defer();
     let {objectStore, id, index, offset, size} = requestOptions;
     let data = [];
     let db;
 
     if (!size || size > MAX_STORE_OBJECT_COUNT) {
       size = MAX_STORE_OBJECT_COUNT;
     }
 
--- a/devtools/server/actors/stylesheets.js
+++ b/devtools/server/actors/stylesheets.js
@@ -315,17 +315,17 @@ var StyleSheetActor = protocol.ActorClas
     if (!this.ownerNode) {
       return promise.resolve([]);
     }
 
     if (this._cssRules) {
       return this._cssRules;
     }
 
-    let deferred = promise.defer();
+    let deferred = defer();
 
     let onSheetLoaded = (event) => {
       this.ownerNode.removeEventListener("load", onSheetLoaded);
 
       deferred.resolve(this.rawSheet.cssRules);
     };
 
     this.ownerNode.addEventListener("load", onSheetLoaded);
@@ -542,17 +542,17 @@ var StyleSheetActor = protocol.ActorClas
 
   /**
    * Fetch the source map for this stylesheet.
    *
    * @return {Promise}
    *         A promise that resolves with a SourceMapConsumer, or null.
    */
   _fetchSourceMap: function () {
-    let deferred = promise.defer();
+    let deferred = defer();
 
     this._getText().then(sheetContent => {
       let url = this._extractSourceMapUrl(sheetContent);
       if (!url) {
         // no source map for this stylesheet
         deferred.resolve(null);
         return;
       }
--- a/devtools/server/actors/webbrowser.js
+++ b/devtools/server/actors/webbrowser.js
@@ -738,17 +738,17 @@ BrowserTabActor.prototype = {
            this._browser.frameLoader.messageManager;
   },
 
   update() {
     // If the child happens to be crashed/close/detach, it won't have _form set,
     // so only request form update if some code is still listening on the other
     // side.
     if (!this.exited) {
-      this._deferredUpdate = promise.defer();
+      this._deferredUpdate = defer();
       let onFormUpdate = msg => {
         // There may be more than just one childtab.js up and running
         if (this._form.actor != msg.json.actor) {
           return;
         }
         this._mm.removeMessageListener("debug:form", onFormUpdate);
         this._form = msg.json;
         this._deferredUpdate.resolve(this);
@@ -825,17 +825,17 @@ exports.BrowserTabActor = BrowserTabActo
 
 function BrowserAddonList(connection) {
   this._connection = connection;
   this._actorByAddonId = new Map();
   this._onListChanged = null;
 }
 
 BrowserAddonList.prototype.getList = function () {
-  let deferred = promise.defer();
+  let deferred = defer();
   AddonManager.getAllAddons((addons) => {
     for (let addon of addons) {
       let actor = this._actorByAddonId.get(addon.id);
       if (!actor) {
         if (addon.isWebExtension) {
           actor = new WebExtensionParentActor(this._connection, addon);
         } else {
           actor = new BrowserAddonActor(this._connection, addon);
--- a/devtools/server/actors/webgl.js
+++ b/devtools/server/actors/webgl.js
@@ -254,17 +254,17 @@ exports.WebGLActor = protocol.ActorClass
     return this._programActorsCache.filter(e => e.ownerWindow == id);
   },
 
   /**
    * Waits for one frame via `requestAnimationFrame` on the tab actor's window.
    * Used in tests.
    */
   waitForFrame: function () {
-    let deferred = promise.defer();
+    let deferred = defer();
     this.tabActor.window.requestAnimationFrame(deferred.resolve);
     return deferred.promise;
   },
 
   /**
    * Gets a pixel's RGBA value from a context specified by selector
    * and the coordinates of the pixel in question.
    * Currently only used in tests.
--- a/devtools/server/main.js
+++ b/devtools/server/main.js
@@ -727,17 +727,17 @@ var DebuggerServer = {
     let transport = isWorker ?
                     new WorkerDebuggerTransport(scopeOrManager, prefix) :
                     new ChildDebuggerTransport(scopeOrManager, prefix);
 
     return this._onConnection(transport, prefix, true);
   },
 
   connectToContent(connection, mm, onDestroy) {
-    let deferred = SyncPromise.defer();
+    let deferred = Syncdefer();
 
     let prefix = connection.allocID("content-process");
     let actor, childTransport;
 
     mm.addMessageListener("debug:content-process-actor", function listener(msg) {
       // Arbitrarily choose the first content process to reply
       // XXX: This code needs to be updated if we use more than one content process
       mm.removeMessageListener("debug:content-process-actor", listener);
@@ -1017,17 +1017,17 @@ var DebuggerServer = {
    *        Optional function to invoke when the child process closes
    *        or the connection shuts down. (Need to forget about the
    *        related TabActor)
    * @return object
    *         A promise object that is resolved once the connection is
    *         established.
    */
   connectToChild(connection, frame, onDestroy, {addonId} = {}) {
-    let deferred = SyncPromise.defer();
+    let deferred = Syncdefer();
 
     // Get messageManager from XUL browser (which might be a specialized tunnel for RDM)
     // or else fallback to asking the frameLoader itself.
     let mm = frame.messageManager || frame.frameLoader.messageManager;
     mm.loadFrameScript("resource://devtools/server/child.js", false);
 
     let trackMessageManager = () => {
       frame.addEventListener("DevTools:BrowserSwap", onBrowserSwap);
--- a/devtools/server/tests/mochitest/inspector-helpers.js
+++ b/devtools/server/tests/mochitest/inspector-helpers.js
@@ -85,17 +85,17 @@ function attachURL(url, callback) {
       });
     }
   });
 
   return cleanup;
 }
 
 function promiseOnce(target, event) {
-  let deferred = promise.defer();
+  let deferred = defer();
   target.on(event, (...args) => {
     if (args.length === 1) {
       deferred.resolve(args[0]);
     } else {
       deferred.resolve(args);
     }
   });
   return deferred.promise;
@@ -169,38 +169,38 @@ function assertOwnershipTrees(walker) {
   is(JSON.stringify(clientTree, null, " "), JSON.stringify(serverTree, null, " "),
      "Server and client ownership trees should match.");
 
   return ownershipTreeSize(clientTree.root);
 }
 
 // Verify that an actorID is inaccessible both from the client library and the server.
 function checkMissing(client, actorID) {
-  let deferred = promise.defer();
+  let deferred = defer();
   let front = client.getActor(actorID);
   ok(!front, "Front shouldn't be accessible from the client for actorID: " + actorID);
 
-  deferred = promise.defer();
+  deferred = defer();
   client.request({
     to: actorID,
     type: "request",
   }, response => {
     is(response.error, "noSuchActor", "node list actor should no longer be contactable.");
     deferred.resolve(undefined);
   });
   return deferred.promise;
 }
 
 // Verify that an actorID is accessible both from the client library and the server.
 function checkAvailable(client, actorID) {
-  let deferred = promise.defer();
+  let deferred = defer();
   let front = client.getActor(actorID);
   ok(front, "Front should be accessible from the client for actorID: " + actorID);
 
-  deferred = promise.defer();
+  deferred = defer();
   client.request({
     to: actorID,
     type: "garbageAvailableTest",
   }, response => {
     is(response.error, "unrecognizedPacketType",
        "node list actor should be contactable.");
     deferred.resolve(undefined);
   });
@@ -273,17 +273,17 @@ function assertFrameLoad(mutations) {
 // that mutation out of the list
 function assertChildList(mutations) {
   return assertAndStrip(mutations, "Should have had a frame load change.", isChildList);
 }
 
 // Load mutations aren't predictable, so keep accumulating mutations until
 // the one we're looking for shows up.
 function waitForMutation(walker, test, mutations = []) {
-  let deferred = promise.defer();
+  let deferred = defer();
   for (let change of mutations) {
     if (test(change)) {
       deferred.resolve(mutations);
     }
   }
 
   walker.once("mutations", newMutations => {
     waitForMutation(walker, test, mutations.concat(newMutations)).then(finalMutations => {
--- a/devtools/server/tests/mochitest/test_inspector-dead-nodes.html
+++ b/devtools/server/tests/mochitest/test_inspector-dead-nodes.html
@@ -19,17 +19,17 @@ window.onload = function () {
 };
 
 let gWalker = null;
 let gDoc = null;
 
 addAsyncTest(function* () {
   let url = document.getElementById("inspectorContent").href;
 
-  let def = promise.defer();
+  let def = defer();
   attachURL(url, function (err, client, tab, doc) {
     def.resolve({client, tab, doc});
   });
   let {client, tab, doc} = yield def.promise;
   gDoc = doc;
 
   let {InspectorFront} = require("devtools/shared/fronts/inspector");
   let inspector = InspectorFront(client, tab);
--- a/devtools/server/tests/unit/head_dbg.js
+++ b/devtools/server/tests/unit/head_dbg.js
@@ -817,17 +817,17 @@ function getSourceContent(sourceClient) 
 /**
  * Get a source at the specified url.
  *
  * @param ThreadClient threadClient
  * @param string url
  * @returns Promise<SourceClient>
  */
 function getSource(threadClient, url) {
-  let deferred = promise.defer();
+  let deferred = defer();
   threadClient.getSources((res) => {
     let source = res.sources.filter(function (s) {
       return s.url === url;
     });
     if (source.length) {
       deferred.resolve(threadClient.source(source[0]));
     } else {
       deferred.reject(new Error("source not found"));
@@ -838,17 +838,17 @@ function getSource(threadClient, url) {
 
 /**
  * Do a fake reload which clears the thread debugger
  *
  * @param TabClient tabClient
  * @returns Promise<response>
  */
 function reload(tabClient) {
-  let deferred = promise.defer();
+  let deferred = defer();
   tabClient._reload({}, deferred.resolve);
   return deferred.promise;
 }
 
 /**
  * Returns an array of stack location strings given a thread and a sample.
  *
  * @param object thread
--- a/devtools/server/tests/unit/test_blackboxing-06.js
+++ b/devtools/server/tests/unit/test_blackboxing-06.js
@@ -65,17 +65,17 @@ function setup_code() {
 
   Components.utils.evalInSandbox(code,
                                  gDebuggee,
                                  "1.8",
                                  "http://example.com/abc.js");
 }
 
 function black_box_code() {
-  const d = promise.defer();
+  const d = defer();
 
   gThreadClient.getSources(function ({ sources, error }) {
     do_check_true(!error, "Shouldn't get an error getting sources");
     const source = sources.filter((s) => {
       return s.url.indexOf("b.js") !== -1;
     })[0];
     do_check_true(!!source, "We should have our source in the sources list");
 
@@ -84,17 +84,17 @@ function black_box_code() {
       d.resolve(true);
     });
   });
 
   return d.promise;
 }
 
 function run_code() {
-  const d = promise.defer();
+  const d = defer();
 
   gClient.addOneTimeListener("paused", function (event, packet) {
     d.resolve(packet);
     gThreadClient.resume();
   });
   gDebuggee.a();
 
   return d.promise;
--- a/devtools/server/tests/unit/test_client_request.js
+++ b/devtools/server/tests/unit/test_client_request.js
@@ -144,17 +144,17 @@ function test_close_client_while_sending
 
   // Pile up a second one that will be "pending".
   // i.e. won't event be sent.
   let pendingRequest = gClient.request({
     to: gActorId,
     type: "hello"
   });
 
-  let expectReply = promise.defer();
+  let expectReply = defer();
   gClient.expectReply("root", function (response) {
     do_check_eq(response.error, "connectionClosed");
     do_check_eq(response.message,
                 "server side packet can't be received as the connection just closed.");
     expectReply.resolve();
   });
 
   gClient.close().then(() => {
--- a/devtools/server/tests/unit/test_nesting-01.js
+++ b/devtools/server/tests/unit/test_nesting-01.js
@@ -25,17 +25,17 @@ function run_test() {
         test_nesting();
       });
   });
   do_test_pending();
 }
 
 function test_nesting() {
   const thread = gThreadActor;
-  const { resolve, promise: p } = promise.defer();
+  const { resolve, promise: p } = defer();
 
   let currentStep = 0;
 
   executeSoon(function () {
     // Should be on the first step
     do_check_eq(++currentStep, 1);
     // We should have one nested event loop from unsfeSynchronize
     do_check_eq(thread._nestedEventLoops.size, 1);
--- a/devtools/server/tests/unit/test_nesting-02.js
+++ b/devtools/server/tests/unit/test_nesting-02.js
@@ -26,17 +26,17 @@ function run_test() {
         test_nesting();
       });
   });
   do_test_pending();
 }
 
 function test_nesting() {
   const thread = gThreadActor;
-  const { resolve, promise: p } = promise.defer();
+  const { resolve, promise: p } = defer();
 
   // The following things should happen (in order):
   // 1. In the new event loop (created by unsafeSynchronize)
   // 2. Resolve the promise (shouldn't exit any event loops)
   // 3. Exit the event loop (should also then exit unsafeSynchronize's event loop)
   // 4. Be after the unsafeSynchronize call
   let currentStep = 0;
 
--- a/devtools/server/tests/unit/test_profiler_events-01.js
+++ b/devtools/server/tests/unit/test_profiler_events-01.js
@@ -52,12 +52,12 @@ add_task(function* () {
   do_check_true(events[3] === 2, "compatibility events supported for eventNotifications");
 
   ret = yield front.unregisterEventNotifications(
     { events: ["console-api-profiler", "profiler-started", "profiler-stopped"] });
   do_check_true(ret.registered.length === 3);
 });
 
 function getChromeActors() {
-  let deferred = promise.defer();
+  let deferred = defer();
   get_chrome_actors((client, form) => deferred.resolve([client, form]));
   return deferred.promise;
 }
--- a/devtools/server/tests/unit/test_profiler_events-02.js
+++ b/devtools/server/tests/unit/test_profiler_events-02.js
@@ -19,17 +19,17 @@ function run_test() {
 add_task(function* () {
   let [client, form] = yield getChromeActors();
   let front = new ProfilerFront(client, form);
 
   // Ensure the profiler is not running when the test starts (it could
   // happen if the MOZ_PROFILER_STARTUP environment variable is set).
   Profiler.StopProfiler();
   let eventsCalled = 0;
-  let handledThreeTimes = promise.defer();
+  let handledThreeTimes = defer();
 
   front.on("profiler-status", (response) => {
     dump("'profiler-status' fired\n");
     do_check_true(typeof response.position === "number");
     do_check_true(typeof response.totalSize === "number");
     do_check_true(typeof response.generation === "number");
     do_check_true(response.position > 0 && response.position < response.totalSize);
     do_check_true(response.totalSize === MAX_PROFILER_ENTRIES);
@@ -62,12 +62,12 @@ add_task(function* () {
 
   let totalEvents = eventsCalled;
   yield waitForTime(50);
   do_check_true(totalEvents === eventsCalled,
                 "No more profiler-status events after recording.");
 });
 
 function getChromeActors() {
-  let deferred = promise.defer();
+  let deferred = defer();
   get_chrome_actors((client, form) => deferred.resolve([client, form]));
   return deferred.promise;
 }
--- a/devtools/server/tests/unit/test_protocol_async.js
+++ b/devtools/server/tests/unit/test_protocol_async.js
@@ -52,17 +52,17 @@ var RootActor = protocol.ActorClassWithS
   sayHello: simpleHello,
 
   simpleReturn: function () {
     return this.sequence++;
   },
 
   promiseReturn: function (toWait) {
     // Guarantee that this resolves after simpleReturn returns.
-    let deferred = promise.defer();
+    let deferred = defer();
     let sequence = this.sequence++;
 
     // Wait until the number of requests specified by toWait have
     // happened, to test queuing.
     let check = () => {
       if ((this.sequence - sequence) < toWait) {
         do_execute_soon(check);
         return;
@@ -75,17 +75,17 @@ var RootActor = protocol.ActorClassWithS
   },
 
   simpleThrow: function () {
     throw new Error(this.sequence++);
   },
 
   promiseThrow: function () {
     // Guarantee that this resolves after simpleReturn returns.
-    let deferred = promise.defer();
+    let deferred = defer();
     let sequence = this.sequence++;
     // This should be enough to force a failure if the code is broken.
     do_timeout(150, () => {
       deferred.reject(sequence++);
     });
     return deferred.promise;
   }
 });
@@ -143,17 +143,17 @@ function run_test() {
     }, error => {
       // Check right return order
       do_check_eq(sequence++, 3);
     }));
 
     // While packets are sent in the correct order, rejection handlers
     // registered in "Promise.jsm" may be invoked later than fulfillment
     // handlers, meaning that we can't check the actual order with certainty.
-    let deferAfterRejection = promise.defer();
+    let deferAfterRejection = defer();
 
     calls.push(rootClient.promiseThrow().then(() => {
       do_check_true(false, "promiseThrow shouldn't succeed!");
     }, error => {
       // Check right return order
       do_check_eq(sequence++, 4);
       do_check_true(true, "simple throw should throw");
       deferAfterRejection.resolve();
--- a/devtools/server/tests/unit/test_protocol_longstring.js
+++ b/devtools/server/tests/unit/test_protocol_longstring.js
@@ -160,17 +160,17 @@ function run_test() {
       return strfront.release();
     }).then(() => {
       trace.expectSend({"type": "release", "to": "<actorid>"});
       trace.expectReceive({"from": "<actorid>"});
 
       // That reference should be removed now.
       expectRootChildren(0);
     }).then(() => {
-      let deferred = promise.defer();
+      let deferred = defer();
       rootClient.once("string-event", (str) => {
         trace.expectSend({"type": "emitShortString", "to": "<actorid>"});
         trace.expectReceive({"type": "string-event", "str": "abc", "from": "<actorid>"});
 
         do_check_true(!!str);
         strfront = str;
         // Shouldn't generate any new references
         expectRootChildren(0);
@@ -182,17 +182,17 @@ function run_test() {
       rootClient.emitShortString();
       return deferred.promise;
     }).then(value => {
       do_check_eq(value, SHORT_STR);
     }).then(() => {
       // Will generate no packets
       return strfront.release();
     }).then(() => {
-      let deferred = promise.defer();
+      let deferred = defer();
       rootClient.once("string-event", (str) => {
         trace.expectSend({"type": "emitLongString", "to": "<actorid>"});
         trace.expectReceive({"type": "string-event",
                              "str": {"type": "longString",
                                      "actor": "<actorid>",
                                      "length": 16,
                                      "initial": "abcde"},
                              "from": "<actorid>"});
--- a/devtools/server/tests/unit/test_protocol_simple.js
+++ b/devtools/server/tests/unit/test_protocol_simple.js
@@ -295,28 +295,28 @@ function run_test() {
     }).then(() => {
       return rootClient.renamedEcho("hello");
     }).then(str => {
       trace.expectSend({"type": "echo", "a": "hello", "to": "<actorid>"});
       trace.expectReceive({"value": "hello", "from": "<actorid>"});
 
       do_check_eq(str, "hello");
 
-      let deferred = promise.defer();
+      let deferred = defer();
       rootClient.on("oneway", (response) => {
         trace.expectSend({"type": "testOneWay", "a": "hello", "to": "<actorid>"});
         trace.expectReceive({"type": "oneway", "a": "hello", "from": "<actorid>"});
 
         do_check_eq(response, "hello");
         deferred.resolve();
       });
       do_check_true(typeof (rootClient.testOneWay("hello")) === "undefined");
       return deferred.promise;
     }).then(() => {
-      let deferred = promise.defer();
+      let deferred = defer();
       rootClient.on("falsyOptions", res => {
         trace.expectSend({"type": "emitFalsyOptions", "to": "<actorid>"});
         trace.expectReceive({"type": "falsyOptions",
                              "farce": false,
                              "zero": 0,
                              "from": "<actorid>"});
 
         do_check_true(res.zero === 0);
--- a/devtools/server/tests/unit/test_sourcemaps-10.js
+++ b/devtools/server/tests/unit/test_sourcemaps-10.js
@@ -56,17 +56,17 @@ function define_code() {
 
   code += "//# sourceMappingURL=data:text/json," + map.toString();
 
   Components.utils.evalInSandbox(code, gDebuggee, "1.8",
                                  "http://example.com/www/js/abc.js", 1);
 }
 
 function run_code() {
-  const d = promise.defer();
+  const d = defer();
   gClient.addOneTimeListener("paused", function (event, packet) {
     d.resolve(packet);
     gThreadClient.resume();
   });
   gDebuggee.a();
   return d.promise;
 }
 
--- a/devtools/server/tests/unit/test_sourcemaps-11.js
+++ b/devtools/server/tests/unit/test_sourcemaps-11.js
@@ -56,17 +56,17 @@ function define_code() {
 
   code += "//# sourceMappingURL=data:text/json," + map.toString();
 
   Components.utils.evalInSandbox(code, gDebuggee, "1.8",
                                  "http://example.com/www/js/abc.js", 1);
 }
 
 function run_code() {
-  const d = promise.defer();
+  const d = defer();
   gClient.addOneTimeListener("paused", function () {
     gThreadClient.getFrames(0, 3, function (response) {
       d.resolve(response);
       gThreadClient.resume();
     });
   });
   gDebuggee.a();
   return d.promise;
--- a/devtools/server/worker.js
+++ b/devtools/server/worker.js
@@ -16,17 +16,17 @@ this.rpc = function (method, ...params) 
 
   postMessage(JSON.stringify({
     type: "rpc",
     method: method,
     params: params,
     id: id
   }));
 
-  let deferred = Promise.defer();
+  let deferred = defer();
   rpcDeferreds[id] = deferred;
   return deferred.promise;
 };
 
 loadSubScript("resource://devtools/shared/worker/loader.js");
 
 var Promise = worker.require("promise");
 const defer = require("devtools/shared/defer");
--- a/devtools/shared/webconsole/test/unit/test_throttle.js
+++ b/devtools/shared/webconsole/test/unit/test_throttle.js
@@ -38,17 +38,17 @@ TestStreamListener.prototype = {
     if (this._deferred) {
       this._deferred.resolve(state);
       this._deferred = null;
     }
   },
 
   onStateChanged: function () {
     if (!this._deferred) {
-      this._deferred = promise.defer();
+      this._deferred = defer();
     }
     return this._deferred.promise;
   }
 };
 
 function TestChannel() {
   this.state = "initial";
   this.testListener = new TestStreamListener();