Bug 1843514 - Avoid speculative module loads after importmap r=smaug

Differential Revision: https://phabricator.services.mozilla.com/D183637
This commit is contained in:
Em Zhan
2023-07-16 17:33:17 +00:00
parent 053ab435ce
commit 1ab7773be7
2 changed files with 34 additions and 6 deletions

View File

@@ -230,18 +230,21 @@ nsIContentHandle* nsHtml5TreeBuilder::createElement(
nsHtml5String type =
aAttributes->getValue(nsHtml5AttributeName::ATTR_TYPE);
nsAutoString typeString;
type.ToString(typeString);
if (!mHasSeenImportMap) {
// If we see an importmap, we don't want to later start
// speculative loads for modulepreloads, since such load might
// finish before the importmap is created.
nsAutoString typeString;
type.ToString(typeString);
// If we see an importmap, we don't want to later start speculative
// loads for modulepreloads, since such load might finish before
// the importmap is created. This also applies to module scripts so
// that any modulepreload integrity checks can be performed before
// the modules scripts are loaded.
mHasSeenImportMap =
typeString.LowerCaseFindASCII("importmap") != kNotFound;
}
nsHtml5String url =
aAttributes->getValue(nsHtml5AttributeName::ATTR_SRC);
if (url) {
if (url && !(mHasSeenImportMap &&
typeString.LowerCaseFindASCII("module") != kNotFound)) {
nsHtml5String charset =
aAttributes->getValue(nsHtml5AttributeName::ATTR_CHARSET);
nsHtml5String crossOrigin =