xtensionId; switch (type) { case ExtensionDataType.Base64: lazy.assert.string( value, lazy.pprint`Expected "extensionData.value" to be a string, got ${value}` ); extensionId = await lazy.Addon.installWithBase64( value, !permanent, false ); break; case ExtensionDataType.ArchivePath: case ExtensionDataType.Path: lazy.assert.string( path, lazy.pprint`Expected "extensionData.path" to be a string, got ${path}` ); if (permanent && type == ExtensionDataType.Path) { throw new lazy.error.InvalidWebExtensionError( "Permanent installation of unpacked extensions is not supported" ); } extensionId = await lazy.Addon.installWithPath(path, !permanent, false); } return { extension: extensionId, }; } /** * Uninstalls a WebExtension. * * @see https://w3c.github.io/webdriver-bidi/#command-webExtension-uninstall * * @param {object=} options * @param {Extension} options.extension * The id of the WebExtension to be uninstalled. * * @throws {InvalidArgumentError} * Raised if an argument is of an invalid type or value. * @throws {NoSuchWebExtensionError} * Raised if the WebExtension with provided id could not be found. * @throws {UnknownError} * Raised if the WebExtension cannot be uninstalled. */ async uninstall(options = {}) { const { extension: addonId } = options; lazy.assert.string( addonId, lazy.pprint`Expected "extension" to be a string, got ${addonId}` ); if (addonId === "") { throw new lazy.error.NoSuchWebExtensionError( `Expected "extension" to be a non-empty string, got ${addonId}` ); } await lazy.Addon.uninstall(addonId); } } export const webExtension = WebExtensionModule; PK