mirror of
https://github.com/puppeteer/puppeteer
synced 2024-06-14 14:02:48 +00:00
Refactor JavaScript dialog API
This patch introduces a Dialog class and a new 'dialog' event instead of the 'alert', 'beforeunload', 'confirm' and 'prompt' events and 'Page.handleDialog' method. Fixes #2.
This commit is contained in:
21
test/test.js
21
test/test.js
@@ -155,6 +155,27 @@ describe('Puppeteer', function() {
|
||||
expect(failedResources).toBe(1);
|
||||
}));
|
||||
});
|
||||
|
||||
describe('Page.Events.Dialog', function() {
|
||||
it('should fire', function(done) {
|
||||
page.on('dialog', dialog => {
|
||||
expect(dialog.type).toBe('alert');
|
||||
expect(dialog.message()).toBe('yo');
|
||||
done();
|
||||
});
|
||||
page.evaluate(() => alert('yo'));
|
||||
});
|
||||
// TODO Enable this when crbug.com/718235 is fixed.
|
||||
xit('should allow accepting prompts', SX(async function(done) {
|
||||
page.on('dialog', dialog => {
|
||||
expect(dialog.type).toBe('prompt');
|
||||
expect(dialog.message()).toBe('question?');
|
||||
dialog.accept('answer!');
|
||||
});
|
||||
var result = await page.evaluate(() => prompt('question?'));
|
||||
expect(result).toBe('answer!');
|
||||
}));
|
||||
});
|
||||
});
|
||||
|
||||
// Since Jasmine doesn't like async functions, they should be wrapped
|
||||
|
||||
Reference in New Issue
Block a user