tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

Dialog.ts (752B)


      1 /**
      2 * @license
      3 * Copyright 2017 Google Inc.
      4 * SPDX-License-Identifier: Apache-2.0
      5 */
      6 
      7 import type {Protocol} from 'devtools-protocol';
      8 
      9 import type {CDPSession} from '../api/CDPSession.js';
     10 import {Dialog} from '../api/Dialog.js';
     11 
     12 /**
     13 * @internal
     14 */
     15 export class CdpDialog extends Dialog {
     16  #client: CDPSession;
     17 
     18  constructor(
     19    client: CDPSession,
     20    type: Protocol.Page.DialogType,
     21    message: string,
     22    defaultValue = '',
     23  ) {
     24    super(type, message, defaultValue);
     25    this.#client = client;
     26  }
     27 
     28  override async handle(options: {
     29    accept: boolean;
     30    text?: string;
     31  }): Promise<void> {
     32    await this.#client.send('Page.handleJavaScriptDialog', {
     33      accept: options.accept,
     34      promptText: options.text,
     35    });
     36  }
     37 }