Enable render-blocking inline module scripts
Inline module scripts need to behave like scripts with `src` in many
ways, e.g. if they have imports. Otherwise authors have to use a
fake `src` for artificial reasons.
This implements the spec PR:
https://github.com/whatwg/html/pull/10035
Currently behind a flag (RenderBlockingInlineModuleScript)
Bug: 1514881
Change-Id: I8579d721adbf976a1d5e20d14abc6ef7252b0718
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5184455
Reviewed-by: Kouhei Ueno <kouhei@chromium.org>
Commit-Queue: Noam Rosenthal <nrosenthal@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1250749}
diff --git a/html/dom/render-blocking/parser-inserted-async-inline-module-with-import.html b/html/dom/render-blocking/parser-inserted-async-inline-module-with-import.html
new file mode 100644
index 0000000..50a2add
--- /dev/null
+++ b/html/dom/render-blocking/parser-inserted-async-inline-module-with-import.html
@@ -0,0 +1,21 @@
+<!DOCTYPE html>
+<head>
+<title>Parser-inserted async inline module script elements with "blocking=render" are render-blocking</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script>
+ window.did_execute_script = false;
+</script>
+<script type="module" blocking="render" async>
+ import "/loading/resources/dummy.js?pipe=trickle(d1)";
+ window.did_execute_script = true;
+</script>
+</head>
+<div id="dummy">some text</div>
+
+<script>
+ promise_test(async t => {
+ await new Promise(resolve => requestAnimationFrame(() => resolve()));
+ assert_true(window.did_execute_script, "Parser-inserted async render-blocking inline module script should execute before rAF callback");
+ });
+</script>
diff --git a/html/dom/render-blocking/parser-inserted-inline-module-with-import.html b/html/dom/render-blocking/parser-inserted-inline-module-with-import.html
new file mode 100644
index 0000000..af2ac46
--- /dev/null
+++ b/html/dom/render-blocking/parser-inserted-inline-module-with-import.html
@@ -0,0 +1,21 @@
+<!DOCTYPE html>
+<head>
+<title>Parser-inserted module script elements with "blocking=render" are render-blocking</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script>
+ window.did_execute_script = false;
+</script>
+<script type="module" blocking="render">
+ import "/loading/resources/dummy.js?pipe=trickle(d1)";
+ window.did_execute_script = true;
+</script>
+</head>
+<div id="dummy">some text</div>
+
+<script>
+ promise_test(async t => {
+ await new Promise(resolve => requestAnimationFrame(() => resolve()));
+ assert_true(window.did_execute_script, "Parser-inserted render-blocking inline module script should execute before rAF callback");
+ });
+</script>
diff --git a/html/dom/render-blocking/script-inserted-inline-module-with-import.html b/html/dom/render-blocking/script-inserted-inline-module-with-import.html
new file mode 100644
index 0000000..576c0b3
--- /dev/null
+++ b/html/dom/render-blocking/script-inserted-inline-module-with-import.html
@@ -0,0 +1,25 @@
+<!DOCTYPE html>
+<head>
+<title>Script-inserted module script elements with "blocking=render" are render-blocking</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script>
+ window.did_execute_script = false;
+ const script = document.createElement("script");
+ script.type = "module";
+ script.blocking = "render";
+ script.textContent = `
+ import "/loading/resources/dummy.js?pipe=trickle(d1)";
+ window.did_execute_script = true;
+ `;
+ document.head.append(script);
+</script>
+</head>
+<div id="dummy">some text</div>
+
+<script>
+ promise_test(async t => {
+ await new Promise(resolve => requestAnimationFrame(() => resolve()));
+ assert_true(window.did_execute_script, "Script-inserted render-blocking inline module script should execute before rAF callback");
+ });
+</script>