Title: [214494] trunk
Revision
214494
Author
[email protected]
Date
2017-03-28 14:41:24 -0700 (Tue, 28 Mar 2017)

Log Message

Web Inspector: Add "Disable Caches" option that only applies to the inspected page while Web Inspector is open
https://bugs.webkit.org/show_bug.cgi?id=169865
<rdar://problem/31250573>

Reviewed by Joseph Pecoraro.

Source/_javascript_Core:

* inspector/protocol/Network.json:
Rename the command for disabling resource caching to match the WebCore::Page
flag. This also removes the possibility that this could be confused for the old,
buggy command that this patch rips out.

Source/WebCore:

Rewrite the network agent's command for disabling resource caching to use Page::setResourceCachingEnabled.
The old implementation was doing weird stuff like setting no-cache headers and evicting the
contents of the memory cache, neither of which is correct. The new approach has no side effects
on the network, disk, or memory cache so it can be turned on temporarily without causing problems.

New tests:
- http/tests/inspector/network/set-resource-caching-disabled-disk-cache.html
- http/tests/inspector/network/set-resource-caching-disabled-memory-cache.html

* inspector/InspectorNetworkAgent.h:
* inspector/InspectorNetworkAgent.cpp:
(WebCore::InspectorNetworkAgent::setCacheDisabled): Deleted.
(WebCore::InspectorNetworkAgent::setResourceCachingDisabled): Added.
Implement new command.

(WebCore::InspectorNetworkAgent::willSendRequest):
(WebCore::InspectorNetworkAgent::mainFrameNavigated):
Remove crufty attempts to break caches. I believe these are intended to defeat caching
proxies and similar middlemen, but this is just as likely to cause unusual loading behavior.

* page/Page.h:
(WebCore::Page::isResourceCachingDisabled):
(WebCore::Page::setResourceCachingDisabledOverride):
Add an override setting so that Web Inspector's override does not mess up the value
of isResourceCachingDisabled that may have been set by a WebKit API client.

Source/WebInspectorUI:

Hook up a button in the Network tab to WebCore::Page's resourceCachingDisabled flag.
If it is active, resource loads are subject to a cache policy that never uses a cached response.

* Localizations/en.lproj/localizedStrings.js:
Add localized strings.

* UserInterface/Base/Main.js:
(WebInspector.loaded):
Add a setting for whether to disable resource caching and inform the backend
of our preference. If someone changes the setting, tell the backend again.

* UserInterface/Views/NetworkGridContentView.js:
(WebInspector.NetworkGridContentView):
(WebInspector.NetworkGridContentView.prototype.get navigationItems):
(WebInspector.NetworkGridContentView.prototype._resourceCachingDisabledSettingChanged):
(WebInspector.NetworkGridContentView.prototype._toggleDisableResourceCache):
Add a new activatable navigation item that toggles disableResourceCaching for the inspected page.

* UserInterface/Protocol/Legacy/10.0/InspectorBackendCommands.js:
* UserInterface/Protocol/Legacy/10.3/InspectorBackendCommands.js:
* UserInterface/Protocol/Legacy/7.0/InspectorBackendCommands.js:
* UserInterface/Protocol/Legacy/8.0/InspectorBackendCommands.js:
* UserInterface/Protocol/Legacy/9.0/InspectorBackendCommands.js:
* UserInterface/Protocol/Legacy/9.3/InspectorBackendCommands.js:
* Versions/Inspector-iOS-10.0.json:
* Versions/Inspector-iOS-10.3.json:
* Versions/Inspector-iOS-7.0.json:
* Versions/Inspector-iOS-8.0.json:
* Versions/Inspector-iOS-9.0.json:
* Versions/Inspector-iOS-9.3.json:
Update legacy backend commands to remove the old/broken Network.setCacheDisabled command.

LayoutTests:

Add tests that verify the new command works as expected when it disables resource caching.
I also manually verified that the override setting is cleared when Web Inspector disconnects.
This is not easy to check in a layout test since we rely on the Web Inspector to tell whether
a load happened or not.

* http/tests/inspector/network/set-resource-caching-disabled-disk-cache-expected.txt: Added.
* http/tests/inspector/network/set-resource-caching-disabled-disk-cache.html: Added.
* http/tests/inspector/network/set-resource-caching-disabled-memory-cache-expected.txt: Added.
* http/tests/inspector/network/set-resource-caching-disabled-memory-cache.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (214493 => 214494)


--- trunk/LayoutTests/ChangeLog	2017-03-28 21:17:12 UTC (rev 214493)
+++ trunk/LayoutTests/ChangeLog	2017-03-28 21:41:24 UTC (rev 214494)
@@ -1,3 +1,21 @@
+2017-03-28  Brian Burg  <[email protected]>
+
+        Web Inspector: Add "Disable Caches" option that only applies to the inspected page while Web Inspector is open
+        https://bugs.webkit.org/show_bug.cgi?id=169865
+        <rdar://problem/31250573>
+
+        Reviewed by Joseph Pecoraro.
+
+        Add tests that verify the new command works as expected when it disables resource caching.
+        I also manually verified that the override setting is cleared when Web Inspector disconnects.
+        This is not easy to check in a layout test since we rely on the Web Inspector to tell whether
+        a load happened or not.
+
+        * http/tests/inspector/network/set-resource-caching-disabled-disk-cache-expected.txt: Added.
+        * http/tests/inspector/network/set-resource-caching-disabled-disk-cache.html: Added.
+        * http/tests/inspector/network/set-resource-caching-disabled-memory-cache-expected.txt: Added.
+        * http/tests/inspector/network/set-resource-caching-disabled-memory-cache.html: Added.
+
 2017-03-28  Youenn Fablet  <[email protected]>
 
         Update LayoutTests/fast/mediastream/RTCPeerConnection-addIceCandidate.html to get more coverage

