Bug 1273941 - replace uses of promise.defer in devtools/client/inspector; r=jryans
authorTom Tromey <tom@tromey.com>
Thu, 09 Jun 2016 09:05:41 -0600
changeset 302460 be8fdffc3665b30242dbe639818f19ed320455ad
parent 302459 65a02c905ec6c6265944085e4dcf72b8184ba029
child 302461 3489bbcc48864251f7242fb92f41af1edb031ffa
push id19745
push usercbook@mozilla.com
push dateFri, 24 Jun 2016 07:04:33 +0000
treeherderfx-team@ed1226de3214 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjryans
bugs1273941
milestone50.0a1
Bug 1273941 - replace uses of promise.defer in devtools/client/inspector; r=jryans MozReview-Commit-ID: CBKDIFYL9Ij
devtools/client/inspector/computed/computed.js
devtools/client/inspector/computed/test/browser_computed_keybindings_01.js
devtools/client/inspector/inspector-panel.js
devtools/client/inspector/markup/markup.js
devtools/client/inspector/markup/test/browser_markup_copy_image_data.js
devtools/client/inspector/markup/test/browser_markup_events_form.js
devtools/client/inspector/markup/test/browser_markup_links_05.js
devtools/client/inspector/markup/test/browser_markup_links_07.js
devtools/client/inspector/markup/test/browser_markup_load_01.js
devtools/client/inspector/markup/test/browser_markup_mutation_01.js
devtools/client/inspector/markup/test/browser_markup_node_not_displayed_02.js
devtools/client/inspector/markup/test/head.js
devtools/client/inspector/rules/rules.js
devtools/client/inspector/rules/test/browser_rules_context-menu-show-mdn-docs-03.js
devtools/client/inspector/rules/test/browser_rules_eyedropper.js
devtools/client/inspector/rules/test/browser_rules_original-source-link.js
devtools/client/inspector/rules/test/browser_rules_user-agent-styles.js
devtools/client/inspector/rules/test/doc_frame_script.js
devtools/client/inspector/rules/test/head.js
devtools/client/inspector/shared/test/doc_frame_script.js
devtools/client/inspector/shared/test/head.js
devtools/client/inspector/test/browser_inspector_highlighter-hover_01.js
devtools/client/inspector/test/browser_inspector_menu-06-other.js
devtools/client/inspector/test/head.js
--- a/devtools/client/inspector/computed/computed.js
+++ b/devtools/client/inspector/computed/computed.js
@@ -9,16 +9,17 @@
 "use strict";
 
 const {Cc, Ci} = require("chrome");
 
 const ToolDefinitions = require("devtools/client/definitions").Tools;
 const {CssLogic} = require("devtools/shared/inspector/css-logic");
 const {ELEMENT_STYLE} = require("devtools/shared/specs/styles");
 const promise = require("promise");
+const defer = require("devtools/shared/defer");
 const Services = require("Services");
 const {OutputParser} = require("devtools/client/shared/output-parser");
 const {PrefObserver, PREF_ORIG_SOURCES} = require("devtools/client/styleeditor/utils");
 const {createChild} = require("devtools/client/inspector/shared/utils");
 const {gDevTools} = require("devtools/client/framework/devtools");
 const {XPCOMUtils} = require("resource://gre/modules/XPCOMUtils.jsm");
 const {getCssProperties} = require("devtools/shared/fronts/css-properties");
 
