Diff
Modified: trunk/Source/WebCore/ChangeLog (293367 => 293368)
--- trunk/Source/WebCore/ChangeLog 2022-04-25 22:56:06 UTC (rev 293367)
+++ trunk/Source/WebCore/ChangeLog 2022-04-25 23:14:18 UTC (rev 293368)
@@ -1,5 +1,31 @@
2022-04-25 Devin Rousso <drou...@apple.com>
+ Web Inspector: request interception should not be guarded based on service workers
+ https://bugs.webkit.org/show_bug.cgi?id=239677
+
+ Reviewed by Patrick Angle.
+
+ * inspector/InspectorInstrumentation.h:
+ (WebCore::InspectorInstrumentation::shouldInterceptRequest):
+ (WebCore::InspectorInstrumentation::interceptRequest):
+ * inspector/InspectorInstrumentation.cpp:
+ (WebCore::InspectorInstrumentation::shouldInterceptRequestImpl):
+ * inspector/InspectorInstrumentationWebKit.h:
+ (WebCore::InspectorInstrumentationWebKit::shouldInterceptRequest):
+ (WebCore::InspectorInstrumentationWebKit::interceptRequest):
+ * inspector/InspectorInstrumentationWebKit.cpp:
+ (WebCore::InspectorInstrumentationWebKit::shouldInterceptRequestInternal):
+ Pass along `ResourceLoader` instead of `ResourceRequest` so that `InspectorNetworkAgent::shouldInterceptRequest`
+ can look at the configuration of the load (e.g. `serviceWorkerRegistrationIdentifier`), not
+ just the request configuration.
+
+ * inspector/agents/InspectorNetworkAgent.h:
+ * inspector/agents/InspectorNetworkAgent.cpp:
+ (WebCore::InspectorNetworkAgent::shouldInterceptRequest):
+ Move the `#if ENABLE(SERVICE_WORKER)` here.
+
+2022-04-25 Devin Rousso <drou...@apple.com>
+
Web Inspector: crash when a subresource is intercepted by a skip network local override with an error status code
https://bugs.webkit.org/show_bug.cgi?id=239675
Modified: trunk/Source/WebCore/inspector/InspectorInstrumentation.cpp (293367 => 293368)
--- trunk/Source/WebCore/inspector/InspectorInstrumentation.cpp 2022-04-25 22:56:06 UTC (rev 293367)
+++ trunk/Source/WebCore/inspector/InspectorInstrumentation.cpp 2022-04-25 23:14:18 UTC (rev 293368)
@@ -845,10 +845,10 @@
return false;
}
-bool InspectorInstrumentation::shouldInterceptRequestImpl(InstrumentingAgents& instrumentingAgents, const ResourceRequest& request)
+bool InspectorInstrumentation::shouldInterceptRequestImpl(InstrumentingAgents& instrumentingAgents, const ResourceLoader& loader)
{
if (auto* networkAgent = instrumentingAgents.enabledNetworkAgent())
- return networkAgent->shouldInterceptRequest(request);
+ return networkAgent->shouldInterceptRequest(loader);
return false;
}
Modified: trunk/Source/WebCore/inspector/InspectorInstrumentation.h (293367 => 293368)
--- trunk/Source/WebCore/inspector/InspectorInstrumentation.h 2022-04-25 22:56:06 UTC (rev 293367)
+++ trunk/Source/WebCore/inspector/InspectorInstrumentation.h 2022-04-25 23:14:18 UTC (rev 293368)
@@ -238,7 +238,7 @@
static void willDestroyCachedResource(CachedResource&);
static bool willIntercept(const Frame*, const ResourceRequest&);
- static bool shouldInterceptRequest(const Frame&, const ResourceRequest&);
+ static bool shouldInterceptRequest(const ResourceLoader&);
static bool shouldInterceptResponse(const Frame&, const ResourceResponse&);
static void interceptRequest(ResourceLoader&, Function<void(const ResourceRequest&)>&&);
static void interceptResponse(const Frame&, const ResourceResponse&, ResourceLoaderIdentifier, CompletionHandler<void(const ResourceResponse&, RefPtr<FragmentedSharedBuffer>)>&&);
@@ -446,7 +446,7 @@
static void willDestroyCachedResourceImpl(CachedResource&);
static bool willInterceptImpl(InstrumentingAgents&, const ResourceRequest&);
- static bool shouldInterceptRequestImpl(InstrumentingAgents&, const ResourceRequest&);
+ static bool shouldInterceptRequestImpl(InstrumentingAgents&, const ResourceLoader&);
static bool shouldInterceptResponseImpl(InstrumentingAgents&, const ResourceResponse&);
static void interceptRequestImpl(InstrumentingAgents&, ResourceLoader&, Function<void(const ResourceRequest&)>&&);
static void interceptResponseImpl(InstrumentingAgents&, const ResourceResponse&, ResourceLoaderIdentifier, CompletionHandler<void(const ResourceResponse&, RefPtr<FragmentedSharedBuffer>)>&&);
@@ -1288,11 +1288,11 @@
return false;
}
-inline bool InspectorInstrumentation::shouldInterceptRequest(const Frame& frame, const ResourceRequest& request)
+inline bool InspectorInstrumentation::shouldInterceptRequest(const ResourceLoader& loader)
{
ASSERT(InspectorInstrumentationPublic::hasFrontends());
- if (auto* agents = instrumentingAgents(frame))
- return shouldInterceptRequestImpl(*agents, request);
+ if (auto* agents = instrumentingAgents(loader.frame()))
+ return shouldInterceptRequestImpl(*agents, loader);
return false;
}
@@ -1306,7 +1306,7 @@
inline void InspectorInstrumentation::interceptRequest(ResourceLoader& loader, Function<void(const ResourceRequest&)>&& handler)
{
- ASSERT(InspectorInstrumentation::shouldInterceptRequest(*loader.frame(), loader.request()));
+ ASSERT(InspectorInstrumentation::shouldInterceptRequest(loader));
if (auto* agents = instrumentingAgents(loader.frame()))
interceptRequestImpl(*agents, loader, WTFMove(handler));
}
Modified: trunk/Source/WebCore/inspector/InspectorInstrumentationWebKit.cpp (293367 => 293368)
--- trunk/Source/WebCore/inspector/InspectorInstrumentationWebKit.cpp 2022-04-25 22:56:06 UTC (rev 293367)
+++ trunk/Source/WebCore/inspector/InspectorInstrumentationWebKit.cpp 2022-04-25 23:14:18 UTC (rev 293368)
@@ -30,9 +30,9 @@
namespace WebCore {
-bool InspectorInstrumentationWebKit::shouldInterceptRequestInternal(const Frame& frame, const ResourceRequest& request)
+bool InspectorInstrumentationWebKit::shouldInterceptRequestInternal(const ResourceLoader& loader)
{
- return InspectorInstrumentation::shouldInterceptRequest(frame, request);
+ return InspectorInstrumentation::shouldInterceptRequest(loader);
}
bool InspectorInstrumentationWebKit::shouldInterceptResponseInternal(const Frame& frame, const ResourceResponse& response)
Modified: trunk/Source/WebCore/inspector/InspectorInstrumentationWebKit.h (293367 => 293368)
--- trunk/Source/WebCore/inspector/InspectorInstrumentationWebKit.h 2022-04-25 22:56:06 UTC (rev 293367)
+++ trunk/Source/WebCore/inspector/InspectorInstrumentationWebKit.h 2022-04-25 23:14:18 UTC (rev 293368)
@@ -40,25 +40,22 @@
class WEBCORE_EXPORT InspectorInstrumentationWebKit {
public:
- static bool shouldInterceptRequest(const Frame*, const ResourceRequest&);
+ static bool shouldInterceptRequest(const ResourceLoader&);
static bool shouldInterceptResponse(const Frame*, const ResourceResponse&);
static void interceptRequest(ResourceLoader&, Function<void(const ResourceRequest&)>&&);
static void interceptResponse(const Frame*, const ResourceResponse&, ResourceLoaderIdentifier, CompletionHandler<void(const ResourceResponse&, RefPtr<FragmentedSharedBuffer>)>&&);
private:
- static bool shouldInterceptRequestInternal(const Frame&, const ResourceRequest&);
+ static bool shouldInterceptRequestInternal(const ResourceLoader&);
static bool shouldInterceptResponseInternal(const Frame&, const ResourceResponse&);
static void interceptRequestInternal(ResourceLoader&, Function<void(const ResourceRequest&)>&&);
static void interceptResponseInternal(const Frame&, const ResourceResponse&, ResourceLoaderIdentifier, CompletionHandler<void(const ResourceResponse&, RefPtr<FragmentedSharedBuffer>)>&&);
};
-inline bool InspectorInstrumentationWebKit::shouldInterceptRequest(const Frame* frame, const ResourceRequest& request)
+inline bool InspectorInstrumentationWebKit::shouldInterceptRequest(const ResourceLoader& loader)
{
FAST_RETURN_IF_NO_FRONTENDS(false);
- if (!frame)
- return false;
-
- return shouldInterceptRequestInternal(*frame, request);
+ return shouldInterceptRequestInternal(loader);
}
inline bool InspectorInstrumentationWebKit::shouldInterceptResponse(const Frame* frame, const ResourceResponse& response)
@@ -72,7 +69,7 @@
inline void InspectorInstrumentationWebKit::interceptRequest(ResourceLoader& loader, Function<void(const ResourceRequest&)>&& handler)
{
- ASSERT(InspectorInstrumentationWebKit::shouldInterceptRequest(loader.frame(), loader.request()));
+ ASSERT(InspectorInstrumentationWebKit::shouldInterceptRequest(loader));
interceptRequestInternal(loader, WTFMove(handler));
}
Modified: trunk/Source/WebCore/inspector/agents/InspectorNetworkAgent.cpp (293367 => 293368)
--- trunk/Source/WebCore/inspector/agents/InspectorNetworkAgent.cpp 2022-04-25 22:56:06 UTC (rev 293367)
+++ trunk/Source/WebCore/inspector/agents/InspectorNetworkAgent.cpp 2022-04-25 23:14:18 UTC (rev 293368)
@@ -1108,12 +1108,17 @@
|| shouldIntercept(request.url(), Protocol::Network::NetworkStage::Response);
}
-bool InspectorNetworkAgent::shouldInterceptRequest(const ResourceRequest& request)
+bool InspectorNetworkAgent::shouldInterceptRequest(const ResourceLoader& loader)
{
if (!m_interceptionEnabled)
return false;
- return shouldIntercept(request.url(), Protocol::Network::NetworkStage::Request);
+#if ENABLE(SERVICE_WORKER)
+ if (loader.options().serviceWorkerRegistrationIdentifier)
+ return false;
+#endif
+
+ return shouldIntercept(loader.url(), Protocol::Network::NetworkStage::Request);
}
bool InspectorNetworkAgent::shouldInterceptResponse(const ResourceResponse& response)
Modified: trunk/Source/WebCore/inspector/agents/InspectorNetworkAgent.h (293367 => 293368)
--- trunk/Source/WebCore/inspector/agents/InspectorNetworkAgent.h 2022-04-25 22:56:06 UTC (rev 293367)
+++ trunk/Source/WebCore/inspector/agents/InspectorNetworkAgent.h 2022-04-25 23:14:18 UTC (rev 293368)
@@ -122,7 +122,7 @@
void setInitialScriptContent(ResourceLoaderIdentifier, const String& sourceString);
void didScheduleStyleRecalculation(Document&);
bool willIntercept(const ResourceRequest&);
- bool shouldInterceptRequest(const ResourceRequest&);
+ bool shouldInterceptRequest(const ResourceLoader&);
bool shouldInterceptResponse(const ResourceResponse&);
void interceptResponse(const ResourceResponse&, ResourceLoaderIdentifier, CompletionHandler<void(const ResourceResponse&, RefPtr<FragmentedSharedBuffer>)>&&);
void interceptRequest(ResourceLoader&, Function<void(const ResourceRequest&)>&&);
Modified: trunk/Source/WebKit/ChangeLog (293367 => 293368)
--- trunk/Source/WebKit/ChangeLog 2022-04-25 22:56:06 UTC (rev 293367)
+++ trunk/Source/WebKit/ChangeLog 2022-04-25 23:14:18 UTC (rev 293368)
@@ -1,3 +1,14 @@
+2022-04-25 Devin Rousso <drou...@apple.com>
+
+ Web Inspector: request interception should not be guarded based on service workers
+ https://bugs.webkit.org/show_bug.cgi?id=239677
+
+ Reviewed by Patrick Angle.
+
+ * WebProcess/Network/WebLoaderStrategy.cpp:
+ (WebKit::WebLoaderStrategy::scheduleLoad):
+ Move the `#if ENABLE(SERVICE_WORKER)` to `WebCore::InspectorNetworkAgent::shouldInterceptRequest`.
+
2022-04-25 Wenson Hsieh <wenson_hs...@apple.com>
Unreviewed, fix the macOS Monterey build after r293340
Modified: trunk/Source/WebKit/WebProcess/Network/WebLoaderStrategy.cpp (293367 => 293368)
--- trunk/Source/WebKit/WebProcess/Network/WebLoaderStrategy.cpp 2022-04-25 22:56:06 UTC (rev 293367)
+++ trunk/Source/WebKit/WebProcess/Network/WebLoaderStrategy.cpp 2022-04-25 23:14:18 UTC (rev 293368)
@@ -236,20 +236,20 @@
return;
#endif
- if (!tryLoadingUsingURLSchemeHandler(resourceLoader, trackingParameters)) {
- WEBLOADERSTRATEGY_RELEASE_LOG("scheduleLoad: URL will be scheduled with the NetworkProcess");
+ if (tryLoadingUsingURLSchemeHandler(resourceLoader, trackingParameters))
+ return;
-#if ENABLE(SERVICE_WORKER)
- if (!resourceLoader.options().serviceWorkerRegistrationIdentifier && InspectorInstrumentationWebKit::shouldInterceptRequest(resourceLoader.frame(), resourceLoader.request())) {
- InspectorInstrumentationWebKit::interceptRequest(resourceLoader, [this, protectedResourceLoader = Ref { resourceLoader }, trackingParameters, shouldClearReferrerOnHTTPSToHTTPRedirect, resource](const ResourceRequest& request) {
- scheduleLoadFromNetworkProcess(protectedResourceLoader, request, trackingParameters, shouldClearReferrerOnHTTPSToHTTPRedirect, maximumBufferingTime(resource));
- });
- return;
- }
-#endif
- scheduleLoadFromNetworkProcess(resourceLoader, resourceLoader.request(), trackingParameters, shouldClearReferrerOnHTTPSToHTTPRedirect, maximumBufferingTime(resource));
+ if (InspectorInstrumentationWebKit::shouldInterceptRequest(resourceLoader)) {
+ InspectorInstrumentationWebKit::interceptRequest(resourceLoader, [this, protectedResourceLoader = Ref { resourceLoader }, trackingParameters, shouldClearReferrerOnHTTPSToHTTPRedirect, resource](const ResourceRequest& request) {
+ auto& resourceLoader = protectedResourceLoader.get();
+ WEBLOADERSTRATEGY_RELEASE_LOG("scheduleLoad: intercepted URL will be scheduled with the NetworkProcess");
+ scheduleLoadFromNetworkProcess(resourceLoader, request, trackingParameters, shouldClearReferrerOnHTTPSToHTTPRedirect, maximumBufferingTime(resource));
+ });
return;
}
+
+ WEBLOADERSTRATEGY_RELEASE_LOG("scheduleLoad: URL will be scheduled with the NetworkProcess");
+ scheduleLoadFromNetworkProcess(resourceLoader, resourceLoader.request(), trackingParameters, shouldClearReferrerOnHTTPSToHTTPRedirect, maximumBufferingTime(resource));
}
bool WebLoaderStrategy::tryLoadingUsingURLSchemeHandler(ResourceLoader& resourceLoader, const WebResourceLoader::TrackingParameters& trackingParameters)