selenium-webdriver
Version:
The official WebDriver JavaScript bindings from the Selenium project
58 lines (57 loc) • 3.87 kB
JavaScript
;
// Licensed to the Software Freedom Conservancy (SFC) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The SFC licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
Object.defineProperty(exports, "__esModule", { value: true });
exports.Permissions = void 0;
// DO NOT EDIT! This file is generated by javascript/selenium-webdriver/generate_bidi.mjs.
// Regenerate with: `bazel build //javascript/selenium-webdriver:create-bidi-src`
// Built from the WebDriver BiDi CDDL spec (v1.0).
// Source: https://github.com/w3c/webref/tree/main/ed/cddl
const record_js_1 = require("../serialization/record.js");
const enum_js_1 = require("../serialization/enum.js");
const domain_js_1 = require("../domain.js");
const PermissionsPermissionDescriptor = (0, record_js_1.defineRecord)('permissions.PermissionDescriptor', [{ "name": "name", "wire": "name", "required": true, "type": { "primitive": "string" } }]);
const PermissionsPermissionStateEnum = (0, enum_js_1.defineEnum)('permissions.PermissionState', ["granted", "denied", "prompt"]);
const PermissionsSetPermission = (0, record_js_1.defineRecord)('permissions.setPermission', [{ "name": "method", "wire": "method", "required": true, "type": { "const": "permissions.setPermission" } }, { "name": "params", "wire": "params", "required": true, "type": { "ref": "permissions.SetPermissionParameters" } }]);
const PermissionsSetPermissionParameters = (0, record_js_1.defineRecord)('permissions.SetPermissionParameters', [{ "name": "descriptor", "wire": "descriptor", "required": true, "type": { "ref": "permissions.PermissionDescriptor" } }, { "name": "state", "wire": "state", "required": true, "type": { "ref": "permissions.PermissionState" } }, { "name": "origin", "wire": "origin", "required": true, "type": { "primitive": "string" } }, { "name": "embeddedOrigin", "wire": "embeddedOrigin", "required": false, "type": { "primitive": "string" } }, { "name": "userContext", "wire": "userContext", "required": false, "type": { "primitive": "string" } }]);
// --- Implementation ---
/**
* This is an unsupported API. No compatibility guarantees are provided.
* It tracks the W3C WebDriver BiDi specification directly. As the specification
* evolves, this API will change or be removed without prior notice.
*/
class Permissions extends domain_js_1.Domain {
static async create(driver) {
return new Permissions(await domain_js_1.Domain.connect(driver), domain_js_1.DOMAIN_TOKEN);
}
/**
* @param {PermissionsSetPermissionParameters} params
* @param {PermissionsPermissionDescriptor} params.descriptor
* @param {PermissionsPermissionState} params.state
* @param {string} params.origin
* @param {string} [params.embeddedOrigin]
* @param {string} [params.userContext]
* @returns {Promise<void>}
* @see https://w3c.github.io/webdriver-bidi/#command-permissions-setPermission
*/
async setPermission(params) {
const validatedParams = new PermissionsSetPermissionParameters(params);
await this.send('permissions.setPermission', validatedParams);
}
}
exports.Permissions = Permissions;
Permissions.PermissionState = Object.freeze({ GRANTED: "granted", DENIED: "denied", PROMPT: "prompt" });