Changeset 242896 in webkit


Ignore:
Timestamp:
Mar 13, 2019 12:04:43 PM (5 years ago)
Author:
Joseph Pecoraro
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:
Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r242893 r242896  
     12019-03-13  Joseph Pecoraro  <pecoraro@apple.com>
     2
     3        Web Inspector: Network - HAR Export duplicates blocked/send time if there was no dns/connect block
     4        https://bugs.webkit.org/show_bug.cgi?id=195655
     5        <rdar://problem/48831152>
     6
     7        Reviewed by Devin Rousso.
     8
     9        * http/tests/inspector/network/har/har-basic-expected.txt:
     10        * http/tests/inspector/network/har/har-basic.html:
     11
    1122019-03-13  Antoine Quint  <graouts@apple.com>
    213
  • trunk/LayoutTests/http/tests/inspector/network/har/har-basic-expected.txt

    r223856 r242896  
    143143}
    144144
     145-- Running test case: HAR.Basic.Timing
     146PASS: HAR Timings for entry1 should add up to ~500ms before wait.
     147PASS: HAR Timings for entry2 should add up to ~500ms before wait.
     148PASS: HAR Timings for entry3 should add up to ~500ms before wait.
     149{
     150  "log": {
     151    "version": "1.2",
     152    "creator": "<filtered>",
     153    "pages": [
     154      {
     155        "startedDateTime": "",
     156        "id": "page_0",
     157        "title": "http://127.0.0.1:8000/inspector/network/har/har-basic.html",
     158        "pageTimings": {}
     159      }
     160    ],
     161    "entries": [
     162      {
     163        "pageref": "page_0",
     164        "startedDateTime": "2017-10-23T01:55:52.694Z",
     165        "time": 700,
     166        "request": "<filtered>",
     167        "response": "<filtered>",
     168        "cache": {},
     169        "timings": {
     170          "blocked": 500,
     171          "dns": -1,
     172          "connect": -1,
     173          "ssl": -1,
     174          "send": 0,
     175          "wait": 100.00000000000009,
     176          "receive": 99.99999999999987
     177        },
     178        "_fetchType": "Network Load"
     179      },
     180      {
     181        "pageref": "page_0",
     182        "startedDateTime": "2017-10-23T01:55:52.694Z",
     183        "time": 700,
     184        "request": "<filtered>",
     185        "response": "<filtered>",
     186        "cache": {},
     187        "timings": {
     188          "blocked": 100.00000000000009,
     189          "dns": 99.99999999999987,
     190          "connect": -1,
     191          "ssl": -1,
     192          "send": 300.00000000000006,
     193          "wait": 100.00000000000009,
     194          "receive": 99.99999999999987
     195        },
     196        "_fetchType": "Network Load"
     197      },
     198      {
     199        "pageref": "page_0",
     200        "startedDateTime": "2017-10-23T01:55:52.694Z",
     201        "time": 700,
     202        "request": "<filtered>",
     203        "response": "<filtered>",
     204        "cache": {},
     205        "timings": {
     206          "blocked": 300.00000000000006,
     207          "dns": -1,
     208          "connect": 99.99999999999987,
     209          "ssl": -1,
     210          "send": 100.00000000000009,
     211          "wait": 100.00000000000009,
     212          "receive": 99.99999999999987
     213        },
     214        "_fetchType": "Network Load"
     215      }
     216    ]
     217  }
     218}
     219
  • trunk/LayoutTests/http/tests/inspector/network/har/har-basic.html

    r236891 r242896  
    1616    }
    1717
     18    const timingFilterSet = new Set(["creator", "browser", "request", "response"]);
     19    function HARJSONTimingFilter(key, value) {
     20        if (timingFilterSet.has(key))
     21            return "<filtered>";
     22        return value;
     23    }
     24
     25    const url = "https://example.com/fake.js";
     26    const mimeType = "text/javascript";
     27    const type = WI.Resource.Type.Script;
     28    const requestMethod = "GET";
     29    const requestHeaders = {"Test-Request-Header": "Test Request Header Value"};
     30    const responseHeaders = {"Test-Response-Header": "Test Response Header Value"};
     31    const statusCode = 200;
     32    const statusText = "OK";
     33    const source = "network";
     34    const requestSentWalltime = 1508723752694 / 1000; // Sun Oct 22 2017 18:55:52 GMT-0700, when this test was written.
     35    const timestamp = undefined;
     36    const size = 1234;
     37
    1838    let suite = InspectorTest.createAsyncSuite("HAR.Basic");
    1939
     
    3252        async test() {
    3353            // FIXME: We should have an easier way to construct a Resource with mock data.
    34             const url = "https://example.com/fake.js";
    35             const mimeType = "text/javascript";
    36             const type = WI.Resource.Type.Script;
    37             const requestMethod = "GET";
    38             const requestHeaders = {"Test-Request-Header": "Test Request Header Value"};
    39             const responseHeaders = {"Test-Response-Header": "Test Response Header Value"};
    40             const statusCode = 200;
    41             const statusText = "OK";
    42             const source = "network";
    43             const requestSentWalltime = 1508723752694 / 1000; // Sun Oct 22 2017 18:55:52 GMT-0700, when this test was written.
    44             const timestamp = undefined;
    45             const size = 1234;
    4654            const timingData = {
    4755                startTime: 1,
     
    8290    });
    8391
     92    suite.addTestCase({
     93        name: "HAR.Basic.Timing",
     94        description: "Test for HAR timing data when various dns/connect sections are empty.",
     95        async test() {
     96            function resourceWithTimingData(timingData) {
     97                let resource = new WI.Resource(url, {mimeType, type, requestMethod, requestHeaders, requestSentWalltime});
     98                resource.updateForResponse(url, mimeType, type, responseHeaders, statusCode, statusText, timestamp, timingData, source);
     99                resource.increaseSize(size);
     100                resource.markAsFinished(1.7);
     101                return resource;
     102            }
     103
     104            let resource1 = resourceWithTimingData({
     105                startTime: 1,
     106                domainLookupStart: NaN,
     107                domainLookupEnd: NaN,
     108                connectStart: NaN,
     109                connectEnd: NaN,
     110                secureConnectionStart: NaN,
     111                requestStart: 500,
     112                responseStart: 600,
     113                responseEnd: 700,
     114            });
     115
     116            let resource2 = resourceWithTimingData({
     117                startTime: 1,
     118                domainLookupStart: 100,
     119                domainLookupEnd: 200,
     120                connectStart: NaN,
     121                connectEnd: NaN,
     122                secureConnectionStart: NaN,
     123                requestStart: 500,
     124                responseStart: 600,
     125                responseEnd: 700,
     126            });
     127
     128            let resource3 = resourceWithTimingData({
     129                startTime: 1,
     130                domainLookupStart: NaN,
     131                domainLookupEnd: NaN,
     132                connectStart: 300,
     133                connectEnd: 400,
     134                secureConnectionStart: NaN,
     135                requestStart: 500,
     136                responseStart: 600,
     137                responseEnd: 700,
     138            });
     139
     140            function sumTimingDataTillWait(entry) {
     141                let {blocked, dns, connect, send} = entry.timings;
     142                let sum = 0;
     143                if (blocked > 0)
     144                    sum += blocked;
     145                if (dns > 0)
     146                    sum += dns;
     147                if (connect > 0)
     148                    sum += connect;
     149                if (send > 0)
     150                    sum += send;
     151                return sum;
     152            }
     153
     154            let har = await WI.HARBuilder.buildArchive([resource1, resource2, resource3]);
     155            let {log: {entries: [entry1, entry2, entry3]}} = har;
     156            InspectorTest.expectEqualWithAccuracy(sumTimingDataTillWait(entry1), 500, 0.001, `HAR Timings for entry1 should add up to ~500ms before wait.`);
     157            InspectorTest.expectEqualWithAccuracy(sumTimingDataTillWait(entry2), 500, 0.001, `HAR Timings for entry2 should add up to ~500ms before wait.`);
     158            InspectorTest.expectEqualWithAccuracy(sumTimingDataTillWait(entry3), 500, 0.001, `HAR Timings for entry3 should add up to ~500ms before wait.`);
     159            InspectorTest.json(har, HARJSONTimingFilter);
     160        }
     161    });
     162
    84163    suite.runTestCasesAndFinish();
    85164}
  • trunk/Source/WebInspectorUI/ChangeLog

    r242829 r242896  
     12019-03-13  Joseph Pecoraro  <pecoraro@apple.com>
     2
     3        Web Inspector: Network - HAR Export duplicates blocked/send time if there was no dns/connect block
     4        https://bugs.webkit.org/show_bug.cgi?id=195655
     5        <rdar://problem/48831152>
     6
     7        Reviewed by Devin Rousso.
     8
     9        * UserInterface/Controllers/HARBuilder.js:
     10        (WI.HARBuilder.timings):
     11
    1122019-03-12  Devin Rousso  <drousso@apple.com>
    213
  • trunk/Source/WebInspectorUI/UserInterface/Controllers/HARBuilder.js

    r236766 r242896  
    263263            if (secureConnectionStart)
    264264                result.ssl = ((connectEnd || requestStart) - secureConnectionStart) * 1000;
    265             result.send = (requestStart - (connectEnd || domainLookupEnd || startTime)) * 1000;
     265
     266            // If all the time before requestStart was included in blocked, then make send time zero
     267            // as send time is essentially just blocked time after dns / connection time, and we
     268            // do not want to double count it.
     269            result.send = (domainLookupEnd || connectEnd) ? (requestStart - (connectEnd || domainLookupEnd)) * 1000 : 0;
     270
    266271            result.wait = (responseStart - requestStart) * 1000;
    267272            result.receive = (responseEnd - responseStart) * 1000;
Note: See TracChangeset for help on using the changeset viewer.