Added: trunk/LayoutTests/http/tests/inspector/network/set-resource-caching-disabled-disk-cache-expected.txt (0 => 214494)


--- trunk/LayoutTests/http/tests/inspector/network/set-resource-caching-disabled-disk-cache-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/http/tests/inspector/network/set-resource-caching-disabled-disk-cache-expected.txt	2017-03-28 21:41:24 UTC (rev 214494)
@@ -0,0 +1,16 @@
+Test for `Network.setResourceCachingDisabled` for disk cache loads.
+
+
+== Running test suite: Network.SetResourceCachingDisabled.DiskCache
+-- Running test setup.
+-- Running test case: PossibleNetworkLoad
+PASS: Resource should be created.
+PASS: Resource should receive a Response.
+-- Running test setup.
+
+-- Running test case: SetResourceCachingDisabled.DiskCache
+PASS: Resource should be created.
+PASS: Resource should receive a Response.
+PASS: statusCode should be 200
+PASS: responseSource should be Symbol(network)
+

Added: trunk/LayoutTests/http/tests/inspector/network/set-resource-caching-disabled-disk-cache.html (0 => 214494)


--- trunk/LayoutTests/http/tests/inspector/network/set-resource-caching-disabled-disk-cache.html	                        (rev 0)
+++ trunk/LayoutTests/http/tests/inspector/network/set-resource-caching-disabled-disk-cache.html	2017-03-28 21:41:24 UTC (rev 214494)
@@ -0,0 +1,72 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<script src=""
+<script src=""
+<script>
+// NOTE: this test is based on resource-response-source-disk-cache.html.
+function loadAndTriggerInspector(url) {
+    fetch(url).then(() => {
+        TestPage.dispatchEventToFrontend("LoadComplete");
+    });
+}
+
+function triggerNetworkLoad() {
+    loadAndTriggerInspector("/resources/square100.png");
+}
+
+function triggerDiskCacheLoad() {
+    loadAndTriggerInspector("/resources/square100.png");
+}
+
+function test()
+{
+    let suite = InspectorTest.createAsyncSuite("Network.SetResourceCachingDisabled.DiskCache");
+
+    function addTestCase({name, description, setup, _expression_, statusCode, responseSource}) {
+        suite.addTestCase({
+            name, description, setup,
+            test(resolve, reject) {
+                InspectorTest.evaluateInPage(_expression_);
+                Promise.all([
+                    WebInspector.Frame.awaitEvent(WebInspector.Frame.Event.ResourceWasAdded),
+                    WebInspector.Resource.awaitEvent(WebInspector.Resource.Event.ResponseReceived),
+                    InspectorTest.awaitEvent("LoadComplete"),
+                ]).then(([resourceWasAddedEvent, responseReceivedEvent, loadCompleteEvent]) => {
+                    let resource = resourceWasAddedEvent.data.resource;
+                    InspectorTest.expectThat(resource instanceof WebInspector.Resource, "Resource should be created.");
+                    InspectorTest.expectEqual(resource, responseReceivedEvent.target, "Resource should receive a Response.");
+                    if (statusCode)
+                        InspectorTest.expectEqual(resource.statusCode, statusCode, `statusCode should be ${statusCode}`);
+                    if (responseSource)
+                        InspectorTest.expectEqual(resource.responseSource, responseSource, `responseSource should be ${String(responseSource)}`);
+                }).then(resolve, reject);
+            }
+        });
+    }
+
+    addTestCase({
+        name: "PossibleNetworkLoad",
+        description: "Load a resource from the network, it might be in an earlier disk cache",
+        setup(resolve) { InspectorTest.evaluateInPage(`internals.clearMemoryCache()`, resolve); },
+        _expression_: `triggerNetworkLoad()`,
+    });
+
+    addTestCase({
+        name: "SetResourceCachingDisabled.DiskCache",
+        description: "Fail to load a resource from the disk cache when resource caching is disabled",
+        _expression_: `triggerDiskCacheLoad()`,
+        responseSource: WebInspector.Resource.ResponseSource.Network,
+        setup(resolve) { NetworkAgent.setResourceCachingDisabled(true); resolve(); },
+        statusCode: 200,
+    });
+
+    suite.runTestCasesAndFinish();
+}
+</script>
+</head>
+<body _onload_="runTest()">
+<p>Test for `Network.setResourceCachingDisabled` for disk cache loads.</p>
+</body>
+</html>

Added: trunk/LayoutTests/http/tests/inspector/network/set-resource-caching-disabled-memory-cache-expected.txt (0 => 214494)


--- trunk/LayoutTests/http/tests/inspector/network/set-resource-caching-disabled-memory-cache-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/http/tests/inspector/network/set-resource-caching-disabled-memory-cache-expected.txt	2017-03-28 21:41:24 UTC (rev 214494)
@@ -0,0 +1,10 @@
+Test for `Network.setResourceCachingDisabled` for memory cache loads.
+
+
+== Running test suite: Network.SetResourceCachingDisabled.MemoryCache
+-- Running test setup.
+-- Running test case: Network.SetResourceCachingDisabled.MemoryCache
+PASS: Resource should be exist.
+PASS: statusCode should be 200
+PASS: responseSource should be Symbol(network)
+

Added: trunk/LayoutTests/http/tests/inspector/network/set-resource-caching-disabled-memory-cache.html (0 => 214494)


