Bug 1361369 - Allow async attribute on inline module scripts r=smaug

This commit is contained in:
Jon Coppeard
2018-01-08 15:17:34 +00:00
parent ac540f38f6
commit 69ebe1854a
11 changed files with 70 additions and 40 deletions

View File

@@ -190,12 +190,20 @@ HTMLScriptElement::GetScriptCharset(nsAString& charset)
}
void
HTMLScriptElement::FreezeUriAsyncDefer()
HTMLScriptElement::FreezeExecutionAttrs(nsIDocument* aOwnerDoc)
{
if (mFrozen) {
return;
}
MOZ_ASSERT(!mIsModule && !mAsync && !mDefer && !mExternal);
// Determine whether this is a classic script or a module script.
nsAutoString type;
GetScriptType(type);
mIsModule = aOwnerDoc->ModuleScriptsEnabled() &&
!type.IsEmpty() && type.LowerCaseEqualsASCII("module");
// variation of this code in nsSVGScriptElement - check if changes
// need to be transfered when modifying. Note that we don't use GetSrc here
// because it will return the base URL when the attr value is "".
@@ -228,14 +236,14 @@ HTMLScriptElement::FreezeUriAsyncDefer()
// At this point mUri will be null for invalid URLs.
mExternal = true;
bool async = Async();
bool defer = Defer();
mDefer = !async && defer;
mAsync = async;
}
bool async = (mExternal || mIsModule) && Async();
bool defer = mExternal && Defer();
mDefer = !async && defer;
mAsync = async;
mFrozen = true;
}