Skip to content

Commit

Permalink
fix: stop async scripts running between parser pumps
Browse files Browse the repository at this point in the history
Some pages assume that async scripts don't run in between sync
<script> tags. They probably shouldn't, but this fixes the
behaviour.

Bug: 1197376, 901056
Change-Id: Icd1779f164db77794e25dbcd6e3e92582a55d7a7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2826128
Commit-Queue: Richard Townsend <richard.townsend@arm.com>
Reviewed-by: Kouhei Ueno <kouhei@chromium.org>
Reviewed-by: Mason Freed <masonf@chromium.org>
Cr-Commit-Position: refs/heads/master@{#878839}
  • Loading branch information
richard-townsend-arm authored and chromium-wpt-export-bot committed May 4, 2021
1 parent b01ab77 commit a26300b
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 3 deletions.
5 changes: 4 additions & 1 deletion html/semantics/scripting-1/the-script-element/async_005.htm
Expand Up @@ -17,7 +17,10 @@

function timeout()
{
t.step(function(){ assert_equals(document.getElementById("testresult").innerHTML, "2134")});
t.step(function(){
var actual = document.getElementById("testresult").innerHTML;
assert_in_array(actual, ["2134", "2341"]);
});
t.done();
}

Expand Down
Expand Up @@ -21,8 +21,28 @@
var t = async_test()

function test() {
assert_array_equals(eventOrder, ['inline script #1', 'end script #1', 'include-5 before removing scripts', 'include-5 after removing scripts', 'external script #1', 'external script #2']),
t.done();
// Per-spec, non-blocking/async scripts can execute at any time.
// Therefore, there are two possibilities for the script order here.
// 1. inline script first, followed by include-5 (async), then
// external script #1 (slow async) and finally external #2
// (inline).
// 2. inline script, external '2, 'include 5', then include-1.
assert_array_equals(eventOrder.slice(0, 2), [
'inline script #1', 'end script #1'
]);
if (eventOrder[2] == 'include-5 before removing scripts') {
assert_array_equals(eventOrder.slice(3), [
'include-5 after removing scripts', 'external script #1',
'external script #2'
]);
} else {
assert_array_equals(eventOrder.slice(2), ['external script #2',
'include-5 before removing scripts',
'include-5 after removing scripts',
'external script #1'
]);
}
t.done();
}
onload = t.step_func(test)
</script>
Expand Down

0 comments on commit a26300b

Please sign in to comment.