mirror of
https://github.com/puppeteer/puppeteer
synced 2024-06-14 14:02:48 +00:00
feat: nicer protocol error messages (#2742)
This patch: - stops appending `undefined` to our protocol messages unnecessarily. - rewrites `Cannot find execution context id` to `Execution context was destroyed, most likely because of a navigation.` when it occurs from a Puppeteer ExecutionContext. The error message is left alone if it occurs via a CDPSession.
This commit is contained in:
committed by
Andrey Lushnikov
parent
9a650c818d
commit
73f9c48081
@@ -124,7 +124,7 @@ module.exports.addTests = function({testRunner, expect}) {
|
||||
error = e;
|
||||
}
|
||||
expect(error).toBeTruthy();
|
||||
expect(error.message).toEqual('Protocol error (Network.deleteCookies): At least one of the url and domain needs to be specified undefined');
|
||||
expect(error.message).toEqual('Protocol error (Network.deleteCookies): At least one of the url and domain needs to be specified');
|
||||
});
|
||||
|
||||
it('should not set a cookie with blank page URL', async function({page, server}) {
|
||||
@@ -154,7 +154,7 @@ module.exports.addTests = function({testRunner, expect}) {
|
||||
}
|
||||
expect(error).toBeTruthy();
|
||||
expect(error.message).toEqual(
|
||||
'Protocol error (Network.deleteCookies): At least one of the url and domain needs to be specified undefined'
|
||||
'Protocol error (Network.deleteCookies): At least one of the url and domain needs to be specified'
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
@@ -226,6 +226,16 @@ module.exports.addTests = function({testRunner, expect, puppeteer, DeviceDescrip
|
||||
return audio.play();
|
||||
}
|
||||
});
|
||||
it('should throw a nice error after a navigation', async({page, server}) => {
|
||||
const executionContext = await page.mainFrame().executionContext();
|
||||
|
||||
await Promise.all([
|
||||
page.waitForNavigation(),
|
||||
executionContext.evaluate(() => window.location.reload())
|
||||
]);
|
||||
const error = await executionContext.evaluate(() => null).catch(e => e);
|
||||
expect(error.message).toContain('navigation');
|
||||
});
|
||||
});
|
||||
|
||||
describe('Page.setOfflineMode', function() {
|
||||
|
||||
Reference in New Issue
Block a user