New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add ability to mask URLs in Error.stack. #2021
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not thrilled with the way this uses “override” as a sort of verb/noun/adjective combinations, but the mechanism seems sound.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
r=me with one comment.
if (vm.clientData) { | ||
String overrideURL = vm.clientData->overrideSourceURL(*this, sourceURL); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you filter out http/https URLs to avoid calling a virtual function here?
Right now, only WebKit/WebCore is implementing this interface. And it will limit http
/https
. So I think we can first filter out them here. If we have any other motivations further not filtering these schemes in JavaScriptCore.framework, I think we can revisit and extend it later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you okay doing this (since I wanted to avoid passing the and making a URL
in JSC)?
if (vm.clientData && !sourceURL.startsWithIgnoringASCIICase("http"_s)) {
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need, URL.h
has a protocolIsInHTTPFamily
function which takes a StringView
, not a URL
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you do a follow-up patch to remove the explicit "http"_s
?
https://bugs.webkit.org/show_bug.cgi?id=242278 rdar://81991245 Reviewed by Darin Adler and Yusuke Suzuki. Have StackFrame's toString consult a new overrideSourceURL() method on VM::ClientData that is implemented in WebCore's JSVMClientData that uses the new maskedURLForBindingsIfNeeded() to mask certain URLs from the Error.stack string returned to JavaScript. * Source/JavaScriptCore/inspector/ScriptCallStackFactory.cpp: (Inspector::extractSourceInformationFromException): Pass vm to getLineColumnAndSource(). (Inspector::createScriptCallStackFromException): Pass vm to sourceURL(). * Source/JavaScriptCore/runtime/Error.cpp: (JSC::getLineColumnAndSource): Add vm parameter and pass it to sourceURL(). (JSC::addErrorInfo): Pass vm to getLineColumnAndSource(). * Source/JavaScriptCore/runtime/Error.h: * Source/JavaScriptCore/runtime/ErrorInstance.cpp: (JSC::ErrorInstance::computeErrorInfo): Pass vm to getLineColumnAndSource(). * Source/JavaScriptCore/runtime/StackFrame.cpp: (JSC::StackFrame::sourceURL const): Add vm parameter and call overrideSourceURL() on clientData. (JSC::StackFrame::functionName const): Add some newlines. (JSC::StackFrame::toString const): Pass vm to sourceURL(). * Source/JavaScriptCore/runtime/StackFrame.h: (JSC::StackFrame::codeBlock const): Added. * Source/JavaScriptCore/runtime/VM.h: (JSC::VM::ClientData::overrideSourceURL const): Added. * Source/WebCore/bindings/js/WebCoreJSClientData.cpp: (WebCore::JSVMClientData::overrideSourceURL const): Added. Use maskedURLForBindingsIfNeeded() to mask sourceURLs. * Source/WebCore/bindings/js/WebCoreJSClientData.h: * Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebViewConfiguration.mm: (TEST(WebKit, ConfigurationMaskedURLSchemes)): Added user script tests with Error.stack. Canonical link: https://commits.webkit.org/252253@main
8faa3e2
to
2aac2a8
Compare
Committed 252253@main (2aac2a8): https://commits.webkit.org/252253@main Reviewed commits have been landed. Closing PR #2021 and removing active labels. |
2aac2a8