Bug 171385 - Web Inspector: webkit reload policy should match default behavior
Summary: Web Inspector: webkit reload policy should match default behavior
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Web Inspector (show other bugs)
Version: WebKit Nightly Build
Hardware: All All
: P2 Normal
Assignee: BJ Burg
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2017-04-27 12:13 PDT by Alexander Romanovich
Modified: 2017-05-22 15:06 PDT (History)
12 users (show)

See Also:


Attachments
Patch (1.73 KB, patch)
2017-05-05 16:09 PDT, BJ Burg
no flags Details | Formatted Diff | Diff
Archive of layout-test-results from ews100 for mac-elcapitan (1.18 MB, application/zip)
2017-05-05 17:11 PDT, Build Bot
no flags Details
Archive of layout-test-results from ews104 for mac-elcapitan-wk2 (1.74 MB, application/zip)
2017-05-05 17:20 PDT, Build Bot
no flags Details
Archive of layout-test-results from ews117 for mac-elcapitan (1.93 MB, application/zip)
2017-05-05 18:40 PDT, Build Bot
no flags Details
Patch (8.37 KB, patch)
2017-05-10 13:29 PDT, BJ Burg
no flags Details | Formatted Diff | Diff
Proposed Fix v2 (17.82 KB, patch)
2017-05-15 19:39 PDT, BJ Burg
joepeck: review+
buildbot: commit-queue-
Details | Formatted Diff | Diff
Archive of layout-test-results from ews102 for mac-elcapitan (1.17 MB, application/zip)
2017-05-15 20:59 PDT, Build Bot
no flags Details
Archive of layout-test-results from ews106 for mac-elcapitan-wk2 (1.13 MB, application/zip)
2017-05-15 21:03 PDT, Build Bot
no flags Details
Archive of layout-test-results from ews112 for mac-elcapitan (1.92 MB, application/zip)
2017-05-15 21:15 PDT, Build Bot
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Alexander Romanovich 2017-04-27 12:13:00 PDT
The reload policy used when the web inspector is both open and foregrounded (i.e. all subresources revalidated) does not match the (new) reload policy used when the web inspector is open and backgrounded, or not open at all (i.e. only expired subresources revalidated).

This could be confusing to developers who would expect the web inspector to reflect what's actually happening under normal conditions. It would be preferable if the foregrounded web inspector used the default reload policy. If the developer needs to force revalidation, they can do so by reloading from origin via shift-refresh.

