2016-06-09 13:43:56 +03:00
|
|
|
/* -*- 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 "PerformanceTiming.h"
|
|
|
|
#include "mozilla/dom/PerformanceTimingBinding.h"
|
2017-04-19 09:00:00 +03:00
|
|
|
#include "mozilla/Telemetry.h"
|
|
|
|
#include "nsIDocShell.h"
|
|
|
|
#include "nsIDocShellTreeItem.h"
|
|
|
|
#include "nsIDocument.h"
|
|
|
|
#include "nsITimedChannel.h"
|
2016-06-09 13:43:56 +03:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(PerformanceTiming, mPerformance)
|
|
|
|
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_ROOT_NATIVE(PerformanceTiming, AddRef)
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNROOT_NATIVE(PerformanceTiming, Release)
|
|
|
|
|
2016-06-09 20:04:42 +03:00
|
|
|
PerformanceTiming::PerformanceTiming(Performance* aPerformance,
|
2016-06-09 13:43:56 +03:00
|
|
|
nsITimedChannel* aChannel,
|
|
|
|
nsIHttpChannel* aHttpChannel,
|
|
|
|
DOMHighResTimeStamp aZeroTime)
|
|
|
|
: mPerformance(aPerformance),
|
|
|
|
mFetchStart(0.0),
|
|
|
|
mZeroTime(aZeroTime),
|
|
|
|
mRedirectCount(0),
|
|
|
|
mTimingAllowed(true),
|
|
|
|
mAllRedirectsSameOrigin(true),
|
|
|
|
mInitialized(!!aChannel),
|
|
|
|
mReportCrossOriginRedirect(true)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(aPerformance, "Parent performance object should be provided");
|
|
|
|
|
2017-06-15 11:48:27 +03:00
|
|
|
if (!nsContentUtils::IsPerformanceTimingEnabled() ||
|
|
|
|
nsContentUtils::ShouldResistFingerprinting()) {
|
2016-06-09 13:43:56 +03:00
|
|
|
mZeroTime = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// The aHttpChannel argument is null if this PerformanceTiming object is
|
|
|
|
// being used for navigation timing (which is only relevant for documents).
|
|
|
|
// It has a non-null value if this PerformanceTiming object is being used
|
|
|
|
// for resource timing, which can include document loads, both toplevel and
|
|
|
|
// in subframes, and resources linked from a document.
|
|
|
|
if (aHttpChannel) {
|
|
|
|
mTimingAllowed = CheckAllowedOrigin(aHttpChannel, aChannel);
|
|
|
|
bool redirectsPassCheck = false;
|
|
|
|
aChannel->GetAllRedirectsPassTimingAllowCheck(&redirectsPassCheck);
|
|
|
|
mReportCrossOriginRedirect = mTimingAllowed && redirectsPassCheck;
|
|
|
|
}
|
|
|
|
|
|
|
|
InitializeTimingInfo(aChannel);
|
2017-04-19 09:00:00 +03:00
|
|
|
|
|
|
|
// Non-null aHttpChannel implies that this PerformanceTiming object is being
|
|
|
|
// used for subresources, which is irrelevant to this probe.
|
|
|
|
if (!aHttpChannel &&
|
|
|
|
nsContentUtils::IsPerformanceTimingEnabled() &&
|
|
|
|
IsTopLevelContentDocument()) {
|
|
|
|
Telemetry::Accumulate(Telemetry::TIME_TO_RESPONSE_START_MS,
|
|
|
|
ResponseStartHighRes() - mZeroTime);
|
|
|
|
}
|
2016-06-09 13:43:56 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// Copy the timing info from the channel so we don't need to keep the channel
|
|
|
|
// alive just to get the timestamps.
|
|
|
|
void
|
|
|
|
PerformanceTiming::InitializeTimingInfo(nsITimedChannel* aChannel)
|
|
|
|
{
|
|
|
|
if (aChannel) {
|
|
|
|
aChannel->GetAsyncOpen(&mAsyncOpen);
|
|
|
|
aChannel->GetAllRedirectsSameOrigin(&mAllRedirectsSameOrigin);
|
|
|
|
aChannel->GetRedirectCount(&mRedirectCount);
|
|
|
|
aChannel->GetRedirectStart(&mRedirectStart);
|
|
|
|
aChannel->GetRedirectEnd(&mRedirectEnd);
|
|
|
|
aChannel->GetDomainLookupStart(&mDomainLookupStart);
|
|
|
|
aChannel->GetDomainLookupEnd(&mDomainLookupEnd);
|
|
|
|
aChannel->GetConnectStart(&mConnectStart);
|
2017-07-10 22:01:35 +03:00
|
|
|
aChannel->GetSecureConnectionStart(&mSecureConnectionStart);
|
2016-06-09 13:43:56 +03:00
|
|
|
aChannel->GetConnectEnd(&mConnectEnd);
|
|
|
|
aChannel->GetRequestStart(&mRequestStart);
|
|
|
|
aChannel->GetResponseStart(&mResponseStart);
|
|
|
|
aChannel->GetCacheReadStart(&mCacheReadStart);
|
|
|
|
aChannel->GetResponseEnd(&mResponseEnd);
|
|
|
|
aChannel->GetCacheReadEnd(&mCacheReadEnd);
|
2017-07-10 22:01:35 +03:00
|
|
|
|
|
|
|
// the performance timing api essentially requires that the event timestamps
|
|
|
|
// are >= asyncOpen().. but in truth the browser engages in a number of
|
|
|
|
// speculative activities that sometimes mean connections and lookups begin
|
|
|
|
// earlier. Workaround that here by just using asyncOpen as the minimum
|
|
|
|
// timestamp for dns and connection info.
|
|
|
|
if (!mAsyncOpen.IsNull()) {
|
|
|
|
if (!mDomainLookupStart.IsNull() && mDomainLookupStart < mAsyncOpen) {
|
|
|
|
mDomainLookupStart = mAsyncOpen;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!mDomainLookupEnd.IsNull() && mDomainLookupEnd < mAsyncOpen) {
|
|
|
|
mDomainLookupEnd = mAsyncOpen;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!mConnectStart.IsNull() && mConnectStart < mAsyncOpen) {
|
|
|
|
mConnectStart = mAsyncOpen;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!mSecureConnectionStart.IsNull() && mSecureConnectionStart < mAsyncOpen) {
|
|
|
|
mSecureConnectionStart = mAsyncOpen;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!mConnectEnd.IsNull() && mConnectEnd < mAsyncOpen) {
|
|
|
|
mConnectEnd = mAsyncOpen;
|
|
|
|
}
|
|
|
|
}
|
2016-06-09 13:43:56 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
PerformanceTiming::~PerformanceTiming()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
DOMHighResTimeStamp
|
|
|
|
PerformanceTiming::FetchStartHighRes()
|
|
|
|
{
|
|
|
|
if (!mFetchStart) {
|
2017-06-15 11:48:27 +03:00
|
|
|
if (!nsContentUtils::IsPerformanceTimingEnabled() || !IsInitialized() ||
|
|
|
|
nsContentUtils::ShouldResistFingerprinting()) {
|
2016-06-09 13:43:56 +03:00
|
|
|
return mZeroTime;
|
|
|
|
}
|
|
|
|
MOZ_ASSERT(!mAsyncOpen.IsNull(), "The fetch start time stamp should always be "
|
|
|
|
"valid if the performance timing is enabled");
|
|
|
|
mFetchStart = (!mAsyncOpen.IsNull())
|
|
|
|
? TimeStampToDOMHighRes(mAsyncOpen)
|
|
|
|
: 0.0;
|
|
|
|
}
|
|
|
|
return mFetchStart;
|
|
|
|
}
|
|
|
|
|
|
|
|
DOMTimeMilliSec
|
|
|
|
PerformanceTiming::FetchStart()
|
|
|
|
{
|
|
|
|
return static_cast<int64_t>(FetchStartHighRes());
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
PerformanceTiming::CheckAllowedOrigin(nsIHttpChannel* aResourceChannel,
|
|
|
|
nsITimedChannel* aChannel)
|
|
|
|
{
|
|
|
|
if (!IsInitialized()) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Check that the current document passes the ckeck.
|
|
|
|
nsCOMPtr<nsILoadInfo> loadInfo;
|
|
|
|
aResourceChannel->GetLoadInfo(getter_AddRefs(loadInfo));
|
|
|
|
if (!loadInfo) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// TYPE_DOCUMENT loads have no loadingPrincipal. And that's OK, because we
|
|
|
|
// never actually need to have a performance timing entry for TYPE_DOCUMENT
|
|
|
|
// loads.
|
|
|
|
if (loadInfo->GetExternalContentPolicyType() == nsIContentPolicy::TYPE_DOCUMENT) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsCOMPtr<nsIPrincipal> principal = loadInfo->LoadingPrincipal();
|
|
|
|
|
|
|
|
// Check if the resource is either same origin as the page that started
|
|
|
|
// the load, or if the response contains the proper Timing-Allow-Origin
|
|
|
|
// header with the domain of the page that started the load.
|
|
|
|
return aChannel->TimingAllowCheck(principal);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
PerformanceTiming::TimingAllowed() const
|
|
|
|
{
|
|
|
|
return mTimingAllowed;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint16_t
|
|
|
|
PerformanceTiming::GetRedirectCount() const
|
|
|
|
{
|
2017-06-15 11:48:27 +03:00
|
|
|
if (!nsContentUtils::IsPerformanceTimingEnabled() || !IsInitialized() ||
|
|
|
|
nsContentUtils::ShouldResistFingerprinting()) {
|
2016-06-09 13:43:56 +03:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
if (!mAllRedirectsSameOrigin) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
return mRedirectCount;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
PerformanceTiming::ShouldReportCrossOriginRedirect() const
|
|
|
|
{
|
2017-06-15 11:48:27 +03:00
|
|
|
if (!nsContentUtils::IsPerformanceTimingEnabled() || !IsInitialized() ||
|
|
|
|
nsContentUtils::ShouldResistFingerprinting()) {
|
2016-06-09 13:43:56 +03:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// If the redirect count is 0, or if one of the cross-origin
|
|
|
|
// redirects doesn't have the proper Timing-Allow-Origin header,
|
|
|
|
// then RedirectStart and RedirectEnd will be set to zero
|
|
|
|
return (mRedirectCount != 0) && mReportCrossOriginRedirect;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* RedirectStartHighRes() is used by both the navigation timing and the
|
|
|
|
* resource timing. Since, navigation timing and resource timing check and
|
|
|
|
* interpret cross-domain redirects in a different manner,
|
|
|
|
* RedirectStartHighRes() will make no checks for cross-domain redirect.
|
|
|
|
* It's up to the consumers of this method (PerformanceTiming::RedirectStart()
|
|
|
|
* and PerformanceResourceTiming::RedirectStart() to make such verifications.
|
|
|
|
*
|
|
|
|
* @return a valid timing if the Performance Timing is enabled
|
|
|
|
*/
|
|
|
|
DOMHighResTimeStamp
|
|
|
|
PerformanceTiming::RedirectStartHighRes()
|
|
|
|
{
|
2017-06-15 11:48:27 +03:00
|
|
|
if (!nsContentUtils::IsPerformanceTimingEnabled() || !IsInitialized() ||
|
|
|
|
nsContentUtils::ShouldResistFingerprinting()) {
|
2016-06-09 13:43:56 +03:00
|
|
|
return mZeroTime;
|
|
|
|
}
|
|
|
|
return TimeStampToDOMHighResOrFetchStart(mRedirectStart);
|
|
|
|
}
|
|
|
|
|
|
|
|
DOMTimeMilliSec
|
|
|
|
PerformanceTiming::RedirectStart()
|
|
|
|
{
|
|
|
|
if (!IsInitialized()) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
// We have to check if all the redirect URIs had the same origin (since there
|
|
|
|
// is no check in RedirectStartHighRes())
|
|
|
|
if (mAllRedirectsSameOrigin && mRedirectCount) {
|
|
|
|
return static_cast<int64_t>(RedirectStartHighRes());
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* RedirectEndHighRes() is used by both the navigation timing and the resource
|
|
|
|
* timing. Since, navigation timing and resource timing check and interpret
|
|
|
|
* cross-domain redirects in a different manner, RedirectEndHighRes() will make
|
|
|
|
* no checks for cross-domain redirect. It's up to the consumers of this method
|
|
|
|
* (PerformanceTiming::RedirectEnd() and
|
|
|
|
* PerformanceResourceTiming::RedirectEnd() to make such verifications.
|
|
|
|
*
|
|
|
|
* @return a valid timing if the Performance Timing is enabled
|
|
|
|
*/
|
|
|
|
DOMHighResTimeStamp
|
|
|
|
PerformanceTiming::RedirectEndHighRes()
|
|
|
|
{
|
2017-06-15 11:48:27 +03:00
|
|
|
if (!nsContentUtils::IsPerformanceTimingEnabled() || !IsInitialized() ||
|
|
|
|
nsContentUtils::ShouldResistFingerprinting()) {
|
2016-06-09 13:43:56 +03:00
|
|
|
return mZeroTime;
|
|
|
|
}
|
|
|
|
return TimeStampToDOMHighResOrFetchStart(mRedirectEnd);
|
|
|
|
}
|
|
|
|
|
|
|
|
DOMTimeMilliSec
|
|
|
|
PerformanceTiming::RedirectEnd()
|
|
|
|
{
|
|
|
|
if (!IsInitialized()) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
// We have to check if all the redirect URIs had the same origin (since there
|
|
|
|
// is no check in RedirectEndHighRes())
|
|
|
|
if (mAllRedirectsSameOrigin && mRedirectCount) {
|
|
|
|
return static_cast<int64_t>(RedirectEndHighRes());
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
DOMHighResTimeStamp
|
|
|
|
PerformanceTiming::DomainLookupStartHighRes()
|
|
|
|
{
|
2017-06-15 11:48:27 +03:00
|
|
|
if (!nsContentUtils::IsPerformanceTimingEnabled() || !IsInitialized() ||
|
|
|
|
nsContentUtils::ShouldResistFingerprinting()) {
|
2016-06-09 13:43:56 +03:00
|
|
|
return mZeroTime;
|
|
|
|
}
|
|
|
|
return TimeStampToDOMHighResOrFetchStart(mDomainLookupStart);
|
|
|
|
}
|
|
|
|
|
|
|
|
DOMTimeMilliSec
|
|
|
|
PerformanceTiming::DomainLookupStart()
|
|
|
|
{
|
|
|
|
return static_cast<int64_t>(DomainLookupStartHighRes());
|
|
|
|
}
|
|
|
|
|
|
|
|
DOMHighResTimeStamp
|
|
|
|
PerformanceTiming::DomainLookupEndHighRes()
|
|
|
|
{
|
2017-06-15 11:48:27 +03:00
|
|
|
if (!nsContentUtils::IsPerformanceTimingEnabled() || !IsInitialized() ||
|
|
|
|
nsContentUtils::ShouldResistFingerprinting()) {
|
2016-06-09 13:43:56 +03:00
|
|
|
return mZeroTime;
|
|
|
|
}
|
|
|
|
// Bug 1155008 - nsHttpTransaction is racy. Return DomainLookupStart when null
|
|
|
|
return mDomainLookupEnd.IsNull() ? DomainLookupStartHighRes()
|
|
|
|
: TimeStampToDOMHighRes(mDomainLookupEnd);
|
|
|
|
}
|
|
|
|
|
|
|
|
DOMTimeMilliSec
|
|
|
|
PerformanceTiming::DomainLookupEnd()
|
|
|
|
{
|
|
|
|
return static_cast<int64_t>(DomainLookupEndHighRes());
|
|
|
|
}
|
|
|
|
|
|
|
|
DOMHighResTimeStamp
|
|
|
|
PerformanceTiming::ConnectStartHighRes()
|
|
|
|
{
|
2017-06-15 11:48:27 +03:00
|
|
|
if (!nsContentUtils::IsPerformanceTimingEnabled() || !IsInitialized() ||
|
|
|
|
nsContentUtils::ShouldResistFingerprinting()) {
|
2016-06-09 13:43:56 +03:00
|
|
|
return mZeroTime;
|
|
|
|
}
|
|
|
|
return mConnectStart.IsNull() ? DomainLookupEndHighRes()
|
|
|
|
: TimeStampToDOMHighRes(mConnectStart);
|
|
|
|
}
|
|
|
|
|
|
|
|
DOMTimeMilliSec
|
|
|
|
PerformanceTiming::ConnectStart()
|
|
|
|
{
|
|
|
|
return static_cast<int64_t>(ConnectStartHighRes());
|
|
|
|
}
|
|
|
|
|
2017-07-10 22:01:35 +03:00
|
|
|
DOMHighResTimeStamp
|
|
|
|
PerformanceTiming::SecureConnectionStartHighRes()
|
|
|
|
{
|
|
|
|
if (!nsContentUtils::IsPerformanceTimingEnabled() || !IsInitialized() ||
|
|
|
|
nsContentUtils::ShouldResistFingerprinting()) {
|
|
|
|
return mZeroTime;
|
|
|
|
}
|
|
|
|
return mSecureConnectionStart.IsNull() ? mZeroTime
|
|
|
|
: TimeStampToDOMHighRes(mSecureConnectionStart);
|
|
|
|
}
|
|
|
|
|
|
|
|
DOMTimeMilliSec
|
|
|
|
PerformanceTiming::SecureConnectionStart()
|
|
|
|
{
|
|
|
|
return static_cast<int64_t>(SecureConnectionStartHighRes());
|
|
|
|
}
|
|
|
|
|
2016-06-09 13:43:56 +03:00
|
|
|
DOMHighResTimeStamp
|
|
|
|
PerformanceTiming::ConnectEndHighRes()
|
|
|
|
{
|
2017-06-15 11:48:27 +03:00
|
|
|
if (!nsContentUtils::IsPerformanceTimingEnabled() || !IsInitialized() ||
|
|
|
|
nsContentUtils::ShouldResistFingerprinting()) {
|
2016-06-09 13:43:56 +03:00
|
|
|
return mZeroTime;
|
|
|
|
}
|
|
|
|
// Bug 1155008 - nsHttpTransaction is racy. Return ConnectStart when null
|
|
|
|
return mConnectEnd.IsNull() ? ConnectStartHighRes()
|
|
|
|
: TimeStampToDOMHighRes(mConnectEnd);
|
|
|
|
}
|
|
|
|
|
|
|
|
DOMTimeMilliSec
|
|
|
|
PerformanceTiming::ConnectEnd()
|
|
|
|
{
|
|
|
|
return static_cast<int64_t>(ConnectEndHighRes());
|
|
|
|
}
|
|
|
|
|
|
|
|
DOMHighResTimeStamp
|
|
|
|
PerformanceTiming::RequestStartHighRes()
|
|
|
|
{
|
2017-06-15 11:48:27 +03:00
|
|
|
if (!nsContentUtils::IsPerformanceTimingEnabled() || !IsInitialized() ||
|
|
|
|
nsContentUtils::ShouldResistFingerprinting()) {
|
2016-06-09 13:43:56 +03:00
|
|
|
return mZeroTime;
|
|
|
|
}
|
|
|
|
return TimeStampToDOMHighResOrFetchStart(mRequestStart);
|
|
|
|
}
|
|
|
|
|
|
|
|
DOMTimeMilliSec
|
|
|
|
PerformanceTiming::RequestStart()
|
|
|
|
{
|
|
|
|
return static_cast<int64_t>(RequestStartHighRes());
|
|
|
|
}
|
|
|
|
|
|
|
|
DOMHighResTimeStamp
|
|
|
|
PerformanceTiming::ResponseStartHighRes()
|
|
|
|
{
|
2017-06-15 11:48:27 +03:00
|
|
|
if (!nsContentUtils::IsPerformanceTimingEnabled() || !IsInitialized() ||
|
|
|
|
nsContentUtils::ShouldResistFingerprinting()) {
|
2016-06-09 13:43:56 +03:00
|
|
|
return mZeroTime;
|
|
|
|
}
|
|
|
|
if (mResponseStart.IsNull() ||
|
|
|
|
(!mCacheReadStart.IsNull() && mCacheReadStart < mResponseStart)) {
|
|
|
|
mResponseStart = mCacheReadStart;
|
|
|
|
}
|
2017-08-23 17:50:18 +03:00
|
|
|
|
|
|
|
if (mResponseStart.IsNull() ||
|
|
|
|
(!mRequestStart.IsNull() && mResponseStart < mRequestStart)) {
|
|
|
|
mResponseStart = mRequestStart;
|
|
|
|
}
|
2016-06-09 13:43:56 +03:00
|
|
|
return TimeStampToDOMHighResOrFetchStart(mResponseStart);
|
|
|
|
}
|
|
|
|
|
|
|
|
DOMTimeMilliSec
|
|
|
|
PerformanceTiming::ResponseStart()
|
|
|
|
{
|
|
|
|
return static_cast<int64_t>(ResponseStartHighRes());
|
|
|
|
}
|
|
|
|
|
|
|
|
DOMHighResTimeStamp
|
|
|
|
PerformanceTiming::ResponseEndHighRes()
|
|
|
|
{
|
2017-06-15 11:48:27 +03:00
|
|
|
if (!nsContentUtils::IsPerformanceTimingEnabled() || !IsInitialized() ||
|
|
|
|
nsContentUtils::ShouldResistFingerprinting()) {
|
2016-06-09 13:43:56 +03:00
|
|
|
return mZeroTime;
|
|
|
|
}
|
|
|
|
if (mResponseEnd.IsNull() ||
|
|
|
|
(!mCacheReadEnd.IsNull() && mCacheReadEnd < mResponseEnd)) {
|
|
|
|
mResponseEnd = mCacheReadEnd;
|
|
|
|
}
|
|
|
|
// Bug 1155008 - nsHttpTransaction is racy. Return ResponseStart when null
|
|
|
|
return mResponseEnd.IsNull() ? ResponseStartHighRes()
|
|
|
|
: TimeStampToDOMHighRes(mResponseEnd);
|
|
|
|
}
|
|
|
|
|
|
|
|
DOMTimeMilliSec
|
|
|
|
PerformanceTiming::ResponseEnd()
|
|
|
|
{
|
|
|
|
return static_cast<int64_t>(ResponseEndHighRes());
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
PerformanceTiming::IsInitialized() const
|
|
|
|
{
|
|
|
|
return mInitialized;
|
|
|
|
}
|
|
|
|
|
|
|
|
JSObject*
|
|
|
|
PerformanceTiming::WrapObject(JSContext *cx, JS::Handle<JSObject*> aGivenProto)
|
|
|
|
{
|
|
|
|
return PerformanceTimingBinding::Wrap(cx, this, aGivenProto);
|
|
|
|
}
|
|
|
|
|
2017-04-19 09:00:00 +03:00
|
|
|
bool
|
|
|
|
PerformanceTiming::IsTopLevelContentDocument() const
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIDocument> document = mPerformance->GetDocumentIfCurrent();
|
|
|
|
if (!document) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
nsCOMPtr<nsIDocShell> docShell = document->GetDocShell();
|
|
|
|
if (!docShell) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
nsCOMPtr<nsIDocShellTreeItem> rootItem;
|
|
|
|
Unused << docShell->GetSameTypeRootTreeItem(getter_AddRefs(rootItem));
|
|
|
|
if (rootItem.get() != static_cast<nsIDocShellTreeItem*>(docShell.get())) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return rootItem->ItemType() == nsIDocShellTreeItem::typeContent;
|
|
|
|
}
|
|
|
|
|
2016-06-09 13:43:56 +03:00
|
|
|
} // dom namespace
|
|
|
|
} // mozilla namespace
|