Support HTML parser reentrancy (#32820)

* Update parser interface for reentrancy.

Signed-off-by: Josh Matthews <josh@joshmatthews.net>

* Remove assertions around invoking scripts with active parser.

Signed-off-by: Josh Matthews <josh@joshmatthews.net>

* Add regression test.

Signed-off-by: Josh Matthews <josh@joshmatthews.net>

* Run test with normal and async html parser.

Signed-off-by: Josh Matthews <josh@joshmatthews.net>

---------

Signed-off-by: Josh Matthews <josh@joshmatthews.net>
This commit is contained in:
Josh Matthews 2024-08-16 12:25:50 -04:00 committed by GitHub
parent d44c0f7e5d
commit 4df7a1af25
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
13 changed files with 248 additions and 211 deletions

View file

@ -13776,6 +13776,39 @@
{}
]
],
"parser-reentrancy-customelement.window.js": [
"0df997aa6c521ef31c32c4054568ed005e011663",
[
"mozilla/parser-reentrancy-customelement.window.html?async",
{
"script_metadata": [
[
"variant",
"?default"
],
[
"variant",
"?async"
]
]
}
],
[
"mozilla/parser-reentrancy-customelement.window.html?default",
{
"script_metadata": [
[
"variant",
"?default"
],
[
"variant",
"?async"
]
]
}
]
],
"partial_shadow_dom.html": [
"74e308f94036a6dbf5c4223cd3d229f49ffceb4e",
[

View file

@ -0,0 +1,6 @@
[parser-reentrancy-customelement.window.html?default]
prefs: ["dom.servoparser.async_html_tokenizer.enabled:false"]
[parser-reentrancy-customelement.window.html?async]
expected: CRASH
prefs: ["dom.servoparser.async_html_tokenizer.enabled:true"]

View file

@ -0,0 +1,22 @@
// META: variant=?default
// META: variant=?async
let script = "\
class PopupInfo extends HTMLElement { \
connectedCallback() { \
frameElement.globalTest.step_timeout(() => frameElement.globalTest.done(), 0); \
document.open(); \
document.write('did not panic'); \
document.close(); \
} \
} \
\
customElements.define('popup-info', PopupInfo); \
";
async_test(function(t) {
let iframe = document.createElement('iframe');
iframe.globalTest = t;
iframe.srcdoc = "<script>" + script + "<" + "/script><popup-info></popup-info>";
document.body.appendChild(iframe);
}, "Dynamic markup insertion during custom element callbacks does not panic");