mirror of
https://github.com/servo/servo.git
synced 2025-09-06 04:58:21 +01:00
Update web-platform-tests to revision 44702f2bc8ea98bc32b5b244f2fe63c6ce66d49d
This commit is contained in:
parent
85fa6409bb
commit
c227604a2c
997 changed files with 45660 additions and 14650 deletions
92
tests/wpt/web-platform-tests/preload/modulepreload.html
Normal file
92
tests/wpt/web-platform-tests/preload/modulepreload.html
Normal file
|
@ -0,0 +1,92 @@
|
|||
<!DOCTYPE html>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<body>
|
||||
<script>
|
||||
|
||||
function verifyNumberOfDownloads(url, number) {
|
||||
var numDownloads = 0;
|
||||
let absoluteURL = new URL(url, location.href).href;
|
||||
performance.getEntriesByName(absoluteURL).forEach(entry => {
|
||||
if (entry.transferSize > 0) {
|
||||
numDownloads++;
|
||||
}
|
||||
});
|
||||
assert_equals(numDownloads, number, url);
|
||||
}
|
||||
|
||||
function attachAndWaitForLoad(element) {
|
||||
return new Promise((resolve, reject) => {
|
||||
element.onload = resolve;
|
||||
element.onerror = reject;
|
||||
document.body.appendChild(element);
|
||||
});
|
||||
}
|
||||
|
||||
function attachAndWaitForError(element) {
|
||||
return new Promise((resolve, reject) => {
|
||||
element.onload = reject;
|
||||
element.onerror = resolve;
|
||||
document.body.appendChild(element);
|
||||
});
|
||||
}
|
||||
|
||||
promise_test(function(t) {
|
||||
var link = document.createElement('link');
|
||||
link.rel = 'modulepreload';
|
||||
link.href = 'resources/dummy.js';
|
||||
return attachAndWaitForLoad(link).then(() => {
|
||||
verifyNumberOfDownloads('resources/dummy.js', 1);
|
||||
|
||||
// Verify that <script> doesn't fetch the module again.
|
||||
var script = document.createElement('script');
|
||||
script.type = 'module';
|
||||
script.src = 'resources/dummy.js';
|
||||
return attachAndWaitForLoad(script);
|
||||
}).then(() => {
|
||||
verifyNumberOfDownloads('resources/dummy.js', 1);
|
||||
});
|
||||
}, 'link rel=modulepreload');
|
||||
|
||||
promise_test(function(t) {
|
||||
var link = document.createElement('link');
|
||||
link.rel = 'modulepreload';
|
||||
link.href = 'resources/module1.js';
|
||||
return attachAndWaitForLoad(link).then(() => {
|
||||
// Currently, modulepreload doesn't perform submodules fetch.
|
||||
verifyNumberOfDownloads('resources/module1.js', 1);
|
||||
verifyNumberOfDownloads('resources/module2.js', 0);
|
||||
|
||||
var script = document.createElement('script');
|
||||
script.type = 'module';
|
||||
script.src = 'resources/module1.js';
|
||||
return attachAndWaitForLoad(script);
|
||||
}).then(() => {
|
||||
verifyNumberOfDownloads('resources/module1.js', 1);
|
||||
verifyNumberOfDownloads('resources/module2.js', 1);
|
||||
});
|
||||
}, 'link rel=modulepreload with submodules');
|
||||
|
||||
promise_test(function(t) {
|
||||
var link = document.createElement('link');
|
||||
link.rel = 'modulepreload';
|
||||
link.href = 'resources/syntax-error.js';
|
||||
return attachAndWaitForError(link);
|
||||
}, 'link rel=modulepreload for a module with syntax error');
|
||||
|
||||
promise_test(function(t) {
|
||||
var link = document.createElement('link');
|
||||
link.rel = 'modulepreload';
|
||||
link.href = 'resources/not-exist.js';
|
||||
return attachAndWaitForError(link);
|
||||
}, 'link rel=modulepreload for a module with network error');
|
||||
|
||||
promise_test(function(t) {
|
||||
var link = document.createElement('link');
|
||||
link.rel = 'modulepreload';
|
||||
link.href = null;
|
||||
return attachAndWaitForError(link);
|
||||
}, 'link rel=modulepreload with bad href attribute');
|
||||
|
||||
</script>
|
||||
</body>
|
|
@ -0,0 +1,2 @@
|
|||
import { y } from './module2.js';
|
||||
export let x = y + 1;
|
|
@ -0,0 +1 @@
|
|||
export let y = 1;
|
|
@ -0,0 +1 @@
|
|||
;-)
|
Loading…
Add table
Add a link
Reference in a new issue