Bug 958167 - Use Inspector DevToolsUtils.makeInfallible in inspector actor instead of its own version. r=fitzgen draft
authorNicolas Chevobbe <chevobbe.nicolas@gmail.com>
Sun, 08 May 2016 10:51:14 +0200
changeset 364676 81102232bc9f94bc7e084695a98b78c8f5453e73
parent 364531 98730e9d1455e5819b67a7bdfcd0bc976e509ff1
child 520361 2246c3254e4369d68769fc879904b8e7edca3b0b
push id17537
push userchevobbe.nicolas@gmail.com
push dateSun, 08 May 2016 08:55:56 +0000
reviewersfitzgen
bugs958167
milestone49.0a1
Bug 958167 - Use Inspector DevToolsUtils.makeInfallible in inspector actor instead of its own version. r=fitzgen MozReview-Commit-ID: 4U7DCDFhQ6Y
devtools/server/actors/inspector.js
--- a/devtools/server/actors/inspector.js
+++ b/devtools/server/actors/inspector.js
@@ -75,16 +75,17 @@ const {
   getFrameElement
 } = require("devtools/shared/layout/utils");
 const {getLayoutChangesObserver, releaseLayoutChangesObserver} =
   require("devtools/server/actors/layout");
 
 loader.lazyRequireGetter(this, "CSS", "CSS");
 
 const {EventParsers} = require("devtools/shared/event-parsers");
+const { makeInfallible } = require("devtools/shared/DevToolsUtils");
 
 const FONT_FAMILY_PREVIEW_TEXT = "The quick brown fox jumps over the lazy dog";
 const FONT_FAMILY_PREVIEW_TEXT_SIZE = 20;
 const PSEUDO_CLASSES = [":hover", ":active", ":focus"];
 const HIDDEN_CLASS = "__fx-devtools-hide-shortcut__";
 const XHTML_NS = "http://www.w3.org/1999/xhtml";
 const XUL_NS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
 const IMAGE_FETCHING_TIMEOUT = 500;
@@ -146,29 +147,16 @@ loader.lazyGetter(this, "DOMParser", fun
 
 loader.lazyGetter(this, "eventListenerService", function () {
   return Cc["@mozilla.org/eventlistenerservice;1"]
            .getService(Ci.nsIEventListenerService);
 });
 
 loader.lazyGetter(this, "CssLogic", () => require("devtools/shared/inspector/css-logic").CssLogic);
 
-// XXX: A poor man's makeInfallible until we move it out of transport.js
-// Which should be very soon.
-function makeInfallible(handler) {
-  return function (...args) {
-    try {
-      return handler.apply(this, args);
-    } catch(ex) {
-      console.error(ex);
-    }
-    return undefined;
-  };
-}
-
 // A resolve that hits the main loop first.
 function delayedResolve(value) {
   let deferred = promise.defer();
   Services.tm.mainThread.dispatch(makeInfallible(() => {
     deferred.resolve(value);
   }), 0);
   return deferred.promise;
 }