mirror of
https://github.com/roytam1/UXP.git
synced 2026-05-26 23:18:26 +00:00
Issue #1691 - Part 7b: Make load request element optional. https://bugzilla.mozilla.org/show_bug.cgi?id=1342012
(cherry picked from commit 169bb5d2ada59026fb6407716a7b3862810c9b97)
This commit is contained in:
+12
-10
@@ -89,6 +89,7 @@ ScriptFetchOptions::ScriptFetchOptions(mozilla::CORSMode aCORSMode,
|
||||
nsIPrincipal* aTriggeringPrincipal)
|
||||
: mCORSMode(aCORSMode)
|
||||
, mReferrerPolicy(aReferrerPolicy)
|
||||
, mIsPreload(false)
|
||||
, mElement(aElement)
|
||||
, mTriggeringPrincipal(aTriggeringPrincipal)
|
||||
{
|
||||
@@ -1110,7 +1111,7 @@ ScriptLoader::ProcessLoadedModuleTree(ModuleLoadRequest* aRequest)
|
||||
RefPtr<ScriptLoadRequest> req = mDynamicImportRequests.Steal(aRequest);
|
||||
RunScriptWhenSafe(req);
|
||||
} else if (aRequest->mIsInline &&
|
||||
aRequest->Element()->GetParserCreated() == NOT_FROM_PARSER) {
|
||||
aRequest->GetParserCreated() == NOT_FROM_PARSER) {
|
||||
RunScriptWhenSafe(aRequest);
|
||||
} else {
|
||||
MaybeMoveToLoadedList(aRequest);
|
||||
@@ -1510,7 +1511,7 @@ ScriptLoader::ProcessScriptElement(nsIScriptElement *aElement)
|
||||
// preloaded
|
||||
// note that a script-inserted script can steal a preload!
|
||||
request = mPreloads[i].mRequest;
|
||||
request->SetElement(aElement);
|
||||
request->SetIsLoadRequest(aElement);
|
||||
nsString preloadCharset(mPreloads[i].mCharset);
|
||||
mPreloads.RemoveElementAt(i);
|
||||
|
||||
@@ -1981,7 +1982,7 @@ ScriptLoader::ProcessRequest(ScriptLoadRequest* aRequest)
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIScriptElement> oldParserInsertedScript;
|
||||
uint32_t parserCreated = aRequest->Element()->GetParserCreated();
|
||||
uint32_t parserCreated = aRequest->GetParserCreated();
|
||||
if (parserCreated) {
|
||||
oldParserInsertedScript = mCurrentParserInsertedScript;
|
||||
mCurrentParserInsertedScript = aRequest->Element();
|
||||
@@ -2192,15 +2193,15 @@ ScriptLoader::EvaluateScript(ScriptLoadRequest* aRequest)
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIContent> scriptContent(do_QueryInterface(aRequest->Element()));
|
||||
nsIDocument* ownerDoc = scriptContent->OwnerDoc();
|
||||
if (ownerDoc != mDocument) {
|
||||
// Willful violation of HTML5 as of 2010-12-01
|
||||
return NS_ERROR_FAILURE;
|
||||
MOZ_ASSERT_IF(!scriptContent, aRequest->AsModuleRequest()->IsDynamicImport());
|
||||
if (scriptContent) {
|
||||
nsIDocument* ownerDoc = scriptContent->OwnerDoc();
|
||||
if (ownerDoc != mDocument) {
|
||||
// Willful violation of HTML5 as of 2010-12-01
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
// Get the script-type to be used by this element.
|
||||
NS_ASSERTION(scriptContent, "no content - what is default script-type?");
|
||||
|
||||
nsCOMPtr<nsIScriptGlobalObject> globalObject = GetScriptGlobalObject();
|
||||
if (!globalObject) {
|
||||
return NS_ERROR_FAILURE;
|
||||
@@ -2955,6 +2956,7 @@ ScriptLoader::PreloadURI(nsIURI *aURI,
|
||||
aReferrerPolicy);
|
||||
request->mIsInline = false;
|
||||
request->SetScriptMode(aDefer, aAsync);
|
||||
request->SetIsPreloadRequest();
|
||||
|
||||
nsresult rv = StartLoad(request, aType, aScriptFromHead);
|
||||
if (NS_FAILED(rv)) {
|
||||
|
||||
Reference in New Issue
Block a user