Bug 1378850 - Stop using sdk/core/heritage in DevTools webconsole hudservice; r=zer0 draft
authorJan Odvarko <odvarko@gmail.com>
Fri, 07 Jul 2017 13:37:56 +0200
changeset 605312 4198e912c9e875cceaddaf1cfd73077ad6838b3f
parent 605055 20f32734df750bddada9d1edca665c2ea53946f0
child 636454 2c53136cda7cc8cd8873fbc6e1d25f45db270bb9
push id67366
push userjodvarko@mozilla.com
push dateFri, 07 Jul 2017 11:38:28 +0000
reviewerszer0
bugs1378850
milestone56.0a1
Bug 1378850 - Stop using sdk/core/heritage in DevTools webconsole hudservice; r=zer0 MozReview-Commit-ID: z4vQV9g0uZ
devtools/client/webconsole/console-output.js
devtools/client/webconsole/hudservice.js
devtools/shared/DevToolsUtils.js
--- a/devtools/client/webconsole/console-output.js
+++ b/devtools/client/webconsole/console-output.js
@@ -19,25 +19,23 @@ loader.lazyRequireGetter(this, "ObjectCl
 const XHTML_NS = "http://www.w3.org/1999/xhtml";
 
 const WebConsoleUtils = require("devtools/client/webconsole/utils").Utils;
 const { getSourceNames } = require("devtools/client/shared/source-utils");
 const {Task} = require("devtools/shared/task");
 const l10n = require("devtools/client/webconsole/webconsole-l10n");
 const nodeConstants = require("devtools/shared/dom-node-constants");
 const {PluralForm} = require("devtools/shared/plural-form");
+const { extend } = require("devtools/shared/DevToolsUtils");
 
 const MAX_STRING_GRIP_LENGTH = 36;
 const {ELLIPSIS} = require("devtools/shared/l10n");
 
 const validProtocols = /^(http|https|ftp|data|javascript|resource|chrome):/i;
 
-const extend = (prototype, properties) =>
-  Object.create(prototype, Object.getOwnPropertyDescriptors(properties));
-
 // Constants for compatibility with the Web Console output implementation before
 // bug 778766.
 // TODO: remove these once bug 778766 is fixed.
 const COMPAT = {
   // The various categories of messages.
   CATEGORIES: {
     NETWORK: 0,
     CSS: 1,
--- a/devtools/client/webconsole/hudservice.js
+++ b/devtools/client/webconsole/hudservice.js
@@ -1,18 +1,16 @@
 /* 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 {Cc, Ci, Cu} = require("chrome");
-
 var WebConsoleUtils = require("devtools/client/webconsole/utils").Utils;
-var { extend } = require("sdk/core/heritage");
+const { extend } = require("devtools/shared/DevToolsUtils");
 var {TargetFactory} = require("devtools/client/framework/target");
 var {Tools} = require("devtools/client/definitions");
 const { Task } = require("devtools/shared/task");
 var promise = require("promise");
 var Services = require("Services");
 
 loader.lazyRequireGetter(this, "Telemetry", "devtools/client/shared/telemetry");
 loader.lazyRequireGetter(this, "WebConsoleFrame", "devtools/client/webconsole/webconsole", true);
--- a/devtools/shared/DevToolsUtils.js
+++ b/devtools/shared/DevToolsUtils.js
@@ -24,16 +24,26 @@ var DevToolsUtils = exports;
 
 // Re-export the thread-safe utils.
 const ThreadSafeDevToolsUtils = require("./ThreadSafeDevToolsUtils.js");
 for (let key of Object.keys(ThreadSafeDevToolsUtils)) {
   exports[key] = ThreadSafeDevToolsUtils[key];
 }
 
 /**
+ * Utility function, that is useful for creating objects that inherit from other
+ * objects, without associated classes.
+ *
+ * Replacement for `extends` API from "sdk/core/heritage".
+ */
+exports.extend = function (prototype, properties) {
+  return Object.create(prototype, Object.getOwnPropertyDescriptors(properties));
+};
+
+/**
  * Waits for the next tick in the event loop to execute a callback.
  */
 exports.executeSoon = function (fn) {
   if (isWorker) {
     setImmediate(fn);
   } else {
     let executor;
     // Only enable async stack reporting when DEBUG_JS_MODULES is set