mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 806591 - Add CommonUtils.generateUUID utility function; r=rnewman
This commit is contained in:
parent
d041d8d828
commit
3a8504a280
12
services/common/tests/unit/test_utils_uuid.js
Normal file
12
services/common/tests/unit/test_utils_uuid.js
Normal file
@ -0,0 +1,12 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
"use strict";
|
||||
|
||||
function run_test() {
|
||||
let uuid = CommonUtils.generateUUID();
|
||||
do_check_eq(uuid.length, 36);
|
||||
do_check_eq(uuid[8], "-");
|
||||
|
||||
run_next_test();
|
||||
}
|
@ -15,6 +15,7 @@ tail =
|
||||
[test_utils_namedTimer.js]
|
||||
[test_utils_stackTrace.js]
|
||||
[test_utils_utf8.js]
|
||||
[test_utils_uuid.js]
|
||||
|
||||
[test_aitc_server.js]
|
||||
[test_async_chain.js]
|
||||
|
@ -467,6 +467,22 @@ this.CommonUtils = {
|
||||
|
||||
return new BinaryInputStream(stream).readBytes(count);
|
||||
},
|
||||
|
||||
/**
|
||||
* Generate a new UUID using nsIUUIDGenerator.
|
||||
*
|
||||
* Example value: "1e00a2e2-1570-443e-bf5e-000354124234"
|
||||
*
|
||||
* @return string A hex-formatted UUID string.
|
||||
*/
|
||||
generateUUID: function generateUUID() {
|
||||
let uuid = Cc["@mozilla.org/uuid-generator;1"]
|
||||
.getService(Ci.nsIUUIDGenerator)
|
||||
.generateUUID()
|
||||
.toString();
|
||||
|
||||
return uuid.substring(1, uuid.length - 1);
|
||||
},
|
||||
};
|
||||
|
||||
XPCOMUtils.defineLazyGetter(CommonUtils, "_utf8Converter", function() {
|
||||
|
Loading…
Reference in New Issue
Block a user