Bug 1514654 [wpt PR 14548] - Verify TTFB in resource-timing.html WPT by measuring that the delay occurs between responseStart and responseEnd, a=testonly
authorAndrew Comminos <acomminos@fb.com>
Wed, 19 Dec 2018 12:09:35 +0000
changeset 515040 7b3a9d543fa3970a534623af923d4e2d77aa834d
parent 515039 d102ed7e2f5e5dc4c25af133be3bae0e0c9d8c42
child 515041 030974f99191feb97b4b625f1476945dcb64d1a3
push id1953
push userffxbld-merge
push dateMon, 11 Mar 2019 12:10:20 +0000
treeherdermozilla-release@9c35dcbaa899 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstestonly
bugs1514654, 14548, 568024, 1377725, 617021
milestone66.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1514654 [wpt PR 14548] - Verify TTFB in resource-timing.html WPT by measuring that the delay occurs between responseStart and responseEnd, a=testonly Automatic update from web-platform-tests Verify TTFB in resource-timing.html WPT by measuring that the delay occurs between responseStart and responseEnd When simulating a delay after a statusline, measure that the delay is not included in the TTFB by measuring that it occurred between responseStart and responseEnd rather than requestStart and responseStart. This makes the tests less flaky when subject to shaky network and thread scheduling conditions, as might be present using Firefox's chaos mode. Bug: 568024 Change-Id: I0356f6256af6bc87fbb14860ed05472526c03e5d Reviewed-on: https://chromium-review.googlesource.com/c/1377725 Reviewed-by: Yoav Weiss <yoav@yoav.ws> Commit-Queue: Andrew Comminos <acomminos@fb.com> Cr-Commit-Position: refs/heads/master@{#617021} -- wpt-commits: 7275e40d9bc2a6cebec14f29a4993334bb208ed8 wpt-pr: 14548
testing/web-platform/tests/resource-timing/resource-timing.js
--- a/testing/web-platform/tests/resource-timing/resource-timing.js
+++ b/testing/web-platform/tests/resource-timing/resource-timing.js
@@ -222,17 +222,17 @@ window.onload =
                         });
                     }
                 });
             });
 
         // Ensure that responseStart only measures the time up to the first few
         // bytes of the header response. This is tested by writing an HTTP 1.1
         // status line, followed by a flush, then a pause before the end of the
-        // headers. The tests makes sure that responseStart is not delayed by
+        // headers. The test makes sure that responseStart is not delayed by
         // this pause.
         [
             { initiator: "iframe",         response: "(done)",    mime: mimeHtml },
             { initiator: "xmlhttprequest", response: "(done)",    mime: mimeText },
             { initiator: "script",         response: '"";',       mime: mimeScript },
             { initiator: "link",           response: ".unused{}", mime: mimeCss },
         ]
         .forEach(function (template) {
@@ -243,35 +243,36 @@ window.onload =
                         test,
                         template.initiator,
                         getSyntheticUrl("status:200"
                                         + "&flush"
                                         + "&" + serverStepDelay + "ms"
                                         + "&mime:" + template.mime
                                         + "&send:" + encodeURIComponent(template.response)),
                         function (initiator, entry) {
-                            // Test that the delay between 'requestStart' and
-                            // 'responseStart' does not include the added delay
-                            // post-statusline.
-                            assert_less_than(
-                                entry.responseStart - entry.requestStart,
-                                serverStepDelay,
+                            // Test that the delay between 'responseStart' and
+                            // 'responseEnd' includes the delay, which implies
+                            // that 'responseStart' was measured at the time of
+                            // status line receipt.
+                            assert_greater_than_equal(
+                                entry.responseEnd,
+                                entry.responseStart + serverStepDelay,
                                 "Delay after HTTP/1.1 status should not affect 'responseStart'.");
 
                             test.done();
                         });
                     }
                 });
             });
 
         // Test that responseStart uses the timing of 1XX responses by
         // synthesizing a delay between a 100 and 200 status, and verifying that
-        // responseStart does not include this delay. If the delay is included,
-        // this implies that the 200 status line was (incorrectly) used for
-        // responseStart timing, despite the 100 response arriving earlier.
+        // this delay is included before responseEnd. If the delay is not
+        // included, this implies that the 200 status line was (incorrectly) used
+        // for responseStart timing, despite the 100 response arriving earlier.
         //
         // Source: "In the case where more than one response is available for a
         // request, due to an Informational 1xx response, the reported
         // responseStart value is that of the first response to the last
         // request."
         [
             { initiator: "iframe",         response: "(done)",    mime: mimeHtml },
             { initiator: "xmlhttprequest", response: "(done)",    mime: mimeText },
@@ -287,19 +288,19 @@ window.onload =
                         template.initiator,
                         getSyntheticUrl("status:100"
                                         + "&flush"
                                         + "&" + serverStepDelay + "ms"
                                         + "&status:200"
                                         + "&mime:" + template.mime
                                         + "&send:" + encodeURIComponent(template.response)),
                         function (initiator, entry) {
-                            assert_less_than(
-                                entry.responseStart - entry.requestStart,
-                                serverStepDelay,
+                            assert_greater_than_equal(
+                                entry.responseEnd,
+                                entry.responseStart + serverStepDelay,
                                 "HTTP/1.1 1XX (first) response should determine 'responseStart' timing.");
 
                             test.done();
                         });
                     }
                 });
             });