summaryrefslogtreecommitdiffstats
path: root/dom/performance
diff options
context:
space:
mode:
authorjanekptacijarabaci <janekptacijarabaci@seznam.cz>2018-03-17 13:35:25 +0100
committerjanekptacijarabaci <janekptacijarabaci@seznam.cz>2018-03-17 13:35:25 +0100
commita10b23932cd567324b7e1071f3ddc4c46a8270d8 (patch)
tree5c299765112a1c41800b08a93f9cc875764fdf4c /dom/performance
parenta24511ca8e19afe4d19008ba903e1edab0af3223 (diff)
downloadUXP-a10b23932cd567324b7e1071f3ddc4c46a8270d8.tar
UXP-a10b23932cd567324b7e1071f3ddc4c46a8270d8.tar.gz
UXP-a10b23932cd567324b7e1071f3ddc4c46a8270d8.tar.lz
UXP-a10b23932cd567324b7e1071f3ddc4c46a8270d8.tar.xz
UXP-a10b23932cd567324b7e1071f3ddc4c46a8270d8.zip
Set "secureConnectionStart" to 0 for pages with HTTP scheme
Issue #67
Diffstat (limited to 'dom/performance')
-rwxr-xr-xdom/performance/PerformanceTiming.cpp27
-rwxr-xr-xdom/performance/PerformanceTiming.h2
-rw-r--r--dom/performance/tests/test_performance_user_timing.js2
3 files changed, 27 insertions, 4 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
diff --git a/dom/performance/PerformanceTiming.h b/dom/performance/PerformanceTiming.h
index edfac8d02..fc7e7d5bd 100755
--- a/dom/performance/PerformanceTiming.h
+++ b/dom/performance/PerformanceTiming.h
@@ -274,6 +274,8 @@ private:
// redirectEnd attributes. It is false if there were no redirects, or if
// any of the responses didn't pass the timing-allow-check
bool mReportCrossOriginRedirect;
+
+ bool mSecureConnection;
};
} // namespace dom
diff --git a/dom/performance/tests/test_performance_user_timing.js b/dom/performance/tests/test_performance_user_timing.js
index 3d05ebb77..cd8261bbd 100644
--- a/dom/performance/tests/test_performance_user_timing.js
+++ b/dom/performance/tests/test_performance_user_timing.js
@@ -263,7 +263,7 @@ var steps = [
performance.measure("test", n);
ok(true, "Measure created from reserved name as starting time: " + n);
} catch (e) {
- ok(["redirectStart", "redirectEnd", "unloadEventStart", "unloadEventEnd", "loadEventEnd"].indexOf(n) >= 0,
+ ok(["redirectStart", "redirectEnd", "unloadEventStart", "unloadEventEnd", "loadEventEnd", "secureConnectionStart"].indexOf(n) >= 0,
"Measure created from reserved name as starting time: " + n + " and threw expected error");
}
};