--- trunk/LayoutTests/http/tests/inspector/network/set-resource-caching-disabled-memory-cache.html	                        (rev 0)
+++ trunk/LayoutTests/http/tests/inspector/network/set-resource-caching-disabled-memory-cache.html	2017-03-28 21:41:24 UTC (rev 214494)
@@ -0,0 +1,60 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<script src=""
+<script src=""
+<script>
+// NOTE: this test is based on resource-response-source-memory-cache.html.
+
+TestPage.dispatchEventToFrontend("LoadComplete");
+
+function test()
+{
+    let suite = InspectorTest.createAsyncSuite("Network.SetResourceCachingDisabled.MemoryCache");
+
+    function addReloadTestCase({name, description, setup, _expression_, pattern, ignoreCache, statusCode, responseSource}) {
+        suite.addTestCase({
+            name, description, setup,
+            test(resolve, reject) {
+                NetworkAgent.setResourceCachingDisabled(true);
+                InspectorTest.reloadPage(ignoreCache);
+                InspectorTest.awaitEvent("LoadComplete").then((event) => {
+                    let resource = null;
+                    for (let item of WebInspector.frameResourceManager.mainFrame.resourceCollection.items) {
+                        if (pattern.test(item.url)) {
+                            resource = item;
+                            break;
+                        }
+                    }
+                    if (!resource) {
+                        InspectorTest.fail("Failed to find specific resource.");
+                        reject();
+                        return;
+                    }
+                    InspectorTest.expectThat(resource instanceof WebInspector.Resource, "Resource should be exist.");
+                    InspectorTest.expectEqual(resource.statusCode, statusCode, `statusCode should be ${statusCode}`);
+                    InspectorTest.expectEqual(resource.responseSource, responseSource, `responseSource should be ${String(responseSource)}`);
+                }).then(resolve, reject);
+            }
+        });
+    }
+
+    addReloadTestCase({
+        name: "Network.SetResourceCachingDisabled.MemoryCache",
+        description: "Fail to load a resource from the memory cache by reloading this page when resource caching is disabled.",
+        pattern: /cached-script\.js$/,
+        setup(resolve) { NetworkAgent.setResourceCachingDisabled(true); resolve(); },
+        ignoreCache: false,
+        responseSource: WebInspector.Resource.ResponseSource.Network,
+        statusCode: 200,
+    });
+
+    suite.runTestCasesAndFinish();
+}
+</script>
+</head>
+<body _onload_="runTest()">
+<p>Test for `Network.setResourceCachingDisabled` for memory cache loads.</p>
+</body>
+</html>

Modified: trunk/Source/_javascript_Core/ChangeLog (214493 => 214494)


--- trunk/Source/_javascript_Core/ChangeLog	2017-03-28 21:17:12 UTC (rev 214493)
+++ trunk/Source/_javascript_Core/ChangeLog	2017-03-28 21:41:24 UTC (rev 214494)
@@ -1,3 +1,16 @@
+2017-03-28  Brian Burg  <[email protected]>
+
+        Web Inspector: Add "Disable Caches" option that only applies to the inspected page while Web Inspector is open
+        https://bugs.webkit.org/show_bug.cgi?id=169865
+        <rdar://problem/31250573>
+
+        Reviewed by Joseph Pecoraro.
+
+        * inspector/protocol/Network.json:
+        Rename the command for disabling resource caching to match the WebCore::Page
+        flag. This also removes the possibility that this could be confused for the old,
+        buggy command that this patch rips out.
+
 2017-03-25  Yusuke Suzuki  <[email protected]>
 
         [JSC] Move platformThreadSignal to WTF

Modified: trunk/Source/_javascript_Core/inspector/protocol/Network.json (214493 => 214494)


