Diff
Modified: trunk/Source/WebCore/ChangeLog (261717 => 261718)
--- trunk/Source/WebCore/ChangeLog 2020-05-14 22:45:38 UTC (rev 261717)
+++ trunk/Source/WebCore/ChangeLog 2020-05-14 23:11:52 UTC (rev 261718)
@@ -1,3 +1,23 @@
+2020-05-14 Timothy Hatcher <timo...@apple.com>
+
+ Add sourceURL to _evaluateJavaScript: so the scripts appear in Web Inspector.
+ https://bugs.webkit.org/show_bug.cgi?id=211904
+ rdar://problem/62074376
+
+ Reviewed by Devin Rousso.
+
+ Added sourceURL to RunJavaScriptParameters. Use it instead of the frame's document URL.
+
+ * bindings/js/RunJavaScriptParameters.h:
+ (WebCore::RunJavaScriptParameters::RunJavaScriptParameters):
+ (WebCore::RunJavaScriptParameters::encode const):
+ (WebCore::RunJavaScriptParameters::decode):
+ * bindings/js/ScriptController.cpp:
+ (WebCore::ScriptController::executeScriptInWorldIgnoringException):
+ (WebCore::ScriptController::executeScriptInWorld):
+ (WebCore::ScriptController::callInWorld):
+ (WebCore::ScriptController::executeUserAgentScriptInWorld):
+
2020-05-14 Eric Carlson <eric.carl...@apple.com>
[Cocoa] Don't clear NowPlaying state unless it was set
Modified: trunk/Source/WebCore/bindings/js/RunJavaScriptParameters.h (261717 => 261718)
--- trunk/Source/WebCore/bindings/js/RunJavaScriptParameters.h 2020-05-14 22:45:38 UTC (rev 261717)
+++ trunk/Source/WebCore/bindings/js/RunJavaScriptParameters.h 2020-05-14 23:11:52 UTC (rev 261718)
@@ -26,6 +26,7 @@
#pragma once
#include <wtf/HashMap.h>
+#include <wtf/URL.h>
#include <wtf/Vector.h>
#include <wtf/text/WTFString.h>
@@ -37,8 +38,9 @@
using ArgumentWireBytesMap = HashMap<String, Vector<uint8_t>>;
struct RunJavaScriptParameters {
- RunJavaScriptParameters(String&& source, RunAsAsyncFunction runAsAsyncFunction, Optional<ArgumentWireBytesMap>&& arguments, ForceUserGesture forceUserGesture)
+ RunJavaScriptParameters(String&& source, URL&& sourceURL, RunAsAsyncFunction runAsAsyncFunction, Optional<ArgumentWireBytesMap>&& arguments, ForceUserGesture forceUserGesture)
: source(WTFMove(source))
+ , sourceURL(WTFMove(sourceURL))
, runAsAsyncFunction(runAsAsyncFunction)
, arguments(WTFMove(arguments))
, forceUserGesture(forceUserGesture)
@@ -45,8 +47,9 @@
{
}
- RunJavaScriptParameters(const String& source, bool runAsAsyncFunction, Optional<ArgumentWireBytesMap>&& arguments, bool forceUserGesture)
+ RunJavaScriptParameters(const String& source, URL&& sourceURL, bool runAsAsyncFunction, Optional<ArgumentWireBytesMap>&& arguments, bool forceUserGesture)
: source(source)
+ , sourceURL(WTFMove(sourceURL))
, runAsAsyncFunction(runAsAsyncFunction ? RunAsAsyncFunction::Yes : RunAsAsyncFunction::No)
, arguments(WTFMove(arguments))
, forceUserGesture(forceUserGesture ? ForceUserGesture::Yes : ForceUserGesture::No)
@@ -53,8 +56,9 @@
{
}
- RunJavaScriptParameters(String&& source, bool runAsAsyncFunction, Optional<ArgumentWireBytesMap>&& arguments, bool forceUserGesture)
+ RunJavaScriptParameters(String&& source, URL&& sourceURL, bool runAsAsyncFunction, Optional<ArgumentWireBytesMap>&& arguments, bool forceUserGesture)
: source(WTFMove(source))
+ , sourceURL(WTFMove(sourceURL))
, runAsAsyncFunction(runAsAsyncFunction ? RunAsAsyncFunction::Yes : RunAsAsyncFunction::No)
, arguments(WTFMove(arguments))
, forceUserGesture(forceUserGesture ? ForceUserGesture::Yes : ForceUserGesture::No)
@@ -62,6 +66,7 @@
}
String source;
+ URL sourceURL;
RunAsAsyncFunction runAsAsyncFunction;
Optional<ArgumentWireBytesMap> arguments;
ForceUserGesture forceUserGesture;
@@ -68,7 +73,7 @@
template<typename Encoder> void encode(Encoder& encoder) const
{
- encoder << source << runAsAsyncFunction << arguments << forceUserGesture;
+ encoder << source << sourceURL << runAsAsyncFunction << arguments << forceUserGesture;
}
template<typename Decoder> static Optional<RunJavaScriptParameters> decode(Decoder& decoder)
@@ -77,6 +82,10 @@
if (!decoder.decode(source))
return WTF::nullopt;
+ URL sourceURL;
+ if (!decoder.decode(sourceURL))
+ return WTF::nullopt;
+
RunAsAsyncFunction runAsAsyncFunction;
if (!decoder.decode(runAsAsyncFunction))
return WTF::nullopt;
@@ -89,7 +98,7 @@
if (!decoder.decode(forceUserGesture))
return WTF::nullopt;
- return { RunJavaScriptParameters { WTFMove(source), runAsAsyncFunction, WTFMove(arguments), forceUserGesture } };
+ return { RunJavaScriptParameters { WTFMove(source), WTFMove(sourceURL), runAsAsyncFunction, WTFMove(arguments), forceUserGesture } };
}
};
Modified: trunk/Source/WebCore/bindings/js/ScriptController.cpp (261717 => 261718)
--- trunk/Source/WebCore/bindings/js/ScriptController.cpp 2020-05-14 22:45:38 UTC (rev 261717)
+++ trunk/Source/WebCore/bindings/js/ScriptController.cpp 2020-05-14 23:11:52 UTC (rev 261718)
@@ -573,7 +573,7 @@
JSC::JSValue ScriptController::executeScriptInWorldIgnoringException(DOMWrapperWorld& world, const String& script, bool forceUserGesture)
{
- auto result = executeScriptInWorld(world, RunJavaScriptParameters { script, false, WTF::nullopt, forceUserGesture });
+ auto result = executeScriptInWorld(world, { script, URL { }, false, WTF::nullopt, forceUserGesture });
return result ? result.value() : JSC::JSValue { };
}
@@ -592,11 +592,15 @@
if (!canExecuteScripts(AboutToExecuteScript) || isPaused())
return makeUnexpected(ExceptionDetails { "Cannot execute _javascript_ in this document"_s });
+ auto sourceURL = parameters.sourceURL;
+ if (!sourceURL.isValid()) {
+ // FIXME: This is gross, but when setTimeout() and setInterval() are passed JS strings, the thrown errors should use the frame document URL (according to WPT).
+ sourceURL = m_frame.document()->url();
+ }
+
switch (parameters.runAsAsyncFunction) {
- case RunAsAsyncFunction::No: {
- ScriptSourceCode sourceCode(parameters.source, URL(m_frame.document()->url()), TextPosition(), JSC::SourceProviderSourceType::Program, CachedScriptFetcher::create(m_frame.document()->charset()));
- return evaluateInWorld(sourceCode, world);
- }
+ case RunAsAsyncFunction::No:
+ return evaluateInWorld({ parameters.source, WTFMove(sourceURL), TextPosition(), JSC::SourceProviderSourceType::Program, CachedScriptFetcher::create(m_frame.document()->charset()) }, world);
case RunAsAsyncFunction::Yes:
return callInWorld(WTFMove(parameters), world);
default:
@@ -640,7 +644,7 @@
functionStringBuilder.append("){", parameters.source, "})");
- auto sourceCode = ScriptSourceCode { functionStringBuilder.toString(), URL(m_frame.document()->url()), TextPosition(), JSC::SourceProviderSourceType::Program, CachedScriptFetcher::create(m_frame.document()->charset()) };
+ auto sourceCode = ScriptSourceCode { functionStringBuilder.toString(), WTFMove(parameters.sourceURL), TextPosition(), JSC::SourceProviderSourceType::Program, CachedScriptFetcher::create(m_frame.document()->charset()) };
const auto& jsSourceCode = sourceCode.jsSourceCode();
String sourceURL = jsSourceCode.provider()->url().string();
@@ -698,7 +702,7 @@
}
ValueOrException ScriptController::executeUserAgentScriptInWorld(DOMWrapperWorld& world, const String& script, bool forceUserGesture)
{
- return executeUserAgentScriptInWorldInternal(world, { script, false, WTF::nullopt, forceUserGesture });
+ return executeUserAgentScriptInWorldInternal(world, { script, URL { }, false, WTF::nullopt, forceUserGesture });
}
ValueOrException ScriptController::executeUserAgentScriptInWorldInternal(DOMWrapperWorld& world, RunJavaScriptParameters&& parameters)
Modified: trunk/Source/WebKit/ChangeLog (261717 => 261718)
--- trunk/Source/WebKit/ChangeLog 2020-05-14 22:45:38 UTC (rev 261717)
+++ trunk/Source/WebKit/ChangeLog 2020-05-14 23:11:52 UTC (rev 261718)
@@ -1,3 +1,35 @@
+2020-05-14 Timothy Hatcher <timo...@apple.com>
+
+ Add sourceURL to _evaluateJavaScript: so the scripts appear in Web Inspector.
+ https://bugs.webkit.org/show_bug.cgi?id=211904
+ rdar://problem/62074376
+
+ Reviewed by Devin Rousso.
+
+ Added sourceURL version of _evaluateJavaScript: that passes the sourceURL to RunJavaScriptParameters.
+ If the sourceURL is invalid, generate a unique user script URL so the source code errors are not showing
+ up with the frame's document URL and bogus locations.
+
+ * UIProcess/API/C/WKPage.cpp:
+ (WKPageRunJavaScriptInMainFrame): pass API::UserScript::generateUniqueURL() for the sourceURL.
+ * UIProcess/API/Cocoa/WKUserScript.mm:
+ (-[WKUserScript initWithSource:injectionTime:forMainFrameOnly:]): Clean up WebCore::UserScript initializer.
+ (-[WKUserScript _initWithSource:injectionTime:forMainFrameOnly:legacyWhitelist:legacyBlacklist:userContentWorld:]): Ditto.
+ (-[WKUserScript _initWithSource:injectionTime:forMainFrameOnly:legacyWhitelist:legacyBlacklist:associatedURL:userContentWorld:]): Ditto.
+ (-[WKUserScript _initWithSource:injectionTime:forMainFrameOnly:legacyWhitelist:legacyBlacklist:contentWorld:]): Ditto.
+ (-[WKUserScript _initWithSource:injectionTime:forMainFrameOnly:legacyWhitelist:legacyBlacklist:associatedURL:contentWorld:]): Ditto.
+ (-[WKUserScript _initWithSource:injectionTime:forMainFrameOnly:legacyWhitelist:legacyBlacklist:associatedURL:contentWorld:deferRunningUntilNotification:]): Ditto.
+ * UIProcess/API/Cocoa/WKWebView.mm:
+ (-[WKWebView _evaluateJavaScript:asAsyncFunction:withArguments:forceUserGesture:inFrame:inWorld:completionHandler:]): Renamed to add sourceURL.
+ (-[WKWebView _evaluateJavaScript:asAsyncFunction:withSourceURL:withArguments:forceUserGesture:inFrame:inWorld:completionHandler:]): Added sourceURL.
+ (-[WKWebView _evaluateJavaScript:withSourceURL:inFrame:inContentWorld:completionHandler:]): Added. Pass sourceURL through.
+ (-[WKWebView evaluateJavaScript:completionHandler:]): Call new method with sourceURL as nil.
+ (-[WKWebView evaluateJavaScript:inContentWorld:completionHandler:]): Ditto.
+ (-[WKWebView callAsyncJavaScript:arguments:inContentWorld:completionHandler:]): Ditto.
+ (-[WKWebView _callAsyncJavaScript:arguments:inFrame:inContentWorld:completionHandler:]): Ditto.
+ (-[WKWebView _evaluateJavaScript:inFrame:inContentWorld:completionHandler:]): Ditto.
+ * UIProcess/API/Cocoa/WKWebViewPrivate.h:
+
2020-05-14 Chris Dumez <cdu...@apple.com>
WebsiteDataStore functions should only send IPC to WebProcesses that are associated with its session
Modified: trunk/Source/WebKit/UIProcess/API/C/WKPage.cpp (261717 => 261718)
--- trunk/Source/WebKit/UIProcess/API/C/WKPage.cpp 2020-05-14 22:45:38 UTC (rev 261717)
+++ trunk/Source/WebKit/UIProcess/API/C/WKPage.cpp 2020-05-14 23:11:52 UTC (rev 261718)
@@ -2495,7 +2495,7 @@
void WKPageRunJavaScriptInMainFrame(WKPageRef pageRef, WKStringRef scriptRef, void* context, WKPageRunJavaScriptFunction callback)
{
- toImpl(pageRef)->runJavaScriptInMainFrame({ toImpl(scriptRef)->string(), false, WTF::nullopt, true }, [context, callback](API::SerializedScriptValue* returnValue, Optional<WebCore::ExceptionDetails>, CallbackBase::Error error) {
+ toImpl(pageRef)->runJavaScriptInMainFrame({ toImpl(scriptRef)->string(), URL { }, false, WTF::nullopt, true }, [context, callback](API::SerializedScriptValue* returnValue, Optional<WebCore::ExceptionDetails>, CallbackBase::Error error) {
callback(toAPI(returnValue), (error != CallbackBase::Error::None) ? toAPI(API::Error::create().ptr()) : 0, context);
});
}
Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKUserScript.mm (261717 => 261718)
--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKUserScript.mm 2020-05-14 22:45:38 UTC (rev 261717)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKUserScript.mm 2020-05-14 23:11:52 UTC (rev 261718)
@@ -36,7 +36,7 @@
if (!(self = [super init]))
return nil;
- API::Object::constructInWrapper<API::UserScript>(self, WebCore::UserScript { WTF::String(source), API::UserScript::generateUniqueURL(), { }, { }, API::toWebCoreUserScriptInjectionTime(injectionTime), forMainFrameOnly ? WebCore::UserContentInjectedFrames::InjectInTopFrameOnly : WebCore::UserContentInjectedFrames::InjectInAllFrames, WebCore::WaitForNotificationBeforeInjecting::No }, API::ContentWorld::pageContentWorld());
+ API::Object::constructInWrapper<API::UserScript>(self, WebCore::UserScript { source, API::UserScript::generateUniqueURL(), { }, { }, API::toWebCoreUserScriptInjectionTime(injectionTime), forMainFrameOnly ? WebCore::UserContentInjectedFrames::InjectInTopFrameOnly : WebCore::UserContentInjectedFrames::InjectInAllFrames, WebCore::WaitForNotificationBeforeInjecting::No }, API::ContentWorld::pageContentWorld());
return self;
}
@@ -85,7 +85,7 @@
if (!(self = [super init]))
return nil;
- API::Object::constructInWrapper<API::UserScript>(self, WebCore::UserScript { WTF::String(source), API::UserScript::generateUniqueURL(), makeVector<String>(legacyWhitelist), makeVector<String>(legacyBlacklist), API::toWebCoreUserScriptInjectionTime(injectionTime), forMainFrameOnly ? WebCore::UserContentInjectedFrames::InjectInTopFrameOnly : WebCore::UserContentInjectedFrames::InjectInAllFrames, WebCore::WaitForNotificationBeforeInjecting::No }, *userContentWorld->_contentWorld->_contentWorld);
+ API::Object::constructInWrapper<API::UserScript>(self, WebCore::UserScript { source, API::UserScript::generateUniqueURL(), makeVector<String>(legacyWhitelist), makeVector<String>(legacyBlacklist), API::toWebCoreUserScriptInjectionTime(injectionTime), forMainFrameOnly ? WebCore::UserContentInjectedFrames::InjectInTopFrameOnly : WebCore::UserContentInjectedFrames::InjectInAllFrames, WebCore::WaitForNotificationBeforeInjecting::No }, *userContentWorld->_contentWorld->_contentWorld);
return self;
}
@@ -95,7 +95,7 @@
if (!(self = [super init]))
return nil;
- API::Object::constructInWrapper<API::UserScript>(self, WebCore::UserScript { WTF::String(source), URL(associatedURL), makeVector<String>(legacyWhitelist), makeVector<String>(legacyBlacklist), API::toWebCoreUserScriptInjectionTime(injectionTime), forMainFrameOnly ? WebCore::UserContentInjectedFrames::InjectInTopFrameOnly : WebCore::UserContentInjectedFrames::InjectInAllFrames, WebCore::WaitForNotificationBeforeInjecting::No }, *userContentWorld->_contentWorld->_contentWorld);
+ API::Object::constructInWrapper<API::UserScript>(self, WebCore::UserScript { source, associatedURL, makeVector<String>(legacyWhitelist), makeVector<String>(legacyBlacklist), API::toWebCoreUserScriptInjectionTime(injectionTime), forMainFrameOnly ? WebCore::UserContentInjectedFrames::InjectInTopFrameOnly : WebCore::UserContentInjectedFrames::InjectInAllFrames, WebCore::WaitForNotificationBeforeInjecting::No }, *userContentWorld->_contentWorld->_contentWorld);
return self;
}
@@ -111,7 +111,7 @@
if (!(self = [super init]))
return nil;
- API::Object::constructInWrapper<API::UserScript>(self, WebCore::UserScript { WTF::String(source), API::UserScript::generateUniqueURL(), makeVector<String>(legacyWhitelist), makeVector<String>(legacyBlacklist), API::toWebCoreUserScriptInjectionTime(injectionTime), forMainFrameOnly ? WebCore::UserContentInjectedFrames::InjectInTopFrameOnly : WebCore::UserContentInjectedFrames::InjectInAllFrames, WebCore::WaitForNotificationBeforeInjecting::No }, *contentWorld->_contentWorld);
+ API::Object::constructInWrapper<API::UserScript>(self, WebCore::UserScript { source, API::UserScript::generateUniqueURL(), makeVector<String>(legacyWhitelist), makeVector<String>(legacyBlacklist), API::toWebCoreUserScriptInjectionTime(injectionTime), forMainFrameOnly ? WebCore::UserContentInjectedFrames::InjectInTopFrameOnly : WebCore::UserContentInjectedFrames::InjectInAllFrames, WebCore::WaitForNotificationBeforeInjecting::No }, *contentWorld->_contentWorld);
return self;
}
@@ -121,7 +121,7 @@
if (!(self = [super init]))
return nil;
- API::Object::constructInWrapper<API::UserScript>(self, WebCore::UserScript { WTF::String(source), URL(associatedURL), makeVector<String>(legacyWhitelist), makeVector<String>(legacyBlacklist), API::toWebCoreUserScriptInjectionTime(injectionTime), forMainFrameOnly ? WebCore::UserContentInjectedFrames::InjectInTopFrameOnly : WebCore::UserContentInjectedFrames::InjectInAllFrames, WebCore::WaitForNotificationBeforeInjecting::No }, *contentWorld->_contentWorld);
+ API::Object::constructInWrapper<API::UserScript>(self, WebCore::UserScript { source, associatedURL, makeVector<String>(legacyWhitelist), makeVector<String>(legacyBlacklist), API::toWebCoreUserScriptInjectionTime(injectionTime), forMainFrameOnly ? WebCore::UserContentInjectedFrames::InjectInTopFrameOnly : WebCore::UserContentInjectedFrames::InjectInAllFrames, WebCore::WaitForNotificationBeforeInjecting::No }, *contentWorld->_contentWorld);
return self;
}
@@ -131,7 +131,7 @@
if (!(self = [super init]))
return nil;
- API::Object::constructInWrapper<API::UserScript>(self, WebCore::UserScript { WTF::String(source), URL(associatedURL), makeVector<String>(legacyWhitelist), makeVector<String>(legacyBlacklist), API::toWebCoreUserScriptInjectionTime(injectionTime), forMainFrameOnly ? WebCore::UserContentInjectedFrames::InjectInTopFrameOnly : WebCore::UserContentInjectedFrames::InjectInAllFrames, deferRunningUntilNotification ? WebCore::WaitForNotificationBeforeInjecting::Yes : WebCore::WaitForNotificationBeforeInjecting::No }, *contentWorld->_contentWorld);
+ API::Object::constructInWrapper<API::UserScript>(self, WebCore::UserScript { source, associatedURL, makeVector<String>(legacyWhitelist), makeVector<String>(legacyBlacklist), API::toWebCoreUserScriptInjectionTime(injectionTime), forMainFrameOnly ? WebCore::UserContentInjectedFrames::InjectInTopFrameOnly : WebCore::UserContentInjectedFrames::InjectInAllFrames, deferRunningUntilNotification ? WebCore::WaitForNotificationBeforeInjecting::Yes : WebCore::WaitForNotificationBeforeInjecting::No }, *contentWorld->_contentWorld);
return self;
}
Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm (261717 => 261718)
--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm 2020-05-14 22:45:38 UTC (rev 261717)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm 2020-05-14 23:11:52 UTC (rev 261718)
@@ -816,17 +816,17 @@
- (void)evaluateJavaScript:(NSString *)_javascript_String completionHandler:(void (^)(id, NSError *))completionHandler
{
- [self _evaluateJavaScript:_javascript_String asAsyncFunction:NO withArguments:nil forceUserGesture:YES inFrame:nil inWorld:WKContentWorld.pageWorld completionHandler:completionHandler];
+ [self _evaluateJavaScript:_javascript_String asAsyncFunction:NO withSourceURL:nil withArguments:nil forceUserGesture:YES inFrame:nil inWorld:WKContentWorld.pageWorld completionHandler:completionHandler];
}
- (void)evaluateJavaScript:(NSString *)_javascript_String inContentWorld:(WKContentWorld *)contentWorld completionHandler:(void (^)(id, NSError *))completionHandler
{
- [self _evaluateJavaScript:_javascript_String asAsyncFunction:NO withArguments:nil forceUserGesture:YES inFrame:nil inWorld:contentWorld completionHandler:completionHandler];
+ [self _evaluateJavaScript:_javascript_String asAsyncFunction:NO withSourceURL:nil withArguments:nil forceUserGesture:YES inFrame:nil inWorld:contentWorld completionHandler:completionHandler];
}
- (void)callAsyncJavaScript:(NSString *)_javascript_String arguments:(NSDictionary<NSString *, id> *)arguments inContentWorld:(WKContentWorld *)contentWorld completionHandler:(void (^)(id, NSError *error))completionHandler
{
- [self _evaluateJavaScript:_javascript_String asAsyncFunction:YES withArguments:arguments forceUserGesture:YES inFrame:nil inWorld:contentWorld completionHandler:completionHandler];
+ [self _evaluateJavaScript:_javascript_String asAsyncFunction:YES withSourceURL:nil withArguments:arguments forceUserGesture:YES inFrame:nil inWorld:contentWorld completionHandler:completionHandler];
}
static bool validateArgument(id argument)
@@ -863,7 +863,7 @@
return false;
}
-- (void)_evaluateJavaScript:(NSString *)_javascript_String asAsyncFunction:(BOOL)asAsyncFunction withArguments:(NSDictionary<NSString *, id> *)arguments forceUserGesture:(BOOL)forceUserGesture inFrame:(WKFrameInfo *)frame inWorld:(WKContentWorld *)world completionHandler:(void (^)(id, NSError *))completionHandler
+- (void)_evaluateJavaScript:(NSString *)_javascript_String asAsyncFunction:(BOOL)asAsyncFunction withSourceURL:(NSURL *)sourceURL withArguments:(NSDictionary<NSString *, id> *)arguments forceUserGesture:(BOOL)forceUserGesture inFrame:(WKFrameInfo *)frame inWorld:(WKContentWorld *)world completionHandler:(void (^)(id, NSError *))completionHandler
{
auto handler = adoptNS([completionHandler copy]);
@@ -904,7 +904,7 @@
frameID = makeObjectIdentifier<WebCore::FrameIdentifierType>(identifier);
}
- _page->runJavaScriptInFrameInScriptWorld(WebCore::RunJavaScriptParameters { _javascript_String, !!asAsyncFunction, WTFMove(argumentsMap), !!forceUserGesture }, frameID, *world->_contentWorld.get(), [handler](API::SerializedScriptValue* serializedScriptValue, Optional<WebCore::ExceptionDetails> details, WebKit::ScriptValueCallback::Error errorCode) {
+ _page->runJavaScriptInFrameInScriptWorld({ _javascript_String, sourceURL, !!asAsyncFunction, WTFMove(argumentsMap), !!forceUserGesture }, frameID, *world->_contentWorld.get(), [handler](API::SerializedScriptValue* serializedScriptValue, Optional<WebCore::ExceptionDetails> details, WebKit::ScriptValueCallback::Error errorCode) {
if (!handler)
return;
@@ -2200,19 +2200,24 @@
- (void)_evaluateJavaScriptWithoutUserGesture:(NSString *)_javascript_String completionHandler:(void (^)(id, NSError *))completionHandler
{
- [self _evaluateJavaScript:_javascript_String asAsyncFunction:NO withArguments:nil forceUserGesture:NO inFrame:nil inWorld:WKContentWorld.pageWorld completionHandler:completionHandler];
+ [self _evaluateJavaScript:_javascript_String asAsyncFunction:NO withSourceURL:nil withArguments:nil forceUserGesture:NO inFrame:nil inWorld:WKContentWorld.pageWorld completionHandler:completionHandler];
}
- (void)_callAsyncJavaScript:(NSString *)functionBody arguments:(NSDictionary<NSString *, id> *)arguments inFrame:(WKFrameInfo *)frame inContentWorld:(WKContentWorld *)contentWorld completionHandler:(void (^)(id, NSError *error))completionHandler
{
- [self _evaluateJavaScript:functionBody asAsyncFunction:YES withArguments:arguments forceUserGesture:YES inFrame:frame inWorld:contentWorld completionHandler:completionHandler];
+ [self _evaluateJavaScript:functionBody asAsyncFunction:YES withSourceURL:nil withArguments:arguments forceUserGesture:YES inFrame:frame inWorld:contentWorld completionHandler:completionHandler];
}
- (void)_evaluateJavaScript:(NSString *)_javascript_String inFrame:(WKFrameInfo *)frame inContentWorld:(WKContentWorld *)contentWorld completionHandler:(void (^)(id, NSError *error))completionHandler
{
- [self _evaluateJavaScript:_javascript_String asAsyncFunction:NO withArguments:nil forceUserGesture:YES inFrame:frame inWorld:contentWorld completionHandler:completionHandler];
+ [self _evaluateJavaScript:_javascript_String asAsyncFunction:NO withSourceURL:nil withArguments:nil forceUserGesture:YES inFrame:frame inWorld:contentWorld completionHandler:completionHandler];
}
+- (void)_evaluateJavaScript:(NSString *)_javascript_String withSourceURL:(NSURL *)url inFrame:(WKFrameInfo *)frame inContentWorld:(WKContentWorld *)contentWorld completionHandler:(void (^)(id, NSError *error))completionHandler
+{
+ [self _evaluateJavaScript:_javascript_String asAsyncFunction:NO withSourceURL:url withArguments:nil forceUserGesture:YES inFrame:frame inWorld:contentWorld completionHandler:completionHandler];
+}
+
- (void)_updateWebsitePolicies:(_WKWebsitePolicies *)websitePolicies
{
}
Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewPrivate.h (261717 => 261718)
--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewPrivate.h 2020-05-14 22:45:38 UTC (rev 261717)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewPrivate.h 2020-05-14 23:11:52 UTC (rev 261718)
@@ -211,6 +211,7 @@
- (void)_evaluateJavaScriptWithoutUserGesture:(NSString *)_javascript_String completionHandler:(void (^)(id, NSError *))completionHandler WK_API_AVAILABLE(macos(10.13), ios(11.0));
- (void)_evaluateJavaScript:(NSString *)_javascript_String inFrame:(WKFrameInfo *)frame inContentWorld:(WKContentWorld *)contentWorld completionHandler:(void (^)(id, NSError * error))completionHandler WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA));
+- (void)_evaluateJavaScript:(NSString *)_javascript_String withSourceURL:(NSURL *)sourceURL inFrame:(WKFrameInfo *)frame inContentWorld:(WKContentWorld *)contentWorld completionHandler:(void (^)(id, NSError * error))completionHandler WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA));
- (void)_callAsyncJavaScript:(NSString *)functionBody arguments:(NSDictionary<NSString *, id> *)arguments inFrame:(WKFrameInfo *)frame inContentWorld:(WKContentWorld *)contentWorld completionHandler:(void (^)(id, NSError *error))completionHandler WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA));
@property (nonatomic, setter=_setLayoutMode:) _WKLayoutMode _layoutMode;
Modified: trunk/Source/WebKit/UIProcess/API/glib/WebKitWebView.cpp (261717 => 261718)
--- trunk/Source/WebKit/UIProcess/API/glib/WebKitWebView.cpp 2020-05-14 22:45:38 UTC (rev 261717)
+++ trunk/Source/WebKit/UIProcess/API/glib/WebKitWebView.cpp 2020-05-14 23:11:52 UTC (rev 261718)
@@ -3695,7 +3695,7 @@
g_return_if_fail(script);
GRefPtr<GTask> task = adoptGRef(g_task_new(webView, cancellable, callback, userData));
- getPage(webView).runJavaScriptInMainFrame({ String::fromUTF8(script), false, WTF::nullopt, true }, [task = WTFMove(task)](API::SerializedScriptValue* serializedScriptValue, Optional<ExceptionDetails> details, WebKit::CallbackBase::Error) {
+ getPage(webView).runJavaScriptInMainFrame({ String::fromUTF8(script), URL { }, false, WTF::nullopt, true }, [task = WTFMove(task)](API::SerializedScriptValue* serializedScriptValue, Optional<ExceptionDetails> details, WebKit::CallbackBase::Error) {
ExceptionDetails exceptionDetails;
if (details)
exceptionDetails = *details;
@@ -3797,7 +3797,7 @@
GRefPtr<GTask> task = adoptGRef(g_task_new(webView, cancellable, callback, userData));
auto world = API::ContentWorld::sharedWorldWithName(String::fromUTF8(worldName));
- getPage(webView).runJavaScriptInFrameInScriptWorld({ String::fromUTF8(script), false, WTF::nullopt, true }, WTF::nullopt, world.get(), [task = WTFMove(task)](API::SerializedScriptValue* serializedScriptValue, Optional<ExceptionDetails> details, WebKit::CallbackBase::Error) {
+ getPage(webView).runJavaScriptInFrameInScriptWorld({ String::fromUTF8(script), URL { }, false, WTF::nullopt, true }, WTF::nullopt, world.get(), [task = WTFMove(task)](API::SerializedScriptValue* serializedScriptValue, Optional<ExceptionDetails> details, WebKit::CallbackBase::Error) {
ExceptionDetails exceptionDetails;
if (details)
exceptionDetails = *details;
@@ -3839,7 +3839,7 @@
WebKitWebView* webView = WEBKIT_WEB_VIEW(g_task_get_source_object(task.get()));
gpointer outputStreamData = g_memory_output_stream_get_data(G_MEMORY_OUTPUT_STREAM(object));
- getPage(webView).runJavaScriptInMainFrame({ String::fromUTF8(reinterpret_cast<const gchar*>(outputStreamData)), false, WTF::nullopt, true},
+ getPage(webView).runJavaScriptInMainFrame({ String::fromUTF8(reinterpret_cast<const gchar*>(outputStreamData)), URL { }, false, WTF::nullopt, true },
[task](API::SerializedScriptValue* serializedScriptValue, Optional<ExceptionDetails> details, WebKit::CallbackBase::Error) {
ExceptionDetails exceptionDetails;
if (details)
Modified: trunk/Source/WebKit/UIProcess/Inspector/socket/RemoteInspectorProtocolHandler.cpp (261717 => 261718)
--- trunk/Source/WebKit/UIProcess/Inspector/socket/RemoteInspectorProtocolHandler.cpp 2020-05-14 22:45:38 UTC (rev 261717)
+++ trunk/Source/WebKit/UIProcess/Inspector/socket/RemoteInspectorProtocolHandler.cpp 2020-05-14 23:11:52 UTC (rev 261718)
@@ -118,7 +118,7 @@
void RemoteInspectorProtocolHandler::runScript(const String& script)
{
- m_page.runJavaScriptInMainFrame({ script, false, WTF::nullopt, false },
+ m_page.runJavaScriptInMainFrame({ script, URL { }, false, WTF::nullopt, false },
[](API::SerializedScriptValue*, Optional<WebCore::ExceptionDetails> exceptionDetails, CallbackBase::Error) {
if (exceptionDetails)
LOG_ERROR("Exception running script \"%s\"", exceptionDetails->message.utf8().data());