Web Inspector: HAR Extension for Resource Priority
authorjoepeck@webkit.org <joepeck@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 16 Mar 2019 03:14:52 +0000 (03:14 +0000)
committerjoepeck@webkit.org <joepeck@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 16 Mar 2019 03:14:52 +0000 (03:14 +0000)
https://bugs.webkit.org/show_bug.cgi?id=195693

Reviewed by Devin Rousso.

Source/WebInspectorUI:

* UserInterface/Controllers/HARBuilder.js:
(WI.HARBuilder.entry):
(WI.HARBuilder.priority):
(WI.HARBuilder.networkPriorityFromHARPriority):
Include priority custom extension.

* UserInterface/Models/LocalResource.js:
(WI.LocalResource.fromHAREntry):
Import priority.

LayoutTests:

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

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@243031 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/http/tests/inspector/network/har/har-basic-expected.txt
LayoutTests/http/tests/inspector/network/har/har-page-expected.txt
Source/WebInspectorUI/ChangeLog
Source/WebInspectorUI/UserInterface/Controllers/HARBuilder.js
Source/WebInspectorUI/UserInterface/Models/LocalResource.js

index ccd81b4..8ca4865 100644 (file)
@@ -1,5 +1,15 @@
 2019-03-15  Joseph Pecoraro  <pecoraro@apple.com>
 
+        Web Inspector: HAR Extension for Resource Priority
+        https://bugs.webkit.org/show_bug.cgi?id=195693
+
+        Reviewed by Devin Rousso.
+
+        * http/tests/inspector/network/har/har-basic-expected.txt:
+        * http/tests/inspector/network/har/har-page-expected.txt:
+
+2019-03-15  Joseph Pecoraro  <pecoraro@apple.com>
+
         Web Inspector: Timelines - Import / Export Timeline Recordings
         https://bugs.webkit.org/show_bug.cgi?id=195709
         <rdar://problem/23188921>
index 48fc8bb..97a10bf 100644 (file)
@@ -136,7 +136,8 @@ Basic tests for HAR.
         },
         "serverIPAddress": "12.34.56.78",
         "connection": "1",
-        "_fetchType": "Network Load"
+        "_fetchType": "Network Load",
+        "_priority": "medium"
       }
     ]
   }
index 3d05c99..7d5b3b7 100644 (file)
@@ -61,7 +61,8 @@ HAR Page Test.
           "send": "<filtered>",
           "wait": "<filtered>",
           "receive": "<filtered>"
-        }
+        },
+        "_priority": "high"
       },
       {
         "pageref": "page_0",
@@ -102,7 +103,8 @@ HAR Page Test.
           "send": "<filtered>",
           "wait": "<filtered>",
           "receive": "<filtered>"
-        }
+        },
+        "_priority": "high"
       },
       {
         "pageref": "page_0",
@@ -143,7 +145,8 @@ HAR Page Test.
           "send": "<filtered>",
           "wait": "<filtered>",
           "receive": "<filtered>"
-        }
+        },
+        "_priority": "high"
       },
       {
         "pageref": "page_0",
@@ -191,7 +194,8 @@ HAR Page Test.
           "send": "<filtered>",
           "wait": "<filtered>",
           "receive": "<filtered>"
-        }
+        },
+        "_priority": "medium"
       },
       {
         "pageref": "page_0",
@@ -245,7 +249,8 @@ HAR Page Test.
           "send": "<filtered>",
           "wait": "<filtered>",
           "receive": "<filtered>"
-        }
+        },
+        "_priority": "medium"
       },
       {
         "pageref": "page_0",
@@ -298,7 +303,8 @@ HAR Page Test.
           "send": "<filtered>",
           "wait": "<filtered>",
           "receive": "<filtered>"
-        }
+        },
+        "_priority": "medium"
       },
       {
         "pageref": "page_0",
@@ -351,7 +357,8 @@ HAR Page Test.
           "send": "<filtered>",
           "wait": "<filtered>",
           "receive": "<filtered>"
-        }
+        },
+        "_priority": "medium"
       },
       {
         "pageref": "page_0",
@@ -404,7 +411,8 @@ HAR Page Test.
           "send": "<filtered>",
           "wait": "<filtered>",
           "receive": "<filtered>"
-        }
+        },
+        "_priority": "medium"
       },
       {
         "pageref": "page_0",
@@ -461,7 +469,8 @@ HAR Page Test.
           "send": "<filtered>",
           "wait": "<filtered>",
           "receive": "<filtered>"
-        }
+        },
+        "_priority": "medium"
       },
       {
         "pageref": "page_0",
@@ -524,7 +533,8 @@ HAR Page Test.
           "send": "<filtered>",
           "wait": "<filtered>",
           "receive": "<filtered>"
-        }
+        },
+        "_priority": "medium"
       },
       {
         "pageref": "page_0",
@@ -591,7 +601,8 @@ HAR Page Test.
           "send": "<filtered>",
           "wait": "<filtered>",
           "receive": "<filtered>"
-        }
+        },
+        "_priority": "medium"
       },
       {
         "pageref": "page_0",
@@ -662,7 +673,8 @@ HAR Page Test.
           "send": "<filtered>",
           "wait": "<filtered>",
           "receive": "<filtered>"
-        }
+        },
+        "_priority": "medium"
       },
       {
         "pageref": "page_0",
@@ -737,7 +749,8 @@ HAR Page Test.
           "send": "<filtered>",
           "wait": "<filtered>",
           "receive": "<filtered>"
-        }
+        },
+        "_priority": "medium"
       }
     ]
   }
index c6afcbb..8aae098 100644 (file)
@@ -1,5 +1,22 @@
 2019-03-15  Joseph Pecoraro  <pecoraro@apple.com>
 
+        Web Inspector: HAR Extension for Resource Priority
+        https://bugs.webkit.org/show_bug.cgi?id=195693
+
+        Reviewed by Devin Rousso.
+
+        * UserInterface/Controllers/HARBuilder.js:
+        (WI.HARBuilder.entry):
+        (WI.HARBuilder.priority):
+        (WI.HARBuilder.networkPriorityFromHARPriority):
+        Include priority custom extension.
+
+        * UserInterface/Models/LocalResource.js:
+        (WI.LocalResource.fromHAREntry):
+        Import priority.
+
+2019-03-15  Joseph Pecoraro  <pecoraro@apple.com>
+
         Web Inspector: CPU Usage Timeline - Give long thread names a tooltip if they could be ellipsized
         https://bugs.webkit.org/show_bug.cgi?id=195314
 
index 1350dfc..48e90ce 100644 (file)
@@ -114,7 +114,9 @@ WI.HARBuilder = class HARBuilder
         if (resource.responseSource !== WI.Resource.ResponseSource.Unknown)
             entry._fetchType = HARBuilder.fetchType(resource.responseSource);
 
-        // FIXME: <https://webkit.org/b/195693> Web Inspector: HAR Extension for Resource Priority
+        // WebKit Custom Field `_priority`.
+        if (resource.priority !== WI.Resource.NetworkPriority.Unknown)
+            entry._priority = HARBuilder.priority(resource.priority);
 
         return entry;
     }
@@ -315,7 +317,22 @@ WI.HARBuilder = class HARBuilder
             return "Service Worker";
         }
 
-        console.assert(false);
+        console.assert();
+        return undefined;
+    }
+
+    static priority(priority)
+    {
+        switch (priority) {
+        case WI.Resource.NetworkPriority.Low:
+            return "low";
+        case WI.Resource.NetworkPriority.Medium:
+            return "medium";
+        case WI.Resource.NetworkPriority.High:
+            return "high";
+        }
+
+        console.assert();
         return undefined;
     }
 
@@ -344,7 +361,7 @@ WI.HARBuilder = class HARBuilder
         }
 
         if (protocol)
-            console.warn("Unknown HAR Protocol value", protocol);
+            console.warn("Unknown HAR protocol value", protocol);
         return null;
     }
 
@@ -360,7 +377,23 @@ WI.HARBuilder = class HARBuilder
         }
 
         if (fetchType)
-            console.warn("Unknown HAR Protocol _fetchType", fetchType);
+            console.warn("Unknown HAR _fetchType value", fetchType);
         return WI.Resource.ResponseSource.Other;
     }
+
+    static networkPriorityFromHARPriority(priority)
+    {
+        switch (priority) {
+        case "low":
+            return WI.Resource.NetworkPriority.Low;
+        case "medium":
+            return WI.Resource.NetworkPriority.Medium;
+        case "high":
+            return WI.Resource.NetworkPriority.High;
+        }
+
+        if (priority)
+            console.warn("Unknown HAR priority value", priority);
+        return WI.Resource.NetworkPriority.Unknown;
+    }
 };
index 953dbe2..fb8ab42 100644 (file)
@@ -99,7 +99,6 @@ WI.LocalResource = class LocalResource extends WI.Resource
     {
         // FIXME: <https://webkit.org/b/195695> Web Inspector: HAR Extension for `serverIPAddress` port number
         // FIXME: <https://webkit.org/b/195694> Web Inspector: HAR Extension for Redirect Timing Info
-        // FIXME: <https://webkit.org/b/195693> Web Inspector: HAR Extension for Resource Priority
 
         let {request, response, startedDateTime, timings} = entry;
         let requestSentWalltime = WI.HARBuilder.dateFromHARDate(startedDateTime) / 1000;
@@ -182,7 +181,7 @@ WI.LocalResource = class LocalResource extends WI.Resource
             metrics: {
                 responseSource: WI.HARBuilder.responseSourceFromHARFetchType(entry._fetchType),
                 protocol: WI.HARBuilder.protocolFromHARProtocol(response.httpVersion),
-                priority: null,
+                priority: WI.HARBuilder.networkPriorityFromHARPriority(entry._priority),
                 remoteAddress: entry.serverIPAddress || null,
                 connectionIdentifier: entry.connection ? parseInt(entry.connection) : null,
                 requestHeaderBytesSent: request.headersSize >= 0 ? request.headersSize : NaN,