test(goto): add failing load event test for webkit (#8809)

This commit is contained in:
Joel Einbinder 2021-09-09 15:42:46 -04:00 committed by GitHub
parent eca82eee4a
commit 7fe30bb182
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 44 additions and 0 deletions

View File

@ -0,0 +1,23 @@
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Load Event Test</title>
</head>
<body>
<script>
window.results = [];
window.addEventListener('load', function() {
window.results.push('load');
});
window.addEventListener('DOMContentLoaded', function() {
window.results.push('DOMContentLoaded');
});
</script>
<script type="module" src="./module.js"></script>
<script>
window.results.push('script tag after after module');
</script>
</body>
</html>

View File

@ -0,0 +1,3 @@
import {foo} from '/slow.js';
console.log('foo is', foo);
window.results.push('module');

View File

@ -526,3 +526,21 @@ it('should not crash when RTCPeerConnection is used', async ({ page, server, bro
}); });
}); });
}); });
it('should properly wait for load', async ({page, server, browserName}) => {
it.fixme(browserName === 'webkit', 'WebKit has a bug where Page.frameStoppedLoading is sent too early.');
server.setRoute('/slow.js', async (req, res) => {
await new Promise(x => setTimeout(x, 100));
res.writeHead(200, {'Content-Type': 'application/javascript'});
res.end(`window.results.push('slow module');export const foo = 'slow';`);
});
await page.goto(server.PREFIX + '/load-event/load-event.html');
const results = await page.evaluate('window.results');
expect(results).toEqual([
'script tag after after module',
'slow module',
'module',
'DOMContentLoaded',
'load'
]);
});