Merge remote-tracking branch 'origin/master' into custom

This commit is contained in:
roytam1 2020-09-10 21:08:44 +08:00
commit 3b48e4818a
12 changed files with 126 additions and 58 deletions

View file

@ -1471,6 +1471,9 @@ nsHTMLDocument::Open(JSContext* cx,
// document again otherwise the document could have a non-zero onload block // document again otherwise the document could have a non-zero onload block
// count without the onload blocker request being in the loadgroup. // count without the onload blocker request being in the loadgroup.
EnsureOnloadBlocker(); EnsureOnloadBlocker();
// Throw away loaded modules created for the previous global.
ScriptLoader()->ClearModuleMap();
} }
// Step 8 - Clear all event listeners out of our DOM tree // Step 8 - Clear all event listeners out of our DOM tree

View file

@ -56,7 +56,7 @@ public:
ModuleLoadRequest(nsIURI* aURI, ModuleLoadRequest(nsIURI* aURI,
ModuleLoadRequest* aParent); ModuleLoadRequest* aParent);
bool IsTopLevel() const { bool IsTopLevel() const override {
return mIsTopLevel; return mIsTopLevel;
} }

View file

@ -477,6 +477,11 @@ ScriptLoader::GetFetchedModule(nsIURI* aURL) const
return ms; return ms;
} }
void ScriptLoader::ClearModuleMap() {
MOZ_ASSERT(mFetchingModules.IsEmpty());
mFetchedModules.Clear();
}
nsresult nsresult
ScriptLoader::ProcessFetchedModuleSource(ModuleLoadRequest* aRequest) ScriptLoader::ProcessFetchedModuleSource(ModuleLoadRequest* aRequest)
{ {
@ -559,7 +564,9 @@ ScriptLoader::CreateModuleScript(ModuleLoadRequest* aRequest)
rv = nsJSUtils::CompileModule(cx, srcBuf, global, options, &module); rv = nsJSUtils::CompileModule(cx, srcBuf, global, options, &module);
} }
} }
MOZ_ASSERT(NS_SUCCEEDED(rv) == (module != nullptr)); MOZ_ASSERT(NS_SUCCEEDED(rv) == (module != nullptr));
RefPtr<ModuleScript> moduleScript = new ModuleScript(this, aRequest->mBaseURL); RefPtr<ModuleScript> moduleScript = new ModuleScript(this, aRequest->mBaseURL);
aRequest->mModuleScript = moduleScript; aRequest->mModuleScript = moduleScript;
@ -979,7 +986,7 @@ ScriptLoader::StartLoad(ScriptLoadRequest *aRequest, const nsAString &aType,
if (aRequest->IsModuleRequest()) { if (aRequest->IsModuleRequest()) {
// Check whether the module has been fetched or is currently being fetched, // Check whether the module has been fetched or is currently being fetched,
// and if so wait for it. // and if so wait for it rather than starting a new fetch.
ModuleLoadRequest* request = aRequest->AsModuleRequest(); ModuleLoadRequest* request = aRequest->AsModuleRequest();
if (ModuleMapContainsURL(request->mURI)) { if (ModuleMapContainsURL(request->mURI)) {
WaitForModuleFetch(request->mURI) WaitForModuleFetch(request->mURI)
@ -988,9 +995,6 @@ ScriptLoader::StartLoad(ScriptLoadRequest *aRequest, const nsAString &aType,
&ModuleLoadRequest::LoadFailed); &ModuleLoadRequest::LoadFailed);
return NS_OK; return NS_OK;
} }
// Otherwise put the URL in the module map and mark it as fetching.
SetModuleFetchStarted(request);
} }
nsContentPolicyType contentPolicyType = aRequest->IsPreload() nsContentPolicyType contentPolicyType = aRequest->IsPreload()
@ -1103,7 +1107,16 @@ ScriptLoader::StartLoad(ScriptLoadRequest *aRequest, const nsAString &aType,
rv = NS_NewIncrementalStreamLoader(getter_AddRefs(loader), handler); rv = NS_NewIncrementalStreamLoader(getter_AddRefs(loader), handler);
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
return channel->AsyncOpen2(loader); rv = channel->AsyncOpen2(loader);
NS_ENSURE_SUCCESS(rv, rv);
if (aRequest->IsModuleRequest()) {
// We successfully started fetching a module so put its URL in the module
// map and mark it as fetching.
SetModuleFetchStarted(aRequest->AsModuleRequest());
}
return NS_OK;
} }
bool bool
@ -1355,8 +1368,8 @@ ScriptLoader::ProcessScriptElement(nsIScriptElement *aElement)
} }
} }
// Should still be in loading stage of script. // Should still be in loading stage of script unless we're loading a module.
NS_ASSERTION(!request->InCompilingStage(), NS_ASSERTION(!request->InCompilingStage() || request->IsModuleRequest(),
"Request should not yet be in compiling stage."); "Request should not yet be in compiling stage.");
request->mJSVersion = version; request->mJSVersion = version;
@ -1904,14 +1917,17 @@ ScriptLoader::FillCompileOptionsForRequest(const AutoJSAPI&jsapi,
aOptions->setMutedErrors(!subsumes); aOptions->setMutedErrors(!subsumes);
} }
JSContext* cx = jsapi.cx(); if (!aRequest->IsModuleRequest()) {
JS::Rooted<JS::Value> elementVal(cx); // Only do this for classic scripts.
MOZ_ASSERT(aRequest->mElement); JSContext* cx = jsapi.cx();
if (NS_SUCCEEDED(nsContentUtils::WrapNative(cx, aRequest->mElement, JS::Rooted<JS::Value> elementVal(cx);
&elementVal, MOZ_ASSERT(aRequest->mElement);
/* aAllowWrapping = */ true))) { if (NS_SUCCEEDED(nsContentUtils::WrapNative(cx, aRequest->mElement,
MOZ_ASSERT(elementVal.isObject()); &elementVal,
aOptions->setElement(&elementVal.toObject()); /* aAllowWrapping = */ true))) {
MOZ_ASSERT(elementVal.isObject());
aOptions->setElement(&elementVal.toObject());
}
} }
return NS_OK; return NS_OK;
@ -2373,7 +2389,7 @@ ScriptLoader::HandleLoadError(ScriptLoadRequest *aRequest, nsresult aResult) {
RefPtr<ScriptLoadRequest> req = mXSLTRequests.Steal(aRequest); RefPtr<ScriptLoadRequest> req = mXSLTRequests.Steal(aRequest);
FireScriptAvailable(aResult, req); FireScriptAvailable(aResult, req);
} }
} else if (aRequest->IsModuleRequest()) { } else if (aRequest->IsModuleRequest() && !aRequest->IsPreload()) {
ModuleLoadRequest* modReq = aRequest->AsModuleRequest(); ModuleLoadRequest* modReq = aRequest->AsModuleRequest();
MOZ_ASSERT(!modReq->IsTopLevel()); MOZ_ASSERT(!modReq->IsTopLevel());
MOZ_ASSERT(!modReq->isInList()); MOZ_ASSERT(!modReq->isInList());
@ -2394,8 +2410,19 @@ ScriptLoader::HandleLoadError(ScriptLoadRequest *aRequest, nsresult aResult) {
FireScriptAvailable(aResult, aRequest); FireScriptAvailable(aResult, aRequest);
ContinueParserAsync(aRequest); ContinueParserAsync(aRequest);
mCurrentParserInsertedScript = oldParserInsertedScript; mCurrentParserInsertedScript = oldParserInsertedScript;
} else if (aRequest->IsPreload()) {
if (aRequest->IsModuleRequest()) {
// If there is an error preloading modules, cancel the load request.
aRequest->Cancel();
}
if (aRequest->IsTopLevel()) {
MOZ_ALWAYS_TRUE(mPreloads.RemoveElement(aRequest, PreloadRequestComparator()));
}
MOZ_ASSERT(!aRequest->isInList());
} else { } else {
mPreloads.RemoveElement(aRequest, PreloadRequestComparator()); // This happens for blocking requests cancelled by ParsingComplete().
MOZ_ASSERT(aRequest->IsCanceled());
MOZ_ASSERT(!aRequest->isInList());
} }
} }
@ -2424,6 +2451,18 @@ ScriptLoader::NumberOfProcessors()
return mNumberOfProcessors; return mNumberOfProcessors;
} }
static bool
IsInternalURIScheme(nsIURI* uri)
{
// Note: Extend this if other schemes need to be included.
bool isResource;
if (NS_SUCCEEDED(uri->SchemeIs("resource", &isResource)) && isResource) {
return true;
}
return false;
}
nsresult nsresult
ScriptLoader::PrepareLoadedRequest(ScriptLoadRequest* aRequest, ScriptLoader::PrepareLoadedRequest(ScriptLoadRequest* aRequest,
nsIIncrementalStreamLoader* aLoader, nsIIncrementalStreamLoader* aLoader,
@ -2511,7 +2550,17 @@ ScriptLoader::PrepareLoadedRequest(ScriptLoadRequest* aRequest,
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
} }
channel->GetURI(getter_AddRefs(request->mBaseURL)); nsCOMPtr<nsIURI> uri;
rv = channel->GetOriginalURI(getter_AddRefs(uri));
NS_ENSURE_SUCCESS(rv, rv);
// Fixup internal scheme URIs like resource:, because the channel URI
// will point to file: which won't be allowed to load.
if (uri && IsInternalURIScheme(uri)) {
request->mBaseURL = uri;
} else {
channel->GetURI(getter_AddRefs(request->mBaseURL));
}
// Attempt to compile off main thread. // Attempt to compile off main thread.
rv = AttemptAsyncScriptCompile(request); rv = AttemptAsyncScriptCompile(request);
@ -2593,18 +2642,31 @@ ScriptLoader::PreloadURI(nsIURI *aURI,
return; return;
} }
ScriptKind scriptKind = ScriptKind::Classic;
if (mDocument->ModuleScriptsEnabled()) { if (mDocument->ModuleScriptsEnabled()) {
// Don't load nomodule scripts. // Don't load nomodule scripts.
if (aNoModule) { if (aNoModule) {
return; return;
} }
// TODO: Preload module scripts. // Preload module scripts.
if (aType.LowerCaseEqualsASCII("module")) { static const char kASCIIWhitespace[] = "\t\n\f\r ";
return;
nsAutoString type(aType);
type.Trim(kASCIIWhitespace);
if (type.LowerCaseEqualsASCII("module")) {
scriptKind = ScriptKind::Module;
} }
} }
if (scriptKind == ScriptKind::Classic &&
!aType.IsEmpty() && !nsContentUtils::IsJavascriptMIMEType(aType)) {
// Unknown type (not type = module and not type = JS MIME type).
// Don't load it.
return;
}
SRIMetadata sriMetadata; SRIMetadata sriMetadata;
if (!aIntegrity.IsEmpty()) { if (!aIntegrity.IsEmpty()) {
MOZ_LOG(SRILogHelper::GetSriLog(), mozilla::LogLevel::Debug, MOZ_LOG(SRILogHelper::GetSriLog(), mozilla::LogLevel::Debug,
@ -2618,7 +2680,7 @@ ScriptLoader::PreloadURI(nsIURI *aURI,
} }
RefPtr<ScriptLoadRequest> request = RefPtr<ScriptLoadRequest> request =
CreateLoadRequest(ScriptKind::Classic, aURI, nullptr, 0, CreateLoadRequest(scriptKind, aURI, nullptr, 0,
Element::StringToCORSMode(aCrossOrigin), sriMetadata, Element::StringToCORSMode(aCrossOrigin), sriMetadata,
aReferrerPolicy); aReferrerPolicy);
request->mIsInline = false; request->mIsInline = false;

View file

@ -173,6 +173,12 @@ public:
return mScriptMode == ScriptMode::eAsync; return mScriptMode == ScriptMode::eAsync;
} }
virtual bool IsTopLevel() const
{
// Classic scripts are always top level.
return true;
}
void MaybeCancelOffThreadScript(); void MaybeCancelOffThreadScript();
using super::getNext; using super::getNext;
@ -500,6 +506,12 @@ public:
return mPendingChildLoaders.AppendElement(aChild) != nullptr; return mPendingChildLoaders.AppendElement(aChild) != nullptr;
} }
/*
* Clear the map of loaded modules. Called when a Document object is reused
* for a different global.
*/
void ClearModuleMap();
private: private:
virtual ~ScriptLoader(); virtual ~ScriptLoader();

