-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Test the supported values of <link rel=preload as> (#45200)
* Test the supported values of <link rel=preload as> The supported values are: image, fetch, font, script, style, json, track Unsupported values: - video, audio (streamed with range requests) - object, iframe, worklet, worker (not subresources) - any unknown value * Remove spurious things * Use step_timeout
- Loading branch information
Showing
1 changed file
with
44 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<title>Test the supported value for <link rel=preload as="..."></title> | ||
<meta name="timeout" content="long"> | ||
<meta name="variant" content="?as=image&expected=1"> | ||
<meta name="variant" content="?as=fetch&expected=1"> | ||
<meta name="variant" content="?as=font&expected=1"> | ||
<meta name="variant" content="?as=script&expected=1"> | ||
<meta name="variant" content="?as=style&expected=1"> | ||
<meta name="variant" content="?as=json&expected=1"> | ||
<meta name="variant" content="?as=track&expected=1"> | ||
|
||
<meta name="variant" content="?as=garbagefoobar&expected=0"> | ||
<meta name="variant" content="?as=video&expected=0"> | ||
<meta name="variant" content="?as=audio&expected=0"> | ||
<meta name="variant" content="?as=object&expected=0"> | ||
<meta name="variant" content="?as=iframe&expected=0"> | ||
<meta name="variant" content="?as=worklet&expected=0"> | ||
|
||
<script src="/common/utils.js"></script> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<body> | ||
<script> | ||
const params = new URLSearchParams(location.search); | ||
const as = params.get("as"); | ||
const expected = Number(params.get("expected")); | ||
promise_test(async t => { | ||
const link = document.createElement("link"); | ||
link.href = new URL("/common/echo.py?content=nothing", location.href).href; | ||
link.rel = "preload"; | ||
link.as = as; | ||
document.head.append(link); | ||
await new Promise(resolve => { | ||
t.step_timeout(resolve, 1000); | ||
link.addEventListener("load", resolve); | ||
link.addEventListener("error", resolve); | ||
}); | ||
const resources = performance.getEntriesByName(link.href); | ||
assert_equals(resources.length, expected); | ||
}); | ||
</script> | ||
</body> | ||
</html> |