@@ -390,17 +391,17 @@ CssComputedView.prototype = {
     return {type, value};
   },
 
   _createPropertyViews: function () {
     if (this._createViewsPromise) {
       return this._createViewsPromise;
     }
 
-    let deferred = promise.defer();
+    let deferred = defer();
     this._createViewsPromise = deferred.promise;
 
     this.refreshSourceFilter();
     this.numVisibleProperties = 0;
     let fragment = this.styleDocument.createDocumentFragment();
 
     this._createViewsProcess = new UpdateProcess(
       this.styleWindow, CssComputedView.propertyNames, {
@@ -470,17 +471,17 @@ CssComputedView.prototype = {
       this.noResults.hidden = true;
 
       // Reset visible property count
       this.numVisibleProperties = 0;
 
       // Reset zebra striping.
       this._darkStripe = true;
 
-      let deferred = promise.defer();
+      let deferred = defer();
       this._refreshProcess = new UpdateProcess(
         this.styleWindow, this.propertyViews, {
           onItem: (propView) => {
             propView.refresh();
           },
           onDone: () => {
             this._refreshProcess = null;
             this.noResults.hidden = this.numVisibleProperties > 0;
@@ -1337,17 +1338,17 @@ SelectorView.prototype = {
       let oldSource = this.source;
       this.source = CssLogic.l10n("rule.sourceElement");
       return promise.resolve(oldSource);
     }
 
     let showOrig = Services.prefs.getBoolPref(PREF_ORIG_SOURCES);
 
     if (showOrig && rule.type !== ELEMENT_STYLE) {
-      let deferred = promise.defer();
+      let deferred = defer();
 
       // set as this first so we show something while we're fetching
       this.source = CssLogic.shortSource(this.sheet) + ":" + rule.line;
 
       rule.getOriginalLocation().then(({href, line}) => {
         let oldSource = this.source;
         this.source = CssLogic.shortSource({href: href}) + ":" + line;
         deferred.resolve(oldSource);
--- a/devtools/client/inspector/computed/test/browser_computed_keybindings_01.js
+++ b/devtools/client/inspector/computed/test/browser_computed_keybindings_01.js
@@ -64,17 +64,17 @@ function* checkToggleKeyBinding(win, key
   info("Collapsing the property");
   EventUtils.synthesizeKey(key, {}, win);
   yield onCollapse;
   is(rulesTable.innerHTML, "", "The property has been collapsed");
 }
 
 function checkHelpLinkKeybinding(view) {
   info("Check that MDN link is opened on \"F1\"");
-  let def = promise.defer();
+  let def = defer();
 
   let propView = getFirstVisiblePropertyView(view);
   propView.mdnLinkClick = function () {
     ok(true, "Pressing F1 opened the MDN link");
     def.resolve();
   };
 
   EventUtils.synthesizeKey("VK_F1", {}, view.styleWindow);
--- a/devtools/client/inspector/inspector-panel.js
+++ b/devtools/client/inspector/inspector-panel.js
@@ -7,16 +7,17 @@
 /* eslint max-len: [2, 100, 2, {ignoreUrls: true, "ignorePattern": "\\s*require\\s*\\(|^\\s*loader\\.lazy|-\\*-"}] */ // eslint-disable-line
 
 "use strict";
 
 const {Cc, Ci} = require("chrome");
 
 var Services = require("Services");
 var promise = require("promise");
+var defer = require("devtools/shared/defer");
 var EventEmitter = require("devtools/shared/event-emitter");
 var clipboard = require("sdk/clipboard");
 const {executeSoon} = require("devtools/shared/DevToolsUtils");
 var {KeyShortcuts} = require("devtools/client/shared/key-shortcuts");
 var {Task} = require("devtools/shared/task");
 const {initCssProperties} = require("devtools/shared/fronts/css-properties");
 const nodeConstants = require("devtools/shared/dom-node-constants");
 
@@ -182,17 +183,17 @@ InspectorPanel.prototype = {
       }).catch(e => console.error(e)),
       this._target.actorHasMethod("inspector", "resolveRelativeURL").then(value => {
         this._supportsResolveRelativeURL = value;
       }).catch(e => console.error(e)),
     ]);
   },
 
   _deferredOpen: function (defaultSelection) {
-    let deferred = promise.defer();
+    let deferred = defer();
 
     this.walker.on("new-root", this.onNewRoot);
 
     this.selection.on("new-node-front", this.onNewSelection);
     this.selection.on("before-new-node-front", this.onBeforeNewSelection);
     this.selection.on("detached-front", this.onDetached);
 
     this.breadcrumbs = new HTMLBreadcrumbs(this);
--- a/devtools/client/inspector/markup/markup.js
+++ b/devtools/client/inspector/markup/markup.js
@@ -29,16 +29,17 @@ const HTML_VOID_ELEMENTS = [ "area", "ba
   "hr", "img", "input", "keygen", "link", "meta", "param", "source",
   "track", "wbr" ];
 
 const {UndoStack} = require("devtools/client/shared/undo");
 const {editableField, InplaceEditor} =
       require("devtools/client/shared/inplace-editor");
 const {HTMLEditor} = require("devtools/client/inspector/markup/html-editor");
 const promise = require("promise");
+const defer = require("devtools/shared/defer");
 const Services = require("Services");
 const {HTMLTooltip} = require("devtools/client/shared/widgets/HTMLTooltip");
 const {setImageTooltip, setBrokenImageTooltip} =
       require("devtools/client/shared/widgets/tooltip/ImageTooltipHelper");
 const {setEventTooltip} = require("devtools/client/shared/widgets/tooltip/EventTooltipHelper");
 const EventEmitter = require("devtools/shared/event-emitter");
 const Heritage = require("sdk/core/heritage");
 const {parseAttribute} =
@@ -420,17 +421,17 @@ MarkupView.prototype = {
       this._briefBoxModelPromise = null;
       this._briefBoxModelTimer = null;
     }
   },
 
   _brieflyShowBoxModel: function (nodeFront) {
     this._clearBriefBoxModelTimer();
     let onShown = this._showBoxModel(nodeFront);
-    this._briefBoxModelPromise = promise.defer();
+    this._briefBoxModelPromise = defer();
 
     this._briefBoxModelTimer = setTimeout(() => {
       this._hideBoxModel()
           .then(this._briefBoxModelPromise.resolve,
                 this._briefBoxModelPromise.resolve);
     }, NEW_SELECTION_HIGHLIGHTER_TIMER);
 
     return promise.all([onShown, this._briefBoxModelPromise.promise]);
@@ -1324,17 +1325,17 @@ MarkupView.prototype = {
    * @return {Promise} that will resolve when the inner HTML has been updated.
    */
   updateNodeInnerHTML: function (node, newValue, oldValue) {
     let container = this.getContainer(node);
     if (!container) {
       return promise.reject();
     }
 
-    let def = promise.defer();
+    let def = defer();
 
     container.undo.do(() => {
       this.walker.setInnerHTML(node, newValue).then(def.resolve, def.reject);
     }, () => {
       this.walker.setInnerHTML(node, oldValue);
     });
 
     return def.promise;
@@ -1354,17 +1355,17 @@ MarkupView.prototype = {
    *         been inserted.
    */
   insertAdjacentHTMLToNode: function (node, position, value) {
     let container = this.getContainer(node);
     if (!container) {
       return promise.reject();
     }
 
-    let def = promise.defer();
+    let def = defer();
 
     let injectedNodes = [];
     container.undo.do(() => {
       this.walker.insertAdjacentHTML(node, position, value).then(nodeArray => {
         injectedNodes = nodeArray.nodes;
         return nodeArray;
       }).then(def.resolve, def.reject);
     }, () => {
--- a/devtools/client/inspector/markup/test/browser_markup_copy_image_data.js
+++ b/devtools/client/inspector/markup/test/browser_markup_copy_image_data.js
@@ -43,17 +43,17 @@ function* assertCopyImageDataAvailable(i
   let allMenuItems = openContextMenuAndGetAllItems(inspector);
   let item = allMenuItems.find(i => i.id === "node-menu-copyimagedatauri");
 
   ok(item, "The menu item was found in the contextual menu");
   ok(!item.disabled, "The menu item is enabled");
 }
 
 function triggerCopyImageUrlAndWaitForClipboard(expected, inspector) {
-  let def = promise.defer();
+  let def = defer();
 
   SimpleTest.waitForClipboard(expected, () => {
     inspector.markup.getContainer(inspector.selection.nodeFront)
                     .copyImageDataUri();
   }, () => {
     ok(true, "The clipboard contains the expected value " +
              expected.substring(0, 50) + "...");
     def.resolve();
--- a/devtools/client/inspector/markup/test/browser_markup_events_form.js
+++ b/devtools/client/inspector/markup/test/browser_markup_events_form.js
@@ -31,17 +31,17 @@ add_task(function* () {
   let value = nodeFront.getFormProperty("test-property");
   is(value, "test-value", "There must be custom property");
 
   info("Unregistering actor");
   yield unregisterActor(registrar, front);
 });
 
 function registerTestActor(toolbox) {
-  let deferred = promise.defer();
+  let deferred = defer();
 
   let options = {
     prefix: "eventsFormActor",
     actorClass: "EventsFormActor",
     moduleUrl: TEST_ACTOR_URL,
   };
 
   // Register as a tab actor
--- a/devtools/client/inspector/markup/test/browser_markup_links_05.js
+++ b/devtools/client/inspector/markup/test/browser_markup_links_05.js
@@ -64,17 +64,17 @@ add_task(function* () {
   yield onFailed;
 
   ok(true, "The node selection failed");
   is(inspector.selection.nodeFront.tagName.toLowerCase(), "output",
     "The <output> node is still selected");
 });
 
 function waitForTabLoad(tab) {
-  let def = promise.defer();
+  let def = defer();
   tab.addEventListener("load", function onLoad(e) {
     // Skip load event for about:blank
     if (tab.linkedBrowser.currentURI.spec === "about:blank") {
       return;
     }
     tab.removeEventListener("load", onLoad);
     def.resolve();
   });
--- a/devtools/client/inspector/markup/test/browser_markup_links_07.js
+++ b/devtools/client/inspector/markup/test/browser_markup_links_07.js
@@ -54,17 +54,17 @@ add_task(function* () {
   info("Try to follow link wiith middle-click, check no new node selected");
   yield followLinkNoNewNode(linkEl, false, inspector);
 
   info("Try to follow link wiith meta/ctrl-click, check no new node selected");
   yield followLinkNoNewNode(linkEl, true, inspector);
 });
 
 function waitForTabLoad(tab) {
-  let def = promise.defer();
+  let def = defer();
   tab.addEventListener("load", function onLoad() {
     // Skip load event for about:blank
     if (tab.linkedBrowser.currentURI.spec === "about:blank") {
       return;
     }
     tab.removeEventListener("load", onLoad);
     def.resolve();
   });
--- a/devtools/client/inspector/markup/test/browser_markup_load_01.js
+++ b/devtools/client/inspector/markup/test/browser_markup_load_01.js
@@ -57,15 +57,15 @@ function* chooseWithInspectElementContex
     type: "contextmenu",
     button: 2
   }, gBrowser.selectedBrowser);
 
   yield testActor.synthesizeKey({key: "Q", options: {}});
 }
 
 function waitForLinkedBrowserEvent(tab, event) {
-  let def = promise.defer();
+  let def = defer();
   tab.linkedBrowser.addEventListener(event, function cb() {
     tab.linkedBrowser.removeEventListener(event, cb, true);
     def.resolve();
   }, true);
   return def.promise;
 }
--- a/devtools/client/inspector/markup/test/browser_markup_mutation_01.js
+++ b/devtools/client/inspector/markup/test/browser_markup_mutation_01.js
@@ -276,17 +276,17 @@ add_task(function* () {
     info("Starting test: " + desc);
 
     numMutations = numMutations || 1;
 
     info("Executing the test markup mutation");
 
     // If a test expects more than one mutation it may come through in a single
     // event or possibly in multiples.
-    let def = promise.defer();
+    let def = defer();
     let seenMutations = 0;
     inspector.on("markupmutation", function onmutation(e, mutations) {
       seenMutations += mutations.length;
       info("Receieved " + seenMutations +
            " mutations, expecting at least " + numMutations);
       if (seenMutations >= numMutations) {
         inspector.off("markupmutation", onmutation);
         def.resolve();
--- a/devtools/client/inspector/markup/test/browser_markup_node_not_displayed_02.js
+++ b/devtools/client/inspector/markup/test/browser_markup_node_not_displayed_02.js
@@ -121,17 +121,17 @@ function* runTestData(inspector, testAct
                       {selector, before, changeStyle, after}) {
   info("Getting the " + selector + " test node");
   let nodeFront = yield getNodeFront(selector, inspector);
   let container = getContainerForNodeFront(nodeFront, inspector);
   is(!container.elt.classList.contains("not-displayed"), before,
     "The container is marked as " + (before ? "shown" : "hidden"));
 
   info("Listening for the display-change event");
-  let onDisplayChanged = promise.defer();
+  let onDisplayChanged = defer();
   inspector.markup.walker.once("display-change", onDisplayChanged.resolve);
 
   info("Making style changes");
   yield changeStyle(testActor);
   let nodes = yield onDisplayChanged.promise;
 
   info("Verifying that the list of changed nodes include our container");
 
--- a/devtools/client/inspector/markup/test/head.js
+++ b/devtools/client/inspector/markup/test/head.js
@@ -108,17 +108,17 @@ function* getFirstChildNodeValue(selecto
  * children updates to be handled.
  * @param {InspectorPanel} inspector The instance of InspectorPanel currently
  * loaded in the toolbox
  * @return a promise that resolves when all queued children updates have been
  * handled
  */
 function waitForChildrenUpdated({markup}) {
   info("Waiting for queued children updates to be handled");
-  let def = promise.defer();
+  let def = defer();
   markup._waitForChildren().then(() => {
     executeSoon(def.resolve);
   });
   return def.promise;
 }
 
 /**
  * Simulate a click on the markup-container (a line in the markup-view)
@@ -273,17 +273,17 @@ function searchUsingSelectorSearch(selec
 
 /**
  * This shouldn't be used in the tests, but is useful when writing new tests or
  * debugging existing tests in order to introduce delays in the test steps
  * @param {Number} ms The time to wait
  * @return A promise that resolves when the time is passed
  */
 function wait(ms) {
-  let def = promise.defer();
+  let def = defer();
   setTimeout(def.resolve, ms);
   return def.promise;
 }
 
 /**
  * Check to see if the inspector menu items for editing are disabled.
  * Things like Edit As HTML, Delete Node, etc.
  * @param {NodeFront} nodeFront
@@ -347,17 +347,17 @@ function* (nodeFront, inspector, assert 
          !pasteHTMLMenuItem.disabled;
 });
 
 /**
  * Wait for all current promises to be resolved. See this as executeSoon that
  * can be used with yield.
  */
 function promiseNextTick() {
-  let deferred = promise.defer();
+  let deferred = defer();
   executeSoon(deferred.resolve);
   return deferred.promise;
 }
 
 /**
  * Collapses the current text selection in an input field and tabs to the next
  * field.
  */
@@ -443,17 +443,17 @@ function* waitForMultipleChildrenUpdates
  *
  * @returns {HttpServer}
  */
 function createTestHTTPServer() {
   const {HttpServer} = Cu.import("resource://testing-common/httpd.js", {});
   let server = new HttpServer();
 
   registerCleanupFunction(function* cleanup() {
-    let destroyed = promise.defer();
+    let destroyed = defer();
     server.stop(() => {
       destroyed.resolve();
     });
     yield destroyed.promise;
   });
 
   server.start(-1);
   return server;
--- a/devtools/client/inspector/rules/rules.js
+++ b/devtools/client/inspector/rules/rules.js
@@ -4,16 +4,17 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 /* globals gDevTools */
 
 "use strict";
 
 const {Cc, Ci} = require("chrome");
 const promise = require("promise");
+const defer = require("devtools/shared/defer");
 const Services = require("Services");
 const {XPCOMUtils} = require("resource://gre/modules/XPCOMUtils.jsm");
 const {Task} = require("devtools/shared/task");
 const {Tools} = require("devtools/client/definitions");
 const {CssLogic} = require("devtools/shared/inspector/css-logic");
 const {ELEMENT_STYLE} = require("devtools/shared/specs/styles");
 const {OutputParser} = require("devtools/client/shared/output-parser");
 const {PrefObserver, PREF_ORIG_SOURCES} = require("devtools/client/styleeditor/utils");
@@ -120,17 +121,17 @@ function createDummyDocument() {
   let ssm = Services.scriptSecurityManager;
 
   // We probably need to call InheritFromDocShellToDoc to get the correct origin
   // attributes, but right now we can't call it from JS.
   let nullPrincipal = ssm.createNullPrincipal(docShell.getOriginAttributes());
   docShell.createAboutBlankContentViewer(nullPrincipal);
   let window = docShell.contentViewer.DOMDocument.defaultView;
   window.location = "data:text/html,<html></html>";
-  let deferred = promise.defer();
+  let deferred = defer();
   eventTarget.addEventListener("DOMContentLoaded", function handler() {
     eventTarget.removeEventListener("DOMContentLoaded", handler, false);
     deferred.resolve(window.document);
     frame.remove();
   }, false);
   gDummyPromise = deferred.promise;
   return gDummyPromise;
 }
--- a/devtools/client/inspector/rules/test/browser_rules_context-menu-show-mdn-docs-03.js
+++ b/devtools/client/inspector/rules/test/browser_rules_context-menu-show-mdn-docs-03.js
@@ -72,17 +72,17 @@ add_task(function* () {
  * @param state {boolean} Desired value of the pref.
  *
  * Note that if the pref already has the value in `state`,
  * then the prefObserver will not trigger. So you should only
  * call this function if you know the pref's current value is
  * not `state`.
  */
 function* setBooleanPref(pref, state) {
-  let oncePrefChanged = promise.defer();
+  let oncePrefChanged = defer();
   let prefObserver = new PrefObserver("devtools.");
   prefObserver.on(pref, oncePrefChanged.resolve);
 
   info("Set the pref " + pref + " to: " + state);
   Services.prefs.setBoolPref(pref, state);
 
   info("Wait for prefObserver to call back so the UI can update");
   yield oncePrefChanged.promise;
--- a/devtools/client/inspector/rules/test/browser_rules_eyedropper.js
+++ b/devtools/client/inspector/rules/test/browser_rules_eyedropper.js
@@ -71,17 +71,17 @@ add_task(function* () {
   ok(dropper, "dropper opened");
 
   yield testSelect(view, swatch, dropper);
 
   checkTelemetry();
 });
 
 function testESC(swatch, dropper) {
-  let deferred = promise.defer();
+  let deferred = defer();
 
   dropper.once("destroy", () => {
     let color = swatch.style.backgroundColor;
     is(color, ORIGINAL_COLOR, "swatch didn't change after pressing ESC");
 
     deferred.resolve();
   });
 
@@ -124,17 +124,17 @@ function checkTelemetry() {
     is(snapshot.sum, expected,
       "eyedropper telemetry value correct for " + histogramId);
   }
 }
 
 /* Helpers */
 
 function openEyedropper(view, swatch) {
-  let deferred = promise.defer();
+  let deferred = defer();
 
   let tooltip = view.tooltips.colorPicker.tooltip;
 
   tooltip.once("shown", () => {
     let tooltipDoc = tooltip.content.contentDocument;
     let dropperButton = tooltipDoc.querySelector("#eyedropper-button");
 
     tooltip.once("eyedropper-opened", (event, dropper) => {
--- a/devtools/client/inspector/rules/test/browser_rules_original-source-link.js
+++ b/devtools/client/inspector/rules/test/browser_rules_original-source-link.js
@@ -45,17 +45,17 @@ function* testClickingLink(toolbox, view
   info("Finding the stylesheet link and clicking it");
   let link = getRuleViewLinkByIndex(view, 1);
   link.scrollIntoView();
   link.click();
   yield onStyleEditorReady;
 }
 
 function checkDisplayedStylesheet(toolbox) {
-  let def = promise.defer();
+  let def = defer();
 
   let panel = toolbox.getCurrentPanel();
   panel.UI.on("editor-selected", (event, editor) => {
     // The style editor selects the first sheet at first load before
     // selecting the desired sheet.
     if (editor.styleSheet.href.endsWith("scss")) {
       info("Original source editor selected");
       editor.getSourceEditor().then(editorSelected)
--- a/devtools/client/inspector/rules/test/browser_rules_user-agent-styles.js
+++ b/devtools/client/inspector/rules/test/browser_rules_user-agent-styles.js
@@ -81,17 +81,17 @@ add_task(function* () {
   Services.prefs.clearUserPref(PREF_UA_STYLES);
 });
 
 function* setUserAgentStylesPref(val) {
   info("Setting the pref " + PREF_UA_STYLES + " to: " + val);
 
   // Reset the pref and wait for PrefObserver to callback so UI
   // has a chance to get updated.
-  let oncePrefChanged = promise.defer();
+  let oncePrefChanged = defer();
   let prefObserver = new PrefObserver("devtools.");
   prefObserver.on(PREF_UA_STYLES, oncePrefChanged.resolve);
   Services.prefs.setBoolPref(PREF_UA_STYLES, val);
   yield oncePrefChanged.promise;
   prefObserver.off(PREF_UA_STYLES, oncePrefChanged.resolve);
 }
 
 function* userAgentStylesVisible(inspector, view) {
--- a/devtools/client/inspector/rules/test/doc_frame_script.js
+++ b/devtools/client/inspector/rules/test/doc_frame_script.js
@@ -15,17 +15,17 @@
 // The response message should have the same name "Test:msgName"
 //
 // Some listeners do not send a response message back.
 
 var {classes: Cc, interfaces: Ci, utils: Cu} = Components;
 
 var {require} = Cu.import("resource://devtools/shared/Loader.jsm", {});
 var {CssLogic} = require("devtools/shared/inspector/css-logic");
-var promise = require("promise");
+var defer = require("devtools/shared/defer");
 
 /**
  * Get a value for a given property name in a css rule in a stylesheet, given
  * their indexes
  * @param {Object} data Expects a data object with the following properties
  * - {Number} styleSheetIndex
  * - {Number} ruleIndex
  * - {String} name
@@ -120,17 +120,17 @@ var dumpn = msg => dump(msg + "\n");
  *
  * @param {Function} validatorFn A validator function that returns a boolean.
  * This is called every few milliseconds to check if the result is true. When
  * it is true, the promise resolves.
  * @return a promise that resolves when the function returned true or rejects
  * if the timeout is reached
  */
 function waitForSuccess(validatorFn) {
-  let def = promise.defer();
+  let def = defer();
 
   function wait(fn) {
     if (fn()) {
       def.resolve();
     } else {
       setTimeout(() => wait(fn), 200);
     }
   }
--- a/devtools/client/inspector/rules/test/head.js
+++ b/devtools/client/inspector/rules/test/head.js
@@ -50,17 +50,17 @@ addTab = function (url) {
  * @return {Promise} A promise that resolves to the response data when the
  * message has been received
  */
 function waitForContentMessage(name) {
   info("Expecting message " + name + " from content");
 
   let mm = gBrowser.selectedBrowser.messageManager;
 
-  let def = promise.defer();
+  let def = defer();
   mm.addMessageListener(name, function onMessage(msg) {
     mm.removeMessageListener(name, onMessage);
     def.resolve(msg.data);
   });
   return def.promise;
 }
 
 /**
--- a/devtools/client/inspector/shared/test/doc_frame_script.js
+++ b/devtools/client/inspector/shared/test/doc_frame_script.js
@@ -15,17 +15,17 @@
 // The response message should have the same name "Test:MsgName"
 //
 // Some listeners do not send a response message back.
 
 var {classes: Cc, interfaces: Ci, utils: Cu} = Components;
 
 var {require} = Cu.import("resource://devtools/shared/Loader.jsm", {});
 var {CssLogic} = require("devtools/shared/inspector/css-logic");
-var promise = require("promise");
+var defer = require("devtools/shared/defer");
 
 /**
  * Get a value for a given property name in a css rule in a stylesheet, given
  * their indexes
  * @param {Object} data Expects a data object with the following properties
  * - {Number} styleSheetIndex
  * - {Number} ruleIndex
  * - {String} name
@@ -123,17 +123,17 @@ var dumpn = msg => dump(msg + "\n");
  * This is called every few milliseconds to check if the result is true. When
  * it is true, the promise resolves.
  * @param {String} name Optional name of the test. This is used to generate
  * the success and failure messages.
  * @return a promise that resolves when the function returned true or rejects
  * if the timeout is reached
  */
 function waitForSuccess(validatorFn, name = "untitled") {
-  let def = promise.defer();
+  let def = defer();
 
   function wait(fn) {
     if (fn()) {
       def.resolve();
     } else {
       setTimeout(() => wait(fn), 200);
     }
   }
--- a/devtools/client/inspector/shared/test/head.js
+++ b/devtools/client/inspector/shared/test/head.js
@@ -96,17 +96,17 @@ addTab = function (url) {
  * @return {Promise} A promise that resolves to the response data when the
  * message has been received
  */
 function waitForContentMessage(name) {
   info("Expecting message " + name + " from content");
 
   let mm = gBrowser.selectedBrowser.messageManager;
 
-  let def = promise.defer();
+  let def = defer();
   mm.addMessageListener(name, function onMessage(msg) {
     mm.removeMessageListener(name, onMessage);
     def.resolve(msg.data);
   });
   return def.promise;
 }
 
 /**
@@ -209,17 +209,17 @@ var focusEditableField = Task.async(func
  *        When it is true, the promise resolves.
  * @param {String} name
  *        Optional name of the test. This is used to generate
  *        the success and failure messages.
  * @return a promise that resolves when the function returned true or rejects
  * if the timeout is reached
  */
 function waitForSuccess(validatorFn, name = "untitled") {
-  let def = promise.defer();
+  let def = defer();
 
   function wait(validator) {
     if (validator()) {
       ok(true, "Validator function " + name + " returned true");
       def.resolve();
     } else {
       setTimeout(() => wait(validator), 200);
     }
--- a/devtools/client/inspector/test/browser_inspector_highlighter-hover_01.js
+++ b/devtools/client/inspector/test/browser_inspector_highlighter-hover_01.js
@@ -28,14 +28,14 @@ add_task(function* () {
   yield waitForTheBrieflyShowBoxModelTimeout();
 
   yield testActor.setProperty("p", "textContent", "dary!!!!");
   isVisible = yield testActor.isHighlighting();
   ok(isVisible, "the highlighter is still visible");
 });
 
 function waitForTheBrieflyShowBoxModelTimeout() {
-  let deferred = promise.defer();
+  let deferred = defer();
   // Note that the current timeout is 1 sec and is neither configurable nor
   // exported anywhere we can access, so hard-coding the timeout
   setTimeout(deferred.resolve, 1500);
   return deferred.promise;
 }
--- a/devtools/client/inspector/test/browser_inspector_menu-06-other.js
+++ b/devtools/client/inspector/test/browser_inspector_menu-06-other.js
@@ -75,17 +75,17 @@ add_task(function* () {
   function* testDeleteRootNode() {
     info("Testing 'Delete Node' menu item does not delete root node.");
     yield selectNode("html", inspector);
 
     let allMenuItems = openContextMenuAndGetAllItems(inspector);
     let deleteNode = allMenuItems.find(item => item.id === "node-menu-delete");
     deleteNode.click();
 
-    let deferred = promise.defer();
+    let deferred = defer();
     executeSoon(deferred.resolve);
     yield deferred.promise;
 
     ok((yield testActor.eval("!!content.document.documentElement")),
        "Document element still alive.");
   }
 
   function* testScrollIntoView() {
--- a/devtools/client/inspector/test/head.js
+++ b/devtools/client/inspector/test/head.js
@@ -449,17 +449,17 @@ var clickContainer = Task.async(function
 /**
  * Simulate the mouse leaving the markup-view area
  * @param {InspectorPanel} inspector The instance of InspectorPanel currently
  * loaded in the toolbox
  * @return a promise when done
  */
 function mouseLeaveMarkupView(inspector) {
   info("Leaving the markup-view area");
-  let def = promise.defer();
+  let def = defer();
 
   // Find another element to mouseover over in order to leave the markup-view
   let btn = inspector.toolbox.doc.querySelector("#toolbox-controls");
 
   EventUtils.synthesizeMouseAtCenter(btn, {type: "mousemove"},
     inspector.toolbox.win);
   executeSoon(def.resolve);
 
@@ -650,17 +650,17 @@ function* waitForMultipleChildrenUpdates
  * children updates to be handled.
  * @param {InspectorPanel} inspector The instance of InspectorPanel currently
  * loaded in the toolbox
  * @return a promise that resolves when all queued children updates have been
  * handled
  */
 function waitForChildrenUpdated({markup}) {
   info("Waiting for queued children updates to be handled");
-  let def = promise.defer();
+  let def = defer();
   markup._waitForChildren().then(() => {
     executeSoon(def.resolve);
   });
   return def.promise;
 }
 
 /**
  * Wait for the toolbox to emit the styleeditor-selected event and when done
@@ -669,17 +669,17 @@ function waitForChildrenUpdated({markup}
  *
  * @param {Toolbox} toolbox
  * @param {String} href
  *        Optional, if not provided, wait for the first editor to be ready
  * @return a promise that resolves to the editor when the stylesheet editor is
  * ready
  */
 function waitForStyleEditor(toolbox, href) {
-  let def = promise.defer();
+  let def = defer();
 
   info("Waiting for the toolbox to switch to the styleeditor");
   toolbox.once("styleeditor-selected").then(() => {
     let panel = toolbox.getCurrentPanel();
     ok(panel && panel.UI, "Styleeditor panel switched to front");
 
     // A helper that resolves the promise once it receives an editor that
     // matches the expected href. Returns false if the editor was not correct.
@@ -720,17 +720,17 @@ function waitForStyleEditor(toolbox, hre
  *        Function to execute before checking for the
  *        clipboard content
  * @param {String|Function} expected
  *        An expected string or validator function
  * @return a promise that resolves when the expected string has been found or
  * the validator function has returned true, rejects otherwise.
  */
 function waitForClipboard(setup, expected) {
-  let def = promise.defer();
+  let def = defer();
   SimpleTest.waitForClipboard(expected, setup, def.resolve, def.reject);
   return def.promise;
 }
 
 /**
  * Checks if document's active element is within the given element.
  * @param  {HTMLDocument}  doc document with active element in question
  * @param  {DOMNode}       container element tested on focus containment