From de848dc97f17cdc30703c236ee5b5c77172be2e9 Mon Sep 17 00:00:00 2001 From: Adam Vandolder Date: Thu, 17 Nov 2022 20:11:23 +0000 Subject: [PATCH] Bug 1632975 - Run microtask checkpoint before processing script. r=smaug Differential Revision: https://phabricator.services.mozilla.com/D162261 --- dom/base/test/mochitest.ini | 1 + dom/base/test/test_bug1632975.html | 54 ++++++++++++++++++++++++++++++ dom/script/ScriptElement.cpp | 3 ++ dom/script/ScriptLoader.cpp | 7 ---- 4 files changed, 58 insertions(+), 7 deletions(-) create mode 100644 dom/base/test/test_bug1632975.html diff --git a/dom/base/test/mochitest.ini b/dom/base/test/mochitest.ini index aa90d3dfecde..15e688453a33 100644 --- a/dom/base/test/mochitest.ini +++ b/dom/base/test/mochitest.ini @@ -610,6 +610,7 @@ support-files = file_bug1100912.html [test_bug1499169.html] skip-if = toolkit == 'android' # Timeouts on android due to page closing issues with embedded pdf [test_bug1576154.html] +[test_bug1632975.html] [test_bug1640766.html] support-files = iframe1_bug1640766.html diff --git a/dom/base/test/test_bug1632975.html b/dom/base/test/test_bug1632975.html new file mode 100644 index 000000000000..8b54ca47a55a --- /dev/null +++ b/dom/base/test/test_bug1632975.html @@ -0,0 +1,54 @@ + + + + + Test for Bug 1632975 + + + + + + +Mozilla Bug 1632975 +

+ + + diff --git a/dom/script/ScriptElement.cpp b/dom/script/ScriptElement.cpp index bebd9aae307f..a1ef0f1a70a6 100644 --- a/dom/script/ScriptElement.cpp +++ b/dom/script/ScriptElement.cpp @@ -115,6 +115,9 @@ bool ScriptElement::MaybeProcessScript() { mAlreadyStarted = true; + nsContentUtils::AddScriptRunner(NS_NewRunnableFunction( + "ScriptElement::MaybeProcessScript", []() { nsAutoMicroTask mt; })); + nsCOMPtr parser = ((nsIScriptElement*)this)->GetCreatorParser(); if (parser) { nsCOMPtr sink = parser->GetContentSink(); diff --git a/dom/script/ScriptLoader.cpp b/dom/script/ScriptLoader.cpp index b966391396fc..0e90d4dc63e1 100644 --- a/dom/script/ScriptLoader.cpp +++ b/dom/script/ScriptLoader.cpp @@ -1186,13 +1186,6 @@ bool ScriptLoader::ProcessInlineScript(nsIScriptElement* aElement, } } - { - // We must perform a microtask checkpoint when inserting script elements - // as specified by: https://html.spec.whatwg.org/#parsing-main-incdata - // For the non-inline module cases this happens in ProcessRequest. - mozilla::nsAutoMicroTask mt; - } - // This calls OnFetchComplete directly since there's no need to start // fetching an inline script. nsresult rv = modReq->OnFetchComplete(NS_OK);