--- trunk/Source/_javascript_Core/inspector/protocol/Network.json	2017-03-28 21:17:12 UTC (rev 214493)
+++ trunk/Source/_javascript_Core/inspector/protocol/Network.json	2017-03-28 21:41:24 UTC (rev 214494)
@@ -167,11 +167,11 @@
             ]
         },
         {
-            "name": "setCacheDisabled",
+            "name": "setResourceCachingDisabled",
             "parameters": [
-                { "name": "cacheDisabled", "type": "boolean", "description": "Cache disabled state." }
+                { "name": "disabled", "type": "boolean", "description": "Whether to prevent usage of the resource cache." }
             ],
-            "description": "Toggles ignoring cache for each request. If <code>true</code>, cache will not be used."
+            "description": "Toggles whether the resource cache may be used when loading resources in the inspected page. If <code>true</code>, the resource cache will not be used when loading resources."
         },
         {
             "name": "loadResource",

Modified: trunk/Source/WebCore/ChangeLog (214493 => 214494)


--- trunk/Source/WebCore/ChangeLog	2017-03-28 21:17:12 UTC (rev 214493)
+++ trunk/Source/WebCore/ChangeLog	2017-03-28 21:41:24 UTC (rev 214494)
@@ -1,3 +1,37 @@
+2017-03-28  Brian Burg  <[email protected]>
+
+        Web Inspector: Add "Disable Caches" option that only applies to the inspected page while Web Inspector is open
+        https://bugs.webkit.org/show_bug.cgi?id=169865
+        <rdar://problem/31250573>
+
+        Reviewed by Joseph Pecoraro.
+
+        Rewrite the network agent's command for disabling resource caching to use Page::setResourceCachingEnabled.
+        The old implementation was doing weird stuff like setting no-cache headers and evicting the
+        contents of the memory cache, neither of which is correct. The new approach has no side effects
+        on the network, disk, or memory cache so it can be turned on temporarily without causing problems.
+
+        New tests:
+        - http/tests/inspector/network/set-resource-caching-disabled-disk-cache.html
+        - http/tests/inspector/network/set-resource-caching-disabled-memory-cache.html
+
+        * inspector/InspectorNetworkAgent.h:
+        * inspector/InspectorNetworkAgent.cpp:
+        (WebCore::InspectorNetworkAgent::setCacheDisabled): Deleted.
+        (WebCore::InspectorNetworkAgent::setResourceCachingDisabled): Added.
+        Implement new command.
+
+        (WebCore::InspectorNetworkAgent::willSendRequest):
+        (WebCore::InspectorNetworkAgent::mainFrameNavigated):
+        Remove crufty attempts to break caches. I believe these are intended to defeat caching
+        proxies and similar middlemen, but this is just as likely to cause unusual loading behavior.
+
+        * page/Page.h:
+        (WebCore::Page::isResourceCachingDisabled):
+        (WebCore::Page::setResourceCachingDisabledOverride):
+        Add an override setting so that Web Inspector's override does not mess up the value
+        of isResourceCachingDisabled that may have been set by a WebKit API client.
+
 2017-03-28  Youenn Fablet  <[email protected]>
 
         Fix addIceCandidate after r214441

Modified: trunk/Source/WebCore/inspector/InspectorNetworkAgent.cpp (214493 => 214494)


--- trunk/Source/WebCore/inspector/InspectorNetworkAgent.cpp	2017-03-28 21:17:12 UTC (rev 214493)
+++ trunk/Source/WebCore/inspector/InspectorNetworkAgent.cpp	2017-03-28 21:41:24 UTC (rev 214494)
@@ -342,12 +342,6 @@
     for (auto& entry : m_extraRequestHeaders)
         request.setHTTPHeaderField(entry.key, entry.value);
 
-    if (m_cacheDisabled) {
-        request.setHTTPHeaderField(HTTPHeaderName::Pragma, "no-cache");
-        request.setCachePolicy(ReloadIgnoringCacheData);
-        request.setHTTPHeaderField(HTTPHeaderName::CacheControl, "no-cache");
-    }
-
     Inspector::Protocol::Page::ResourceType resourceType = InspectorPageAgent::resourceTypeJson(type);
 
     RefPtr<Inspector::Protocol::Network::Initiator> initiatorObject = buildInitiatorObject(loader.frame() ? loader.frame()->document() : nullptr);
@@ -654,6 +648,8 @@
     m_instrumentingAgents.setInspectorNetworkAgent(nullptr);
     m_resourcesData->clear();
     m_extraRequestHeaders.clear();
+
+    m_pageAgent->page().setResourceCachingDisabledOverride(false);
 }
 
 void InspectorNetworkAgent::setExtraHTTPHeaders(ErrorString&, const InspectorObject& headers)
@@ -698,11 +694,9 @@
     errorString = ASCIILiteral("No data found for resource with given identifier");
 }
 
-void InspectorNetworkAgent::setCacheDisabled(ErrorString&, bool cacheDisabled)
+void InspectorNetworkAgent::setResourceCachingDisabled(ErrorString&, bool disabled)
 {
-    m_cacheDisabled = cacheDisabled;
-    if (cacheDisabled)
-        MemoryCache::singleton().evictResources();
+    m_pageAgent->page().setResourceCachingDisabledOverride(disabled);
 }
 
 void InspectorNetworkAgent::loadResource(ErrorString& errorString, const String& frameId, const String& urlString, Ref<LoadResourceCallback>&& callback)
@@ -783,9 +777,6 @@
 
 void InspectorNetworkAgent::mainFrameNavigated(DocumentLoader& loader)
 {
-    if (m_cacheDisabled)
-        MemoryCache::singleton().evictResources();
-
     m_resourcesData->clear(m_pageAgent->loaderId(&loader));
 }
 

Modified: trunk/Source/WebCore/inspector/InspectorNetworkAgent.h (214493 => 214494)


--- trunk/Source/WebCore/inspector/InspectorNetworkAgent.h	2017-03-28 21:17:12 UTC (rev 214493)
+++ trunk/Source/WebCore/inspector/InspectorNetworkAgent.h	2017-03-28 21:41:24 UTC (rev 214494)
@@ -110,7 +110,7 @@
     void disable(ErrorString&) override;
     void setExtraHTTPHeaders(ErrorString&, const Inspector::InspectorObject& headers) override;
     void getResponseBody(ErrorString&, const String& requestId, String* content, bool* base64Encoded) override;
-    void setCacheDisabled(ErrorString&, bool cacheDisabled) override;
+    void setResourceCachingDisabled(ErrorString&, bool disabled) override;
     void loadResource(ErrorString&, const String& frameId, const String& url, Ref<LoadResourceCallback>&&) override;
 
 private:
@@ -133,7 +133,6 @@
 
     std::unique_ptr<NetworkResourcesData> m_resourcesData;
     bool m_enabled { false };
-    bool m_cacheDisabled { false };
     bool m_loadingXHRSynchronously { false };
     HashMap<String, String> m_extraRequestHeaders;
     HashSet<unsigned long> m_hiddenRequestIdentifiers;

Modified: trunk/Source/WebCore/page/Page.h (214493 => 214494)


--- trunk/Source/WebCore/page/Page.h	2017-03-28 21:17:12 UTC (rev 214493)
+++ trunk/Source/WebCore/page/Page.h	2017-03-28 21:41:24 UTC (rev 214494)
@@ -563,9 +563,12 @@
     String captionUserPreferencesStyleSheet();
     void setCaptionUserPreferencesStyleSheet(const String&);
 
-    bool isResourceCachingDisabled() const { return m_resourceCachingDisabled; }
+    bool isResourceCachingDisabled() const { return m_resourceCachingDisabled || m_resourceCachingDisabledOverride; }
     void setResourceCachingDisabled(bool disabled) { m_resourceCachingDisabled = disabled; }
 
