Bug 1434374 - Always import deprecated-sync-promises as a module. r=jdescottes draft
authorAlexandre Poirot <poirot.alex@gmail.com>
Mon, 05 Feb 2018 08:11:30 -0800
changeset 752566 ff43eb99fe0f4f3a1c42f666fddcf842563b0d32
parent 752511 0ac953fcddf10132eaecdb753d72b2ba5a43c32a
child 752567 8bc49ece2e850ea89161e442f6df2078f78b322a
child 752583 e7efe383715b8574027fd4ae0e460a6083fbdfe4
push id98294
push userbmo:poirot.alex@gmail.com
push dateThu, 08 Feb 2018 14:27:38 +0000
reviewersjdescottes
bugs1434374
milestone60.0a1
Bug 1434374 - Always import deprecated-sync-promises as a module. r=jdescottes MozReview-Commit-ID: B97O55CxD8T
devtools/client/debugger/test/mochitest/head.js
devtools/shared/client/breakpoint-client.js
devtools/shared/client/debugger-client.js
devtools/shared/client/tab-client.js
devtools/shared/client/thread-client.js
devtools/shared/deprecated-sync-thenables.js
--- a/devtools/client/debugger/test/mochitest/head.js
+++ b/devtools/client/debugger/test/mochitest/head.js
@@ -20,17 +20,17 @@ var { DebuggerClient } = require("devtoo
 var ObjectClient = require("devtools/shared/client/object-client");
 var { AddonManager } = Cu.import("resource://gre/modules/AddonManager.jsm", {});
 var EventEmitter = require("devtools/shared/old-event-emitter");
 var { Toolbox } = require("devtools/client/framework/toolbox");
 
 const chromeRegistry = Cc["@mozilla.org/chrome/chrome-registry;1"].getService(Ci.nsIChromeRegistry);
 
 // Override promise with deprecated-sync-thenables
-promise = Cu.import("resource://devtools/shared/deprecated-sync-thenables.js", {}).Promise;
+promise = require("devtools/shared/deprecated-sync-thenables");
 
 const EXAMPLE_URL = "http://example.com/browser/devtools/client/debugger/test/mochitest/";
 const FRAME_SCRIPT_URL = getRootDirectory(gTestPath) + "code_frame-script.js";
 const CHROME_URL = "chrome://mochitests/content/browser/devtools/client/debugger/test/mochitest/";
 const CHROME_URI = Services.io.newURI(CHROME_URL);
 
 Services.prefs.setBoolPref("devtools.debugger.new-debugger-frontend", false);
 
--- a/devtools/shared/client/breakpoint-client.js
+++ b/devtools/shared/client/breakpoint-client.js
@@ -1,16 +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 { Cu } = require("chrome");
-const promise = Cu.import("resource://devtools/shared/deprecated-sync-thenables.js", {}).Promise;
+const promise = require("devtools/shared/deprecated-sync-thenables");
 
 const eventSource = require("devtools/shared/client/event-source");
 const {DebuggerClient} = require("devtools/shared/client/debugger-client");
 
 /**
  * Breakpoint clients are used to remove breakpoints that are no longer used.
  *
  * @param client DebuggerClient
--- a/devtools/shared/client/debugger-client.js
+++ b/devtools/shared/client/debugger-client.js
@@ -1,17 +1,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/. */
 
 "use strict";
 
 const { Cu } = require("chrome");
 const Services = require("Services");
-const promise = Cu.import("resource://devtools/shared/deprecated-sync-thenables.js", {}).Promise;
+const promise = require("devtools/shared/deprecated-sync-thenables");
 
 const DevToolsUtils = require("devtools/shared/DevToolsUtils");
 const { getStack, callFunctionWithAsyncStack } = require("devtools/shared/platform/stack");
 const eventSource = require("devtools/shared/client/event-source");
 const {
   ThreadStateTypes,
   UnsolicitedNotifications,
   UnsolicitedPauses,
--- a/devtools/shared/client/tab-client.js
+++ b/devtools/shared/client/tab-client.js
@@ -1,16 +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 { Cu } = require("chrome");
-const promise = Cu.import("resource://devtools/shared/deprecated-sync-thenables.js", {}).Promise;
+const promise = require("devtools/shared/deprecated-sync-thenables");
 
 const DevToolsUtils = require("devtools/shared/DevToolsUtils");
 const eventSource = require("devtools/shared/client/event-source");
 const {arg, DebuggerClient} = require("devtools/shared/client/debugger-client");
 loader.lazyRequireGetter(this, "ThreadClient", "devtools/shared/client/thread-client");
 
 const noop = () => {};
 
--- a/devtools/shared/client/thread-client.js
+++ b/devtools/shared/client/thread-client.js
@@ -1,16 +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 { Cu } = require("chrome");
-const promise = Cu.import("resource://devtools/shared/deprecated-sync-thenables.js", {}).Promise;
+const promise = require("devtools/shared/deprecated-sync-thenables");
 
 const DevToolsUtils = require("devtools/shared/DevToolsUtils");
 const {arg, DebuggerClient} = require("devtools/shared/client/debugger-client");
 const eventSource = require("devtools/shared/client/event-source");
 const {ThreadStateTypes} = require("devtools/shared/client/constants");
 
 loader.lazyRequireGetter(this, "ArrayBufferClient", "devtools/shared/client/array-buffer-client");
 loader.lazyRequireGetter(this, "EnvironmentClient", "devtools/shared/client/environment-client");
--- a/devtools/shared/deprecated-sync-thenables.js
+++ b/devtools/shared/deprecated-sync-thenables.js
@@ -1,27 +1,23 @@
 /* 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/. */
 
 /**
- * THIS MODULE IS DEPRECATED. IMPORT "Promise.jsm" INSTEAD.
+ * THIS MODULE IS DEPRECATED. Use DOM Promises instead.
  */
 
 /* eslint-disable */
 
 "use strict";
 
 this.Promise = {};
 
-if (typeof (require) === "function") {
-  module.exports = Promise;
-} else {
-  this.EXPORTED_SYMBOLS = ["Promise"];
-}
+module.exports = Promise;
 
 function fulfilled(value) {
   return { then: function then(fulfill) { fulfill(value); } };
 }
 
 function rejected(reason) {
   return { then: function then(fulfill, reject) { reject(reason); } };
 }