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
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 import { Module } from "chrome://remote/content/shared/messagehandler/Module.sys.mjs";
9 ChromeUtils.defineESModuleGetters(lazy, {
10 deserialize: "chrome://remote/content/webdriver-bidi/RemoteValue.sys.mjs",
11 serialize: "chrome://remote/content/webdriver-bidi/RemoteValue.sys.mjs",
15 * Base class for all WindowGlobal BiDi MessageHandler modules.
17 export class WindowGlobalBiDiModule extends Module {
19 return this.#processActor.getNodeCache();
23 return ChromeUtils.domProcessChild.getActor("WebDriverProcessData");
27 * Wrapper to deserialize a local / remote value.
29 * @param {object} serializedValue
30 * Value of any type to be deserialized.
31 * @param {Realm} realm
32 * The Realm in which the value is deserialized.
33 * @param {ExtraSerializationOptions=} extraOptions
34 * Extra Remote Value deserialization options.
37 * Deserialized representation of the value.
39 deserialize(serializedValue, realm, extraOptions = {}) {
40 extraOptions.nodeCache = this.#nodeCache;
42 return lazy.deserialize(serializedValue, realm, extraOptions);
46 * Wrapper to serialize a value as a remote value.
48 * @param {object} value
49 * Value of any type to be serialized.
50 * @param {SerializationOptions} serializationOptions
51 * Options which define how ECMAScript objects should be serialized.
52 * @param {OwnershipModel} ownershipType
53 * The ownership model to use for this serialization.
54 * @param {Realm} realm
55 * The Realm from which comes the value being serialized.
56 * @param {ExtraSerializationOptions} extraOptions
57 * Extra Remote Value serialization options.
60 * Promise that resolves to the serialized representation of the value.
69 const { nodeCache = this.#nodeCache, seenNodeIds = new Map() } =
72 const serializedValue = lazy.serialize(
78 { nodeCache, seenNodeIds }
81 return serializedValue;