mirror of
https://github.com/puppeteer/puppeteer
synced 2024-06-14 14:02:48 +00:00
Do not leak event listeners on navigation
This patch: - introduces helper.addEventListener/helper.removeEventListeners to simplify event management - moves NavigatorWatchdog over to the helper.addEventListener to stop leaking event listeners
This commit is contained in:
11
test/test.js
11
test/test.js
@@ -364,7 +364,7 @@ describe('Puppeteer', function() {
|
||||
} catch (e) {
|
||||
error = e;
|
||||
}
|
||||
expect(error.message).toContain('SSL Certiciate error');
|
||||
expect(error.message).toContain('SSL Certificate error');
|
||||
}));
|
||||
it('should fail when exceeding maximum navigation timeout', SX(async function() {
|
||||
let error = null;
|
||||
@@ -492,6 +492,15 @@ describe('Puppeteer', function() {
|
||||
// Expect navigation to succeed.
|
||||
expect(response.ok).toBe(true);
|
||||
}));
|
||||
it('should not leak listeners durint navigation', SX(async function() {
|
||||
let warning = null;
|
||||
const warningHandler = w => warning = w;
|
||||
process.on('warning', warningHandler);
|
||||
for (let i = 0; i < 20; ++i)
|
||||
await page.navigate(EMPTY_PAGE);
|
||||
process.removeListener('warning', warningHandler);
|
||||
expect(warning).toBe(null);
|
||||
}));
|
||||
});
|
||||
|
||||
describe('Page.waitForNavigation', function() {
|
||||
|
||||
Reference in New Issue
Block a user