forked from mirrors/gecko-dev
Bug 1865610: part 3) Add fetchpriority attribute support for preloaded stylesheets. r=smaug,emilio,necko-reviewers,jesup
Includes corresponding Link header fields. Differential Revision: https://phabricator.services.mozilla.com/D191866
This commit is contained in:
parent
49a3f2c3eb
commit
c7f6b261d8
16 changed files with 63 additions and 68 deletions
|
|
@ -12538,7 +12538,7 @@ SheetPreloadStatus Document::PreloadStyle(
|
|||
nsIURI* uri, const Encoding* aEncoding, const nsAString& aCrossOriginAttr,
|
||||
const enum ReferrerPolicy aReferrerPolicy, const nsAString& aNonce,
|
||||
const nsAString& aIntegrity, css::StylePreloadKind aKind,
|
||||
uint64_t aEarlyHintPreloaderId) {
|
||||
uint64_t aEarlyHintPreloaderId, const nsAString& aFetchPriority) {
|
||||
MOZ_ASSERT(aKind != css::StylePreloadKind::None);
|
||||
|
||||
// The CSSLoader will retain this object after we return.
|
||||
|
|
@ -12550,7 +12550,8 @@ SheetPreloadStatus Document::PreloadStyle(
|
|||
// Charset names are always ASCII.
|
||||
auto result = CSSLoader()->LoadSheet(
|
||||
uri, aKind, aEncoding, referrerInfo, obs, aEarlyHintPreloaderId,
|
||||
Element::StringToCORSMode(aCrossOriginAttr), aNonce, aIntegrity);
|
||||
Element::StringToCORSMode(aCrossOriginAttr), aNonce, aIntegrity,
|
||||
nsGenericHTMLElement::ToFetchPriority(aFetchPriority));
|
||||
if (result.isErr()) {
|
||||
return SheetPreloadStatus::Errored;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2945,7 +2945,8 @@ class Document : public nsINode,
|
|||
const nsAString& aNonce,
|
||||
const nsAString& aIntegrity,
|
||||
css::StylePreloadKind,
|
||||
uint64_t aEarlyHintPreloaderId);
|
||||
uint64_t aEarlyHintPreloaderId,
|
||||
const nsAString& aFetchPriority);
|
||||
|
||||
/**
|
||||
* Called by the chrome registry to load style sheets.
|
||||
|
|
|
|||
|
|
@ -317,14 +317,15 @@ nsresult nsContentSink::ProcessLinkFromHeader(const net::LinkHeader& aHeader,
|
|||
PreloadHref(aHeader.mHref, aHeader.mAs, aHeader.mType, aHeader.mMedia,
|
||||
aHeader.mNonce, aHeader.mIntegrity, aHeader.mSrcset,
|
||||
aHeader.mSizes, aHeader.mCrossOrigin, aHeader.mReferrerPolicy,
|
||||
aEarlyHintPreloaderId);
|
||||
aEarlyHintPreloaderId, aHeader.mFetchPriority);
|
||||
}
|
||||
|
||||
if ((linkTypes & LinkStyle::eMODULE_PRELOAD) &&
|
||||
mDocument->ScriptLoader()->GetModuleLoader()) {
|
||||
PreloadModule(aHeader.mHref, aHeader.mAs, aHeader.mMedia, aHeader.mNonce,
|
||||
aHeader.mIntegrity, aHeader.mCrossOrigin,
|
||||
aHeader.mReferrerPolicy, aEarlyHintPreloaderId);
|
||||
aHeader.mReferrerPolicy, aEarlyHintPreloaderId,
|
||||
aHeader.mFetchPriority);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -436,7 +437,8 @@ void nsContentSink::PreloadHref(const nsAString& aHref, const nsAString& aAs,
|
|||
const nsAString& aSrcset,
|
||||
const nsAString& aSizes, const nsAString& aCORS,
|
||||
const nsAString& aReferrerPolicy,
|
||||
uint64_t aEarlyHintPreloaderId) {
|
||||
uint64_t aEarlyHintPreloaderId,
|
||||
const nsAString& aFetchPriority) {
|
||||
auto encoding = mDocument->GetDocumentCharacterSet();
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
NS_NewURI(getter_AddRefs(uri), aHref, encoding, mDocument->GetDocBaseURI());
|
||||
|
|
@ -462,16 +464,14 @@ void nsContentSink::PreloadHref(const nsAString& aHref, const nsAString& aAs,
|
|||
|
||||
mDocument->Preloads().PreloadLinkHeader(
|
||||
uri, aHref, policyType, aAs, aType, aNonce, aIntegrity, aSrcset, aSizes,
|
||||
aCORS, aReferrerPolicy, aEarlyHintPreloaderId);
|
||||
aCORS, aReferrerPolicy, aEarlyHintPreloaderId, aFetchPriority);
|
||||
}
|
||||
|
||||
void nsContentSink::PreloadModule(const nsAString& aHref, const nsAString& aAs,
|
||||
const nsAString& aMedia,
|
||||
const nsAString& aNonce,
|
||||
const nsAString& aIntegrity,
|
||||
const nsAString& aCORS,
|
||||
const nsAString& aReferrerPolicy,
|
||||
uint64_t aEarlyHintPreloaderId) {
|
||||
void nsContentSink::PreloadModule(
|
||||
const nsAString& aHref, const nsAString& aAs, const nsAString& aMedia,
|
||||
const nsAString& aNonce, const nsAString& aIntegrity,
|
||||
const nsAString& aCORS, const nsAString& aReferrerPolicy,
|
||||
uint64_t aEarlyHintPreloaderId, const nsAString& aFetchPriority) {
|
||||
ModuleLoader* moduleLoader = mDocument->ScriptLoader()->GetModuleLoader();
|
||||
|
||||
if (!StaticPrefs::network_modulepreload()) {
|
||||
|
|
@ -507,7 +507,7 @@ void nsContentSink::PreloadModule(const nsAString& aHref, const nsAString& aAs,
|
|||
mDocument->Preloads().PreloadLinkHeader(
|
||||
uri, aHref, nsIContentPolicy::TYPE_SCRIPT, u"script"_ns, u"module"_ns,
|
||||
aNonce, aIntegrity, u""_ns, u""_ns, aCORS, aReferrerPolicy,
|
||||
aEarlyHintPreloaderId);
|
||||
aEarlyHintPreloaderId, aFetchPriority);
|
||||
}
|
||||
|
||||
void nsContentSink::PrefetchDNS(const nsAString& aHref) {
|
||||
|
|
|
|||
|
|
@ -144,13 +144,15 @@ class nsContentSink : public nsICSSLoaderObserver,
|
|||
const nsAString& aNonce, const nsAString& aIntegrity,
|
||||
const nsAString& aSrcset, const nsAString& aSizes,
|
||||
const nsAString& aCORS, const nsAString& aReferrerPolicy,
|
||||
uint64_t aEarlyHintPreloaderId);
|
||||
uint64_t aEarlyHintPreloaderId,
|
||||
const nsAString& aFetchPriority);
|
||||
|
||||
void PreloadModule(const nsAString& aHref, const nsAString& aAs,
|
||||
const nsAString& aMedia, const nsAString& aNonce,
|
||||
const nsAString& aIntegrity, const nsAString& aCORS,
|
||||
const nsAString& aReferrerPolicy,
|
||||
uint64_t aEarlyHintPreloaderId);
|
||||
uint64_t aEarlyHintPreloaderId,
|
||||
const nsAString& aFetchPriority);
|
||||
|
||||
// For PrefetchDNS() aHref can either be the usual
|
||||
// URI format or of the form "//www.hostname.com" without a scheme.
|
||||
|
|
|
|||
|
|
@ -362,7 +362,7 @@ SheetLoadData::SheetLoadData(
|
|||
UseSystemPrincipal aUseSystemPrincipal, StylePreloadKind aPreloadKind,
|
||||
const Encoding* aPreloadEncoding, nsICSSLoaderObserver* aObserver,
|
||||
nsIPrincipal* aTriggeringPrincipal, nsIReferrerInfo* aReferrerInfo,
|
||||
const nsAString& aNonce)
|
||||
const nsAString& aNonce, FetchPriority aFetchPriority)
|
||||
: mLoader(aLoader),
|
||||
mEncoding(nullptr),
|
||||
mURI(aURI),
|
||||
|
|
@ -388,7 +388,7 @@ SheetLoadData::SheetLoadData(
|
|||
mTriggeringPrincipal(aTriggeringPrincipal),
|
||||
mReferrerInfo(aReferrerInfo),
|
||||
mNonce(aNonce),
|
||||
mFetchPriority(FetchPriority::Auto),
|
||||
mFetchPriority(aFetchPriority),
|
||||
mGuessedEncoding(
|
||||
GetFallbackEncoding(*aLoader, nullptr, aPreloadEncoding)),
|
||||
mCompatMode(aLoader->CompatMode(aPreloadKind)) {
|
||||
|
|
@ -2120,7 +2120,7 @@ Result<RefPtr<StyleSheet>, nsresult> Loader::LoadSheetSync(
|
|||
nsCOMPtr<nsIReferrerInfo> referrerInfo = new ReferrerInfo(nullptr);
|
||||
return InternalLoadNonDocumentSheet(
|
||||
aURL, StylePreloadKind::None, aParsingMode, aUseSystemPrincipal, nullptr,
|
||||
referrerInfo, nullptr, CORS_NONE, u""_ns, u""_ns, 0);
|
||||
referrerInfo, nullptr, CORS_NONE, u""_ns, u""_ns, 0, FetchPriority::Auto);
|
||||
}
|
||||
|
||||
Result<RefPtr<StyleSheet>, nsresult> Loader::LoadSheet(
|
||||
|
|
@ -2129,19 +2129,21 @@ Result<RefPtr<StyleSheet>, nsresult> Loader::LoadSheet(
|
|||
nsCOMPtr<nsIReferrerInfo> referrerInfo = new ReferrerInfo(nullptr);
|
||||
return InternalLoadNonDocumentSheet(
|
||||
aURI, StylePreloadKind::None, aParsingMode, aUseSystemPrincipal, nullptr,
|
||||
referrerInfo, aObserver, CORS_NONE, u""_ns, u""_ns, 0);
|
||||
referrerInfo, aObserver, CORS_NONE, u""_ns, u""_ns, 0,
|
||||
FetchPriority::Auto);
|
||||
}
|
||||
|
||||
Result<RefPtr<StyleSheet>, nsresult> Loader::LoadSheet(
|
||||
nsIURI* aURL, StylePreloadKind aPreloadKind,
|
||||
const Encoding* aPreloadEncoding, nsIReferrerInfo* aReferrerInfo,
|
||||
nsICSSLoaderObserver* aObserver, uint64_t aEarlyHintPreloaderId,
|
||||
CORSMode aCORSMode, const nsAString& aNonce, const nsAString& aIntegrity) {
|
||||
CORSMode aCORSMode, const nsAString& aNonce, const nsAString& aIntegrity,
|
||||
FetchPriority aFetchPriority) {
|
||||
LOG(("css::Loader::LoadSheet(aURL, aObserver) api call"));
|
||||
return InternalLoadNonDocumentSheet(
|
||||
aURL, aPreloadKind, eAuthorSheetFeatures, UseSystemPrincipal::No,
|
||||
aPreloadEncoding, aReferrerInfo, aObserver, aCORSMode, aNonce, aIntegrity,
|
||||
aEarlyHintPreloaderId);
|
||||
aEarlyHintPreloaderId, aFetchPriority);
|
||||
}
|
||||
|
||||
Result<RefPtr<StyleSheet>, nsresult> Loader::InternalLoadNonDocumentSheet(
|
||||
|
|
@ -2149,7 +2151,7 @@ Result<RefPtr<StyleSheet>, nsresult> Loader::InternalLoadNonDocumentSheet(
|
|||
UseSystemPrincipal aUseSystemPrincipal, const Encoding* aPreloadEncoding,
|
||||
nsIReferrerInfo* aReferrerInfo, nsICSSLoaderObserver* aObserver,
|
||||
CORSMode aCORSMode, const nsAString& aNonce, const nsAString& aIntegrity,
|
||||
uint64_t aEarlyHintPreloaderId) {
|
||||
uint64_t aEarlyHintPreloaderId, FetchPriority aFetchPriority) {
|
||||
MOZ_ASSERT(aURL, "Must have a URI to load");
|
||||
MOZ_ASSERT(aUseSystemPrincipal == UseSystemPrincipal::No || !aObserver,
|
||||
"Shouldn't load system-principal sheets async");
|
||||
|
|
@ -2180,7 +2182,8 @@ Result<RefPtr<StyleSheet>, nsresult> Loader::InternalLoadNonDocumentSheet(
|
|||
|
||||
auto data = MakeRefPtr<SheetLoadData>(
|
||||
this, aURL, sheet, SyncLoad(syncLoad), aUseSystemPrincipal, aPreloadKind,
|
||||
aPreloadEncoding, aObserver, triggeringPrincipal, aReferrerInfo, aNonce);
|
||||
aPreloadEncoding, aObserver, triggeringPrincipal, aReferrerInfo, aNonce,
|
||||
aFetchPriority);
|
||||
MOZ_ASSERT(data->GetRequestingNode() == mDocument);
|
||||
if (state == SheetState::Complete) {
|
||||
LOG((" Sheet already complete"));
|
||||
|
|
|
|||
|
|
@ -41,6 +41,7 @@ class StyleSheet;
|
|||
namespace dom {
|
||||
class DocGroup;
|
||||
class Element;
|
||||
enum class FetchPriority : uint8_t;
|
||||
} // namespace dom
|
||||
|
||||
// The load data for a <link> or @import style-sheet.
|
||||
|
|
@ -373,10 +374,12 @@ class Loader final {
|
|||
nsIURI* aURI, StylePreloadKind, const Encoding* aPreloadEncoding,
|
||||
nsIReferrerInfo* aReferrerInfo, nsICSSLoaderObserver* aObserver,
|
||||
uint64_t aEarlyHintPreloaderId, CORSMode aCORSMode,
|
||||
const nsAString& aNonce, const nsAString& aIntegrity);
|
||||
const nsAString& aNonce, const nsAString& aIntegrity,
|
||||
dom::FetchPriority aFetchPriority);
|
||||
|
||||
/**
|
||||
* As above, but without caring for a couple things.
|
||||
* Only to be called by `PreloadedStyleSheet::PreloadAsync`.
|
||||
*/
|
||||
Result<RefPtr<StyleSheet>, nsresult> LoadSheet(nsIURI*, SheetParsingMode,
|
||||
UseSystemPrincipal,
|
||||
|
|
@ -560,7 +563,7 @@ class Loader final {
|
|||
UseSystemPrincipal, const Encoding* aPreloadEncoding,
|
||||
nsIReferrerInfo* aReferrerInfo, nsICSSLoaderObserver* aObserver,
|
||||
CORSMode aCORSMode, const nsAString& aNonce, const nsAString& aIntegrity,
|
||||
uint64_t aEarlyHintPreloaderId);
|
||||
uint64_t aEarlyHintPreloaderId, dom::FetchPriority aFetchPriority);
|
||||
|
||||
RefPtr<StyleSheet> LookupInlineSheetInCache(const nsAString&, nsIPrincipal*);
|
||||
|
||||
|
|
|
|||
|
|
@ -70,14 +70,12 @@ class SheetLoadData final
|
|||
nsIPrincipal* aTriggeringPrincipal, nsIReferrerInfo*);
|
||||
|
||||
// Data for loading a non-document sheet
|
||||
// TODO: does this include sheets linked from a Link header? If so, the fetch
|
||||
// priority needs to be passed too.
|
||||
SheetLoadData(css::Loader*, nsIURI*, StyleSheet*, SyncLoad,
|
||||
UseSystemPrincipal, StylePreloadKind,
|
||||
const Encoding* aPreloadEncoding,
|
||||
nsICSSLoaderObserver* aObserver,
|
||||
nsIPrincipal* aTriggeringPrincipal, nsIReferrerInfo*,
|
||||
const nsAString& aNonce);
|
||||
const nsAString& aNonce, dom::FetchPriority aFetchPriority);
|
||||
|
||||
nsIReferrerInfo* ReferrerInfo() const { return mReferrerInfo; }
|
||||
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@
|
|||
#include "mozilla/dom/CSSImportRule.h"
|
||||
#include "mozilla/dom/CSSRuleList.h"
|
||||
#include "mozilla/dom/Element.h"
|
||||
#include "mozilla/dom/FetchPriority.h"
|
||||
#include "mozilla/dom/MediaList.h"
|
||||
#include "mozilla/dom/Promise.h"
|
||||
#include "mozilla/dom/ReferrerInfo.h"
|
||||
|
|
@ -680,7 +681,7 @@ void StyleSheet::MaybeRejectReplacePromise() {
|
|||
mReplacePromise = nullptr;
|
||||
}
|
||||
|
||||
// https://wicg.github.io/construct-stylesheets/#dom-cssstylesheet-replace
|
||||
// https://drafts.csswg.org/cssom/#dom-cssstylesheet-replace
|
||||
already_AddRefed<dom::Promise> StyleSheet::Replace(const nsACString& aText,
|
||||
ErrorResult& aRv) {
|
||||
nsIGlobalObject* globalObject = nullptr;
|
||||
|
|
@ -725,7 +726,7 @@ already_AddRefed<dom::Promise> StyleSheet::Replace(const nsACString& aText,
|
|||
css::Loader::UseSystemPrincipal::No, css::StylePreloadKind::None,
|
||||
/* aPreloadEncoding */ nullptr, /* aObserver */ nullptr,
|
||||
mConstructorDocument->NodePrincipal(), GetReferrerInfo(),
|
||||
/* aNonce */ u""_ns);
|
||||
/* aNonce */ u""_ns, FetchPriority::Auto);
|
||||
|
||||
// In parallel
|
||||
// 5.1 Parse aText into rules.
|
||||
|
|
|
|||
|
|
@ -80,7 +80,7 @@ void nsHtml5SpeculativeLoad::Perform(nsHtml5TreeOpExecutor* aExecutor) {
|
|||
mUrlOrSizes, mCharsetOrSrcset, mCrossOrigin, mMedia,
|
||||
mReferrerPolicyOrIntegrity, mNonce,
|
||||
mTypeOrCharsetSourceOrDocumentModeOrMetaCSPOrSizesOrIntegrity,
|
||||
mIsLinkPreload);
|
||||
mIsLinkPreload, mFetchPriority);
|
||||
break;
|
||||
case eSpeculativeLoadManifest:
|
||||
// TODO: remove this
|
||||
|
|
|
|||
|
|
@ -213,7 +213,8 @@ class nsHtml5SpeculativeLoad {
|
|||
inline void InitStyle(nsHtml5String aUrl, nsHtml5String aCharset,
|
||||
nsHtml5String aCrossOrigin, nsHtml5String aMedia,
|
||||
nsHtml5String aReferrerPolicy, nsHtml5String aNonce,
|
||||
nsHtml5String aIntegrity, bool aLinkPreload) {
|
||||
nsHtml5String aIntegrity, bool aLinkPreload,
|
||||
nsHtml5String aFetchPriority) {
|
||||
MOZ_ASSERT(mOpCode == eSpeculativeLoadUninitialized,
|
||||
"Trying to reinitialize a speculative load!");
|
||||
mOpCode = eSpeculativeLoadStyle;
|
||||
|
|
@ -231,6 +232,7 @@ class nsHtml5SpeculativeLoad {
|
|||
aIntegrity.ToString(
|
||||
mTypeOrCharsetSourceOrDocumentModeOrMetaCSPOrSizesOrIntegrity);
|
||||
mIsLinkPreload = aLinkPreload;
|
||||
aFetchPriority.ToString(mFetchPriority);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -364,9 +364,11 @@ nsIContentHandle* nsHtml5TreeBuilder::createElement(
|
|||
nsHtml5AttributeName::ATTR_REFERRERPOLICY);
|
||||
nsHtml5String media =
|
||||
aAttributes->getValue(nsHtml5AttributeName::ATTR_MEDIA);
|
||||
nsHtml5String fetchPriority = aAttributes->getValue(
|
||||
nsHtml5AttributeName::ATTR_FETCHPRIORITY);
|
||||
mSpeculativeLoadQueue.AppendElement()->InitStyle(
|
||||
url, charset, crossOrigin, media, referrerPolicy, nonce,
|
||||
integrity, false);
|
||||
integrity, false, fetchPriority);
|
||||
}
|
||||
} else if (rel.LowerCaseEqualsASCII("preconnect")) {
|
||||
nsHtml5String url =
|
||||
|
|
@ -395,6 +397,8 @@ nsIContentHandle* nsHtml5TreeBuilder::createElement(
|
|||
nsHtml5AttributeName::ATTR_REFERRERPOLICY);
|
||||
nsHtml5String media =
|
||||
aAttributes->getValue(nsHtml5AttributeName::ATTR_MEDIA);
|
||||
nsHtml5String fetchPriority = aAttributes->getValue(
|
||||
nsHtml5AttributeName::ATTR_FETCHPRIORITY);
|
||||
|
||||
// Note that respective speculative loaders for scripts and
|
||||
// styles check all additional attributes to be equal to use the
|
||||
|
|
@ -406,14 +410,6 @@ 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,
|
||||
|
|
@ -422,7 +418,7 @@ nsIContentHandle* nsHtml5TreeBuilder::createElement(
|
|||
} else if (as.LowerCaseEqualsASCII("style")) {
|
||||
mSpeculativeLoadQueue.AppendElement()->InitStyle(
|
||||
url, charset, crossOrigin, media, referrerPolicy, nonce,
|
||||
integrity, true);
|
||||
integrity, true, fetchPriority);
|
||||
} else if (as.LowerCaseEqualsASCII("image")) {
|
||||
nsHtml5String srcset = aAttributes->getValue(
|
||||
nsHtml5AttributeName::ATTR_IMAGESRCSET);
|
||||
|
|
|
|||
|
|
@ -1233,7 +1233,8 @@ void nsHtml5TreeOpExecutor::PreloadStyle(
|
|||
const nsAString& aURL, const nsAString& aCharset,
|
||||
const nsAString& aCrossOrigin, const nsAString& aMedia,
|
||||
const nsAString& aReferrerPolicy, const nsAString& aNonce,
|
||||
const nsAString& aIntegrity, bool aLinkPreload) {
|
||||
const nsAString& aIntegrity, bool aLinkPreload,
|
||||
const nsAString& aFetchPriority) {
|
||||
nsCOMPtr<nsIURI> uri = ConvertIfNotPreloadedYetAndMediaApplies(aURL, aMedia);
|
||||
if (!uri) {
|
||||
return;
|
||||
|
|
@ -1254,7 +1255,7 @@ void nsHtml5TreeOpExecutor::PreloadStyle(
|
|||
GetPreloadReferrerPolicy(aReferrerPolicy), aNonce, aIntegrity,
|
||||
aLinkPreload ? css::StylePreloadKind::FromLinkRelPreloadElement
|
||||
: css::StylePreloadKind::FromParser,
|
||||
0);
|
||||
0, aFetchPriority);
|
||||
}
|
||||
|
||||
void nsHtml5TreeOpExecutor::PreloadImage(
|
||||
|
|
|
|||
|
|
@ -254,7 +254,8 @@ class nsHtml5TreeOpExecutor final
|
|||
void PreloadStyle(const nsAString& aURL, const nsAString& aCharset,
|
||||
const nsAString& aCrossOrigin, const nsAString& aMedia,
|
||||
const nsAString& aReferrerPolicy, const nsAString& aNonce,
|
||||
const nsAString& aIntegrity, bool aLinkPreload);
|
||||
const nsAString& aIntegrity, bool aLinkPreload,
|
||||
const nsAString& aFetchPriority);
|
||||
|
||||
void PreloadImage(const nsAString& aURL, const nsAString& aCrossOrigin,
|
||||
const nsAString& aMedia, const nsAString& aSrcset,
|
||||
|
|
|
|||
|
|
@ -1,9 +1,6 @@
|
|||
[fetchpriority.h2.html]
|
||||
lsan-allowed: [mozilla::net::AddStaticElement, InitializeStaticHeaders, mozilla::net::nvFIFO::nvFIFO, mozilla::net::Http2BaseCompressor::Http2BaseCompressor] # https://bugzilla.mozilla.org/show_bug.cgi?id=1759310
|
||||
prefs: [network.fetchpriority.enabled:true]
|
||||
[link-initial-load-stylesheet.h2.html: test different 'fetchpriority' values]
|
||||
expected: FAIL
|
||||
|
||||
[link-initial-preload.h2.html: test different 'fetchpriority' values]
|
||||
expected: FAIL
|
||||
|
||||
|
|
@ -22,14 +19,5 @@
|
|||
[link-header.h2.html?pipe=header(Link,<dummy.js?1>; rel=modulepreload; fetchpriority=low,True)|header(Link,<dummy.js?2>; rel=modulepreload; fetchpriority=high,True)|header(Link,<dummy.js?3>; rel=modulepreload; fetchpriority=auto,True)|header(Link,<dummy.js?4>; rel=modulepreload,True): test different 'fetchpriority' values]
|
||||
expected: FAIL
|
||||
|
||||
[link-initial-preload-style.h2.html: test different 'fetchpriority' values]
|
||||
expected: FAIL
|
||||
|
||||
[link-dynamic-preload-style.h2.html: test different 'fetchpriority' values]
|
||||
expected: FAIL
|
||||
|
||||
[link-header.h2.html?pipe=header(Link,<dummy.txt?1>; rel=preload; as=fetch; fetchpriority=low,True)|header(Link,<dummy.txt?2>; rel=preload; as=fetch; fetchpriority=high,True)|header(Link,<dummy.txt?3>; rel=preload; as=fetch; fetchpriority=auto,True)|header(Link,<dummy.txt?4>; rel=preload; as=fetch,True)|header(Link,<dummy.font?1>; rel=preload; as=font; fetchpriority=low,True)|header(Link,<dummy.font?2>; rel=preload; as=font; fetchpriority=high,True)|header(Link,<dummy.font?3>; rel=preload; as=font; fetchpriority=auto,True)|header(Link,<dummy.font?4>; rel=preload; as=font,True)|header(Link,<dummy.image?1>; rel=preload; as=image; fetchpriority=low,True)|header(Link,<dummy.image?2>; rel=preload; as=image; fetchpriority=high,True)|header(Link,<dummy.image?3>; rel=preload; as=image; fetchpriority=auto,True)|header(Link,<dummy.image?4>; rel=preload; as=image,True)|header(Link,<dummy.script?1>; rel=preload; as=script; fetchpriority=low,True)|header(Link,<dummy.script?2>; rel=preload; as=script; fetchpriority=high,True)|header(Link,<dummy.script?3>; rel=preload; as=script; fetchpriority=auto,True)|header(Link,<dummy.script?4>; rel=preload; as=script,True): test different 'fetchpriority' values]
|
||||
expected: FAIL
|
||||
|
||||
[link-header.h2.html?pipe=header(Link,<dummy.css?1>; rel=preload; as=style; fetchpriority=low,True)|header(Link,<dummy.css?2>; rel=preload; as=style; fetchpriority=high,True)|header(Link,<dummy.css?3>; rel=preload; as=style; fetchpriority=auto,True)|header(Link,<dummy.css?4>; rel=preload; as=style,True): test different 'fetchpriority' values]
|
||||
expected: FAIL
|
||||
|
|
|
|||
|
|
@ -80,8 +80,7 @@ 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->GetFetchPriority(fetchPriority);
|
||||
aLinkElement->GetRel(rel);
|
||||
|
||||
nsAutoString nonce;
|
||||
|
|
@ -117,18 +116,16 @@ void PreloadService::PreloadLinkHeader(
|
|||
const nsAString& aAs, const nsAString& aType, const nsAString& aNonce,
|
||||
const nsAString& aIntegrity, const nsAString& aSrcset,
|
||||
const nsAString& aSizes, const nsAString& aCORS,
|
||||
const nsAString& aReferrerPolicy, uint64_t aEarlyHintPreloaderId) {
|
||||
const nsAString& aReferrerPolicy, uint64_t aEarlyHintPreloaderId,
|
||||
const nsAString& aFetchPriority) {
|
||||
if (aPolicyType == nsIContentPolicy::TYPE_INVALID) {
|
||||
MOZ_ASSERT_UNREACHABLE("Caller should check");
|
||||
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,
|
||||
aFetchPriority,
|
||||
/* aFromHeader = */ true, aEarlyHintPreloaderId);
|
||||
}
|
||||
|
||||
|
|
@ -187,7 +184,7 @@ PreloadService::PreloadOrCoalesceResult PreloadService::PreloadOrCoalesce(
|
|||
PreloadReferrerPolicy(aReferrerPolicy), aNonce, aIntegrity,
|
||||
aFromHeader ? css::StylePreloadKind::FromLinkRelPreloadHeader
|
||||
: css::StylePreloadKind::FromLinkRelPreloadElement,
|
||||
aEarlyHintPreloaderId);
|
||||
aEarlyHintPreloaderId, aFetchPriority);
|
||||
switch (status) {
|
||||
case dom::SheetPreloadStatus::AlreadyComplete:
|
||||
return {nullptr, /* already_complete = */ true};
|
||||
|
|
|
|||
|
|
@ -78,7 +78,8 @@ class PreloadService {
|
|||
const nsAString& aIntegrity, const nsAString& aSrcset,
|
||||
const nsAString& aSizes, const nsAString& aCORS,
|
||||
const nsAString& aReferrerPolicy,
|
||||
uint64_t aEarlyHintPreloaderId);
|
||||
uint64_t aEarlyHintPreloaderId,
|
||||
const nsAString& aFetchPriority);
|
||||
|
||||
void PreloadScript(nsIURI* aURI, const nsAString& aType,
|
||||
const nsAString& aCharset, const nsAString& aCrossOrigin,
|
||||
|
|
|
|||
Loading…
Reference in a new issue