forked from mirrors/gecko-dev
Bug 1896150 - Add RenderBlockingStatusType to the PerformanceResourceTiming Interface, r=emilio,necko-reviewers
Differential Revision: https://phabricator.services.mozilla.com/D210053
This commit is contained in:
parent
10cdb4892f
commit
c872f9d77b
14 changed files with 72 additions and 17 deletions
|
|
@ -246,6 +246,7 @@ struct TimedChannelInfo
|
|||
bool allRedirectsSameOrigin;
|
||||
bool allRedirectsPassTimingAllowCheck;
|
||||
bool? timingAllowCheckForPrincipal;
|
||||
bool renderBlocking;
|
||||
TimeStamp launchServiceWorkerStart;
|
||||
TimeStamp launchServiceWorkerEnd;
|
||||
TimeStamp dispatchFetchEventStart;
|
||||
|
|
|
|||
|
|
@ -131,3 +131,8 @@ bool PerformanceResourceTiming::ReportRedirectForCaller(
|
|||
return BasePrincipal::Cast(&aCaller)->AddonHasPermission(
|
||||
nsGkAtoms::all_urlsPermission);
|
||||
}
|
||||
|
||||
RenderBlockingStatusType PerformanceResourceTiming::RenderBlockingStatus()
|
||||
const {
|
||||
return mTimingData->RenderBlockingStatus();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,6 +15,8 @@
|
|||
#include "PerformanceTiming.h"
|
||||
|
||||
namespace mozilla::dom {
|
||||
enum class RenderBlockingStatusType : uint8_t;
|
||||
|
||||
#define IMPL_RESOURCE_TIMING_TAO_PROTECTED_TIMING_PROP(name) \
|
||||
DOMHighResTimeStamp name(nsIPrincipal& aSubjectPrincipal) const { \
|
||||
bool allowed = !mTimingData->RedirectCountReal() \
|
||||
|
|
@ -62,6 +64,8 @@ class PerformanceResourceTiming : public PerformanceEntry {
|
|||
mInitiatorType = aInitiatorType;
|
||||
}
|
||||
|
||||
RenderBlockingStatusType RenderBlockingStatus() const;
|
||||
|
||||
void GetNextHopProtocol(nsAString& aNextHopProtocol) const {
|
||||
if (mTimingData->TimingAllowed()) {
|
||||
aNextHopProtocol = mTimingData->NextHopProtocol();
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@
|
|||
#include "PerformanceTiming.h"
|
||||
#include "mozilla/BasePrincipal.h"
|
||||
#include "mozilla/StaticPrefs_dom.h"
|
||||
#include "mozilla/dom/PerformanceResourceTimingBinding.h"
|
||||
#include "mozilla/dom/PerformanceTimingBinding.h"
|
||||
#include "mozilla/glean/GleanMetrics.h"
|
||||
#include "nsIDocShell.h"
|
||||
|
|
@ -200,6 +201,14 @@ PerformanceTimingData::PerformanceTimingData(nsITimedChannel* aChannel,
|
|||
if (aHttpChannel) {
|
||||
SetPropertiesFromHttpChannel(aHttpChannel, aChannel);
|
||||
}
|
||||
|
||||
bool renderBlocking = false;
|
||||
if (aChannel) {
|
||||
aChannel->GetRenderBlocking(&renderBlocking);
|
||||
}
|
||||
mRenderBlockingStatus = renderBlocking
|
||||
? RenderBlockingStatusType::Blocking
|
||||
: RenderBlockingStatusType::Non_blocking;
|
||||
}
|
||||
|
||||
PerformanceTimingData::PerformanceTimingData(
|
||||
|
|
@ -227,6 +236,9 @@ PerformanceTimingData::PerformanceTimingData(
|
|||
mTransferSize(aIPCData.transferSize()),
|
||||
mDecodedBodySize(aIPCData.decodedBodySize()),
|
||||
mRedirectCount(aIPCData.redirectCount()),
|
||||
mRenderBlockingStatus(aIPCData.renderBlocking()
|
||||
? RenderBlockingStatusType::Blocking
|
||||
: RenderBlockingStatusType::Non_blocking),
|
||||
mAllRedirectsSameOrigin(aIPCData.allRedirectsSameOrigin()),
|
||||
mAllRedirectsPassTAO(aIPCData.allRedirectsPassTAO()),
|
||||
mSecureConnection(aIPCData.secureConnection()),
|
||||
|
|
@ -252,6 +264,8 @@ IPCPerformanceTimingData PerformanceTimingData::ToIPC() {
|
|||
Unused << serverTimingData->GetDescription(description);
|
||||
ipcServerTiming.AppendElement(IPCServerTiming(name, duration, description));
|
||||
}
|
||||
bool renderBlocking =
|
||||
mRenderBlockingStatus == RenderBlockingStatusType::Blocking;
|
||||
return IPCPerformanceTimingData(
|
||||
ipcServerTiming, mNextHopProtocol, mAsyncOpen, mRedirectStart,
|
||||
mRedirectEnd, mDomainLookupStart, mDomainLookupEnd, mConnectStart,
|
||||
|
|
@ -259,8 +273,8 @@ IPCPerformanceTimingData PerformanceTimingData::ToIPC() {
|
|||
mCacheReadStart, mResponseEnd, mCacheReadEnd, mWorkerStart,
|
||||
mWorkerRequestStart, mWorkerResponseEnd, mZeroTime, mFetchStart,
|
||||
mEncodedBodySize, mTransferSize, mDecodedBodySize, mRedirectCount,
|
||||
mAllRedirectsSameOrigin, mAllRedirectsPassTAO, mSecureConnection,
|
||||
mTimingAllowed, mInitialized);
|
||||
renderBlocking, mAllRedirectsSameOrigin, mAllRedirectsPassTAO,
|
||||
mSecureConnection, mTimingAllowed, mInitialized);
|
||||
}
|
||||
|
||||
void PerformanceTimingData::SetPropertiesFromHttpChannel(
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ class nsIHttpChannel;
|
|||
namespace mozilla::dom {
|
||||
|
||||
class PerformanceTiming;
|
||||
enum class RenderBlockingStatusType : uint8_t;
|
||||
|
||||
class PerformanceTimingData final {
|
||||
friend class PerformanceTiming;
|
||||
|
|
@ -164,6 +165,10 @@ class PerformanceTimingData final {
|
|||
|
||||
nsTArray<nsCOMPtr<nsIServerTiming>> GetServerTiming();
|
||||
|
||||
RenderBlockingStatusType RenderBlockingStatus() const {
|
||||
return mRenderBlockingStatus;
|
||||
}
|
||||
|
||||
private:
|
||||
// Checks if the resource is either same origin as the page that started
|
||||
// the load, or if the response contains the Timing-Allow-Origin header
|
||||
|
|
@ -207,6 +212,8 @@ class PerformanceTimingData final {
|
|||
|
||||
uint8_t mRedirectCount = 0;
|
||||
|
||||
RenderBlockingStatusType mRenderBlockingStatus;
|
||||
|
||||
bool mAllRedirectsSameOrigin = false;
|
||||
|
||||
bool mAllRedirectsPassTAO = false;
|
||||
|
|
|
|||
|
|
@ -39,6 +39,7 @@ struct IPCPerformanceTimingData {
|
|||
uint64_t transferSize;
|
||||
uint64_t decodedBodySize;
|
||||
uint8_t redirectCount;
|
||||
bool renderBlocking;
|
||||
bool allRedirectsSameOrigin;
|
||||
bool allRedirectsPassTAO;
|
||||
bool secureConnection;
|
||||
|
|
|
|||
|
|
@ -10,6 +10,8 @@
|
|||
* liability, trademark and document use rules apply.
|
||||
*/
|
||||
|
||||
enum RenderBlockingStatusType { "blocking", "non-blocking" };
|
||||
|
||||
[Exposed=(Window,Worker)]
|
||||
interface PerformanceResourceTiming : PerformanceEntry
|
||||
{
|
||||
|
|
@ -54,5 +56,8 @@ interface PerformanceResourceTiming : PerformanceEntry
|
|||
[SecureContext, Frozen, Cached, Pure, NeedsSubjectPrincipal]
|
||||
readonly attribute sequence<PerformanceServerTiming> serverTiming;
|
||||
|
||||
[Pref="dom.element.blocking.enabled"]
|
||||
readonly attribute RenderBlockingStatusType renderBlockingStatus;
|
||||
|
||||
[Default] object toJSON();
|
||||
};
|
||||
|
|
|
|||
|
|
@ -2406,7 +2406,7 @@
|
|||
# Whether the blocking attribute implementation is enabled,
|
||||
# see https://html.spec.whatwg.org/#blocking-attributes
|
||||
- name: dom.element.blocking.enabled
|
||||
type: bool
|
||||
type: RelaxedAtomicBool
|
||||
value: false
|
||||
mirror: always
|
||||
|
||||
|
|
|
|||
|
|
@ -86,6 +86,10 @@ interface nsITimedChannel : nsISupports {
|
|||
}
|
||||
%}
|
||||
|
||||
// Whether this request is render-blocking:
|
||||
// https://w3c.github.io/resource-timing/#dom-renderblockingstatustype
|
||||
[noscript] attribute boolean renderBlocking;
|
||||
|
||||
// The following are only set if the document is (partially) read from the
|
||||
// cache
|
||||
[noscript] readonly attribute TimeStamp cacheReadStart;
|
||||
|
|
|
|||
|
|
@ -246,7 +246,8 @@ HttpBaseChannel::HttpBaseChannel()
|
|||
StaticPrefs::browser_opaqueResponseBlocking()),
|
||||
mChannelBlockedByOpaqueResponse(false),
|
||||
mDummyChannelForImageCache(false),
|
||||
mHasContentDecompressed(false) {
|
||||
mHasContentDecompressed(false),
|
||||
mRenderBlocking(false) {
|
||||
StoreApplyConversion(true);
|
||||
StoreAllowSTS(true);
|
||||
StoreTracingEnabled(true);
|
||||
|
|
@ -6531,5 +6532,17 @@ HttpBaseChannel::GetHasContentDecompressed(bool* value) {
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
HttpBaseChannel::SetRenderBlocking(bool aRenderBlocking) {
|
||||
mRenderBlocking = aRenderBlocking;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
HttpBaseChannel::GetRenderBlocking(bool* aRenderBlocking) {
|
||||
*aRenderBlocking = mRenderBlocking;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
} // namespace net
|
||||
} // namespace mozilla
|
||||
|
|
|
|||
|
|
@ -1017,6 +1017,9 @@ class HttpBaseChannel : public nsHashPropertyBag,
|
|||
|
||||
bool mHasContentDecompressed;
|
||||
|
||||
// A flag that should be false if render-blocking is not stated
|
||||
bool mRenderBlocking;
|
||||
|
||||
// clang-format off
|
||||
MOZ_ATOMIC_BITFIELDS(mAtomicBitfields3, 8, (
|
||||
(bool, AsyncOpenTimeOverriden, 1),
|
||||
|
|
|
|||
|
|
@ -831,6 +831,16 @@ NS_IMETHODIMP NullHttpChannel::GetDocumentCharacterSet(
|
|||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
NullHttpChannel::SetRenderBlocking(bool aRenderBlocking) {
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
NullHttpChannel::GetRenderBlocking(bool* aRenderBlocking) {
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
#define IMPL_TIMING_ATTR(name) \
|
||||
NS_IMETHODIMP \
|
||||
NullHttpChannel::Get##name##Time(PRTime* _retval) { \
|
||||
|
|
|
|||
|
|
@ -1,3 +1,3 @@
|
|||
prefs: [privacy.reduceTimerPrecision:false]
|
||||
prefs: [privacy.reduceTimerPrecision:false, dom.element.blocking.enabled:true]
|
||||
lsan-allowed: [Alloc, AllocateProtoAndIfaceCache, InitializeStaticHeaders, Malloc, ProtoAndIfaceCache, Realloc, alloc::raw_vec::finish_grow, build_input_gamma_table, mozilla::detail::HashTable, mozilla::dom::Performance::CreateForMainThread, mozilla::dom::PerformanceMainThread::CreateNavigationTimingEntry, mozilla::dom::PerformanceObserver::Constructor, mozilla::dom::ProtoAndIfaceCache::PageTableCache::EntrySlotOrCreate, mozilla::dom::ScriptLoader::CreateLoadRequest, mozilla::intl::FluentBundle::Constructor, mozilla::intl::FluentResource::Constructor, mozilla::net::nsStandardURL::TemplatedMutator, nsPresContext::NotifyContentfulPaint, nsStringBuffer::Alloc, posix_memalign]
|
||||
leak-threshold: [default:51200]
|
||||
|
|
|
|||
|
|
@ -1,12 +1,6 @@
|
|||
[idlharness.any.html]
|
||||
expected:
|
||||
if (os == "android") and fission: [OK, TIMEOUT]
|
||||
[PerformanceResourceTiming interface: attribute renderBlockingStatus]
|
||||
expected: FAIL
|
||||
|
||||
[PerformanceResourceTiming interface: resource must inherit property "renderBlockingStatus" with the proper type]
|
||||
expected: FAIL
|
||||
|
||||
[PerformanceResourceTiming interface: default toJSON operation on resource]
|
||||
expected: FAIL
|
||||
|
||||
|
|
@ -38,12 +32,6 @@
|
|||
[idlharness.any.worker.html]
|
||||
expected:
|
||||
if (os == "android") and fission: [OK, TIMEOUT]
|
||||
[PerformanceResourceTiming interface: attribute renderBlockingStatus]
|
||||
expected: FAIL
|
||||
|
||||
[PerformanceResourceTiming interface: resource must inherit property "renderBlockingStatus" with the proper type]
|
||||
expected: FAIL
|
||||
|
||||
[PerformanceResourceTiming interface: default toJSON operation on resource]
|
||||
expected: FAIL
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue