Bug 940542 - Use Promise.jsm instead of deprecated-sync-thenables in Inspector. r=pbrosset
authorSami Jaktholm <sjakthol@outlook.com>
Tue, 16 Dec 2014 10:06:00 -0500
changeset 220241 38b13fa63bcd682eb462e1444b1b70ed97ea39c2
parent 220240 14e17056fc813fb70ab14434592a83802d164aa2
child 220242 7ad4cbf2129993f94f293eb653fb212f7df03d95
push id10460
push userryanvm@gmail.com
push dateThu, 18 Dec 2014 03:17:45 +0000
treeherderfx-team@c2af7ad0a783 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspbrosset
bugs940542
milestone37.0a1
Bug 940542 - Use Promise.jsm instead of deprecated-sync-thenables in Inspector. r=pbrosset
browser/devtools/inspector/breadcrumbs.js
browser/devtools/inspector/inspector-panel.js
browser/devtools/inspector/selector-search.js
--- a/browser/devtools/inspector/breadcrumbs.js
+++ b/browser/devtools/inspector/breadcrumbs.js
@@ -11,17 +11,17 @@ const ENSURE_SELECTION_VISIBLE_DELAY = 5
 
 Cu.import("resource://gre/modules/XPCOMUtils.jsm");
 Cu.import("resource:///modules/devtools/DOMHelpers.jsm");
 Cu.import("resource://gre/modules/Services.jsm");
 Cu.import("resource:///modules/devtools/ViewHelpers.jsm");
 const ELLIPSIS = Services.prefs.getComplexValue("intl.ellipsis", Ci.nsIPrefLocalizedString).data;
 const MAX_LABEL_LENGTH = 40;
 
-let promise = require("devtools/toolkit/deprecated-sync-thenables");
+let promise = require("resource://gre/modules/Promise.jsm").Promise;
 
 const LOW_PRIORITY_ELEMENTS = {
   "HEAD": true,
   "BASE": true,
   "BASEFONT": true,
   "ISINDEX": true,
   "LINK": true,
   "META": true,
@@ -133,23 +133,24 @@ HTMLBreadcrumbs.prototype = {
       if (selection != this.selection.nodeFront) {
         return promise.reject("selection-changed");
       }
       return result;
     }
   },
 
   /**
-   * Print any errors (except selection guard errors).
+   * Warn if rejection was caused by selection change, print an error otherwise.
    */
   selectionGuardEnd: function(err) {
-    if (err != "selection-changed") {
+    if (err === "selection-changed") {
+      console.warn("Asynchronous operation was aborted as selection changed.");
+    } else {
       console.error(err);
     }
-    promise.reject(err);
   },
 
   /**
    * Build a string that represents the node: tagName#id.class1.class2.
    *
    * @param aNode The node to pretty-print
    * @returns a string
    */
--- a/browser/devtools/inspector/inspector-panel.js
+++ b/browser/devtools/inspector/inspector-panel.js
@@ -3,17 +3,17 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 const {Cc, Ci, Cu, Cr} = require("chrome");
 
 Cu.import("resource://gre/modules/Services.jsm");
 
-let promise = require("devtools/toolkit/deprecated-sync-thenables");
+let promise = require("resource://gre/modules/Promise.jsm").Promise;
 let EventEmitter = require("devtools/toolkit/event-emitter");
 let clipboard = require("sdk/clipboard");
 
 loader.lazyGetter(this, "MarkupView", () => require("devtools/markupview/markup-view").MarkupView);
 loader.lazyGetter(this, "HTMLBreadcrumbs", () => require("devtools/inspector/breadcrumbs").HTMLBreadcrumbs);
 loader.lazyGetter(this, "ToolSidebar", () => require("devtools/framework/sidebar").ToolSidebar);
 loader.lazyGetter(this, "SelectorSearch", () => require("devtools/inspector/selector-search").SelectorSearch);
 
--- a/browser/devtools/inspector/selector-search.js
+++ b/browser/devtools/inspector/selector-search.js
@@ -1,15 +1,15 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 "use strict";
 
-const promise = require("devtools/toolkit/deprecated-sync-thenables");
+const promise = require("resource://gre/modules/Promise.jsm").Promise;
 loader.lazyGetter(this, "EventEmitter", () => require("devtools/toolkit/event-emitter"));
 loader.lazyGetter(this, "AutocompletePopup", () => require("devtools/shared/autocomplete-popup").AutocompletePopup);
 
 // Maximum number of selector suggestions shown in the panel.
 const MAX_SUGGESTIONS = 15;
 
 /**
  * Converts any input box on a page to a CSS selector search and suggestion box.