Bug 1198797 - Centralise creation of UUIDs in Marionette; r=ato

--HG--
extra : commitid : Ea8vtP8SvRy
extra : rebase_source : e08e8708ea9f3f3de5bbee56ac7809efcf924e52
This commit is contained in:
Shaif Chowdhury 2016-01-14 14:25:46 +00:00
parent ef0b0e075e
commit c13a8ae6ec
2 changed files with 9 additions and 5 deletions

View File

@ -48,7 +48,6 @@ const CLICK_TO_START_PREF = "marionette.debugging.clicktostart";
const CONTENT_LISTENER_PREF = "marionette.contentListener";
const logger = Log.repository.getLogger("Marionette");
const uuidGen = Cc["@mozilla.org/uuid-generator;1"].getService(Ci.nsIUUIDGenerator);
const globalMessageManager = Cc["@mozilla.org/globalmessagemanager;1"]
.getService(Ci.nsIMessageBroadcaster);
@ -510,10 +509,9 @@ GeckoDriver.prototype.listeningPromise = function() {
/** Create a new session. */
GeckoDriver.prototype.newSession = function(cmd, resp) {
let uuid = uuidGen.generateUUID().toString();
this.sessionId = cmd.parameters.sessionId ||
cmd.parameters.session_id ||
uuid.substring(1, uuid.length - 1);
elements.generateUUID();
this.newSessionCommandId = cmd.id;
this.setSessionCapabilities(cmd.parameters.capabilities);

View File

@ -22,6 +22,7 @@ XPCOMUtils.defineLazyModuleGetter(this, 'clearInterval',
this.EXPORTED_SYMBOLS = [
"Accessibility",
"elements",
"ElementManager",
"CLASS_NAME",
"SELECTOR",
@ -280,8 +281,7 @@ ElementManager.prototype = {
delete this.seenItems[i];
}
}
let uuid = uuidGen.generateUUID().toString();
let id = uuid.substring(1, uuid.length - 1);
let id = elements.generateUUID();
this.seenItems[id] = Components.utils.getWeakReference(element);
return id;
},
@ -754,3 +754,9 @@ ElementManager.prototype = {
return elements;
},
}
this.elements = {};
elements.generateUUID = function() {
let uuid = uuidGen.generateUUID().toString();
return uuid.substring(1, uuid.length - 1);
};