Title: [242896] trunk
Revision
242896
Author
joep...@webkit.org
Date
2019-03-13 12:04:43 -0700 (Wed, 13 Mar 2019)

Log Message

Web Inspector: Network - HAR Export duplicates blocked/send time if there was no dns/connect block
https://bugs.webkit.org/show_bug.cgi?id=195655
<rdar://problem/48831152>

Reviewed by Devin Rousso.

Source/WebInspectorUI:

* UserInterface/Controllers/HARBuilder.js:
(WI.HARBuilder.timings):

LayoutTests:

* http/tests/inspector/network/har/har-basic-expected.txt:
* http/tests/inspector/network/har/har-basic.html:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (242895 => 242896)


--- trunk/LayoutTests/ChangeLog	2019-03-13 18:45:31 UTC (rev 242895)
+++ trunk/LayoutTests/ChangeLog	2019-03-13 19:04:43 UTC (rev 242896)
@@ -1,3 +1,14 @@
+2019-03-13  Joseph Pecoraro  <pecor...@apple.com>
+
+        Web Inspector: Network - HAR Export duplicates blocked/send time if there was no dns/connect block
+        https://bugs.webkit.org/show_bug.cgi?id=195655
+        <rdar://problem/48831152>
+
+        Reviewed by Devin Rousso.
+
+        * http/tests/inspector/network/har/har-basic-expected.txt:
+        * http/tests/inspector/network/har/har-basic.html:
+
 2019-03-13  Antoine Quint  <grao...@apple.com>
 
         REGRESSION(r240634): Element::hasPointerCapture() passes a JS-controlled value directly into a HashMap as a key

Modified: trunk/LayoutTests/http/tests/inspector/network/har/har-basic-expected.txt (242895 => 242896)


--- trunk/LayoutTests/http/tests/inspector/network/har/har-basic-expected.txt	2019-03-13 18:45:31 UTC (rev 242895)
+++ trunk/LayoutTests/http/tests/inspector/network/har/har-basic-expected.txt	2019-03-13 19:04:43 UTC (rev 242896)
@@ -142,3 +142,78 @@
   }
 }
 
+-- Running test case: HAR.Basic.Timing
+PASS: HAR Timings for entry1 should add up to ~500ms before wait.
+PASS: HAR Timings for entry2 should add up to ~500ms before wait.
+PASS: HAR Timings for entry3 should add up to ~500ms before wait.
+{
+  "log": {
+    "version": "1.2",
+    "creator": "<filtered>",
+    "pages": [
+      {
+        "startedDateTime": "",
+        "id": "page_0",
+        "title": "http://127.0.0.1:8000/inspector/network/har/har-basic.html",
+        "pageTimings": {}
+      }
+    ],
+    "entries": [
+      {
+        "pageref": "page_0",
+        "startedDateTime": "2017-10-23T01:55:52.694Z",
+        "time": 700,
+        "request": "<filtered>",
+        "response": "<filtered>",
+        "cache": {},
+        "timings": {
+          "blocked": 500,
+          "dns": -1,
+          "connect": -1,
+          "ssl": -1,
+          "send": 0,
+          "wait": 100.00000000000009,
+          "receive": 99.99999999999987
+        },
+        "_fetchType": "Network Load"
+      },
+      {
+        "pageref": "page_0",
+        "startedDateTime": "2017-10-23T01:55:52.694Z",
+        "time": 700,
+        "request": "<filtered>",
+        "response": "<filtered>",
+        "cache": {},
+        "timings": {
+          "blocked": 100.00000000000009,
+          "dns": 99.99999999999987,
+          "connect": -1,
+          "ssl": -1,
+          "send": 300.00000000000006,
+          "wait": 100.00000000000009,
+          "receive": 99.99999999999987
+        },
+        "_fetchType": "Network Load"
+      },
+      {
+        "pageref": "page_0",
+        "startedDateTime": "2017-10-23T01:55:52.694Z",
+        "time": 700,
+        "request": "<filtered>",
+        "response": "<filtered>",
+        "cache": {},
+        "timings": {
+          "blocked": 300.00000000000006,
+          "dns": -1,
+          "connect": 99.99999999999987,
+          "ssl": -1,
+          "send": 100.00000000000009,
+          "wait": 100.00000000000009,
+          "receive": 99.99999999999987
+        },
+        "_fetchType": "Network Load"
+      }
+    ]
+  }
+}
+

Modified: trunk/LayoutTests/http/tests/inspector/network/har/har-basic.html (242895 => 242896)


--- trunk/LayoutTests/http/tests/inspector/network/har/har-basic.html	2019-03-13 18:45:31 UTC (rev 242895)
+++ trunk/LayoutTests/http/tests/inspector/network/har/har-basic.html	2019-03-13 19:04:43 UTC (rev 242896)
@@ -15,6 +15,26 @@
         return value;
     }
 
+    const timingFilterSet = new Set(["creator", "browser", "request", "response"]);
+    function HARJSONTimingFilter(key, value) {
+        if (timingFilterSet.has(key))
+            return "<filtered>";
+        return value;
+    }
+
+    const url = ""
+    const mimeType = "text/_javascript_";
+    const type = WI.Resource.Type.Script;
+    const requestMethod = "GET";
+    const requestHeaders = {"Test-Request-Header": "Test Request Header Value"};
+    const responseHeaders = {"Test-Response-Header": "Test Response Header Value"};
+    const statusCode = 200;
+    const statusText = "OK";
+    const source = "network";
+    const requestSentWalltime = 1508723752694 / 1000; // Sun Oct 22 2017 18:55:52 GMT-0700, when this test was written.
+    const timestamp = undefined;
+    const size = 1234;
+
     let suite = InspectorTest.createAsyncSuite("HAR.Basic");
 
     suite.addTestCase({
@@ -31,18 +51,6 @@
         description: "Should be able to generate a HAR with resources.",
         async test() {
             // FIXME: We should have an easier way to construct a Resource with mock data.
-            const url = ""
-            const mimeType = "text/_javascript_";
-            const type = WI.Resource.Type.Script;
-            const requestMethod = "GET";
-            const requestHeaders = {"Test-Request-Header": "Test Request Header Value"};
-            const responseHeaders = {"Test-Response-Header": "Test Response Header Value"};
-            const statusCode = 200;
-            const statusText = "OK";
-            const source = "network";
-            const requestSentWalltime = 1508723752694 / 1000; // Sun Oct 22 2017 18:55:52 GMT-0700, when this test was written.
-            const timestamp = undefined;
-            const size = 1234;
             const timingData = {
                 startTime: 1,
                 domainLookupStart: 100,
@@ -81,6 +89,77 @@
         }
     });
 
+    suite.addTestCase({
+        name: "HAR.Basic.Timing",
+        description: "Test for HAR timing data when various dns/connect sections are empty.",
+        async test() {
+            function resourceWithTimingData(timingData) {
+                let resource = new WI.Resource(url, {mimeType, type, requestMethod, requestHeaders, requestSentWalltime});
+                resource.updateForResponse(url, mimeType, type, responseHeaders, statusCode, statusText, timestamp, timingData, source);
+                resource.increaseSize(size);
+                resource.markAsFinished(1.7);
+                return resource;
+            }
+
+            let resource1 = resourceWithTimingData({
+                startTime: 1,
+                domainLookupStart: NaN,
+                domainLookupEnd: NaN,
+                connectStart: NaN,
+                connectEnd: NaN,
+                secureConnectionStart: NaN,
+                requestStart: 500,
+                responseStart: 600,
+                responseEnd: 700,
+            });
+
+            let resource2 = resourceWithTimingData({
+                startTime: 1,
+                domainLookupStart: 100,
+                domainLookupEnd: 200,
+                connectStart: NaN,
+                connectEnd: NaN,
+                secureConnectionStart: NaN,
+                requestStart: 500,
+                responseStart: 600,
+                responseEnd: 700,
+            });
+
+            let resource3 = resourceWithTimingData({
+                startTime: 1,
+                domainLookupStart: NaN,
+                domainLookupEnd: NaN,
+                connectStart: 300,
+                connectEnd: 400,
+                secureConnectionStart: NaN,
+                requestStart: 500,
+                responseStart: 600,
+                responseEnd: 700,
+            });
+
+            function sumTimingDataTillWait(entry) {
+                let {blocked, dns, connect, send} = entry.timings;
+                let sum = 0;
+                if (blocked > 0)
+                    sum += blocked;
+                if (dns > 0)
+                    sum += dns;
+                if (connect > 0)
+                    sum += connect;
+                if (send > 0)
+                    sum += send;
+                return sum;
+            }
+
+            let har = await WI.HARBuilder.buildArchive([resource1, resource2, resource3]);
+            let {log: {entries: [entry1, entry2, entry3]}} = har;
+            InspectorTest.expectEqualWithAccuracy(sumTimingDataTillWait(entry1), 500, 0.001, `HAR Timings for entry1 should add up to ~500ms before wait.`);
+            InspectorTest.expectEqualWithAccuracy(sumTimingDataTillWait(entry2), 500, 0.001, `HAR Timings for entry2 should add up to ~500ms before wait.`);
+            InspectorTest.expectEqualWithAccuracy(sumTimingDataTillWait(entry3), 500, 0.001, `HAR Timings for entry3 should add up to ~500ms before wait.`);
+            InspectorTest.json(har, HARJSONTimingFilter);
+        }
+    });
+
     suite.runTestCasesAndFinish();
 }
 </script>

Modified: trunk/Source/WebInspectorUI/ChangeLog (242895 => 242896)


--- trunk/Source/WebInspectorUI/ChangeLog	2019-03-13 18:45:31 UTC (rev 242895)
+++ trunk/Source/WebInspectorUI/ChangeLog	2019-03-13 19:04:43 UTC (rev 242896)
@@ -1,3 +1,14 @@
+2019-03-13  Joseph Pecoraro  <pecor...@apple.com>
+
+        Web Inspector: Network - HAR Export duplicates blocked/send time if there was no dns/connect block
+        https://bugs.webkit.org/show_bug.cgi?id=195655
+        <rdar://problem/48831152>
+
+        Reviewed by Devin Rousso.
+
+        * UserInterface/Controllers/HARBuilder.js:
+        (WI.HARBuilder.timings):
+
 2019-03-12  Devin Rousso  <drou...@apple.com>
 
         Web Inspector: Sources: allow image collections to be filtered by type

Modified: trunk/Source/WebInspectorUI/UserInterface/Controllers/HARBuilder.js (242895 => 242896)


--- trunk/Source/WebInspectorUI/UserInterface/Controllers/HARBuilder.js	2019-03-13 18:45:31 UTC (rev 242895)
+++ trunk/Source/WebInspectorUI/UserInterface/Controllers/HARBuilder.js	2019-03-13 19:04:43 UTC (rev 242896)
@@ -262,7 +262,12 @@
                 result.connect = ((connectEnd || requestStart) - connectStart) * 1000;
             if (secureConnectionStart)
                 result.ssl = ((connectEnd || requestStart) - secureConnectionStart) * 1000;
-            result.send = (requestStart - (connectEnd || domainLookupEnd || startTime)) * 1000;
+
+            // If all the time before requestStart was included in blocked, then make send time zero
+            // as send time is essentially just blocked time after dns / connection time, and we
+            // do not want to double count it.
+            result.send = (domainLookupEnd || connectEnd) ? (requestStart - (connectEnd || domainLookupEnd)) * 1000 : 0;
+
             result.wait = (responseStart - requestStart) * 1000;
             result.receive = (responseEnd - responseStart) * 1000;
         }
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to