Bug 1560495: Update unload event security information for Navigation-Timing Level 2 specification. r=baku a=RyanVM
authorWill Hawkins <whawkins@mozilla.com>
Tue, 09 Jul 2019 07:19:50 +0000
changeset 544669 6aa4c38274c43f00b98eeb974c7ee067dfc4e8e4
parent 544668 50dcd65bee401205c50299cbe6fa5cc8dc67a5fa
child 544670 20dec11dae3c02b4a87c7a9809de38262f61752d
push id2131
push userffxbld-merge
push dateMon, 26 Aug 2019 18:30:20 +0000
treeherdermozilla-release@b19ffb3ca153 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbaku, RyanVM
bugs1560495
milestone69.0
Bug 1560495: Update unload event security information for Navigation-Timing Level 2 specification. r=baku a=RyanVM Differential Revision: https://phabricator.services.mozilla.com/D36293
dom/performance/PerformanceNavigationTiming.cpp
testing/web-platform/meta/navigation-timing/nav2_test_redirect_xserver_opt_in.html.ini
testing/web-platform/meta/navigation-timing/nav2_test_unloadEvents_no_previous_document.html.ini
testing/web-platform/meta/navigation-timing/nav2_test_unloadEvents_previous_document_cross_origin.sub.html.ini
testing/web-platform/meta/navigation-timing/nav2_test_unloadEvents_with_cross_origin_redirect_chain_partial_opt_in.html.ini
testing/web-platform/meta/navigation-timing/nav2_test_unloadEvents_with_cross_origin_redirect_opt_in.html.ini
testing/web-platform/meta/navigation-timing/nav2_test_unloadEvents_with_cross_origin_redirects.html.ini
testing/web-platform/meta/navigation-timing/nav2_test_unloadEvents_with_previous_document.html.ini
--- a/dom/performance/PerformanceNavigationTiming.cpp
+++ b/dom/performance/PerformanceNavigationTiming.cpp
@@ -24,25 +24,51 @@ JSObject* PerformanceNavigationTiming::W
 #define REDUCE_TIME_PRECISION                      \
   if (mPerformance->IsSystemPrincipal()) {         \
     return rawValue;                               \
   }                                                \
   return nsRFPService::ReduceTimePrecisionAsMSecs( \
       rawValue, mPerformance->GetRandomTimelineSeed())
 
 DOMHighResTimeStamp PerformanceNavigationTiming::UnloadEventStart() const {
-  DOMHighResTimeStamp rawValue =
-      mPerformance->GetDOMTiming()->GetUnloadEventStartHighRes();
+  DOMHighResTimeStamp rawValue = 0;
+  /*
+   * Per Navigation Timing Level 2, the value is 0 if
+   * a. there is no previous document or
+   * b. the same-origin-check fails.
+   *
+   * The same-origin-check is defined as:
+   * 1. If the previous document exists and its origin is not same
+   *    origin as the current document's origin, return "fail".
+   * 2. Let request be the current document's request.
+   * 3. If request's redirect count is not zero, and all of request's
+   *    HTTP redirects have the same origin as the current document,
+   *    return "pass".
+   * 4. Otherwise, return "fail".
+   */
+  if (mTimingData->AllRedirectsSameOrigin()) {  // same-origin-check:2/3
+    /*
+     * GetUnloadEventStartHighRes returns 0 if
+     * 1. there is no previous document (a, above) or
+     * 2. the current URI does not have the same origin as
+     *    the previous document's URI. (same-origin-check:1)
+     */
+    rawValue = mPerformance->GetDOMTiming()->GetUnloadEventStartHighRes();
+  }
 
   REDUCE_TIME_PRECISION;
 }
 
 DOMHighResTimeStamp PerformanceNavigationTiming::UnloadEventEnd() const {
-  DOMHighResTimeStamp rawValue =
-      mPerformance->GetDOMTiming()->GetUnloadEventEndHighRes();
+  DOMHighResTimeStamp rawValue = 0;
+
+  // See comments in PerformanceNavigationTiming::UnloadEventEnd().
+  if (mTimingData->AllRedirectsSameOrigin()) {
+    rawValue = mPerformance->GetDOMTiming()->GetUnloadEventEndHighRes();
+  }
 
   REDUCE_TIME_PRECISION;
 }
 
 DOMHighResTimeStamp PerformanceNavigationTiming::DomInteractive() const {
   DOMHighResTimeStamp rawValue =
       mPerformance->GetDOMTiming()->GetDomInteractiveHighRes();
 
--- a/testing/web-platform/meta/navigation-timing/nav2_test_redirect_xserver_opt_in.html.ini
+++ b/testing/web-platform/meta/navigation-timing/nav2_test_redirect_xserver_opt_in.html.ini
@@ -1,4 +1,2 @@
 [nav2_test_redirect_xserver_opt_in.html]
-  [Navigation Timing 2 WPT]
-    expected: FAIL
-
+  disabled: https://bugzilla.mozilla.org/show_bug.cgi?id=1564217
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/meta/navigation-timing/nav2_test_unloadEvents_no_previous_document.html.ini
@@ -0,0 +1,2 @@
+[nav2_test_unloadEvents_no_previous_document.html]
+  disabled: https://bugzilla.mozilla.org/show_bug.cgi?id=1564217
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/meta/navigation-timing/nav2_test_unloadEvents_previous_document_cross_origin.sub.html.ini
@@ -0,0 +1,2 @@
+[nav2_test_unloadEvents_previous_document_cross_origin.sub.html]
+  disabled: https://bugzilla.mozilla.org/show_bug.cgi?id=1564217
--- a/testing/web-platform/meta/navigation-timing/nav2_test_unloadEvents_with_cross_origin_redirect_chain_partial_opt_in.html.ini
+++ b/testing/web-platform/meta/navigation-timing/nav2_test_unloadEvents_with_cross_origin_redirect_chain_partial_opt_in.html.ini
@@ -1,4 +1,2 @@
-[nav2_test_unloadEvents_with_cross_origin_redirect_chain_partial_opt_in.html]
-  [Navigation Timing 2 WPT]
-    expected: FAIL
-
+[nav2_test_unloadEvents_with_cross_origin_redirect_chain_partial_opt]
+  disabled: https://bugzilla.mozilla.org/show_bug.cgi?id=1564217
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/meta/navigation-timing/nav2_test_unloadEvents_with_cross_origin_redirect_opt_in.html.ini
@@ -0,0 +1,2 @@
+[nav2_test_unloadEvents_with_cross_origin_redirect_opt_in.html]
+  disabled: https://bugzilla.mozilla.org/show_bug.cgi?id=1564217
--- a/testing/web-platform/meta/navigation-timing/nav2_test_unloadEvents_with_cross_origin_redirects.html.ini
+++ b/testing/web-platform/meta/navigation-timing/nav2_test_unloadEvents_with_cross_origin_redirects.html.ini
@@ -1,7 +1,2 @@
-[nav2_test_unloadEvents_with_cross_origin_redirects.html]
-  disabled:
-    if os == "android" and not e10s: https://bugzilla.mozilla.org/show_bug.cgi?id=1499003
-  [Navigation Timing 2 WPT]
-    expected:
-      FAIL
-
+[navigation-timing/nav2_test_unloadEvents_with_cross_origin_redirects.html]
+  disabled: https://bugzilla.mozilla.org/show_bug.cgi?id=1564217
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/meta/navigation-timing/nav2_test_unloadEvents_with_previous_document.html.ini
@@ -0,0 +1,2 @@
+[nav2_test_unloadEvents_with_previous_document.html]
+  disabled: https://bugzilla.mozilla.org/show_bug.cgi?id=1564217