Commit ad303d9f authored by Dominic Farolino's avatar Dominic Farolino Committed by Commit Bot

Add async script scheduling test

This CL adds an async script scheduling test, mainly to document the
current scheduling behavior of async scripts with respect to other
scripts. It indicates that currently, async scripts are allowed to load
before:
 - First Paint
 - The Document is Finished Parsing

A follow-up CL (https://crrev.com/c/2213343) implements the delaying of
async script execution until:
 - Finished Parsing
 - First Paint or Finished Parsing

... and asserts that the implementation affects the output of this test
accordingly. The test has to be hosted in wpt_internal/, because we need
to use WPT server features such as the trickle pipe, that are not
available for use in regular web_tests.

Bug: 1086227
Change-Id: I2562df28efbba2c8ab5c21fe55d82a2e44676f1a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2213354Reviewed-by: default avatarKinuko Yasuda <kinuko@chromium.org>
Commit-Queue: Dominic Farolino <dom@chromium.org>
Cr-Commit-Position: refs/heads/master@{#772199}
parent ddc9c40a
<!doctype html>
<head>
<title>Async Script Execution Order</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<!-- Note: This test serves mainly to document the current scheduling behavior
of async scripts with respect to other scripts and events in the loading
pipeline. It does not represent the "ideal" or "desired" behavior, so
changing it is probably fine. -->
<script>
setup({single_test: true})
const logs = [];
function logScript(msg) {
logs.push(msg);
}
window.onload = e => {
const actualOrder = logs.join(";");
const expectedOrder = "Async;Async;inline1;external;inline2;DOMContentLoaded";
scriptlog.textContent += actualOrder;
assert_equals(actualOrder, expectedOrder);
done();
};
document.addEventListener('DOMContentLoaded', e => { logScript('DOMContentLoaded'); });
</script>
<script async src="resources/async-script.js?1"></script>
<script async src="resources/async-script.js?2"></script>
<link rel=stylesheet href=resources/main.css?pipe=trickle(d1)>
<pre id="scriptlog"></pre>
<script>
logScript('inline1');
</script>
<h1>
Fast finished parsing, slow first paint
</h1>
<script src="resources/external.js?first&pipe=trickle(d2)"></script>
<script>
logScript('inline2');
</script>
</body>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment