Bug 1768534 [wpt PR 34005] - Fix block & unblock ordering when an inline style sheet mutates, a=testonly

Automatic update from web-platform-tests
Fix block & unblock ordering when an inline style sheet mutates

When an inline <style> mutates, it calls AddPendingBlockingSheet() for
the new style sheet first, and then calls RemovePendingBlockingSheet()
for the old style sheet.

This used to be fine when those two methods were just adding /
subtracting some counters. However, after crrev.com/c/3503857, the two
methods become adding / removing the <style> element into / from the
RenderBlockingResourceManager class's set of pending elements, which
assumes that we never double-add or double-remove any element. Then the
relevant states are broken.

This patch reorders the call sites of the two methods to make sure we
remove it before re-adding it.

Fixed: 1323319
Change-Id: If28e35fb794e7bd2d77107ab4f8e867ad66d88ba
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3636301
Reviewed-by: Rune Lillesveen <futhark@chromium.org>
Commit-Queue: Xiaocheng Hu <xiaochengh@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1001530}

--

wpt-commits: 6533b73265da85295177a4c4b4ecf02d94b6100d
wpt-pr: 34005
This commit is contained in:
Xiaocheng Hu 2022-05-16 10:08:58 +00:00 коммит произвёл moz-wptsync-bot
Родитель 0fa01d433c
Коммит 05f666dc5d
1 изменённых файлов: 16 добавлений и 0 удалений

Просмотреть файл

@ -0,0 +1,16 @@
<!DOCTYPE html>
<title>The 'load' event on the style element should still fire after mutation</title>
<link rel="help" href="https://crbug.com/1323319">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
promise_test(async () => {
const style = document.createElement('style');
document.head.appendChild(style);
style.appendChild(document.createTextNode('@import url(/support/css-red.txt);'));
style.appendChild(document.createTextNode('body {color: green; }'));
// The 'load' event should fire.
await new Promise(resolve => style.onload = resolve);
});
</script>