* Don't use expect within Promises (#5466) If a call to expect fails within a Promise it will not be resolved, and causing the test to crash. The patch aligns the code similar to what is used by all the other tests.
This commit is contained in:
parent
dfb2e6056b
commit
6cfe142af1
29671
src/protocol.d.ts
vendored
29671
src/protocol.d.ts
vendored
File diff suppressed because it is too large
Load Diff
@ -25,16 +25,22 @@ const {
|
|||||||
describe('Page.Events.Dialog', function () {
|
describe('Page.Events.Dialog', function () {
|
||||||
setupTestBrowserHooks();
|
setupTestBrowserHooks();
|
||||||
setupTestPageAndContextHooks();
|
setupTestPageAndContextHooks();
|
||||||
|
|
||||||
it('should fire', async () => {
|
it('should fire', async () => {
|
||||||
const { page } = getTestState();
|
const { page } = getTestState();
|
||||||
|
|
||||||
page.on('dialog', (dialog) => {
|
const onDialog = sinon.stub().callsFake((dialog) => {
|
||||||
expect(dialog.type()).toBe('alert');
|
|
||||||
expect(dialog.defaultValue()).toBe('');
|
|
||||||
expect(dialog.message()).toBe('yo');
|
|
||||||
dialog.accept();
|
dialog.accept();
|
||||||
});
|
});
|
||||||
|
page.on('dialog', onDialog);
|
||||||
|
|
||||||
await page.evaluate(() => alert('yo'));
|
await page.evaluate(() => alert('yo'));
|
||||||
|
|
||||||
|
expect(onDialog.callCount).toEqual(1);
|
||||||
|
const dialog = onDialog.firstCall.args[0];
|
||||||
|
expect(dialog.type()).toBe('alert');
|
||||||
|
expect(dialog.defaultValue()).toBe('');
|
||||||
|
expect(dialog.message()).toBe('yo');
|
||||||
});
|
});
|
||||||
|
|
||||||
itFailsFirefox('should allow accepting prompts', async () => {
|
itFailsFirefox('should allow accepting prompts', async () => {
|
||||||
|
@ -163,15 +163,21 @@ describe('navigation', function () {
|
|||||||
|
|
||||||
// Make sure that network events do not emit 'undefined'.
|
// Make sure that network events do not emit 'undefined'.
|
||||||
// @see https://crbug.com/750469
|
// @see https://crbug.com/750469
|
||||||
page.on('request', (request) => expect(request).toBeTruthy());
|
const requests = [];
|
||||||
page.on('requestfinished', (request) => expect(request).toBeTruthy());
|
page.on('request', (request) => requests.push('request'));
|
||||||
page.on('requestfailed', (request) => expect(request).toBeTruthy());
|
page.on('requestfinished', (request) => requests.push('requestfinished'));
|
||||||
|
page.on('requestfailed', (request) => requests.push('requestfailed'));
|
||||||
|
|
||||||
let error = null;
|
let error = null;
|
||||||
await page
|
await page
|
||||||
.goto(httpsServer.EMPTY_PAGE)
|
.goto(httpsServer.EMPTY_PAGE)
|
||||||
.catch((error_) => (error = error_));
|
.catch((error_) => (error = error_));
|
||||||
if (isChrome) expect(error.message).toContain(EXPECTED_SSL_CERT_MESSAGE);
|
if (isChrome) expect(error.message).toContain(EXPECTED_SSL_CERT_MESSAGE);
|
||||||
else expect(error.message).toContain('SSL_ERROR_UNKNOWN');
|
else expect(error.message).toContain('SSL_ERROR_UNKNOWN');
|
||||||
|
|
||||||
|
expect(requests.length).toBe(2);
|
||||||
|
expect(requests[0]).toBe('request');
|
||||||
|
expect(requests[1]).toBe('requestfailed');
|
||||||
});
|
});
|
||||||
itFailsFirefox(
|
itFailsFirefox(
|
||||||
'should fail when navigating to bad SSL after redirects',
|
'should fail when navigating to bad SSL after redirects',
|
||||||
|
Loading…
Reference in New Issue
Block a user