Skip to content

Commit 301d6b2

Browse files
committed
Web Inspector: associate WebAssembly module scripts with the resource that fetched it
https://bugs.webkit.org/show_bug.cgi?id=320249 Reviewed by Yusuke Suzuki. * Source/JavaScriptCore/wasm/WasmModuleInformation.h: * Source/JavaScriptCore/wasm/WasmStreamingCompiler.h: (JSC::Wasm::StreamingCompiler::create): (JSC::Wasm::StreamingCompiler::StreamingCompiler): * Source/JavaScriptCore/wasm/WasmStreamingCompiler.cpp: (JSC::Wasm::StreamingCompiler::StreamingCompiler): (JSC::Wasm::StreamingCompiler::create): * Source/JavaScriptCore/debugger/Debugger.h: * Source/JavaScriptCore/debugger/Debugger.cpp: (JSC::Debugger::sourceParsed): * Source/JavaScriptCore/inspector/protocol/Debugger.json: * Source/JavaScriptCore/inspector/agents/InspectorDebuggerAgent.h: * Source/JavaScriptCore/inspector/agents/InspectorDebuggerAgent.cpp: (Inspector::InspectorDebuggerAgent::requestIdForScript): Added. (Inspector::InspectorDebuggerAgent::didParseSource): * Source/WebCore/inspector/agents/WebDebuggerAgent.h: * Source/WebCore/inspector/agents/WebDebuggerAgent.cpp: (WebCore::WebDebuggerAgent::requestIdForScript): Added. * Source/WebInspectorUI/UserInterface/Protocol/DebuggerObserver.js: (WI.DebuggerObserver.prototype.scriptParsed): Keep the final response URL and request identifier in `ModuleInformation`, and format the protocol `requestId` in Inspector so that it can be process-qualified when site isolation is enabled. * Source/WebInspectorUI/UserInterface/Controllers/NetworkManager.js: (WI.NetworkManager.prototype.resourceRequestWillBeSent): Update assertions for redirects of resources associated with a `WI.Target`. * Source/WebInspectorUI/UserInterface/Controllers/DebuggerManager.js: (WI.DebuggerManager): (WI.DebuggerManager.prototype.scriptDidParse): (WI.DebuggerManager.prototype._tryAssociateScripts): Added. (WI.DebuggerManager.prototype._handleResourceAdded): Added. (WI.DebuggerManager.prototype._handleResourceChanged): Added. * Source/WebInspectorUI/UserInterface/Models/Resource.js: (WI.Resource.prototype.get displayName): (WI.Resource.prototype.associateWithScript): (WI.Resource.Event.ScriptAssociated): Added. * Source/WebInspectorUI/UserInterface/Models/Script.js: (WI.Script): (WI.Script.isWebAssembly): (WI.Script.prototype.get customName): Added. (WI.Script.prototype.tryAssociateWithResource): Added. (WI.Script.prototype._resolveResource): (WI.Script.prototype._resolveResource.hasMatchingScript): Added. (WI.Script.prototype._resolveResource.isMatchingResource): Added. (WI.Script.Event.ResourceChanged): Added. Expand how `WI.Script` are associated with a `WI.Resource`. * Source/WebInspectorUI/UserInterface/Views/ResourceTreeElement.js: (WI.ResourceTreeElement.prototype.get filterableData): (WI.ResourceTreeElement.prototype._updateResource): (WI.ResourceTreeElement.prototype.get mainTitleText): (WI.ResourceTreeElement.prototype._handleScriptAssociated): Added. * Source/WebInspectorUI/UserInterface/Views/OpenResourceDialog.js: (WI.OpenResourceDialog.prototype.didDismissDialog): (WI.OpenResourceDialog.prototype.didPresentDialog): (WI.OpenResourceDialog.prototype._handleScriptResourceChanged): Added. * Source/WebInspectorUI/UserInterface/Views/SearchSidebarPanel.js: (WI.SearchSidebarPanel.prototype._handleTreeSelectionDidChange): * Source/WebInspectorUI/UserInterface/Views/SourcesNavigationSidebarPanel.js: (WI.SourcesNavigationSidebarPanel): (WI.SourcesNavigationSidebarPanel.prototype.closed): (WI.SourcesNavigationSidebarPanel.prototype.treeElementForRepresentedObject): (WI.SourcesNavigationSidebarPanel.prototype.treeElementForRepresentedObject.isAncestor): (WI.SourcesNavigationSidebarPanel.prototype.treeElementForRepresentedObject.getParent): (WI.SourcesNavigationSidebarPanel.prototype._removeScript): Added. (WI.SourcesNavigationSidebarPanel.prototype._handleScriptResourceChanged): Added. (WI.SourcesNavigationSidebarPanel.prototype._handleDebuggerScriptRemoved): * Source/WebInspectorUI/UserInterface/Views/WorkerTreeElement.js: (WI.WorkerTreeElement.prototype.descendantResourceTreeElementTypeDidChange): Added. (WI.WorkerTreeElement.prototype.descendantResourceTreeElementMainTitleDidChange): Added. Replace `WI.Script` with its associated `WI.Resource` wherever possible. * Source/WebInspectorUI/UserInterface/Views/GenericResourceContentView.js: (WI.GenericResourceContentView.prototype.contentAvailable): Added. * Source/WebInspectorUI/UserInterface/Views/ResourceClusterContentView.js: (WI.ResourceClusterContentView): (WI.ResourceClusterContentView.prototype._contentViewForResourceType): * Source/WebInspectorUI/UserInterface/Views/ScriptContentView.js: (WI.ScriptContentView.prototype._contentDidPopulate): Show a binary-content message for non-text resources that do not have a more specific preview. * Source/WebCore/Modules/fetch/FetchLoaderClient.h: (WebCore::FetchLoaderClient::didReceiveResponse): * Source/WebCore/Modules/fetch/FetchLoader.cpp: (WebCore::FetchLoader::didReceiveResponse): * Source/WebCore/Modules/fetch/FetchBodyOwner.h: (WebCore::FetchBodyOwner::BlobLoader::didReceiveResponse): * Source/WebCore/Modules/fetch/FetchBodyOwner.cpp: (WebCore::FetchBodyOwner::BlobLoader::didReceiveResponse): * Source/WebCore/Modules/fetch/FetchResponse.h: (WebCore::FetchResponse::resourceLoaderIdentifier const): Added. (WebCore::FetchResponse::Loader::didReceiveResponse): * Source/WebCore/Modules/fetch/FetchResponse.cpp: (WebCore::FetchResponse::clone): (WebCore::FetchResponse::Loader::didReceiveResponse): * Source/WebCore/loader/WorkerThreadableLoader.cpp: (WebCore::WorkerThreadableLoader::MainThreadBridge::didReceiveResponse): * Source/WebKit/WebProcess/Storage/WebServiceWorkerFetchTaskClient.h: (WebKit::WebServiceWorkerFetchTaskClient::BlobLoader::didReceiveResponse): * Source/WebKit/WebProcess/Inspector/FrameNetworkAgentProxy.cpp: (WebKit::FrameNetworkAgentProxy::willSendRequest): (WebKit::FrameNetworkAgentProxy::willSendRequestOfType): * Source/WebCore/bindings/js/JSDOMGlobalObject.cpp: (WebCore::handleResponseOnStreamingAction): Propagate the request identifier through cloning, `Worker`, `ServiceWorker`, etc.. * LayoutTests/http/tests/inspector/debugger/wasm/resources/named-module.py: Added. * LayoutTests/http/tests/inspector/debugger/wasm/resources/resource-worker.js: Added. * LayoutTests/http/tests/inspector/debugger/wasm/script-url.html: Added. * LayoutTests/http/tests/inspector/debugger/wasm/script-url-expected.txt: Added. * LayoutTests/http/tests/site-isolation/inspector/debugger/resources/wasm-frame.html: Added. * LayoutTests/http/tests/site-isolation/inspector/debugger/wasm-frame-placement.html: Added. * LayoutTests/http/tests/site-isolation/inspector/debugger/wasm-frame-placement-expected.txt: Added. * LayoutTests/inspector/model/frame-extra-scripts.html: * LayoutTests/inspector/model/frame-extra-scripts-expected.txt: * LayoutTests/inspector/model/script-resource-relationship.html: * LayoutTests/inspector/model/script-resource-relationship-expected.txt: Canonical link: https://commits.webkit.org/318207@main
1 parent 2fe096a commit 301d6b2

