Web Inspector: Page Weight indicator clears on pages with zero length resources ...
authorjoepeck@webkit.org <joepeck@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 25 Mar 2019 20:45:37 +0000 (20:45 +0000)
committerjoepeck@webkit.org <joepeck@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 25 Mar 2019 20:45:37 +0000 (20:45 +0000)
https://bugs.webkit.org/show_bug.cgi?id=196170

Reviewed by Timothy Hatcher.

Source/WebInspectorUI:

* UserInterface/Models/DefaultDashboard.js:
(WI.DefaultDashboard.prototype._resourceSizeDidChange):
Catch NaN earlier.

* UserInterface/Models/Resource.js:
(WI.Resource.prototype.updateWithMetrics):
When we receive exact metrics transition the estimated size to zero,
since we won't receive any more updates for the resource.

LayoutTests:

* http/tests/inspector/network/resource-sizes-network.html:
* http/tests/inspector/network/resources/empty.txt: Added.
* platform/mac/http/tests/inspector/network/resource-sizes-network-expected.txt:

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

LayoutTests/ChangeLog
LayoutTests/http/tests/inspector/network/resource-sizes-network.html
LayoutTests/http/tests/inspector/network/resources/empty.txt [new file with mode: 0644]
LayoutTests/platform/mac/http/tests/inspector/network/resource-sizes-network-expected.txt
Source/WebInspectorUI/ChangeLog
Source/WebInspectorUI/UserInterface/Models/DefaultDashboard.js
Source/WebInspectorUI/UserInterface/Models/Resource.js

index ca73505..e88e784 100644 (file)
@@ -1,3 +1,14 @@
+2019-03-25  Joseph Pecoraro  <pecoraro@apple.com>
+
+        Web Inspector: Page Weight indicator clears on pages with zero length resources (macrumors.com)
+        https://bugs.webkit.org/show_bug.cgi?id=196170
+
+        Reviewed by Timothy Hatcher.
+
+        * http/tests/inspector/network/resource-sizes-network.html:
+        * http/tests/inspector/network/resources/empty.txt: Added.
+        * platform/mac/http/tests/inspector/network/resource-sizes-network-expected.txt:
+
 2019-03-25  Eric Carlson  <eric.carlson@apple.com>
 
         Delete MetadataPreloadingNotPermitted, it is unused
index c706a3a..f9f2690 100644 (file)
@@ -43,6 +43,19 @@ function test()
     });
 
     addResourceSizeTest(suite, {
+        name: "Resource.Size.Network.text",
+        description: "Sizes of an empty text resource",
+        url: "resources/empty.txt?" + Math.random(),
+        statusCode: 200,
+        compressed: false,
+        responseSource: WI.Resource.ResponseSource.Network,
+        headers: true,
+        requestBodyTransferSize: 0,
+        responseBodyTransferSize: 0,
+        size: 0,
+    });
+
+    addResourceSizeTest(suite, {
         name: "Resource.Size.Network.text.gzipped",
         description: "Sizes of a gzipped text resource",
         url: "resources/gzipped-lorem.php?" + Math.random(),
diff --git a/LayoutTests/http/tests/inspector/network/resources/empty.txt b/LayoutTests/http/tests/inspector/network/resources/empty.txt
new file mode 100644 (file)
index 0000000..e69de29
index a00e044..ce72b85 100644 (file)
@@ -16,6 +16,20 @@ PASS: responseBodyTransferSize should be exactly 2955 bytes.
 PASS: requestHeadersTransferSize should be non-empty.
 PASS: responseHeadersTransferSize should be non-empty.
 
+-- Running test case: Resource.Size.Network.text
+PASS: statusCode should be 200.
+PASS: compressed should be false.
+PASS: responseSource should be Symbol(network).
+PASS: estimatedNetworkEncodedSize should be exactly 0 bytes.
+PASS: estimatedTotalTransferSize should be >= (encoded body size + headers).
+PASS: size should be exactly 0 bytes.
+PASS: networkEncodedSize should be exactly 0 bytes.
+PASS: networkTotalTransferSize should be >= (encoded body size + headers).
+PASS: requestBodyTransferSize should be exactly 0 bytes.
+PASS: responseBodyTransferSize should be exactly 0 bytes.
+PASS: requestHeadersTransferSize should be non-empty.
+PASS: responseHeadersTransferSize should be non-empty.
+
 -- Running test case: Resource.Size.Network.text.gzipped
 PASS: statusCode should be 200.
 PASS: compressed should be true.
index 9a8b2ae..7fab88e 100644 (file)
@@ -1,3 +1,19 @@
+2019-03-25  Joseph Pecoraro  <pecoraro@apple.com>
+
+        Web Inspector: Page Weight indicator clears on pages with zero length resources (macrumors.com)
+        https://bugs.webkit.org/show_bug.cgi?id=196170
+
+        Reviewed by Timothy Hatcher.
+
+        * UserInterface/Models/DefaultDashboard.js:
+        (WI.DefaultDashboard.prototype._resourceSizeDidChange):
+        Catch NaN earlier.
+
+        * UserInterface/Models/Resource.js:
+        (WI.Resource.prototype.updateWithMetrics):
+        When we receive exact metrics transition the estimated size to zero,
+        since we won't receive any more updates for the resource.
+
 2019-03-24  Devin Rousso  <drousso@apple.com>
 
         Web Inspector: Canvas: WebGL action icon shouldn't invert when selected
index 210e26a..645f993 100644 (file)
@@ -183,7 +183,10 @@ WI.DefaultDashboard = class DefaultDashboard extends WI.Object
     {
         if (event.target.urlComponents.scheme === "data")
             return;
-        this.resourcesSize += event.target.size - event.data.previousSize;
+
+        let delta = event.target.size - event.data.previousSize;
+        console.assert(!isNaN(delta), "Resource size change should never be NaN.");
+        this.resourcesSize += delta;
     }
 
     _startUpdatingTime()
index f2a0f52..fda06c2 100644 (file)
@@ -789,6 +789,10 @@ WI.Resource = class Resource extends WI.SourceCode
             console.assert(this._responseBodyTransferSize >= 0);
             console.assert(this._responseBodySize >= 0);
 
+            // There may have been no size updates received during load if Content-Length was 0.
+            if (isNaN(this._estimatedSize))
+                this._estimatedSize = 0;
+
             this.dispatchEventToListeners(WI.Resource.Event.SizeDidChange, {previousSize: this._estimatedSize});
             this.dispatchEventToListeners(WI.Resource.Event.TransferSizeDidChange);
         }