mirror of
https://github.com/puppeteer/puppeteer
synced 2024-06-14 14:02:48 +00:00
45ab3e0332
This adds a proof-of-concept of `puppeteer-firefox`. This consists of two parts: - `//experimental/juggler` - patches to apply to Firefox. - `//experimental/puppeteer-firefox` - front-end code to be merged with Puppeteer. As things become more stable, we'll gradually move it out of the experimental folder.
58 lines
1.2 KiB
JavaScript
58 lines
1.2 KiB
JavaScript
const {helper, assert, debugError} = require('./helper');
|
|
|
|
class Dialog {
|
|
constructor(client, payload) {
|
|
this._client = client;
|
|
this._dialogId = payload.dialogId;
|
|
this._type = payload.type;
|
|
this._message = payload.message;
|
|
this._handled = false;
|
|
this._defaultValue = payload.defaultValue || '';
|
|
}
|
|
|
|
/**
|
|
* @return {string}
|
|
*/
|
|
type() {
|
|
return this._type;
|
|
}
|
|
|
|
/**
|
|
* @return {string}
|
|
*/
|
|
message() {
|
|
return this._message;
|
|
}
|
|
|
|
/**
|
|
* @return {string}
|
|
*/
|
|
defaultValue() {
|
|
return this._defaultValue;
|
|
}
|
|
|
|
/**
|
|
* @param {string=} promptText
|
|
*/
|
|
async accept(promptText) {
|
|
assert(!this._handled, 'Cannot accept dialog which is already handled!');
|
|
this._handled = true;
|
|
await this._client.send('Page.handleDialog', {
|
|
dialogId: this._dialogId,
|
|
accept: true,
|
|
promptText: promptText
|
|
}).catch(debugError);
|
|
}
|
|
|
|
async dismiss() {
|
|
assert(!this._handled, 'Cannot dismiss dialog which is already handled!');
|
|
this._handled = true;
|
|
await this._client.send('Page.handleDialog', {
|
|
dialogId: this._dialogId,
|
|
accept: false
|
|
}).catch(debugError);
|
|
}
|
|
}
|
|
|
|
module.exports = {Dialog};
|