+    // Web Inspector can override whatever value is set via WebKit SPI, but only while it is open.
+    void setResourceCachingDisabledOverride(bool disabled) { m_resourceCachingDisabledOverride = disabled; }
+
     std::optional<EventThrottlingBehavior> eventThrottlingBehaviorOverride() const { return m_eventThrottlingBehaviorOverride; }
     void setEventThrottlingBehaviorOverride(std::optional<EventThrottlingBehavior> throttling) { m_eventThrottlingBehaviorOverride = throttling; }
 
@@ -780,6 +783,7 @@
     bool m_showAllPlugins { false };
     bool m_controlledByAutomation { false };
     bool m_resourceCachingDisabled { false };
+    bool m_resourceCachingDisabledOverride { false };
     bool m_isUtilityPage;
     UserInterfaceLayoutDirection m_userInterfaceLayoutDirection { UserInterfaceLayoutDirection::LTR };
     

Modified: trunk/Source/WebInspectorUI/ChangeLog (214493 => 214494)


--- trunk/Source/WebInspectorUI/ChangeLog	2017-03-28 21:17:12 UTC (rev 214493)
+++ trunk/Source/WebInspectorUI/ChangeLog	2017-03-28 21:41:24 UTC (rev 214494)
@@ -1,3 +1,43 @@
+2017-03-28  Brian Burg  <[email protected]>
+
+        Web Inspector: Add "Disable Caches" option that only applies to the inspected page while Web Inspector is open
+        https://bugs.webkit.org/show_bug.cgi?id=169865
+        <rdar://problem/31250573>
+
+        Reviewed by Joseph Pecoraro.
+
+        Hook up a button in the Network tab to WebCore::Page's resourceCachingDisabled flag.
+        If it is active, resource loads are subject to a cache policy that never uses a cached response.
+
+        * Localizations/en.lproj/localizedStrings.js:
+        Add localized strings.
+
+        * UserInterface/Base/Main.js:
+        (WebInspector.loaded):
+        Add a setting for whether to disable resource caching and inform the backend
+        of our preference. If someone changes the setting, tell the backend again.
+
+        * UserInterface/Views/NetworkGridContentView.js:
+        (WebInspector.NetworkGridContentView):
+        (WebInspector.NetworkGridContentView.prototype.get navigationItems):
+        (WebInspector.NetworkGridContentView.prototype._resourceCachingDisabledSettingChanged):
+        (WebInspector.NetworkGridContentView.prototype._toggleDisableResourceCache):
+        Add a new activatable navigation item that toggles disableResourceCaching for the inspected page.
+
+        * UserInterface/Protocol/Legacy/10.0/InspectorBackendCommands.js:
+        * UserInterface/Protocol/Legacy/10.3/InspectorBackendCommands.js:
+        * UserInterface/Protocol/Legacy/7.0/InspectorBackendCommands.js:
+        * UserInterface/Protocol/Legacy/8.0/InspectorBackendCommands.js:
+        * UserInterface/Protocol/Legacy/9.0/InspectorBackendCommands.js:
+        * UserInterface/Protocol/Legacy/9.3/InspectorBackendCommands.js:
+        * Versions/Inspector-iOS-10.0.json:
+        * Versions/Inspector-iOS-10.3.json:
+        * Versions/Inspector-iOS-7.0.json:
+        * Versions/Inspector-iOS-8.0.json:
+        * Versions/Inspector-iOS-9.0.json:
+        * Versions/Inspector-iOS-9.3.json:
+        Update legacy backend commands to remove the old/broken Network.setCacheDisabled command.
+
 2017-03-28  Joseph Pecoraro  <[email protected]>
 
         Web Inspector: Inspecting a Main Resource that is JS/JSON does not format / syntax highlight it properly

Modified: trunk/Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js (214493 => 214494)


--- trunk/Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js	2017-03-28 21:17:12 UTC (rev 214493)
+++ trunk/Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js	2017-03-28 21:41:24 UTC (rev 214494)
@@ -436,6 +436,7 @@
 localizedStrings["Identity"] = "Identity";
 localizedStrings["Idle"] = "Idle";
 localizedStrings["Ignore"] = "Ignore";
+localizedStrings["Ignore the resource cache when loading resources"] = "Ignore the resource cache when loading resources";
 localizedStrings["Ignored"] = "Ignored";
 localizedStrings["Image"] = "Image";
 localizedStrings["Image Size"] = "Image Size";
@@ -868,6 +869,7 @@
 localizedStrings["Unsupported property ā€œ%sā€"] = "Unsupported property ā€œ%sā€";
 localizedStrings["Untitled"] = "Untitled";
 localizedStrings["Use Default Media Styles"] = "Use Default Media Styles";
+localizedStrings["Use the resource cache when loading resources"] = "Use the resource cache when loading resources";
 localizedStrings["User Agent"] = "User Agent";
 localizedStrings["User Agent Stylesheet"] = "User Agent Stylesheet";
 localizedStrings["User Stylesheet"] = "User Stylesheet";

Modified: trunk/Source/WebInspectorUI/UserInterface/Base/Main.js (214493 => 214494)


--- trunk/Source/WebInspectorUI/UserInterface/Base/Main.js	2017-03-28 21:17:12 UTC (rev 214493)
+++ trunk/Source/WebInspectorUI/UserInterface/Base/Main.js	2017-03-28 21:41:24 UTC (rev 214494)
@@ -192,6 +192,13 @@
     if (this.showPrintStylesSetting.value && window.PageAgent)
         PageAgent.setEmulatedMedia("print");
 
