mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-27 14:52:16 +00:00
Backed out 5 changesets (bug 1839316) for causing bustages on ScriptLoader.cpp. CLOSED TREE
Backed out changeset 85f107e082ee (bug 1839316) Backed out changeset 8c1e22518c3a (bug 1839316) Backed out changeset a4c3dec0f34c (bug 1839316) Backed out changeset 313ff15742dd (bug 1839316) Backed out changeset fa200e26bbb1 (bug 1839316)
This commit is contained in:
parent
493f922f06
commit
c406bcf318
@ -27,7 +27,6 @@
|
||||
#include "mozilla/dom/Event.h"
|
||||
#include "mozilla/dom/EventTargetBinding.h"
|
||||
#include "mozilla/dom/PopupBlocker.h"
|
||||
#include "mozilla/dom/RequestBinding.h"
|
||||
#include "mozilla/dom/ScriptLoader.h"
|
||||
#include "mozilla/dom/ScriptSettings.h"
|
||||
#include "mozilla/dom/TouchEvent.h"
|
||||
@ -1175,8 +1174,7 @@ nsresult EventListenerManager::CompileEventHandlerInternal(
|
||||
RefPtr<JS::loader::ScriptFetchOptions> fetchOptions =
|
||||
new JS::loader::ScriptFetchOptions(
|
||||
CORS_NONE, aElement->OwnerDoc()->GetReferrerPolicy(),
|
||||
/* aNonce = */ u""_ns, RequestPriority::Auto,
|
||||
JS::loader::ParserMetadata::NotParserInserted,
|
||||
/* aNonce = */ u""_ns, JS::loader::ParserMetadata::NotParserInserted,
|
||||
aElement->OwnerDoc()->NodePrincipal());
|
||||
|
||||
RefPtr<JS::loader::EventScript> eventScript =
|
||||
|
@ -1,13 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "mozilla/dom/FetchPriority.h"
|
||||
|
||||
namespace mozilla::dom {
|
||||
const char* kFetchPriorityAttributeValueHigh = "high";
|
||||
const char* kFetchPriorityAttributeValueLow = "low";
|
||||
const char* kFetchPriorityAttributeValueAuto = "auto";
|
||||
} // namespace mozilla::dom
|
@ -1,23 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifndef mozilla_dom_FetchPriority_h
|
||||
#define mozilla_dom_FetchPriority_h
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
namespace mozilla::dom {
|
||||
|
||||
// <https://html.spec.whatwg.org/multipage/urls-and-fetching.html#fetch-priority-attributes>.
|
||||
enum class FetchPriority : uint8_t { High, Low, Auto };
|
||||
|
||||
extern const char* kFetchPriorityAttributeValueHigh;
|
||||
extern const char* kFetchPriorityAttributeValueLow;
|
||||
extern const char* kFetchPriorityAttributeValueAuto;
|
||||
|
||||
} // namespace mozilla::dom
|
||||
|
||||
#endif // mozilla_dom_FetchPriority_h
|
@ -4,9 +4,6 @@
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "nsAttrValue.h"
|
||||
#include "nsAttrValueOrString.h"
|
||||
#include "nsGenericHTMLElement.h"
|
||||
#include "nsGkAtoms.h"
|
||||
#include "nsStyleConsts.h"
|
||||
#include "mozilla/dom/Document.h"
|
||||
@ -21,10 +18,8 @@
|
||||
#include "nsDOMJSUtils.h"
|
||||
#include "nsIScriptError.h"
|
||||
#include "nsISupportsImpl.h"
|
||||
#include "mozilla/dom/FetchPriority.h"
|
||||
#include "mozilla/dom/HTMLScriptElement.h"
|
||||
#include "mozilla/dom/HTMLScriptElementBinding.h"
|
||||
#include "mozilla/Assertions.h"
|
||||
#include "mozilla/StaticPrefs_dom.h"
|
||||
|
||||
NS_IMPL_NS_NEW_HTML_ELEMENT_CHECK_PARSER(Script)
|
||||
@ -63,19 +58,6 @@ nsresult HTMLScriptElement::BindToTree(BindContext& aContext,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
namespace {
|
||||
// <https://html.spec.whatwg.org/multipage/urls-and-fetching.html#fetch-priority-attributes>.
|
||||
static const nsAttrValue::EnumTable kFetchPriorityEnumTable[] = {
|
||||
{kFetchPriorityAttributeValueHigh, FetchPriority::High},
|
||||
{kFetchPriorityAttributeValueLow, FetchPriority::Low},
|
||||
{kFetchPriorityAttributeValueAuto, FetchPriority::Auto},
|
||||
{nullptr, 0}};
|
||||
|
||||
// <https://html.spec.whatwg.org/multipage/urls-and-fetching.html#fetch-priority-attributes>.
|
||||
static const nsAttrValue::EnumTable*
|
||||
kFetchPriorityEnumTableInvalidValueDefault = &kFetchPriorityEnumTable[2];
|
||||
} // namespace
|
||||
|
||||
bool HTMLScriptElement::ParseAttribute(int32_t aNamespaceID, nsAtom* aAttribute,
|
||||
const nsAString& aValue,
|
||||
nsIPrincipal* aMaybeScriptedPrincipal,
|
||||
@ -90,11 +72,6 @@ bool HTMLScriptElement::ParseAttribute(int32_t aNamespaceID, nsAtom* aAttribute,
|
||||
aResult.ParseStringOrAtom(aValue);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (aAttribute == nsGkAtoms::fetchpriority) {
|
||||
HTMLScriptElement::ParseFetchPriority(aValue, aResult);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return nsGenericHTMLElement::ParseAttribute(aNamespaceID, aAttribute, aValue,
|
||||
@ -225,17 +202,6 @@ CORSMode HTMLScriptElement::GetCORSMode() const {
|
||||
return AttrValueToCORSMode(GetParsedAttr(nsGkAtoms::crossorigin));
|
||||
}
|
||||
|
||||
FetchPriority HTMLScriptElement::GetFetchPriority() const {
|
||||
const nsAttrValue* fetchpriorityAttribute =
|
||||
GetParsedAttr(nsGkAtoms::fetchpriority);
|
||||
if (fetchpriorityAttribute) {
|
||||
MOZ_ASSERT(fetchpriorityAttribute->Type() == nsAttrValue::eEnum);
|
||||
return FetchPriority(fetchpriorityAttribute->GetEnumValue());
|
||||
}
|
||||
|
||||
return FetchPriority::Auto;
|
||||
}
|
||||
|
||||
mozilla::dom::ReferrerPolicy HTMLScriptElement::GetReferrerPolicy() {
|
||||
return GetReferrerPolicyAsEnum();
|
||||
}
|
||||
@ -245,20 +211,6 @@ bool HTMLScriptElement::HasScriptContent() {
|
||||
nsContentUtils::HasNonEmptyTextContent(this);
|
||||
}
|
||||
|
||||
void HTMLScriptElement::GetFetchPriority(nsAString& aFetchPriority) const {
|
||||
// <https://html.spec.whatwg.org/multipage/urls-and-fetching.html#fetch-priority-attributes>.
|
||||
GetEnumAttr(nsGkAtoms::fetchpriority, kFetchPriorityAttributeValueAuto,
|
||||
aFetchPriority);
|
||||
}
|
||||
|
||||
/* static */
|
||||
FetchPriority HTMLScriptElement::ToFetchPriority(const nsAString& aValue) {
|
||||
nsAttrValue attrValue;
|
||||
HTMLScriptElement::ParseFetchPriority(aValue, attrValue);
|
||||
MOZ_ASSERT(attrValue.Type() == nsAttrValue::eEnum);
|
||||
return FetchPriority(attrValue.GetEnumValue());
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/scripting.html#dom-script-supports
|
||||
/* static */
|
||||
bool HTMLScriptElement::Supports(const GlobalObject& aGlobal,
|
||||
@ -269,12 +221,4 @@ bool HTMLScriptElement::Supports(const GlobalObject& aGlobal,
|
||||
aType.EqualsLiteral("importmap"));
|
||||
}
|
||||
|
||||
/* static */
|
||||
void HTMLScriptElement::ParseFetchPriority(const nsAString& aValue,
|
||||
nsAttrValue& aResult) {
|
||||
aResult.ParseEnumValue(aValue, kFetchPriorityEnumTable,
|
||||
false /* aCaseSensitive */,
|
||||
kFetchPriorityEnumTableInvalidValueDefault);
|
||||
}
|
||||
|
||||
} // namespace mozilla::dom
|
||||
|
@ -7,11 +7,9 @@
|
||||
#ifndef mozilla_dom_HTMLScriptElement_h
|
||||
#define mozilla_dom_HTMLScriptElement_h
|
||||
|
||||
#include "mozilla/dom/FetchPriority.h"
|
||||
#include "nsGenericHTMLElement.h"
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "mozilla/dom/ScriptElement.h"
|
||||
#include "nsStringFwd.h"
|
||||
|
||||
namespace mozilla::dom {
|
||||
|
||||
@ -36,7 +34,6 @@ class HTMLScriptElement final : public nsGenericHTMLElement,
|
||||
virtual void GetScriptCharset(nsAString& charset) override;
|
||||
virtual void FreezeExecutionAttrs(const Document* aOwnerDoc) override;
|
||||
virtual CORSMode GetCORSMode() const override;
|
||||
virtual FetchPriority GetFetchPriority() const override;
|
||||
virtual mozilla::dom::ReferrerPolicy GetReferrerPolicy() override;
|
||||
|
||||
// nsIContent
|
||||
@ -131,15 +128,6 @@ class HTMLScriptElement final : public nsGenericHTMLElement,
|
||||
GetEnumAttr(nsGkAtoms::referrerpolicy, "", aReferrerPolicy);
|
||||
}
|
||||
|
||||
void GetFetchPriority(nsAString& aFetchPriority) const;
|
||||
|
||||
void SetFetchPriority(const nsAString& aFetchPriority) {
|
||||
SetHTMLAttr(nsGkAtoms::fetchpriority, aFetchPriority);
|
||||
}
|
||||
|
||||
// <https://html.spec.whatwg.org/#fetch-priority-attribute>.
|
||||
static FetchPriority ToFetchPriority(const nsAString& aValue);
|
||||
|
||||
[[nodiscard]] static bool Supports(const GlobalObject& aGlobal,
|
||||
const nsAString& aType);
|
||||
|
||||
@ -156,9 +144,6 @@ class HTMLScriptElement final : public nsGenericHTMLElement,
|
||||
|
||||
// ScriptElement
|
||||
virtual bool HasScriptContent() override;
|
||||
|
||||
private:
|
||||
static void ParseFetchPriority(const nsAString& aValue, nsAttrValue& aResult);
|
||||
};
|
||||
|
||||
} // namespace mozilla::dom
|
||||
|
@ -43,7 +43,6 @@ EXPORTS.mozilla += [
|
||||
EXPORTS.mozilla.dom += [
|
||||
"ConstraintValidation.h",
|
||||
"ElementInternals.h",
|
||||
"FetchPriority.h",
|
||||
"HTMLAllCollection.h",
|
||||
"HTMLAnchorElement.h",
|
||||
"HTMLAreaElement.h",
|
||||
@ -128,7 +127,6 @@ EXPORTS.mozilla.dom += [
|
||||
UNIFIED_SOURCES += [
|
||||
"ConstraintValidation.cpp",
|
||||
"ElementInternals.cpp",
|
||||
"FetchPriority.cpp",
|
||||
"HTMLAllCollection.cpp",
|
||||
"HTMLAnchorElement.cpp",
|
||||
"HTMLAreaElement.cpp",
|
||||
|
@ -21,7 +21,6 @@
|
||||
#include "js/loader/ScriptLoadRequest.h"
|
||||
#include "js/loader/ModuleLoaderBase.h"
|
||||
#include "js/loader/ModuleLoadRequest.h"
|
||||
#include "mozilla/dom/RequestBinding.h"
|
||||
#include "xpcpublic.h"
|
||||
#include "GeckoProfiler.h"
|
||||
#include "nsContentSecurityManager.h"
|
||||
@ -299,8 +298,8 @@ already_AddRefed<ModuleLoadRequest> ModuleLoader::CreateDynamicImport(
|
||||
// "auto".
|
||||
options = new ScriptFetchOptions(
|
||||
mozilla::CORS_NONE, document->GetReferrerPolicy(),
|
||||
/* aNonce = */ u""_ns, RequestPriority::Auto,
|
||||
ParserMetadata::NotParserInserted, principal, nullptr);
|
||||
/* aNonce = */ u""_ns, ParserMetadata::NotParserInserted, principal,
|
||||
nullptr);
|
||||
baseURL = document->GetDocBaseURI();
|
||||
}
|
||||
|
||||
|
@ -9,10 +9,6 @@
|
||||
#include "ScriptTrace.h"
|
||||
#include "ModuleLoader.h"
|
||||
|
||||
#include "mozilla/Assertions.h"
|
||||
#include "mozilla/dom/FetchPriority.h"
|
||||
#include "mozilla/dom/HTMLScriptElement.h"
|
||||
#include "mozilla/dom/RequestBinding.h"
|
||||
#include "nsIChildChannel.h"
|
||||
#include "zlib.h"
|
||||
|
||||
@ -839,31 +835,16 @@ static bool CSPAllowsInlineScript(nsIScriptElement* aElement,
|
||||
return NS_SUCCEEDED(rv) && allowInlineScript;
|
||||
}
|
||||
|
||||
namespace {
|
||||
constexpr RequestPriority FetchPriorityToRequestPriority(
|
||||
const FetchPriority aFetchPriority) {
|
||||
switch (aFetchPriority) {
|
||||
case FetchPriority::High:
|
||||
return RequestPriority::High;
|
||||
case FetchPriority::Low:
|
||||
return RequestPriority::Low;
|
||||
case FetchPriority::Auto:
|
||||
return RequestPriority::Auto;
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
|
||||
already_AddRefed<ScriptLoadRequest> ScriptLoader::CreateLoadRequest(
|
||||
ScriptKind aKind, nsIURI* aURI, nsIScriptElement* aElement,
|
||||
nsIPrincipal* aTriggeringPrincipal, CORSMode aCORSMode,
|
||||
const nsAString& aNonce, RequestPriority aRequestPriority,
|
||||
const SRIMetadata& aIntegrity, ReferrerPolicy aReferrerPolicy,
|
||||
ParserMetadata aParserMetadata) {
|
||||
const nsAString& aNonce, const SRIMetadata& aIntegrity,
|
||||
ReferrerPolicy aReferrerPolicy, ParserMetadata aParserMetadata) {
|
||||
nsIURI* referrer = mDocument->GetDocumentURIAsReferrer();
|
||||
nsCOMPtr<Element> domElement = do_QueryInterface(aElement);
|
||||
RefPtr<ScriptFetchOptions> fetchOptions = new ScriptFetchOptions(
|
||||
aCORSMode, aReferrerPolicy, aNonce, aRequestPriority, aParserMetadata,
|
||||
aTriggeringPrincipal, domElement);
|
||||
RefPtr<ScriptFetchOptions> fetchOptions =
|
||||
new ScriptFetchOptions(aCORSMode, aReferrerPolicy, aNonce,
|
||||
aParserMetadata, aTriggeringPrincipal, domElement);
|
||||
RefPtr<ScriptLoadContext> context = new ScriptLoadContext();
|
||||
|
||||
if (aKind == ScriptKind::eClassic || aKind == ScriptKind::eImportMap) {
|
||||
@ -1038,14 +1019,12 @@ bool ScriptLoader::ProcessExternalScript(nsIScriptElement* aElement,
|
||||
}
|
||||
|
||||
CORSMode ourCORSMode = aElement->GetCORSMode();
|
||||
const FetchPriority fetchPriority = aElement->GetFetchPriority();
|
||||
ReferrerPolicy referrerPolicy = GetReferrerPolicy(aElement);
|
||||
ParserMetadata parserMetadata = GetParserMetadata(aElement);
|
||||
|
||||
request = CreateLoadRequest(aScriptKind, scriptURI, aElement, principal,
|
||||
ourCORSMode, nonce,
|
||||
FetchPriorityToRequestPriority(fetchPriority),
|
||||
sriMetadata, referrerPolicy, parserMetadata);
|
||||
ourCORSMode, nonce, sriMetadata, referrerPolicy,
|
||||
parserMetadata);
|
||||
request->GetScriptLoadContext()->mIsInline = false;
|
||||
request->GetScriptLoadContext()->SetScriptMode(
|
||||
aElement->GetScriptDeferred(), aElement->GetScriptAsync(), false);
|
||||
@ -1212,18 +1191,12 @@ bool ScriptLoader::ProcessInlineScript(nsIScriptElement* aElement,
|
||||
if (aScriptKind == ScriptKind::eModule) {
|
||||
corsMode = aElement->GetCORSMode();
|
||||
}
|
||||
// <https://html.spec.whatwg.org/multipage/scripting.html#prepare-the-script-element>
|
||||
// step 29 specifies to use the fetch priority. Presumably it has no effect
|
||||
// for inline scripts.
|
||||
const auto fetchPriority = aElement->GetFetchPriority();
|
||||
|
||||
ReferrerPolicy referrerPolicy = GetReferrerPolicy(aElement);
|
||||
ParserMetadata parserMetadata = GetParserMetadata(aElement);
|
||||
|
||||
RefPtr<ScriptLoadRequest> request =
|
||||
CreateLoadRequest(aScriptKind, mDocument->GetDocumentURI(), aElement,
|
||||
mDocument->NodePrincipal(), corsMode, nonce,
|
||||
FetchPriorityToRequestPriority(fetchPriority),
|
||||
SRIMetadata(), // SRI doesn't apply
|
||||
referrerPolicy, parserMetadata);
|
||||
request->GetScriptLoadContext()->mIsInline = true;
|
||||
@ -3571,9 +3544,8 @@ void ScriptLoader::ParsingComplete(bool aTerminated) {
|
||||
void ScriptLoader::PreloadURI(
|
||||
nsIURI* aURI, const nsAString& aCharset, const nsAString& aType,
|
||||
const nsAString& aCrossOrigin, const nsAString& aNonce,
|
||||
const nsAString& aFetchPriority, const nsAString& aIntegrity,
|
||||
bool aScriptFromHead, bool aAsync, bool aDefer, bool aNoModule,
|
||||
bool aLinkPreload, const ReferrerPolicy aReferrerPolicy,
|
||||
const nsAString& aIntegrity, bool aScriptFromHead, bool aAsync, bool aDefer,
|
||||
bool aNoModule, bool aLinkPreload, const ReferrerPolicy aReferrerPolicy,
|
||||
uint64_t aEarlyHintPreloaderId) {
|
||||
NS_ENSURE_TRUE_VOID(mDocument);
|
||||
// Check to see if scripts has been turned off.
|
||||
@ -3605,9 +3577,6 @@ void ScriptLoader::PreloadURI(
|
||||
SRIMetadata sriMetadata;
|
||||
GetSRIMetadata(aIntegrity, &sriMetadata);
|
||||
|
||||
const auto requestPriority = FetchPriorityToRequestPriority(
|
||||
HTMLScriptElement::ToFetchPriority(aFetchPriority));
|
||||
|
||||
// For link type "modulepreload":
|
||||
// https://html.spec.whatwg.org/multipage/links.html#link-type-modulepreload
|
||||
// Step 11. Let options be a script fetch options whose cryptographic nonce is
|
||||
@ -3621,7 +3590,7 @@ void ScriptLoader::PreloadURI(
|
||||
RefPtr<ScriptLoadRequest> request =
|
||||
CreateLoadRequest(scriptKind, aURI, nullptr, mDocument->NodePrincipal(),
|
||||
Element::StringToCORSMode(aCrossOrigin), aNonce,
|
||||
requestPriority, sriMetadata, aReferrerPolicy,
|
||||
sriMetadata, aReferrerPolicy,
|
||||
aLinkPreload ? ParserMetadata::NotParserInserted
|
||||
: ParserMetadata::ParserInserted);
|
||||
request->GetScriptLoadContext()->mIsInline = false;
|
||||
|
@ -79,7 +79,6 @@ class ScriptLoader;
|
||||
class ScriptRequestProcessor;
|
||||
|
||||
enum class ReferrerPolicy : uint8_t;
|
||||
enum class RequestPriority : uint8_t;
|
||||
|
||||
class AsyncCompileShutdownObserver final : public nsIObserver {
|
||||
~AsyncCompileShutdownObserver() { Unregister(); }
|
||||
@ -374,19 +373,14 @@ class ScriptLoader final : public JS::loader::ScriptLoaderInterface {
|
||||
* @param aType The type parameter for the script.
|
||||
* @param aCrossOrigin The crossorigin attribute for the script.
|
||||
* Void if not present.
|
||||
* @param aFetchPriority
|
||||
* <https://html.spec.whatwg.org/#the-script-element:attr-script-fetchpriority>.
|
||||
* @param aIntegrity The expect hash url, if avail, of the request
|
||||
|
||||
* @param aScriptFromHead Whether or not the script was a child of head
|
||||
*/
|
||||
virtual void PreloadURI(nsIURI* aURI, const nsAString& aCharset,
|
||||
const nsAString& aType, const nsAString& aCrossOrigin,
|
||||
const nsAString& aNonce,
|
||||
const nsAString& aFetchPriority,
|
||||
const nsAString& aIntegrity, bool aScriptFromHead,
|
||||
bool aAsync, bool aDefer, bool aNoModule,
|
||||
bool aLinkPreload,
|
||||
const nsAString& aNonce, const nsAString& aIntegrity,
|
||||
bool aScriptFromHead, bool aAsync, bool aDefer,
|
||||
bool aNoModule, bool aLinkPreload,
|
||||
const ReferrerPolicy aReferrerPolicy,
|
||||
uint64_t aEarlyHintPreloaderId);
|
||||
|
||||
@ -435,8 +429,8 @@ class ScriptLoader final : public JS::loader::ScriptLoaderInterface {
|
||||
already_AddRefed<ScriptLoadRequest> CreateLoadRequest(
|
||||
ScriptKind aKind, nsIURI* aURI, nsIScriptElement* aElement,
|
||||
nsIPrincipal* aTriggeringPrincipal, mozilla::CORSMode aCORSMode,
|
||||
const nsAString& aNonce, RequestPriority aRequestPriority,
|
||||
const SRIMetadata& aIntegrity, ReferrerPolicy aReferrerPolicy,
|
||||
const nsAString& aNonce, const SRIMetadata& aIntegrity,
|
||||
ReferrerPolicy aReferrerPolicy,
|
||||
JS::loader::ParserMetadata aParserMetadata);
|
||||
|
||||
/**
|
||||
|
@ -29,7 +29,6 @@ class nsIURI;
|
||||
|
||||
namespace mozilla::dom {
|
||||
class Document;
|
||||
enum class FetchPriority : uint8_t;
|
||||
enum class ReferrerPolicy : uint8_t;
|
||||
} // namespace mozilla::dom
|
||||
|
||||
@ -237,13 +236,6 @@ class nsIScriptElement : public nsIScriptLoaderObserver {
|
||||
return mozilla::CORS_NONE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the fetch priority
|
||||
* (https://html.spec.whatwg.org/multipage/scripting.html#attr-script-fetchpriority)
|
||||
* of the script element.
|
||||
*/
|
||||
virtual mozilla::dom::FetchPriority GetFetchPriority() const = 0;
|
||||
|
||||
/**
|
||||
* Get referrer policy of the script element
|
||||
*/
|
||||
|
@ -6,7 +6,6 @@
|
||||
|
||||
#include "mozilla/dom/SVGScriptElement.h"
|
||||
|
||||
#include "mozilla/dom/FetchPriority.h"
|
||||
#include "nsGkAtoms.h"
|
||||
#include "nsNetUtil.h"
|
||||
#include "nsContentUtils.h"
|
||||
@ -215,9 +214,4 @@ CORSMode SVGScriptElement::GetCORSMode() const {
|
||||
return AttrValueToCORSMode(GetParsedAttr(nsGkAtoms::crossorigin));
|
||||
}
|
||||
|
||||
FetchPriority SVGScriptElement::GetFetchPriority() const {
|
||||
// <https://github.com/w3c/svgwg/issues/916>.
|
||||
return FetchPriority::Auto;
|
||||
}
|
||||
|
||||
} // namespace mozilla::dom
|
||||
|
@ -43,7 +43,6 @@ class SVGScriptElement final : public SVGScriptElementBase,
|
||||
void GetScriptCharset(nsAString& charset) override;
|
||||
void FreezeExecutionAttrs(const Document* aOwnerDoc) override;
|
||||
CORSMode GetCORSMode() const override;
|
||||
FetchPriority GetFetchPriority() const override;
|
||||
|
||||
// ScriptElement
|
||||
bool HasScriptContent() override;
|
||||
|
@ -30,8 +30,6 @@ interface HTMLScriptElement : HTMLElement {
|
||||
attribute DOMString referrerPolicy;
|
||||
[CEReactions, Throws]
|
||||
attribute DOMString text;
|
||||
[Pref="network.fetchpriority.enabled", CEReactions]
|
||||
attribute DOMString fetchPriority;
|
||||
|
||||
static boolean supports(DOMString type);
|
||||
};
|
||||
|
@ -46,7 +46,6 @@ interface Request {
|
||||
};
|
||||
Request includes Body;
|
||||
|
||||
// <https://fetch.spec.whatwg.org/#requestinit>.
|
||||
dictionary RequestInit {
|
||||
ByteString method;
|
||||
HeadersInit headers;
|
||||
@ -79,4 +78,3 @@ enum RequestMode { "same-origin", "no-cors", "cors", "navigate" };
|
||||
enum RequestCredentials { "omit", "same-origin", "include" };
|
||||
enum RequestCache { "default", "no-store", "reload", "no-cache", "force-cache", "only-if-cached" };
|
||||
enum RequestRedirect { "follow", "error", "manual" };
|
||||
enum RequestPriority { "high" , "low" , "auto" };
|
||||
|
@ -9,7 +9,6 @@
|
||||
#include <algorithm>
|
||||
#include <type_traits>
|
||||
|
||||
#include "mozilla/dom/RequestBinding.h"
|
||||
#include "nsIChannel.h"
|
||||
#include "nsIContentPolicy.h"
|
||||
#include "nsIContentSecurityPolicy.h"
|
||||
@ -654,7 +653,7 @@ already_AddRefed<ScriptLoadRequest> WorkerScriptLoader::CreateScriptLoadRequest(
|
||||
// policy is the empty string, and fetch priority is "auto".
|
||||
RefPtr<ScriptFetchOptions> fetchOptions = new ScriptFetchOptions(
|
||||
CORSMode::CORS_NONE, referrerPolicy, /* aNonce = */ u""_ns,
|
||||
RequestPriority::Auto, ParserMetadata::NotParserInserted, nullptr);
|
||||
ParserMetadata::NotParserInserted, nullptr);
|
||||
|
||||
RefPtr<ScriptLoadRequest> request = nullptr;
|
||||
// Bug 1817259 - For now the debugger scripts are always loaded a Classic.
|
||||
|
@ -6,7 +6,6 @@
|
||||
|
||||
#include "js/experimental/JSStencil.h" // JS::Stencil, JS::CompileModuleScriptToStencil, JS::InstantiateModuleStencil
|
||||
#include "js/loader/ModuleLoadRequest.h"
|
||||
#include "mozilla/dom/RequestBinding.h"
|
||||
#include "mozilla/dom/WorkerLoadContext.h"
|
||||
#include "mozilla/dom/WorkerPrivate.h"
|
||||
#include "mozilla/dom/workerinternals/ScriptLoader.h"
|
||||
@ -118,8 +117,8 @@ already_AddRefed<ModuleLoadRequest> WorkerModuleLoader::CreateDynamicImport(
|
||||
ReferrerPolicy referrerPolicy = workerPrivate->GetReferrerPolicy();
|
||||
options = new ScriptFetchOptions(
|
||||
CORSMode::CORS_NONE, referrerPolicy,
|
||||
/* aNonce = */ u""_ns, RequestPriority::Auto,
|
||||
JS::loader::ParserMetadata::NotParserInserted, nullptr);
|
||||
/* aNonce = */ u""_ns, JS::loader::ParserMetadata::NotParserInserted,
|
||||
nullptr);
|
||||
baseURL = GetBaseURI();
|
||||
}
|
||||
|
||||
|
@ -9,7 +9,6 @@
|
||||
#include "mozilla/dom/Document.h"
|
||||
#include "mozilla/dom/Fetch.h"
|
||||
#include "mozilla/dom/Request.h"
|
||||
#include "mozilla/dom/RequestBinding.h"
|
||||
#include "mozilla/dom/Response.h"
|
||||
#include "mozilla/dom/RootedDictionary.h"
|
||||
#include "mozilla/dom/ScriptLoader.h"
|
||||
@ -95,7 +94,7 @@ NS_IMETHODIMP StartModuleLoadRunnable::RunOnWorkletThread() {
|
||||
// policy is the empty string, and fetch priority is "auto".
|
||||
RefPtr<ScriptFetchOptions> fetchOptions = new ScriptFetchOptions(
|
||||
CORSMode::CORS_NONE, ReferrerPolicy::_empty, /* aNonce = */ u""_ns,
|
||||
RequestPriority::Auto, ParserMetadata::NotParserInserted,
|
||||
ParserMetadata::NotParserInserted,
|
||||
/*triggeringPrincipal*/ nullptr);
|
||||
|
||||
WorkletModuleLoader* moduleLoader =
|
||||
|
@ -37,13 +37,11 @@ NS_IMPL_CYCLE_COLLECTION(ScriptFetchOptions, mTriggeringPrincipal, mElement)
|
||||
|
||||
ScriptFetchOptions::ScriptFetchOptions(
|
||||
mozilla::CORSMode aCORSMode, mozilla::dom::ReferrerPolicy aReferrerPolicy,
|
||||
const nsAString& aNonce, mozilla::dom::RequestPriority aFetchPriority,
|
||||
const ParserMetadata aParserMetadata, nsIPrincipal* aTriggeringPrincipal,
|
||||
mozilla::dom::Element* aElement)
|
||||
const nsAString& aNonce, const ParserMetadata aParserMetadata,
|
||||
nsIPrincipal* aTriggeringPrincipal, mozilla::dom::Element* aElement)
|
||||
: mCORSMode(aCORSMode),
|
||||
mReferrerPolicy(aReferrerPolicy),
|
||||
mNonce(aNonce),
|
||||
mFetchPriority(aFetchPriority),
|
||||
mParserMetadata(aParserMetadata),
|
||||
mTriggeringPrincipal(aTriggeringPrincipal),
|
||||
mElement(aElement) {}
|
||||
|
@ -37,7 +37,6 @@ namespace mozilla::dom {
|
||||
class ScriptLoadContext;
|
||||
class WorkerLoadContext;
|
||||
class WorkletLoadContext;
|
||||
enum class RequestPriority : uint8_t;
|
||||
|
||||
} // namespace mozilla::dom
|
||||
|
||||
@ -89,7 +88,6 @@ class ScriptFetchOptions {
|
||||
ScriptFetchOptions(mozilla::CORSMode aCORSMode,
|
||||
enum mozilla::dom::ReferrerPolicy aReferrerPolicy,
|
||||
const nsAString& aNonce,
|
||||
mozilla::dom::RequestPriority aFetchPriority,
|
||||
const ParserMetadata aParserMetadata,
|
||||
nsIPrincipal* aTriggeringPrincipal,
|
||||
mozilla::dom::Element* aElement = nullptr);
|
||||
@ -113,11 +111,6 @@ class ScriptFetchOptions {
|
||||
*/
|
||||
const nsString mNonce;
|
||||
|
||||
/*
|
||||
* <https://html.spec.whatwg.org/multipage/webappapis.html#script-fetch-options>.
|
||||
*/
|
||||
const mozilla::dom::RequestPriority mFetchPriority;
|
||||
|
||||
/*
|
||||
* The parser metadata used for the initial fetch and for fetching any
|
||||
* imported modules
|
||||
@ -301,10 +294,6 @@ class ScriptLoadRequest
|
||||
: ScriptText<Utf8Unit>().clearAndFree();
|
||||
}
|
||||
|
||||
mozilla::dom::RequestPriority FetchPriority() const {
|
||||
return mFetchOptions->mFetchPriority;
|
||||
}
|
||||
|
||||
enum mozilla::dom::ReferrerPolicy ReferrerPolicy() const {
|
||||
return mFetchOptions->mReferrerPolicy;
|
||||
}
|
||||
|
@ -4,7 +4,6 @@
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "ScriptLoadRequest.h"
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "mozilla/ArrayUtils.h" // mozilla::ArrayLength
|
||||
#include "mozilla/Utf8.h" // mozilla::Utf8Unit
|
||||
@ -12,7 +11,6 @@
|
||||
#include <cstdarg>
|
||||
|
||||
#include "mozilla/Logging.h"
|
||||
#include "mozilla/dom/RequestBinding.h"
|
||||
#ifdef ANDROID
|
||||
# include <android/log.h>
|
||||
#endif
|
||||
@ -1806,10 +1804,9 @@ nsresult mozJSModuleLoader::ImportESModule(
|
||||
mModuleLoader->GetGlobalObject()->PrincipalOrNull();
|
||||
MOZ_ASSERT(principal);
|
||||
|
||||
RefPtr<ScriptFetchOptions> options =
|
||||
new ScriptFetchOptions(CORS_NONE, dom::ReferrerPolicy::No_referrer,
|
||||
/* aNonce = */ u""_ns, dom::RequestPriority::Auto,
|
||||
ParserMetadata::NotParserInserted, principal);
|
||||
RefPtr<ScriptFetchOptions> options = new ScriptFetchOptions(
|
||||
CORS_NONE, dom::ReferrerPolicy::No_referrer,
|
||||
/* aNonce = */ u""_ns, ParserMetadata::NotParserInserted, principal);
|
||||
|
||||
RefPtr<ComponentLoadContext> context = new ComponentLoadContext();
|
||||
context->mSkipCheck = aSkipCheck;
|
||||
|
@ -78,7 +78,7 @@ class mozJSModuleLoader final : public nsIMemoryReporter {
|
||||
JS::MutableHandleObject aModuleExports,
|
||||
bool aIgnoreExports = false);
|
||||
|
||||
// Synchronously load an ES6 module and all its dependencies.
|
||||
// Load an ES6 module and all its dependencies.
|
||||
nsresult ImportESModule(
|
||||
JSContext* aCx, const nsACString& aResourceURI,
|
||||
JS::MutableHandleObject aModuleNamespace,
|
||||
|
@ -11728,13 +11728,6 @@
|
||||
value: false
|
||||
mirror: always
|
||||
|
||||
# Indicates whether the `fetchpriority` attribute for elements which support it
|
||||
# (e.g. `<script>`) is enabled.
|
||||
- name: network.fetchpriority.enabled
|
||||
type: bool
|
||||
value: false
|
||||
mirror: always
|
||||
|
||||
# Enables `<link rel="preload">` tag and `Link: rel=preload` response header
|
||||
# handling.
|
||||
- name: network.preload
|
||||
|
@ -63,33 +63,33 @@ void nsHtml5SpeculativeLoad::Perform(nsHtml5TreeOpExecutor* aExecutor) {
|
||||
aExecutor->PreloadScript(
|
||||
mUrlOrSizes, mCharsetOrSrcset,
|
||||
mTypeOrCharsetSourceOrDocumentModeOrMetaCSPOrSizesOrIntegrity,
|
||||
mCrossOrigin, mMedia, mNonce, mFetchPriority,
|
||||
mReferrerPolicyOrIntegrity, mScriptReferrerPolicy, false, mIsAsync,
|
||||
mIsDefer, false, mIsLinkPreload);
|
||||
mCrossOrigin, mMedia, mNonce, mReferrerPolicyOrIntegrity,
|
||||
mScriptReferrerPolicy, false, mIsAsync, mIsDefer, false,
|
||||
mIsLinkPreload);
|
||||
break;
|
||||
case eSpeculativeLoadScriptFromHead:
|
||||
aExecutor->PreloadScript(
|
||||
mUrlOrSizes, mCharsetOrSrcset,
|
||||
mTypeOrCharsetSourceOrDocumentModeOrMetaCSPOrSizesOrIntegrity,
|
||||
mCrossOrigin, mMedia, mNonce, mFetchPriority,
|
||||
mReferrerPolicyOrIntegrity, mScriptReferrerPolicy, true, mIsAsync,
|
||||
mIsDefer, false, mIsLinkPreload);
|
||||
mCrossOrigin, mMedia, mNonce, mReferrerPolicyOrIntegrity,
|
||||
mScriptReferrerPolicy, true, mIsAsync, mIsDefer, false,
|
||||
mIsLinkPreload);
|
||||
break;
|
||||
case eSpeculativeLoadNoModuleScript:
|
||||
aExecutor->PreloadScript(
|
||||
mUrlOrSizes, mCharsetOrSrcset,
|
||||
mTypeOrCharsetSourceOrDocumentModeOrMetaCSPOrSizesOrIntegrity,
|
||||
mCrossOrigin, mMedia, mNonce, mFetchPriority,
|
||||
mReferrerPolicyOrIntegrity, mScriptReferrerPolicy, false, mIsAsync,
|
||||
mIsDefer, true, mIsLinkPreload);
|
||||
mCrossOrigin, mMedia, mNonce, mReferrerPolicyOrIntegrity,
|
||||
mScriptReferrerPolicy, false, mIsAsync, mIsDefer, true,
|
||||
mIsLinkPreload);
|
||||
break;
|
||||
case eSpeculativeLoadNoModuleScriptFromHead:
|
||||
aExecutor->PreloadScript(
|
||||
mUrlOrSizes, mCharsetOrSrcset,
|
||||
mTypeOrCharsetSourceOrDocumentModeOrMetaCSPOrSizesOrIntegrity,
|
||||
mCrossOrigin, mMedia, mNonce, mFetchPriority,
|
||||
mReferrerPolicyOrIntegrity, mScriptReferrerPolicy, true, mIsAsync,
|
||||
mIsDefer, true, mIsLinkPreload);
|
||||
mCrossOrigin, mMedia, mNonce, mReferrerPolicyOrIntegrity,
|
||||
mScriptReferrerPolicy, true, mIsAsync, mIsDefer, true,
|
||||
mIsLinkPreload);
|
||||
break;
|
||||
case eSpeculativeLoadStyle:
|
||||
aExecutor->PreloadStyle(
|
||||
|
@ -169,7 +169,7 @@ class nsHtml5SpeculativeLoad {
|
||||
inline void InitScript(nsHtml5String aUrl, nsHtml5String aCharset,
|
||||
nsHtml5String aType, nsHtml5String aCrossOrigin,
|
||||
nsHtml5String aMedia, nsHtml5String aNonce,
|
||||
nsHtml5String aFetchPriority, nsHtml5String aIntegrity,
|
||||
nsHtml5String aIntegrity,
|
||||
nsHtml5String aReferrerPolicy, bool aParserInHead,
|
||||
bool aAsync, bool aDefer, bool aNoModule,
|
||||
bool aLinkPreload) {
|
||||
@ -189,7 +189,6 @@ class nsHtml5SpeculativeLoad {
|
||||
aCrossOrigin.ToString(mCrossOrigin);
|
||||
aMedia.ToString(mMedia);
|
||||
aNonce.ToString(mNonce);
|
||||
aFetchPriority.ToString(mFetchPriority);
|
||||
aIntegrity.ToString(mReferrerPolicyOrIntegrity);
|
||||
nsAutoString referrerPolicy;
|
||||
aReferrerPolicy.ToString(referrerPolicy);
|
||||
@ -416,12 +415,6 @@ class nsHtml5SpeculativeLoad {
|
||||
* of the "nonce" attribute.
|
||||
*/
|
||||
nsString mNonce;
|
||||
/**
|
||||
* If mOpCode is eSpeculativeLoadNoModuleScript[FromHead] or
|
||||
* eSpeculativeLoadScript[FromHead] this represents the value of the
|
||||
* "fetchpriority" attribute.
|
||||
*/
|
||||
nsString mFetchPriority;
|
||||
/**
|
||||
* If mOpCode is eSpeculativeLoadScript[FromHead] this represents the value
|
||||
* of the "referrerpolicy" attribute. This field holds one of the values
|
||||
|
@ -6,10 +6,7 @@
|
||||
|
||||
#include "ErrorList.h"
|
||||
#include "nsError.h"
|
||||
#include "nsHtml5AttributeName.h"
|
||||
#include "nsHtml5String.h"
|
||||
#include "nsNetUtil.h"
|
||||
#include "mozilla/dom/FetchPriority.h"
|
||||
#include "mozilla/CheckedInt.h"
|
||||
#include "mozilla/Likely.h"
|
||||
#include "mozilla/StaticPrefs_dom.h"
|
||||
@ -254,8 +251,6 @@ nsIContentHandle* nsHtml5TreeBuilder::createElement(
|
||||
aAttributes->getValue(nsHtml5AttributeName::ATTR_CROSSORIGIN);
|
||||
nsHtml5String nonce =
|
||||
aAttributes->getValue(nsHtml5AttributeName::ATTR_NONCE);
|
||||
nsHtml5String fetchPriority =
|
||||
aAttributes->getValue(nsHtml5AttributeName::ATTR_FETCHPRIORITY);
|
||||
nsHtml5String integrity =
|
||||
aAttributes->getValue(nsHtml5AttributeName::ATTR_INTEGRITY);
|
||||
nsHtml5String referrerPolicy = aAttributes->getValue(
|
||||
@ -268,9 +263,8 @@ nsIContentHandle* nsHtml5TreeBuilder::createElement(
|
||||
aAttributes->contains(nsHtml5AttributeName::ATTR_NOMODULE);
|
||||
mSpeculativeLoadQueue.AppendElement()->InitScript(
|
||||
url, charset, type, crossOrigin, /* aMedia = */ nullptr, nonce,
|
||||
fetchPriority, integrity, referrerPolicy,
|
||||
mode == nsHtml5TreeBuilder::IN_HEAD, async, defer, noModule,
|
||||
false);
|
||||
integrity, referrerPolicy, mode == nsHtml5TreeBuilder::IN_HEAD,
|
||||
async, defer, noModule, false);
|
||||
mCurrentHtmlScriptIsAsyncOrDefer = async || defer;
|
||||
}
|
||||
} else if (nsGkAtoms::link == aName) {
|
||||
@ -338,17 +332,8 @@ nsIContentHandle* nsHtml5TreeBuilder::createElement(
|
||||
if (as.LowerCaseEqualsASCII("script")) {
|
||||
nsHtml5String type =
|
||||
aAttributes->getValue(nsHtml5AttributeName::ATTR_TYPE);
|
||||
|
||||
// Bug 1839315: get the attribute's value instead.
|
||||
// Use the empty string and rely on the
|
||||
// "invalid value default" state being used later.
|
||||
// Compared to using a non-empty string, this doesn't
|
||||
// require calling `Release()` for the string.
|
||||
nsHtml5String fetchPriority = nsHtml5String::EmptyString();
|
||||
|
||||
mSpeculativeLoadQueue.AppendElement()->InitScript(
|
||||
url, charset, type, crossOrigin, media, nonce,
|
||||
/* aFetchPriority */ fetchPriority, integrity,
|
||||
url, charset, type, crossOrigin, media, nonce, integrity,
|
||||
referrerPolicy, mode == nsHtml5TreeBuilder::IN_HEAD,
|
||||
false, false, false, true);
|
||||
} else if (as.LowerCaseEqualsASCII("style")) {
|
||||
@ -398,17 +383,8 @@ nsIContentHandle* nsHtml5TreeBuilder::createElement(
|
||||
nsHtml5AttributeName::ATTR_INTEGRITY);
|
||||
nsHtml5String referrerPolicy = aAttributes->getValue(
|
||||
nsHtml5AttributeName::ATTR_REFERRERPOLICY);
|
||||
|
||||
// Bug 1839315: get the attribute's value instead.
|
||||
// Use the empty string and rely on the
|
||||
// "invalid value default" state being used later.
|
||||
// Compared to using a non-empty string, this doesn't
|
||||
// require calling `Release()` for the string.
|
||||
nsHtml5String fetchPriority = nsHtml5String::EmptyString();
|
||||
|
||||
mSpeculativeLoadQueue.AppendElement()->InitScript(
|
||||
url, charset, type, crossOrigin, media, nonce,
|
||||
/* aFetchPriority */ fetchPriority, integrity,
|
||||
url, charset, type, crossOrigin, media, nonce, integrity,
|
||||
referrerPolicy, mode == nsHtml5TreeBuilder::IN_HEAD,
|
||||
false, false, false, true);
|
||||
}
|
||||
@ -507,20 +483,10 @@ nsIContentHandle* nsHtml5TreeBuilder::createElement(
|
||||
aAttributes->getValue(nsHtml5AttributeName::ATTR_INTEGRITY);
|
||||
nsHtml5String referrerPolicy = aAttributes->getValue(
|
||||
nsHtml5AttributeName::ATTR_REFERRERPOLICY);
|
||||
|
||||
// Bug 1847712: SVG's `<script>` element doesn't support
|
||||
// `fetchpriority` yet.
|
||||
// Use the empty string and rely on the
|
||||
// "invalid value default" state being used later.
|
||||
// Compared to using a non-empty string, this doesn't
|
||||
// require calling `Release()` for the string.
|
||||
nsHtml5String fetchPriority = nsHtml5String::EmptyString();
|
||||
|
||||
mSpeculativeLoadQueue.AppendElement()->InitScript(
|
||||
url, nullptr, type, crossOrigin, /* aMedia = */ nullptr, nonce,
|
||||
fetchPriority, integrity, referrerPolicy,
|
||||
mode == nsHtml5TreeBuilder::IN_HEAD, false, false, false,
|
||||
false);
|
||||
integrity, referrerPolicy, mode == nsHtml5TreeBuilder::IN_HEAD,
|
||||
false, false, false, false);
|
||||
}
|
||||
} else if (nsGkAtoms::style == aName) {
|
||||
mImportScanner.Start();
|
||||
|
@ -1205,10 +1205,9 @@ dom::ReferrerPolicy nsHtml5TreeOpExecutor::GetPreloadReferrerPolicy(
|
||||
void nsHtml5TreeOpExecutor::PreloadScript(
|
||||
const nsAString& aURL, const nsAString& aCharset, const nsAString& aType,
|
||||
const nsAString& aCrossOrigin, const nsAString& aMedia,
|
||||
const nsAString& aNonce, const nsAString& aFetchPriority,
|
||||
const nsAString& aIntegrity, dom::ReferrerPolicy aReferrerPolicy,
|
||||
bool aScriptFromHead, bool aAsync, bool aDefer, bool aNoModule,
|
||||
bool aLinkPreload) {
|
||||
const nsAString& aNonce, const nsAString& aIntegrity,
|
||||
dom::ReferrerPolicy aReferrerPolicy, bool aScriptFromHead, bool aAsync,
|
||||
bool aDefer, bool aNoModule, bool aLinkPreload) {
|
||||
nsCOMPtr<nsIURI> uri = ConvertIfNotPreloadedYetAndMediaApplies(aURL, aMedia);
|
||||
if (!uri) {
|
||||
return;
|
||||
@ -1218,8 +1217,8 @@ void nsHtml5TreeOpExecutor::PreloadScript(
|
||||
return;
|
||||
}
|
||||
mDocument->ScriptLoader()->PreloadURI(
|
||||
uri, aCharset, aType, aCrossOrigin, aNonce, aFetchPriority, aIntegrity,
|
||||
aScriptFromHead, aAsync, aDefer, aNoModule, aLinkPreload,
|
||||
uri, aCharset, aType, aCrossOrigin, aNonce, aIntegrity, aScriptFromHead,
|
||||
aAsync, aDefer, aNoModule, aLinkPreload,
|
||||
GetPreloadReferrerPolicy(aReferrerPolicy), 0);
|
||||
}
|
||||
|
||||
|
@ -246,7 +246,6 @@ class nsHtml5TreeOpExecutor final
|
||||
void PreloadScript(const nsAString& aURL, const nsAString& aCharset,
|
||||
const nsAString& aType, const nsAString& aCrossOrigin,
|
||||
const nsAString& aMedia, const nsAString& aNonce,
|
||||
const nsAString& aFetchPriority,
|
||||
const nsAString& aIntegrity,
|
||||
ReferrerPolicy aReferrerPolicy, bool aScriptFromHead,
|
||||
bool aAsync, bool aDefer, bool aNoModule,
|
||||
|
@ -1,2 +1,6 @@
|
||||
[attr-script-fetchpriority.html]
|
||||
prefs: [network.fetchpriority.enabled:true]
|
||||
[fetchpriority attribute on <script> elements should reflect valid IDL values]
|
||||
expected: FAIL
|
||||
|
||||
[default fetchpriority attribute on <script> elements should be 'auto']
|
||||
expected: FAIL
|
||||
|
@ -8,7 +8,6 @@
|
||||
#include "FetchPreloader.h"
|
||||
#include "PreloaderBase.h"
|
||||
#include "mozilla/AsyncEventDispatcher.h"
|
||||
#include "mozilla/dom/FetchPriority.h"
|
||||
#include "mozilla/dom/HTMLLinkElement.h"
|
||||
#include "mozilla/dom/ScriptLoader.h"
|
||||
#include "mozilla/dom/ReferrerInfo.h"
|
||||
@ -73,8 +72,8 @@ already_AddRefed<PreloaderBase> PreloadService::PreloadLinkElement(
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
nsAutoString as, charset, crossOrigin, integrity, referrerPolicy,
|
||||
fetchPriority, rel, srcset, sizes, type, url;
|
||||
nsAutoString as, charset, crossOrigin, integrity, referrerPolicy, rel, srcset,
|
||||
sizes, type, url;
|
||||
|
||||
nsCOMPtr<nsIURI> uri = aLinkElement->GetURI();
|
||||
aLinkElement->GetCharset(charset);
|
||||
@ -84,8 +83,6 @@ already_AddRefed<PreloaderBase> PreloadService::PreloadLinkElement(
|
||||
aLinkElement->GetCrossOrigin(crossOrigin);
|
||||
aLinkElement->GetIntegrity(integrity);
|
||||
aLinkElement->GetReferrerPolicy(referrerPolicy);
|
||||
// Bug 1839315: get "fetchpriority"'s value from the link element instead,
|
||||
fetchPriority = NS_ConvertUTF8toUTF16(dom::kFetchPriorityAttributeValueAuto);
|
||||
aLinkElement->GetRel(rel);
|
||||
|
||||
nsAutoString nonce;
|
||||
@ -104,8 +101,7 @@ already_AddRefed<PreloaderBase> PreloadService::PreloadLinkElement(
|
||||
|
||||
auto result = PreloadOrCoalesce(uri, url, aPolicyType, as, type, charset,
|
||||
srcset, sizes, nonce, integrity, crossOrigin,
|
||||
referrerPolicy, fetchPriority,
|
||||
/* aFromHeader = */ false, 0);
|
||||
referrerPolicy, /* aFromHeader = */ false, 0);
|
||||
|
||||
if (!result.mPreloader) {
|
||||
NotifyNodeEvent(aLinkElement, result.mAlreadyComplete);
|
||||
@ -131,12 +127,8 @@ void PreloadService::PreloadLinkHeader(
|
||||
return;
|
||||
}
|
||||
|
||||
// Bug 1839315: which fetch priority to use here?
|
||||
const nsAutoString fetchPriority =
|
||||
NS_ConvertUTF8toUTF16(dom::kFetchPriorityAttributeValueAuto);
|
||||
PreloadOrCoalesce(aURI, aURL, aPolicyType, aAs, aType, u""_ns, aSrcset,
|
||||
aSizes, aNonce, aIntegrity, aCORS, aReferrerPolicy,
|
||||
fetchPriority,
|
||||
/* aFromHeader = */ true, aEarlyHintPreloaderId);
|
||||
}
|
||||
|
||||
@ -145,8 +137,8 @@ PreloadService::PreloadOrCoalesceResult PreloadService::PreloadOrCoalesce(
|
||||
const nsAString& aAs, const nsAString& aType, const nsAString& aCharset,
|
||||
const nsAString& aSrcset, const nsAString& aSizes, const nsAString& aNonce,
|
||||
const nsAString& aIntegrity, const nsAString& aCORS,
|
||||
const nsAString& aReferrerPolicy, const nsAString& aFetchPriority,
|
||||
bool aFromHeader, uint64_t aEarlyHintPreloaderId) {
|
||||
const nsAString& aReferrerPolicy, bool aFromHeader,
|
||||
uint64_t aEarlyHintPreloaderId) {
|
||||
if (!aURI) {
|
||||
MOZ_ASSERT_UNREACHABLE("Should not pass null nsIURI");
|
||||
return {nullptr, false};
|
||||
@ -187,7 +179,7 @@ PreloadService::PreloadOrCoalesceResult PreloadService::PreloadOrCoalesce(
|
||||
|
||||
if (aAs.LowerCaseEqualsASCII("script")) {
|
||||
PreloadScript(uri, aType, aCharset, aCORS, aReferrerPolicy, aNonce,
|
||||
aFetchPriority, aIntegrity, true /* isInHead - TODO */,
|
||||
aIntegrity, true /* isInHead - TODO */,
|
||||
aEarlyHintPreloaderId);
|
||||
} else if (aAs.LowerCaseEqualsASCII("style")) {
|
||||
auto status = mDocument->PreloadStyle(
|
||||
@ -222,13 +214,12 @@ PreloadService::PreloadOrCoalesceResult PreloadService::PreloadOrCoalesce(
|
||||
void PreloadService::PreloadScript(
|
||||
nsIURI* aURI, const nsAString& aType, const nsAString& aCharset,
|
||||
const nsAString& aCrossOrigin, const nsAString& aReferrerPolicy,
|
||||
const nsAString& aNonce, const nsAString& aFetchPriority,
|
||||
const nsAString& aIntegrity, bool aScriptFromHead,
|
||||
const nsAString& aNonce, const nsAString& aIntegrity, bool aScriptFromHead,
|
||||
uint64_t aEarlyHintPreloaderId) {
|
||||
mDocument->ScriptLoader()->PreloadURI(
|
||||
aURI, aCharset, aType, aCrossOrigin, aNonce, aFetchPriority, aIntegrity,
|
||||
aScriptFromHead, false, false, false, true,
|
||||
PreloadReferrerPolicy(aReferrerPolicy), aEarlyHintPreloaderId);
|
||||
aURI, aCharset, aType, aCrossOrigin, aNonce, aIntegrity, aScriptFromHead,
|
||||
false, false, false, true, PreloadReferrerPolicy(aReferrerPolicy),
|
||||
aEarlyHintPreloaderId);
|
||||
}
|
||||
|
||||
void PreloadService::PreloadImage(nsIURI* aURI, const nsAString& aCrossOrigin,
|
||||
|
@ -81,7 +81,6 @@ class PreloadService {
|
||||
void PreloadScript(nsIURI* aURI, const nsAString& aType,
|
||||
const nsAString& aCharset, const nsAString& aCrossOrigin,
|
||||
const nsAString& aReferrerPolicy, const nsAString& aNonce,
|
||||
const nsAString& aFetchPriority,
|
||||
const nsAString& aIntegrity, bool aScriptFromHead,
|
||||
uint64_t aEarlyHintPreloaderId);
|
||||
|
||||
@ -117,8 +116,7 @@ class PreloadService {
|
||||
const nsAString& aSrcset, const nsAString& aSizes,
|
||||
const nsAString& aNonce, const nsAString& aIntegrity,
|
||||
const nsAString& aCORS, const nsAString& aReferrerPolicy,
|
||||
const nsAString& aFetchPriority, bool aFromHeader,
|
||||
uint64_t aEarlyHintPreloaderId);
|
||||
bool aFromHeader, uint64_t aEarlyHintPreloaderId);
|
||||
|
||||
private:
|
||||
nsRefPtrHashtable<PreloadHashKey, PreloaderBase> mPreloads;
|
||||
|
Loading…
Reference in New Issue
Block a user