diff options
author | Moonchild <mcwerewolf@gmail.com> | 2018-03-18 20:05:22 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-03-18 20:05:22 +0100 |
commit | 393ee744a8d44494a2a3750aec8e3e9845ecf780 (patch) | |
tree | 48f8ea6db87b35d9f28d5f467a1b8dbe62c35c24 /dom/performance/PerformanceTiming.cpp | |
parent | b2af10d6cf38b23fd0697b1835943df32301c785 (diff) | |
parent | a10b23932cd567324b7e1071f3ddc4c46a8270d8 (diff) | |
download | UXP-393ee744a8d44494a2a3750aec8e3e9845ecf780.tar UXP-393ee744a8d44494a2a3750aec8e3e9845ecf780.tar.gz UXP-393ee744a8d44494a2a3750aec8e3e9845ecf780.tar.lz UXP-393ee744a8d44494a2a3750aec8e3e9845ecf780.tar.xz UXP-393ee744a8d44494a2a3750aec8e3e9845ecf780.zip |
Merge pull request #70 from janekptacijarabaci/js_dom_performancetiming_2
Set "secureConnectionStart" to 0 for pages with HTTP scheme
Diffstat (limited to 'dom/performance/PerformanceTiming.cpp')
-rwxr-xr-x | dom/performance/PerformanceTiming.cpp | 27 |
1 files changed, 24 insertions, 3 deletions
diff --git a/dom/performance/PerformanceTiming.cpp b/dom/performance/PerformanceTiming.cpp index 5f771f0aa..e2f76a21f 100755 --- a/dom/performance/PerformanceTiming.cpp +++ b/dom/performance/PerformanceTiming.cpp @@ -46,6 +46,23 @@ PerformanceTiming::PerformanceTiming(Performance* aPerformance, mReportCrossOriginRedirect = mTimingAllowed && redirectsPassCheck; } + mSecureConnection = false; + nsCOMPtr<nsIURI> uri; + if (aHttpChannel) { + aHttpChannel->GetURI(getter_AddRefs(uri)); + } else { + nsCOMPtr<nsIHttpChannel> httpChannel = do_QueryInterface(aChannel); + if (httpChannel) { + httpChannel->GetURI(getter_AddRefs(uri)); + } + } + + if (uri) { + nsresult rv = uri->SchemeIs("https", &mSecureConnection); + if (NS_FAILED(rv)) { + mSecureConnection = false; + } + } InitializeTimingInfo(aChannel); } @@ -89,7 +106,8 @@ PerformanceTiming::InitializeTimingInfo(nsITimedChannel* aChannel) mConnectStart = mAsyncOpen; } - if (!mSecureConnectionStart.IsNull() && mSecureConnectionStart < mAsyncOpen) { + if (mSecureConnection && !mSecureConnectionStart.IsNull() && + mSecureConnectionStart < mAsyncOpen) { mSecureConnectionStart = mAsyncOpen; } @@ -307,8 +325,11 @@ PerformanceTiming::SecureConnectionStartHighRes() if (!nsContentUtils::IsPerformanceTimingEnabled() || !IsInitialized()) { return mZeroTime; } - return mSecureConnectionStart.IsNull() ? mZeroTime - : TimerClamping::ReduceMsTimeValue(TimeStampToDOMHighRes(mSecureConnectionStart)); + return !mSecureConnection + ? 0 // We use 0 here, because mZeroTime is sometimes set to the navigation + // start time. + : (mSecureConnectionStart.IsNull() ? mZeroTime + : TimerClamping::ReduceMsTimeValue(TimeStampToDOMHighRes(mSecureConnectionStart))); } DOMTimeMilliSec |