View file

@ -1239,6 +1239,7 @@ static const JSFunctionSpec object_static_methods[] = {
JS_FN("isFrozen", obj_isFrozen, 1, 0), JS_FN("isFrozen", obj_isFrozen, 1, 0),
JS_FN("seal", obj_seal, 1, 0), JS_FN("seal", obj_seal, 1, 0),
JS_FN("isSealed", obj_isSealed, 1, 0), JS_FN("isSealed", obj_isSealed, 1, 0),
JS_SELF_HOSTED_FN("fromEntries", "ObjectFromEntries", 1, 0),
JS_FS_END JS_FS_END
}; };

View file

@ -202,3 +202,21 @@ function ObjectLookupGetter(name) {
// Step 3.d. (implicit) // Step 3.d. (implicit)
} }
// Stage 4 draft 2020-09-06 https://tc39.github.io/proposal-object-from-entries/
// Object.fromEntries (iterable)
function ObjectFromEntries(iter) {
// We omit the usual step number comments here because they don't help.
// This implementation inlines AddEntriesFromIterator and
// CreateDataPropertyOnObject, so it looks more like the polyfill
// than the step-by-step spec algorithm.
const obj = {};
for (const pair of allowContentIter(iter)) {
if (!IsObject(pair))
ThrowTypeError(JSMSG_INVALID_MAP_ITERABLE, "Object.fromEntries");
_DefineDataProperty(obj, pair[0], pair[1]);
}
return obj;
}

View file

@ -4708,7 +4708,7 @@ JS::ModuleInstantiate(JSContext* cx, JS::HandleObject moduleArg)
{ {
AssertHeapIsIdle(cx); AssertHeapIsIdle(cx);
CHECK_REQUEST(cx); CHECK_REQUEST(cx);
assertSameCompartment(cx, moduleArg); releaseAssertSameCompartment(cx, moduleArg);
return ModuleObject::Instantiate(cx, moduleArg.as<ModuleObject>()); return ModuleObject::Instantiate(cx, moduleArg.as<ModuleObject>());
} }
@ -4717,7 +4717,7 @@ JS::ModuleEvaluate(JSContext* cx, JS::HandleObject moduleArg)
{ {
AssertHeapIsIdle(cx); AssertHeapIsIdle(cx);
CHECK_REQUEST(cx); CHECK_REQUEST(cx);
assertSameCompartment(cx, moduleArg); releaseAssertSameCompartment(cx, moduleArg);
return ModuleObject::Evaluate(cx, moduleArg.as<ModuleObject>()); return ModuleObject::Evaluate(cx, moduleArg.as<ModuleObject>());
} }
@ -6204,7 +6204,7 @@ JS_SetPendingException(JSContext* cx, HandleValue value)
{ {
AssertHeapIsIdle(cx); AssertHeapIsIdle(cx);
CHECK_REQUEST(cx); CHECK_REQUEST(cx);
assertSameCompartment(cx, value); releaseAssertSameCompartment(cx, value);
cx->setPendingException(value); cx->setPendingException(value);
} }

