Commit 20e77a0e authored by michaelshum321's avatar michaelshum321
Browse files

Bug 1787997 - Refactor remote UUID Usage to a Shared UUID Module r=jdescottes,webdriver-reviewers

parent f80234e7
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -5,6 +5,7 @@
const lazy = {};

ChromeUtils.defineESModuleGetters(lazy, {
  generateUUID: "chrome://remote/content/shared/UUID.sys.mjs",
  UnsupportedError: "chrome://remote/content/cdp/Error.sys.mjs",
});

@@ -95,7 +96,7 @@ export class StreamRegistry {
      throw new lazy.UnsupportedError(`Unknown stream type for ${stream}`);
    }

    const handle = Services.uuid.generateUUID().toString().slice(1, -1);
    const handle = lazy.generateUUID();

    this.streams.set(handle, stream);
    return handle;
+7 −1
Original line number Diff line number Diff line
@@ -4,6 +4,12 @@

import { ContentProcessDomain } from "chrome://remote/content/cdp/domains/ContentProcessDomain.sys.mjs";

const lazy = {};

ChromeUtils.defineESModuleGetters(lazy, {
  generateUUID: "chrome://remote/content/shared/UUID.sys.mjs",
});

const { LOAD_FLAGS_BYPASS_CACHE, LOAD_FLAGS_BYPASS_PROXY, LOAD_FLAGS_NONE } =
  Ci.nsIWebNavigation;

@@ -170,7 +176,7 @@ export class Page extends ContentProcessDomain {
    if (worldName) {
      this.worldsToEvaluateOnLoad.add(worldName);
    }
    const identifier = Services.uuid.generateUUID().toString().slice(1, -1);
    const identifier = lazy.generateUUID();
    this.scriptsToEvaluateOnLoad.set(identifier, { worldName, source });

    return { identifier };
+7 −5
Original line number Diff line number Diff line
@@ -2,6 +2,12 @@
 * 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/. */

const lazy = {};

ChromeUtils.defineESModuleGetters(lazy, {
  generateUUID: "chrome://remote/content/shared/UUID.sys.mjs",
});

const TYPED_ARRAY_CLASSES = [
  "Uint8Array",
  "Uint8ClampedArray",
@@ -18,10 +24,6 @@ const TYPED_ARRAY_CLASSES = [
const ERROR_CYCLIC_REFERENCE = "Object reference chain is too long";
const ERROR_CANNOT_RETURN_BY_VALUE = "Object couldn't be returned by value";

function uuid() {
  return Services.uuid.generateUUID().toString().slice(1, -1);
}

function randomInt() {
  return crypto.getRandomValues(new Uint32Array(1))[0];
}
@@ -92,7 +94,7 @@ export class ExecutionContext {
   * can be represented via multiple references.
   */
  setRemoteObject(debuggerObj) {
    const objectId = uuid();
    const objectId = lazy.generateUUID();

    // TODO: Wrap Symbol into an object,
    // which would allow us to set the objectId.
+2 −2
Original line number Diff line number Diff line
@@ -11,6 +11,7 @@ ChromeUtils.defineESModuleGetters(lazy, {

  DialogHandler:
    "chrome://remote/content/cdp/domains/parent/page/DialogHandler.sys.mjs",
  generateUUID: "chrome://remote/content/shared/UUID.sys.mjs",
  PollPromise: "chrome://remote/content/shared/Sync.sys.mjs",
  print: "chrome://remote/content/shared/PDF.sys.mjs",
  streamRegistry: "chrome://remote/content/cdp/domains/parent/IO.sys.mjs",
@@ -100,8 +101,7 @@ export class Page extends Domain {
    let networkLessLoaderId;
    if (!hitsNetwork) {
      // This navigation will not hit the network, use a randomly generated id.
      const uuid = Services.uuid.generateUUID().toString();
      networkLessLoaderId = uuid.substring(1, uuid.length - 1);
      networkLessLoaderId = lazy.generateUUID();

      // Update the content process map of loader ids.
      await this.executeInChild("_updateLoaderId", {
+3 −1
Original line number Diff line number Diff line
@@ -9,6 +9,8 @@ const lazy = {};
ChromeUtils.defineESModuleGetters(lazy, {
  ContextualIdentityService:
    "resource://gre/modules/ContextualIdentityService.sys.mjs",

  generateUUID: "chrome://remote/content/shared/UUID.sys.mjs",
  TabManager: "chrome://remote/content/shared/TabManager.sys.mjs",
  TabSession: "chrome://remote/content/cdp/sessions/TabSession.sys.mjs",
  windowManager: "chrome://remote/content/shared/WindowManager.sys.mjs",
@@ -185,7 +187,7 @@ export class Target extends Domain {
    const tabSession = new lazy.TabSession(
      this.session.connection,
      target,
      Services.uuid.generateUUID().toString().slice(1, -1)
      lazy.generateUUID()
    );
    this.session.connection.registerSession(tabSession);

Loading