44 files changed

Lines changed: 1020 additions & 68 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/usr/bin/env python3
2+
3+
import base64
4+
import os
5+
import sys
6+
7+
module = base64.b64decode(
8+
'AGFzbQEAAAABBwFgAn9/AX8DAgEABQMBAAEHEAIDYWRkAAAGbWVtb3J5AgAKCQEHACAAIAFqCwAaBG5hbWUAExJlbWJlZGRlZC1uYW1lLndhc20='
9+
)
10+
11+
headers = b'Content-Type: application/wasm\r\n'
12+
if os.environ.get('QUERY_STRING') == 'memory-cache':
13+
headers += b'Cache-Control: max-age=3600\r\n'
14+
15+
sys.stdout.buffer.write(headers + b'\r\n' + module)
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
let wasmInstances = [];
2+
3+
addEventListener("message", async (event) => {
4+
try {
5+
let {instance} = await WebAssembly.instantiateStreaming(fetch(event.data));
6+
wasmInstances.push(instance);
7+
postMessage({result: "instantiated"});
8+
} catch (error) {
9+
postMessage({error: String(error)});
10+
}
11+
});
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
Tests that WebAssembly modules preserve URLs supplied by streaming fetches and the module loader.
2+
3+
4+
== Running test suite: WI.Script.URL.WebAssembly
5+
-- Running test case: WI.Script.URL.WebAssembly.Streaming
6+
PASS: Should preserve the WebAssembly module's real URL.
7+
PASS: Should not expose the resource URL as a `sourceURL` directive.
8+
PASS: Should use the WebAssembly module's name section as the display name.
9+
PASS: Should associate the WebAssembly script with a Resource.
10+
PASS: Should associate the WebAssembly script with the resource for the module URL.
11+
PASS: The associated Resource should use the WebAssembly module's name section as its display name.
12+
PASS: The Resource should be associated with the WebAssembly script.
13+
PASS: The associated Resource should be treated as a script.
14+
PASS: The WebAssembly script should belong to the main frame.
15+
PASS: The associated Resource should belong to the main frame.
16+
PASS: The resource-backed WebAssembly script should not be an extra script.
17+
18+
-- Running test case: WI.Script.URL.WebAssembly.StreamingResponseClone
19+
PASS: Should preserve the WebAssembly module's real URL.
20+
PASS: Should not expose the resource URL as a `sourceURL` directive.
21+
PASS: Should use the WebAssembly module's name section as the display name.
22+
PASS: Should associate the WebAssembly script with a Resource.
23+
PASS: Should associate the WebAssembly script with the resource for the module URL.
24+
PASS: The associated Resource should use the WebAssembly module's name section as its display name.
25+
PASS: The Resource should be associated with the WebAssembly script.
26+
PASS: The associated Resource should be treated as a script.
27+
PASS: The WebAssembly script should belong to the main frame.
28+
PASS: The associated Resource should belong to the main frame.
29+
PASS: The resource-backed WebAssembly script should not be an extra script.
30+
PASS: Only one WebAssembly script should associate with a cloned Response's Resource.
31+
PASS: The additional clone should remain visible as an extra script.
32+
33+
-- Running test case: WI.Script.URL.WebAssembly.ModuleLoader
34+
PASS: Should preserve the WebAssembly module's real URL.
35+
PASS: Should not expose the resource URL as a `sourceURL` directive.
36+
PASS: Should use the WebAssembly module's name section as the display name.
37+
PASS: Should associate the WebAssembly script with a Resource.
38+
PASS: Should associate the WebAssembly script with the resource for the module URL.
39+
PASS: The associated Resource should use the WebAssembly module's name section as its display name.
40+
PASS: The Resource should be associated with the WebAssembly script.
41+
PASS: The associated Resource should be treated as a script.
42+
PASS: The WebAssembly script should belong to the main frame.
43+
PASS: The associated Resource should belong to the main frame.
44+
PASS: The resource-backed WebAssembly script should not be an extra script.
45+
46+
-- Running test case: WI.Script.URL.WebAssembly.WorkerStreaming
47+
PASS: Should create a Worker target.
48+
PASS: The Worker's WebAssembly script should associate with a Resource.
49+
PASS: The associated Resource should belong to the Worker target.
50+
PASS: The Worker's associated Resource should not belong to a frame.
51+
PASS: The resource-backed WebAssembly script should not remain an extra script.
52+
53+
-- Running test case: WI.Script.URL.WebAssembly.RepeatedStreamingURL
54+
PASS: Should associate the repeated WebAssembly script with a Resource.
55+
PASS: Should preserve the repeated WebAssembly module's final response URL.
56+
PASS: Repeated loads of the same URL should associate with distinct Resources.
57+
PASS: Repeated loads of the same URL should preserve distinct request identifiers.
58+
59+
-- Running test case: WI.Script.URL.WebAssembly.MemoryCache
60+
PASS: Should associate the initial WebAssembly script with a Resource.
61+
PASS: Should associate the cached WebAssembly script with a Resource.
62+
PASS: The repeated load should use the memory cache.
63+
PASS: The cached WebAssembly script should use the newly-created Resource.
64+
PASS: The cached WebAssembly script should not remain an extra script.
65+
66+
-- Running test case: WI.Script.URL.WebAssembly.FetchedBytes
67+
PASS: The fetched bytes should have a Resource.
68+
PASS: The module should not associate after its fetch provenance is lost.
69+
PASS: The resource-less module should remain visible as an extra script.
70+
71+
-- Running test case: WI.Script.URL.WebAssembly.DirectBytes
72+
PASS: Should not associate the WebAssembly script with a Resource.
73+
PASS: The WebAssembly script should belong to the main frame.
74+
PASS: The resource-less WebAssembly script should be an extra script.
75+

0 commit comments

Comments
 (0)