Bug 1378824 - Stop using sdk/util/uuid in DevTools. r=jdescottes
MozReview-Commit-ID: KdIK4Vlrp4s
--- a/devtools/client/inspector/webpack.config.js
+++ b/devtools/client/inspector/webpack.config.js
@@ -100,17 +100,17 @@ module.exports = envConfig => {
path.join(__dirname, "./webpack/devtools-utils-sham.js"),
"devtools/shared/locales": path.join(__dirname, "../../shared/locales/en-US"),
"devtools/shared/platform": path.join(__dirname, "../../shared/platform/content"),
"devtools": path.join(__dirname, "../../"),
"gcli": path.join(__dirname, "../../shared/gcli/source/lib/gcli"),
"method": path.join(__dirname, "../../../addon-sdk/source/lib/method"),
"modules/libpref/init/all":
path.join(__dirname, "../../../modules/libpref/init/all.js"),
- "sdk/util/uuid":
+ "devtools/shared/generate-uuid":
path.join(__dirname, "./webpack/uuid-sham.js"),
"sdk": path.join(__dirname, "../../../addon-sdk/source/lib/sdk"),
"Services": path.join(__dirname, "../shared/shim/Services.js"),
"toolkit/locales":
path.join(__dirname, "../../../toolkit/locales/en-US/chrome/global"),
},
},
--- a/devtools/client/inspector/webpack/uuid-sham.js
+++ b/devtools/client/inspector/webpack/uuid-sham.js
@@ -5,15 +5,15 @@
"use strict";
const s4 = function () {
return Math.floor((1 + Math.random()) * 0x10000)
.toString(16)
.substring(1);
};
-let uuid = function () {
+let generateUUID = function () {
return "ss-s-s-s-sss".replace(/s/g, function () {
return s4();
});
};
-module.exports = { uuid };
+module.exports = { generateUUID };
--- a/devtools/client/shared/redux/middleware/promise.js
+++ b/devtools/client/shared/redux/middleware/promise.js
@@ -1,28 +1,28 @@
/* 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 uuidgen = require("sdk/util/uuid").uuid;
+const { generateUUID } = require("devtools/shared/generate-uuid");
const defer = require("devtools/shared/defer");
const {
entries, toObject, executeSoon
} = require("devtools/shared/DevToolsUtils");
const PROMISE = exports.PROMISE = "@@dispatch/promise";
function promiseMiddleware({ dispatch, getState }) {
return next => action => {
if (!(PROMISE in action)) {
return next(action);
}
const promiseInst = action[PROMISE];
- const seqId = uuidgen().toString();
+ const seqId = generateUUID().toString();
// Create a new action that doesn't have the promise field and has
// the `seqId` field that represents the sequence id
action = Object.assign(
toObject(entries(action).filter(pair => pair[0] !== PROMISE)), { seqId }
);
dispatch(Object.assign({}, action, { status: "start" }));
new file mode 100644
--- /dev/null
+++ b/devtools/shared/generate-uuid.js
@@ -0,0 +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 } = require("chrome");
+const { generateUUID } =
+ Cc["@mozilla.org/uuid-generator;1"].getService(Ci.nsIUUIDGenerator);
+
+/**
+ * Returns a new `uuid`.
+ *
+ */
+
+module.exports = { generateUUID };
--- a/devtools/shared/moz.build
+++ b/devtools/shared/moz.build
@@ -50,16 +50,17 @@ DevToolsModules(
'defer.js',
'deprecated-sync-thenables.js',
'DevToolsUtils.js',
'dom-node-constants.js',
'dom-node-filter-constants.js',
'event-emitter.js',
'extend.js',
'flags.js',
+ 'generate-uuid.js',
'indentation.js',
'l10n.js',
'loader-plugin-raw.jsm',
'Loader.jsm',
'Parser.jsm',
'path.js',
'plural-form.js',
'protocol.js',