See original context here: https://bugs.webkit.org/show_bug.cgi?id=171264#c16
Comment 1 BJ Burg 2017-04-27 13:33:10 PDT
(In reply to Alexander Romanovich from comment #0)
> The reload policy used when the web inspector is both open and foregrounded
> (i.e. all subresources revalidated) does not match the (new) reload policy
> used when the web inspector is open and backgrounded, or not open at all
> (i.e. only expired subresources revalidated).

It doesn't have to do with foreground vs background. It's whether you are sending Cmd-R to Safari or Web Inspector, which use different APIs. Currently, Web Inspector does this in the backend:

    OptionSet<ReloadOption> reloadOptions;
    if (optionalIgnoreCache && *optionalIgnoreCache)
        reloadOptions |= ReloadOption::FromOrigin;
    m_page.mainFrame().loader().reload(reloadOptions);

So I believe we just need to use ReloadOption::ExpiredOnly in the normal case.

> This could be confusing to developers who would expect the web inspector to
> reflect what's actually happening under normal conditions. It would be
> preferable if the foregrounded web inspector used the default reload policy.
> If the developer needs to force revalidation, they can do so by reloading
> from origin via shift-refresh.
> 
> See original context here: https://bugs.webkit.org/show_bug.cgi?id=171264#c16
Comment 2 Radar WebKit Bug Importer 2017-04-27 13:33:47 PDT
<rdar://problem/31871515>
Comment 3 Alexander Romanovich 2017-04-28 12:17:28 PDT
Makes sense.

Another impact of the difference in API between Web Inspector and Safari results in the fact that you can force a reload-from-origin with cmd-shift-r in Web Inspector but not in Safari. It would be helpful to allow cmd-shift-r in Safari as well.

Aside from clearing up the above-mentioned confusion that can arise from a divergence in behavior, allowing cmd-shift-r in Safari, and not just in Web Inspector, would contribute to solving this long standing issue: Safari does not currently support 304s for main resources like all other major browsers do (https://bugs.webkit.org/show_bug.cgi?id=114738).

This is because a cmd-r in Safari currently does a reload-from-origin for the main resource, whereas it should perform revalidation. Resolving that would be a huge performance win, especially on large pages like blogs, and my hope would be that solving this would assist in bringing traction on that very important issue as well.
Comment 4 BJ Burg 2017-04-28 13:59:30 PDT
(In reply to Alexander Romanovich from comment #3)
> Makes sense.
> 
> Another impact of the difference in API between Web Inspector and Safari
> results in the fact that you can force a reload-from-origin with cmd-shift-r
> in Web Inspector but not in Safari. It would be helpful to allow cmd-shift-r
> in Safari as well.

This was introduced in Safari Technology Preview 28, as Cmd-Option-R. I might add a secondary key binding in Web Inspector to match that one.
Comment 5 BJ Burg 2017-05-05 16:09:07 PDT
Created attachment 309233 [details]
Patch
Comment 6 Build Bot 2017-05-05 17:11:18 PDT
Comment on attachment 309233 [details]
Patch

Attachment 309233 [details] did not pass mac-ews (mac):
Output: http://webkit-queues.webkit.org/results/3681980

New failing tests:
http/tests/inspector/network/resource-response-source-memory-cache.html
Comment 7 Build Bot 2017-05-05 17:11:19 PDT
Created attachment 309245 [details]
Archive of layout-test-results from ews100 for mac-elcapitan

The attached test failures were seen while running run-webkit-tests on the mac-ews.
Bot: ews100  Port: mac-elcapitan  Platform: Mac OS X 10.11.6
Comment 8 Build Bot 2017-05-05 17:20:02 PDT
Comment on attachment 309233 [details]
Patch

Attachment 309233 [details] did not pass mac-wk2-ews (mac-wk2):
Output: http://webkit-queues.webkit.org/results/3682008

New failing tests:
http/tests/inspector/network/resource-response-source-memory-cache.html
http/tests/inspector/network/resource-sizes-memory-cache.html
Comment 9 Build Bot 2017-05-05 17:20:03 PDT
Created attachment 309247 [details]
Archive of layout-test-results from ews104 for mac-elcapitan-wk2

The attached test failures were seen while running run-webkit-tests on the mac-wk2-ews.
Bot: ews104  Port: mac-elcapitan-wk2  Platform: Mac OS X 10.11.6
Comment 10 Build Bot 2017-05-05 18:40:45 PDT
Comment on attachment 309233 [details]
Patch

Attachment 309233 [details] did not pass mac-debug-ews (mac):
Output: http://webkit-queues.webkit.org/results/3682352

New failing tests:
http/tests/inspector/network/resource-response-source-memory-cache.html
Comment 11 Build Bot 2017-05-05 18:40:47 PDT
Created attachment 309255 [details]
Archive of layout-test-results from ews117 for mac-elcapitan

The attached test failures were seen while running run-webkit-tests on the mac-debug-ews.
Bot: ews117  Port: mac-elcapitan  Platform: Mac OS X 10.11.6
Comment 12 Antti Koivisto 2017-05-08 10:22:48 PDT
Comment on attachment 309233 [details]
Patch

r=me, with test/test results updated
Comment 13 BJ Burg 2017-05-08 11:05:00 PDT
(In reply to Build Bot from comment #10)
> Comment on attachment 309233 [details]
> Patch
> 
> Attachment 309233 [details] did not pass mac-debug-ews (mac):
> Output: http://webkit-queues.webkit.org/results/3682352
> 
> New failing tests:
> http/tests/inspector/network/resource-response-source-memory-cache.html

It seems that this test no longer does what it's supposed to. It's not clear to me why the new ReloadOption would cause this to return HTTP 200 instead of still using the memory cache (HTTP 304). Antti, is this expected behavior?
Comment 14 Antti Koivisto 2017-05-08 12:54:21 PDT
The failure is

 PASS: Resource should be exist.
-PASS: statusCode should be 304
+FAIL: statusCode should be 304
+    Expected: 304
+    Actual: 200
 PASS: responseSource should be Symbol(memory-cache)

That is, the response is coming from the memory cache and has not been revalidated from the server (original 200 instead of 304). That is exactly what is expected from this change.

If you still want to test 304 case you should modify (or expend) the test to use an expired resource (Cache-Control: max-age=0 or similar).
Comment 15 BJ Burg 2017-05-10 11:26:59 PDT
(In reply to Antti Koivisto from comment #14)
> The failure is
> 
>  PASS: Resource should be exist.
> -PASS: statusCode should be 304
> +FAIL: statusCode should be 304
> +    Expected: 304
> +    Actual: 200
>  PASS: responseSource should be Symbol(memory-cache)
> 
> That is, the response is coming from the memory cache and has not been
> revalidated from the server (original 200 instead of 304). That is exactly
> what is expected from this change.
> 
> If you still want to test 304 case you should modify (or expend) the test to
> use an expired resource (Cache-Control: max-age=0 or similar).

I tried pretty much every combination of cache control response headers (using cache-simulator.cgi), and none of them caused this to return an HTTP 304. I'll just re baseline this to expect HTTP 200.
Comment 16 Joseph Pecoraro 2017-05-10 11:29:18 PDT
(In reply to Brian Burg from comment #15)
> (In reply to Antti Koivisto from comment #14)
> > The failure is
> > 
> >  PASS: Resource should be exist.
> > -PASS: statusCode should be 304
> > +FAIL: statusCode should be 304
> > +    Expected: 304
> > +    Actual: 200
> >  PASS: responseSource should be Symbol(memory-cache)
> > 
> > That is, the response is coming from the memory cache and has not been
> > revalidated from the server (original 200 instead of 304). That is exactly
> > what is expected from this change.
> > 
> > If you still want to test 304 case you should modify (or expend) the test to
> > use an expired resource (Cache-Control: max-age=0 or similar).
> 
> I tried pretty much every combination of cache control response headers
> (using cache-simulator.cgi), and none of them caused this to return an HTTP
> 304. I'll just re baseline this to expect HTTP 200.

Is there any way to get a Memory Cache revalidation response now that we can test?
Comment 17 BJ Burg 2017-05-10 13:29:17 PDT
Created attachment 309628 [details]
Patch
Comment 18 Joseph Pecoraro 2017-05-15 11:13:46 PDT
Comment on attachment 309628 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=309628&action=review

> Source/WebInspectorUI/UserInterface/Base/Main.js:1914
> -    PageAgent.reload(window.event ? window.event.shiftKey : false);
> +    PageAgent.reload.invoke({shouldIgnoreCache: window.event ? window.event.shiftKey : false});

So there is currently no way for users to trigger this new path?

> Source/WebInspectorUI/UserInterface/Test/FrontendTestHarness.js:130
> +        return PageAgent.reload.invoke({shouldIgnoreCache: !!shouldIgnoreCache, revalidateUnexpiredResources: true})

And tests test a different behavior than what users would test.

---

There should be a test for both the behavior users will see and this special reload behavior we have only for tests.
Comment 19 BJ Burg 2017-05-15 19:39:57 PDT
Created attachment 310208 [details]
Proposed Fix v2
Comment 20 Build Bot 2017-05-15 20:59:30 PDT
Comment on attachment 310208 [details]
Proposed Fix v2

Attachment 310208 [details] did not pass mac-ews (mac):
Output: http://webkit-queues.webkit.org/results/3747935

New failing tests:
http/tests/inspector/network/resource-response-source-memory-cache.html
http/tests/inspector/network/resource-response-source-memory-cache-revalidate-expired-only.html
Comment 21 Build Bot 2017-05-15 20:59:31 PDT
Created attachment 310215 [details]
Archive of layout-test-results from ews102 for mac-elcapitan

The attached test failures were seen while running run-webkit-tests on the mac-ews.
Bot: ews102  Port: mac-elcapitan  Platform: Mac OS X 10.11.6
Comment 22 Build Bot 2017-05-15 21:03:21 PDT
Comment on attachment 310208 [details]
Proposed Fix v2

Attachment 310208 [details] did not pass mac-wk2-ews (mac-wk2):
Output: http://webkit-queues.webkit.org/results/3747944

New failing tests:
http/tests/inspector/network/resource-response-source-memory-cache-revalidate-expired-only.html
http/tests/inspector/network/resource-response-source-memory-cache.html
http/tests/inspector/network/resource-sizes-memory-cache.html
Comment 23 Build Bot 2017-05-15 21:03:22 PDT
Created attachment 310217 [details]
Archive of layout-test-results from ews106 for mac-elcapitan-wk2

The attached test failures were seen while running run-webkit-tests on the mac-wk2-ews.
Bot: ews106  Port: mac-elcapitan-wk2  Platform: Mac OS X 10.11.6
Comment 24 Build Bot 2017-05-15 21:15:02 PDT
Comment on attachment 310208 [details]
Proposed Fix v2

Attachment 310208 [details] did not pass mac-debug-ews (mac):
Output: http://webkit-queues.webkit.org/results/3747950

New failing tests:
http/tests/inspector/network/resource-response-source-memory-cache.html
http/tests/inspector/network/resource-response-source-memory-cache-revalidate-expired-only.html
Comment 25 Build Bot 2017-05-15 21:15:03 PDT
Created attachment 310218 [details]
Archive of layout-test-results from ews112 for mac-elcapitan

The attached test failures were seen while running run-webkit-tests on the mac-debug-ews.
Bot: ews112  Port: mac-elcapitan  Platform: Mac OS X 10.11.6
Comment 26 Joseph Pecoraro 2017-05-22 11:30:05 PDT
Comment on attachment 310208 [details]
Proposed Fix v2

View in context: https://bugs.webkit.org/attachment.cgi?id=310208&action=review

Patch looks good to me, just get the tests passing properly.

> Source/JavaScriptCore/inspector/protocol/Page.json:116
> +                { "name": "revalidateUnexpiredResources", "type": "boolean", "optional": true, "description": "If true, unexpired cached subresources will be revalidated when the main resource loads. Otherwise, only expired cached subresources will be revalidated (the default behavior for most WebKit clients)." },

Maybe we should name this revalidateAllResources or just revalidateResources?

> LayoutTests/http/tests/inspector/network/resource-response-source-memory-cache-revalidate-expired-only-expected.txt:9
> +FAIL: statusCode should be 200
> +    Expected: 200
> +    Actual: 304

This seems unexpected.
Comment 27 BJ Burg 2017-05-22 11:34:00 PDT
(In reply to Joseph Pecoraro from comment #26)
> Comment on attachment 310208 [details]
> Proposed Fix v2
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=310208&action=review
> 
> Patch looks good to me, just get the tests passing properly.
> 
> > Source/JavaScriptCore/inspector/protocol/Page.json:116
> > +                { "name": "revalidateUnexpiredResources", "type": "boolean", "optional": true, "description": "If true, unexpired cached subresources will be revalidated when the main resource loads. Otherwise, only expired cached subresources will be revalidated (the default behavior for most WebKit clients)." },
> 
> Maybe we should name this revalidateAllResources or just revalidateResources? 

Ok. I prefer revalidateAllResources.

> > LayoutTests/http/tests/inspector/network/resource-response-source-memory-cache-revalidate-expired-only-expected.txt:9
> > +FAIL: statusCode should be 200
> > +    Expected: 200
> > +    Actual: 304
> 
> This seems unexpected.

Looks like I forgot to rebaseline a final time.
Comment 28 BJ Burg 2017-05-22 15:06:53 PDT
Committed r217248: <http://trac.webkit.org/changeset/217248>