test: add a test for sourceURL in exception stacks (#1880)

This commit is contained in:
Dmitry Gozman 2020-04-20 13:00:31 -07:00 committed by GitHub
parent 649f37f885
commit a0003354d8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -500,12 +500,18 @@ describe('Page.Events.PageError', function() {
expect(error.name).toBe('Error');
expect(error.message).toBe('Fancy error!');
let stack = await page.evaluate(() => window.e.stack);
// Note that WebKit does not use sourceURL for some reason and reports the stack of the 'throw' statement
// instead of the Error constructor call.
// Note that WebKit reports the stack of the 'throw' statement instead of the Error constructor call.
if (WEBKIT)
stack = stack.replace('14:25', '15:19');
expect(error.stack).toBe(stack);
});
it.fail(WEBKIT)('should contain sourceURL', async({page, server}) => {
const [error] = await Promise.all([
page.waitForEvent('pageerror'),
page.goto(server.PREFIX + '/error.html'),
]);
expect(error.stack).toContain('myscript.js');
});
});
describe('Page.setContent', function() {