View file

@ -190,9 +190,9 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=933681
constructorProps(["setPrototypeOf", "getOwnPropertyDescriptor", "getOwnPropertyDescriptors", constructorProps(["setPrototypeOf", "getOwnPropertyDescriptor", "getOwnPropertyDescriptors",
"keys", "is", "defineProperty", "defineProperties", "create", "keys", "is", "defineProperty", "defineProperties", "create",
"getOwnPropertyNames", "getOwnPropertySymbols", "getOwnPropertyNames", "getOwnPropertySymbols",
"preventExtensions", "freeze", "isFrozen", "seal", "preventExtensions", "freeze", "fromEntries", "isFrozen", "seal",
"isSealed", "assign", "getPrototypeOf", "values", "isSealed", "assign", "getPrototypeOf", "values",
"entries", "isExtensible"]) "entries", "isExtensible"]);
gPrototypeProperties['Array'] = gPrototypeProperties['Array'] =
["length", "toSource", "toString", "toLocaleString", "join", "reverse", "sort", "push", ["length", "toSource", "toString", "toLocaleString", "join", "reverse", "sort", "push",
"pop", "shift", "unshift", "splice", "concat", "slice", "lastIndexOf", "indexOf", "pop", "shift", "unshift", "splice", "concat", "slice", "lastIndexOf", "indexOf",

View file

@ -40,10 +40,6 @@
<!ENTITY warning.updatesecurity.enable.label "Enable"> <!ENTITY warning.updatesecurity.enable.label "Enable">
<!ENTITY warning.updatesecurity.enable.tooltip "Enable add-on update security checking"> <!ENTITY warning.updatesecurity.enable.tooltip "Enable add-on update security checking">
<!-- global informations -->
<!ENTITY info.plugincheck.label "Check to see if your plugins are up to date">
<!ENTITY info.plugincheck.tooltip "Check to see if your plugins are up to date">
<!-- categories / views --> <!-- categories / views -->
<!ENTITY view.search.label "Search"> <!ENTITY view.search.label "Search">
<!ENTITY view.discover.label "Get Add-ons"> <!ENTITY view.discover.label "Get Add-ons">

View file

@ -809,15 +809,6 @@ var gViewController = {
} }
}, },
/* Plugincheck service is currently N/A for Pale Moon
cmd_pluginCheck: {
isEnabled: function cmd_pluginCheck_isEnabled() true,
doCommand: function cmd_pluginCheck_doCommand() {
openURL(Services.urlFormatter.formatURLPref("plugins.update.url"));
}
},
*/
cmd_toggleAutoUpdateDefault: { cmd_toggleAutoUpdateDefault: {
isEnabled: function cmd_toggleAutoUpdateDefault_isEnabled() true, isEnabled: function cmd_toggleAutoUpdateDefault_isEnabled() true,
doCommand: function cmd_toggleAutoUpdateDefault_doCommand() { doCommand: function cmd_toggleAutoUpdateDefault_doCommand() {
@ -3028,10 +3019,7 @@ var gDetailView = {
"details.notification.outdated", "details.notification.outdated",
[this._addon.name], 1 [this._addon.name], 1
); );
var warningLink = document.getElementById("detail-warning-link"); document.getElementById("detail-warning-link").hidden = true;
warningLink.value = gStrings.ext.GetStringFromName("details.notification.outdated.link");
warningLink.href = Services.urlFormatter.formatURLPref("plugins.update.url");
warningLink.hidden = false;
} else if (this._addon.blocklistState == Ci.nsIBlocklistService.STATE_VULNERABLE_UPDATE_AVAILABLE) { } else if (this._addon.blocklistState == Ci.nsIBlocklistService.STATE_VULNERABLE_UPDATE_AVAILABLE) {
this.node.setAttribute("notification", "error"); this.node.setAttribute("notification", "error");
document.getElementById("detail-error").textContent = gStrings.ext.formatStringFromName( document.getElementById("detail-error").textContent = gStrings.ext.formatStringFromName(

View file

@ -1329,9 +1329,7 @@
"notification.outdated", "notification.outdated",
[this.mAddon.name], 1 [this.mAddon.name], 1
); );
this._warningLink.value = gStrings.ext.GetStringFromName("notification.outdated.link"); this._warningLink.hidden = true;
this._warningLink.href = Services.urlFormatter.formatURLPref("plugins.update.url");
this._warningLink.hidden = false;
this._warningBtn.hidden = true; this._warningBtn.hidden = true;
} else if (!isUpgrade && this.mAddon.blocklistState == Ci.nsIBlocklistService.STATE_VULNERABLE_UPDATE_AVAILABLE) { } else if (!isUpgrade && this.mAddon.blocklistState == Ci.nsIBlocklistService.STATE_VULNERABLE_UPDATE_AVAILABLE) {
this.setAttribute("notification", "error"); this.setAttribute("notification", "error");

View file

@ -88,7 +88,6 @@
<command id="cmd_back"/> <command id="cmd_back"/>
<command id="cmd_forward"/> <command id="cmd_forward"/>
<command id="cmd_enableCheckCompatibility"/> <command id="cmd_enableCheckCompatibility"/>
<!-- <command id="cmd_pluginCheck"/> -->
<command id="cmd_enableUpdateSecurity"/> <command id="cmd_enableUpdateSecurity"/>
<command id="cmd_toggleAutoUpdateDefault"/> <command id="cmd_toggleAutoUpdateDefault"/>
<command id="cmd_resetAddonAutoUpdate"/> <command id="cmd_resetAddonAutoUpdate"/>
@ -355,15 +354,6 @@
<spacer flex="5000"/> <!-- Necessary to allow the message to wrap --> <spacer flex="5000"/> <!-- Necessary to allow the message to wrap -->
</hbox> </hbox>
</hbox> </hbox>
<!-- <hbox class="view-header global-info-container plugin-info-container">
<hbox class="global-info" flex="1" align="center">
<button class="button-link global-info-plugincheck"
label="&info.plugincheck.label;"
tooltiptext="&info.plugincheck.tooltip;"
command="cmd_pluginCheck"/>
<spacer flex="5000"/>
</hbox>
</hbox> -->
<hbox class="view-header global-info-container experiment-info-container"> <hbox class="view-header global-info-container experiment-info-container">
<hbox class="global-info" flex="1" align="center"> <hbox class="global-info" flex="1" align="center">
<label value="&experiment.info.label;"/> <label value="&experiment.info.label;"/>