+    // COMPATIBILITY (iOS 10.3): Network.setDisableResourceCaching did not exist.
+    this.resourceCachingDisabledSetting = new WebInspector.Setting("disable-resource-caching", false);
+    if (window.NetworkAgent && NetworkAgent.setResourceCachingDisabled && this.resourceCachingDisabledSetting.value) {
+        NetworkAgent.setResourceCachingDisabled(true);
+        this.resourceCachingDisabledSetting.addEventListener(WebInspector.Setting.Event.Changed, this._resourceCachingDisabledSettingChanged, this);
+    }
+
     this.setZoomFactor(WebInspector.settings.zoomFactor.value);
 
     this.mouseCoords = {
@@ -2231,6 +2238,11 @@
     }
 };
 
+WebInspector._resourceCachingDisabledSettingChanged = function(event)
+{
+    NetworkAgent.setResourceCachingDisabled(this.resourceCachingDisabledSetting.value);
+}
+
 WebInspector.elementDragStart = function(element, dividerDrag, elementDragEnd, event, cursor, eventTarget)
 {
     if (WebInspector._elementDraggingEventListener || WebInspector._elementEndDraggingEventListener)

Modified: trunk/Source/WebInspectorUI/UserInterface/Protocol/Legacy/10.0/InspectorBackendCommands.js (214493 => 214494)


--- trunk/Source/WebInspectorUI/UserInterface/Protocol/Legacy/10.0/InspectorBackendCommands.js	2017-03-28 21:17:12 UTC (rev 214493)
+++ trunk/Source/WebInspectorUI/UserInterface/Protocol/Legacy/10.0/InspectorBackendCommands.js	2017-03-28 21:41:24 UTC (rev 214494)
@@ -286,7 +286,6 @@
 InspectorBackend.registerCommand("Network.disable", [], []);
 InspectorBackend.registerCommand("Network.setExtraHTTPHeaders", [{"name": "headers", "type": "object", "optional": false}], []);
 InspectorBackend.registerCommand("Network.getResponseBody", [{"name": "requestId", "type": "string", "optional": false}], ["body", "base64Encoded"]);
-InspectorBackend.registerCommand("Network.setCacheDisabled", [{"name": "cacheDisabled", "type": "boolean", "optional": false}], []);
 InspectorBackend.registerCommand("Network.loadResource", [{"name": "frameId", "type": "string", "optional": false}, {"name": "url", "type": "string", "optional": false}], ["content", "mimeType", "status"]);
 InspectorBackend.activateDomain("Network", "web");
 

Modified: trunk/Source/WebInspectorUI/UserInterface/Protocol/Legacy/10.3/InspectorBackendCommands.js (214493 => 214494)


--- trunk/Source/WebInspectorUI/UserInterface/Protocol/Legacy/10.3/InspectorBackendCommands.js	2017-03-28 21:17:12 UTC (rev 214493)
+++ trunk/Source/WebInspectorUI/UserInterface/Protocol/Legacy/10.3/InspectorBackendCommands.js	2017-03-28 21:41:24 UTC (rev 214494)
@@ -293,7 +293,6 @@
 InspectorBackend.registerCommand("Network.disable", [], []);
 InspectorBackend.registerCommand("Network.setExtraHTTPHeaders", [{"name": "headers", "type": "object", "optional": false}], []);
 InspectorBackend.registerCommand("Network.getResponseBody", [{"name": "requestId", "type": "string", "optional": false}], ["body", "base64Encoded"]);
-InspectorBackend.registerCommand("Network.setCacheDisabled", [{"name": "cacheDisabled", "type": "boolean", "optional": false}], []);
 InspectorBackend.registerCommand("Network.loadResource", [{"name": "frameId", "type": "string", "optional": false}, {"name": "url", "type": "string", "optional": false}], ["content", "mimeType", "status"]);
 InspectorBackend.activateDomain("Network", "web");
 

Modified: trunk/Source/WebInspectorUI/UserInterface/Protocol/Legacy/7.0/InspectorBackendCommands.js (214493 => 214494)


--- trunk/Source/WebInspectorUI/UserInterface/Protocol/Legacy/7.0/InspectorBackendCommands.js	2017-03-28 21:17:12 UTC (rev 214493)
+++ trunk/Source/WebInspectorUI/UserInterface/Protocol/Legacy/7.0/InspectorBackendCommands.js	2017-03-28 21:41:24 UTC (rev 214494)
@@ -126,7 +126,6 @@
 InspectorBackend.registerCommand("Network.disable", [], []);
 InspectorBackend.registerCommand("Network.setExtraHTTPHeaders", [{"name": "headers", "type": "object", "optional": false}], []);
 InspectorBackend.registerCommand("Network.getResponseBody", [{"name": "requestId", "type": "string", "optional": false}], ["body", "base64Encoded"]);
-InspectorBackend.registerCommand("Network.setCacheDisabled", [{"name": "cacheDisabled", "type": "boolean", "optional": false}], []);
 InspectorBackend.activateDomain("Network");
 
 // Database.

Modified: trunk/Source/WebInspectorUI/UserInterface/Protocol/Legacy/8.0/InspectorBackendCommands.js (214493 => 214494)


--- trunk/Source/WebInspectorUI/UserInterface/Protocol/Legacy/8.0/InspectorBackendCommands.js	2017-03-28 21:17:12 UTC (rev 214493)
+++ trunk/Source/WebInspectorUI/UserInterface/Protocol/Legacy/8.0/InspectorBackendCommands.js	2017-03-28 21:41:24 UTC (rev 214494)
@@ -277,7 +277,6 @@
 InspectorBackend.registerCommand("Network.disable", [], []);
 InspectorBackend.registerCommand("Network.setExtraHTTPHeaders", [{"name": "headers", "type": "object", "optional": false}], []);
 InspectorBackend.registerCommand("Network.getResponseBody", [{"name": "requestId", "type": "string", "optional": false}], ["body", "base64Encoded"]);
-InspectorBackend.registerCommand("Network.setCacheDisabled", [{"name": "cacheDisabled", "type": "boolean", "optional": false}], []);
 InspectorBackend.registerCommand("Network.loadResource", [{"name": "frameId", "type": "string", "optional": false}, {"name": "url", "type": "string", "optional": false}], ["content", "mimeType", "status"]);
 InspectorBackend.activateDomain("Network", "web");
 

Modified: trunk/Source/WebInspectorUI/UserInterface/Protocol/Legacy/9.0/InspectorBackendCommands.js (214493 => 214494)


--- trunk/Source/WebInspectorUI/UserInterface/Protocol/Legacy/9.0/InspectorBackendCommands.js	2017-03-28 21:17:12 UTC (rev 214493)
+++ trunk/Source/WebInspectorUI/UserInterface/Protocol/Legacy/9.0/InspectorBackendCommands.js	2017-03-28 21:41:24 UTC (rev 214494)
@@ -246,7 +246,6 @@
 InspectorBackend.registerCommand("Network.disable", [], []);
 InspectorBackend.registerCommand("Network.setExtraHTTPHeaders", [{"name": "headers", "type": "object", "optional": false}], []);
 InspectorBackend.registerCommand("Network.getResponseBody", [{"name": "requestId", "type": "string", "optional": false}], ["body", "base64Encoded"]);
-InspectorBackend.registerCommand("Network.setCacheDisabled", [{"name": "cacheDisabled", "type": "boolean", "optional": false}], []);
 InspectorBackend.registerCommand("Network.loadResource", [{"name": "frameId", "type": "string", "optional": false}, {"name": "url", "type": "string", "optional": false}], ["content", "mimeType", "status"]);
 InspectorBackend.activateDomain("Network", "web");
 

Modified: trunk/Source/WebInspectorUI/UserInterface/Protocol/Legacy/9.3/InspectorBackendCommands.js (214493 => 214494)


--- trunk/Source/WebInspectorUI/UserInterface/Protocol/Legacy/9.3/InspectorBackendCommands.js	2017-03-28 21:17:12 UTC (rev 214493)
+++ trunk/Source/WebInspectorUI/UserInterface/Protocol/Legacy/9.3/InspectorBackendCommands.js	2017-03-28 21:41:24 UTC (rev 214494)
@@ -257,7 +257,6 @@
 InspectorBackend.registerCommand("Network.clearBrowserCache", [], []);
 InspectorBackend.registerCommand("Network.canClearBrowserCookies", [], ["result"]);
 InspectorBackend.registerCommand("Network.clearBrowserCookies", [], []);
-InspectorBackend.registerCommand("Network.setCacheDisabled", [{"name": "cacheDisabled", "type": "boolean", "optional": false}], []);
 InspectorBackend.registerCommand("Network.loadResource", [{"name": "frameId", "type": "string", "optional": false}, {"name": "url", "type": "string", "optional": false}], ["content", "mimeType", "status"]);
 InspectorBackend.activateDomain("Network", "web");
 

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/NetworkGridContentView.js (214493 => 214494)


--- trunk/Source/WebInspectorUI/UserInterface/Views/NetworkGridContentView.js	2017-03-28 21:17:12 UTC (rev 214493)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/NetworkGridContentView.js	2017-03-28 21:41:24 UTC (rev 214494)
@@ -128,6 +128,17 @@
         networkTimeline.addEventListener(WebInspector.Timeline.Event.RecordAdded, this._networkTimelineRecordAdded, this);
         networkTimeline.addEventListener(WebInspector.Timeline.Event.Reset, this._networkTimelineReset, this);
 
+        // COMPATIBILITY (iOS 10.3): Network.setDisableResourceCaching did not exist.
+        if (window.NetworkAgent && NetworkAgent.setResourceCachingDisabled) {
+            let toolTipForDisableResourceCache = WebInspector.UIString("Ignore the resource cache when loading resources");
+            let activatedToolTipForDisableResourceCache = WebInspector.UIString("Use the resource cache when loading resources");
+            this._disableResourceCacheNavigationItem = new WebInspector.ActivateButtonNavigationItem("disable-resource-cache", toolTipForDisableResourceCache, activatedToolTipForDisableResourceCache, "Images/StepOver.svg", 16, 16);
+            this._disableResourceCacheNavigationItem.activated = WebInspector.resourceCachingDisabledSetting.value;
+
+            this._disableResourceCacheNavigationItem.addEventListener(WebInspector.ButtonNavigationItem.Event.Clicked, this._toggleDisableResourceCache, this);
+            WebInspector.resourceCachingDisabledSetting.addEventListener(WebInspector.Setting.Event.Changed, this._resourceCachingDisabledSettingChanged, this);
+        }
+
         let clearImageDimensions = WebInspector.Platform.name === "mac" ? 16 : 15;
         this._clearNetworkItemsNavigationItem = new WebInspector.ButtonNavigationItem("clear-network-items", WebInspector.UIString("Clear Network Items (%s)").format(WebInspector.clearKeyboardShortcut.displayName), "Images/NavigationItemClear.svg", clearImageDimensions, clearImageDimensions);
         this._clearNetworkItemsNavigationItem.addEventListener(WebInspector.ButtonNavigationItem.Event.Clicked, () => this.reset());
@@ -161,7 +172,13 @@
 
     get navigationItems()
     {
-        return [this._clearNetworkItemsNavigationItem];
+        let items = [];
+
+        if (this._disableResourceCacheNavigationItem)
+            items.push(this._disableResourceCacheNavigationItem);
+        items.push(this._clearNetworkItemsNavigationItem);
+
+        return items;
     }
 
     shown()
@@ -261,6 +278,16 @@
 
     // Private
 
+    _resourceCachingDisabledSettingChanged()
+    {
+        this._disableResourceCacheNavigationItem.activated = WebInspector.resourceCachingDisabledSetting.value;
+    }
+
+    _toggleDisableResourceCache()
+    {
+        WebInspector.resourceCachingDisabledSetting.value = !WebInspector.resourceCachingDisabledSetting.value;
+    }
+
     _processPendingRecords()
     {
         if (!this._pendingRecords.length)

Modified: trunk/Source/WebInspectorUI/Versions/Inspector-iOS-10.0.json (214493 => 214494)


--- trunk/Source/WebInspectorUI/Versions/Inspector-iOS-10.0.json	2017-03-28 21:17:12 UTC (rev 214493)
+++ trunk/Source/WebInspectorUI/Versions/Inspector-iOS-10.0.json	2017-03-28 21:41:24 UTC (rev 214494)
@@ -2364,13 +2364,6 @@
             ]
         },
         {
-            "name": "setCacheDisabled",
-            "parameters": [
-                { "name": "cacheDisabled", "type": "boolean", "description": "Cache disabled state." }
-            ],
-            "description": "Toggles ignoring cache for each request. If <code>true</code>, cache will not be used."
-        },
-        {
             "name": "loadResource",
             "async": true,
             "parameters": [

Modified: trunk/Source/WebInspectorUI/Versions/Inspector-iOS-10.3.json (214493 => 214494)


--- trunk/Source/WebInspectorUI/Versions/Inspector-iOS-10.3.json	2017-03-28 21:17:12 UTC (rev 214493)
+++ trunk/Source/WebInspectorUI/Versions/Inspector-iOS-10.3.json	2017-03-28 21:41:24 UTC (rev 214494)
@@ -2407,13 +2407,6 @@
             ]
         },
         {
-            "name": "setCacheDisabled",
-            "parameters": [
-                { "name": "cacheDisabled", "type": "boolean", "description": "Cache disabled state." }
-            ],
-            "description": "Toggles ignoring cache for each request. If <code>true</code>, cache will not be used."
-        },
-        {
             "name": "loadResource",
             "async": true,
             "parameters": [

Modified: trunk/Source/WebInspectorUI/Versions/Inspector-iOS-7.0.json (214493 => 214494)


--- trunk/Source/WebInspectorUI/Versions/Inspector-iOS-7.0.json	2017-03-28 21:17:12 UTC (rev 214493)
+++ trunk/Source/WebInspectorUI/Versions/Inspector-iOS-7.0.json	2017-03-28 21:41:24 UTC (rev 214494)
@@ -794,13 +794,6 @@
                     { "name": "body", "type": "string", "description": "Response body." },
                     { "name": "base64Encoded", "type": "boolean", "description": "True, if content was sent as base64." }
                 ]
-            },
-            {
-                "name": "setCacheDisabled",
-                "parameters": [
-                    { "name": "cacheDisabled", "type": "boolean", "description": "Cache disabled state." }
-                ],
-                "description": "Toggles ignoring cache for each request. If <code>true</code>, cache will not be used."
             }
         ],
         "events": [

Modified: trunk/Source/WebInspectorUI/Versions/Inspector-iOS-8.0.json (214493 => 214494)


--- trunk/Source/WebInspectorUI/Versions/Inspector-iOS-8.0.json	2017-03-28 21:17:12 UTC (rev 214493)
+++ trunk/Source/WebInspectorUI/Versions/Inspector-iOS-8.0.json	2017-03-28 21:41:24 UTC (rev 214494)
@@ -2370,13 +2370,6 @@
             ]
         },
         {
-            "name": "setCacheDisabled",
-            "parameters": [
-                { "name": "cacheDisabled", "type": "boolean", "description": "Cache disabled state." }
-            ],
-            "description": "Toggles ignoring cache for each request. If <code>true</code>, cache will not be used."
-        },
-        {
             "name": "loadResource",
             "async": true,
             "parameters": [

Modified: trunk/Source/WebInspectorUI/Versions/Inspector-iOS-9.0.json (214493 => 214494)


--- trunk/Source/WebInspectorUI/Versions/Inspector-iOS-9.0.json	2017-03-28 21:17:12 UTC (rev 214493)
+++ trunk/Source/WebInspectorUI/Versions/Inspector-iOS-9.0.json	2017-03-28 21:41:24 UTC (rev 214494)
@@ -2112,13 +2112,6 @@
             ]
         },
         {
-            "name": "setCacheDisabled",
-            "parameters": [
-                { "name": "cacheDisabled", "type": "boolean", "description": "Cache disabled state." }
-            ],
-            "description": "Toggles ignoring cache for each request. If <code>true</code>, cache will not be used."
-        },
-        {
             "name": "loadResource",
             "async": true,
             "parameters": [

Modified: trunk/Source/WebInspectorUI/Versions/Inspector-iOS-9.3.json (214493 => 214494)


--- trunk/Source/WebInspectorUI/Versions/Inspector-iOS-9.3.json	2017-03-28 21:17:12 UTC (rev 214493)
+++ trunk/Source/WebInspectorUI/Versions/Inspector-iOS-9.3.json	2017-03-28 21:41:24 UTC (rev 214494)
@@ -2194,13 +2194,6 @@
             "description": "Clears browser cookies."
         },
         {
-            "name": "setCacheDisabled",
-            "parameters": [
-                { "name": "cacheDisabled", "type": "boolean", "description": "Cache disabled state." }
-            ],
-            "description": "Toggles ignoring cache for each request. If <code>true</code>, cache will not be used."
-        },
-        {
             "name": "loadResource",
             "async": true,
             "parameters": [
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to