Bug 1513443 [wpt PR 14472] - Add WPT to verify that 1XX responses are used to provide responseStart timing, a=testonly
authorAndrew Comminos <acomminos@fb.com>
Wed, 19 Dec 2018 12:09:33 +0000
changeset 515039 d102ed7e2f5e5dc4c25af133be3bae0e0c9d8c42
parent 515038 ce83501a41ddc819a6ece865ac8f964b7f0bf5d1
child 515040 7b3a9d543fa3970a534623af923d4e2d77aa834d
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
bugs1513443, 14472, 568024, 1372359, 615853
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 1513443 [wpt PR 14472] - Add WPT to verify that 1XX responses are used to provide responseStart timing, a=testonly Automatic update from web-platform-tests Add WPT to verify that 1XX responses are used to provide responseStart timing Verifies that the UA sets responseStart to the time that an initial 1XX response was received by returning {100, delay, 200} and testing that the delay is not included in responseStart. Bug: 568024 Change-Id: I7295e6478a95abe1b6154ddf1feab764f596a5ec Reviewed-on: https://chromium-review.googlesource.com/c/1372359 Reviewed-by: Yoav Weiss <yoavweiss@chromium.org> Commit-Queue: Yoav Weiss <yoavweiss@chromium.org> Cr-Commit-Position: refs/heads/master@{#615853} -- wpt-commits: 6d3120bad3e5d55bfebb3063a5ef04e7fc231905 wpt-pr: 14472
testing/web-platform/tests/resource-timing/SyntheticResponse.py
testing/web-platform/tests/resource-timing/resource-timing.js
--- a/testing/web-platform/tests/resource-timing/SyntheticResponse.py
+++ b/testing/web-platform/tests/resource-timing/SyntheticResponse.py
@@ -28,15 +28,19 @@ def main(request, response):
                     response.writer.write_header(key, value)
                 response.writer.end_headers()
                 headersSent = True
 
             response.writer.write_content(text)
         elif arg.startswith("status:"):
             code = int(urllib.unquote(arg[7:]))
             response.writer.write_status(code)
-            statusSent = True
+            if code // 100 == 1:
+                # Terminate informational 1XX responses with an empty line.
+                response.writer.end_headers()
+            else:
+                statusSent = True
         elif arg == "flush":
             response.writer.flush()
 
 #        else:
 #            error "  INVALID ARGUMENT %s" % arg
 
--- a/testing/web-platform/tests/resource-timing/resource-timing.js
+++ b/testing/web-platform/tests/resource-timing/resource-timing.js
@@ -257,16 +257,57 @@ window.onload =
                                 "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.
+        //
+        // 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 },
+            { initiator: "script",         response: '"";',       mime: mimeScript },
+            { initiator: "link",           response: ".unused{}", mime: mimeCss },
+        ]
+        .forEach(function (template) {
+            testCases.push({
+                description: "'" + template.initiator + " responseStart uses 1XX (first) response timings'",
+                test: function (test) {
+                    initiateFetch(
+                        test,
+                        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,
+                                "HTTP/1.1 1XX (first) response should determine 'responseStart' timing.");
+
+                            test.done();
+                        });
+                    }
+                });
+            });
+
         // Function to run the next case in the queue.
         var currentTestIndex = -1;
         function runNextCase() {
             var testCase = testCases[++currentTestIndex];
             if (testCase !== undefined) {
                 async_test(testCase.test, testCase.description);
             }
         }