Commit 9c22f660 authored by ananta's avatar ananta Committed by Commit bot

PlzNavigate: Fix for the http/tests/inspector/resource-har-conversion.html layout test failure.

This test turns off caching for the reload request initiated via the DevTools network agent.
Without PlzNavigate, this goes through the normal resource load path, where in
RenderFrameImpl::decidePolicyForNavigation is invoked after which the cache policy is set in
the WebURLRequest to disabled correctly.

With PlzNavigate, the reload request is sent out to the browser via the BeginNavigate IPC
in RenderFrameImpl::decidePolicyForNavigation() and we indicate  to blink that the client
handled the request.

As a result the cache policy does not get set to disabled.

Fix is to add query the dev tools agent if caching is disabled. To achieve this following changes
were needed.
1. Add a virtual function cacheDisabled() to the WebDevToolsAgent class.
2. This function calls to the newly added cacheDisabled() function in the InspectorNetworkAgent class.
   which checks the state variable for the same.

BUG=673745

Review-Url: https://codereview.chromium.org/2611183007
Cr-Commit-Position: refs/heads/master@{#442773}
parent b88b6264
......@@ -157,6 +157,7 @@
#include "mojo/edk/js/core.h"
#include "mojo/edk/js/support.h"
#include "net/base/data_url.h"
#include "net/base/load_flags.h"
#include "net/base/net_errors.h"
#include "net/base/registry_controlled_domains/registry_controlled_domain.h"
#include "net/http/http_util.h"
......@@ -6213,9 +6214,18 @@ void RenderFrameImpl::BeginNavigation(const NavigationPolicyInfo& info) {
info.urlRequest.requestorOrigin().isNull()
? base::Optional<url::Origin>()
: base::Optional<url::Origin>(info.urlRequest.requestorOrigin());
int load_flags = GetLoadFlagsForWebURLRequest(info.urlRequest);
// Requests initiated via devtools can have caching disabled.
if (info.isCacheDisabled) {
// Turn off all caching related flags and set LOAD_BYPASS_CACHE.
load_flags &= ~(net::LOAD_VALIDATE_CACHE | net::LOAD_SKIP_CACHE_VALIDATION |
net::LOAD_ONLY_FROM_CACHE | net::LOAD_DISABLE_CACHE);
load_flags |= net::LOAD_BYPASS_CACHE;
}
BeginNavigationParams begin_navigation_params(
GetWebURLRequestHeaders(info.urlRequest),
GetLoadFlagsForWebURLRequest(info.urlRequest),
GetWebURLRequestHeaders(info.urlRequest), load_flags,
info.urlRequest.hasUserGesture(),
info.urlRequest.skipServiceWorker() !=
blink::WebURLRequest::SkipServiceWorker::None,
......
......@@ -42,9 +42,7 @@ crbug.com/551000 http/tests/inspector/network/network-initiator.html [ Failure ]
crbug.com/551000 virtual/mojo-loading/http/tests/inspector/network/network-document-initiator.html [ Failure ]
crbug.com/551000 virtual/mojo-loading/http/tests/inspector/network/network-initiator.html [ Failure ]
# We are missing several parameters in network har reports.
crbug.com/551000 http/tests/inspector/resource-har-conversion.html [ Failure ]
crbug.com/551000 http/tests/inspector/resource-parameters.html [ Failure ]
crbug.com/551000 virtual/mojo-loading/http/tests/inspector/resource-har-conversion.html [ Failure ]
crbug.com/551000 virtual/mojo-loading/http/tests/inspector/resource-parameters.html [ Failure ]
# Duplicate started loading output.
crbug.com/551000 inspector-protocol/page/frameAttachedDetached.html [ Failure ]
......
......@@ -1425,6 +1425,9 @@ Response InspectorNetworkAgent::emulateNetworkConditions(
}
Response InspectorNetworkAgent::setCacheDisabled(bool cacheDisabled) {
// TODO(ananta)
// We should extract network cache state into a global entity which can be
// queried from FrameLoader and other places.
m_state->setBoolean(NetworkAgentState::cacheDisabled, cacheDisabled);
if (cacheDisabled)
memoryCache()->evictResources();
......@@ -1512,6 +1515,12 @@ bool InspectorNetworkAgent::fetchResourceContent(Document* document,
return false;
}
bool InspectorNetworkAgent::cacheDisabled() {
return m_state->booleanProperty(NetworkAgentState::networkAgentEnabled,
false) &&
m_state->booleanProperty(NetworkAgentState::cacheDisabled, false);
}
void InspectorNetworkAgent::removeFinishedReplayXHRFired(TimerBase*) {
m_replayXHRsToBeDeleted.clear();
}
......
......@@ -227,6 +227,7 @@ class CORE_EXPORT InspectorNetworkAgent final
const KURL&,
String* content,
bool* base64Encoded);
bool cacheDisabled();
private:
explicit InspectorNetworkAgent(InspectedFrames*);
......
......@@ -552,6 +552,12 @@ NavigationPolicy FrameLoaderClientImpl::decidePolicyForNavigation(
navigationInfo.isHistoryNavigationInNewChildFrame =
isHistoryNavigationInNewChildFrame;
navigationInfo.isClientRedirect = isClientRedirect;
// Caching could be disabled for requests initiated by DevTools.
// TODO(ananta)
// We should extract the network cache state into a global component which
// can be queried here and wherever necessary.
navigationInfo.isCacheDisabled =
devToolsAgent() ? devToolsAgent()->cacheDisabled() : false;
if (form)
navigationInfo.form = WebFormElement(form);
......
......@@ -596,6 +596,12 @@ WebString WebDevToolsAgentImpl::evaluateInWebInspectorOverlay(
return m_overlay->evaluateInOverlayForTest(script);
}
bool WebDevToolsAgentImpl::cacheDisabled() {
if (!m_networkAgent)
return false;
return m_networkAgent->cacheDisabled();
}
void WebDevToolsAgentImpl::flushProtocolNotifications() {
if (m_session)
m_session->flushProtocolNotifications();
......
......@@ -98,6 +98,7 @@ class WebDevToolsAgentImpl final
void inspectElementAt(int sessionId, const WebPoint&) override;
void failedToRequestDevTools() override;
WebString evaluateInWebInspectorOverlay(const WebString& script) override;
bool cacheDisabled() override;
private:
WebDevToolsAgentImpl(WebLocalFrameImpl*,
......
......@@ -62,6 +62,10 @@ class WebDevToolsAgent {
// Exposed for TestRunner.
virtual WebString evaluateInWebInspectorOverlay(const WebString& script) = 0;
// Returns true if caching is disabled for network requests issued by dev
// tools.
virtual bool cacheDisabled() = 0;
class MessageDescriptor {
public:
virtual ~MessageDescriptor() {}
......
......@@ -296,6 +296,7 @@ class BLINK_EXPORT WebFrameClient {
bool isHistoryNavigationInNewChildFrame;
bool isClientRedirect;
WebFormElement form;
bool isCacheDisabled;
NavigationPolicyInfo(WebURLRequest& urlRequest)
: extraData(nullptr),
......@@ -304,7 +305,8 @@ class BLINK_EXPORT WebFrameClient {
defaultPolicy(WebNavigationPolicyIgnore),
replacesCurrentHistoryItem(false),
isHistoryNavigationInNewChildFrame(false),
isClientRedirect(false) {}
isClientRedirect(false),
isCacheDisabled(false) {}
};
virtual WebNavigationPolicy decidePolicyForNavigation(
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment