test_UUID.js (652B)
1 /* This Source Code Form is subject to the terms of the Mozilla Public 2 * License, v. 2.0. If a copy of the MPL was not distributed with this file, 3 * You can obtain one at http://mozilla.org/MPL/2.0/. */ 4 5 const { generateUUID } = ChromeUtils.importESModule( 6 "chrome://remote/content/shared/UUID.sys.mjs" 7 ); 8 9 add_task(function test_UUID_valid() { 10 const uuid = generateUUID(); 11 const regExp = new RegExp( 12 /^[a-f|0-9]{8}-[a-f|0-9]{4}-[a-f|0-9]{4}-[a-f|0-9]{4}-[a-f|0-9]{12}$/g 13 ); 14 ok(regExp.test(uuid)); 15 }); 16 17 add_task(function test_UUID_unique() { 18 const uuid1 = generateUUID(); 19 const uuid2 = generateUUID(); 20 notEqual(uuid1, uuid2); 21 });