Title: [292254] trunk
Revision
292254
Author
achristen...@apple.com
Date
2022-04-01 20:04:20 -0700 (Fri, 01 Apr 2022)

Log Message

WKBundlePageUIClient console message support should include source URL, column number, and console messages with arguments
https://bugs.webkit.org/show_bug.cgi?id=238032

Patch by Jeff Miller <je...@apple.com> on 2022-04-01
Reviewed by Alex Christensen.

Source/_javascript_Core:

Add a function to ScriptArguments to get a vector of argument strings. As we do in
ScriptArguments::getFirstArgumentAsString(), avoid triggering Proxy traps on a Proxy object when
generating the vector.

* inspector/ScriptArguments.cpp:
(Inspector::ScriptArguments::getArgumentAtIndexAsString const):
Refactored from getFirstArgumentAsString().
        
(Inspector::ScriptArguments::getFirstArgumentAsString const):
Use getArgumentAtIndexAsString().
        
(Inspector::ScriptArguments::getArgumentsAsStrings const):
* inspector/ScriptArguments.h:

Source/WebCore:

Add a new ChromeClient addMessageWithArgumentsToConsole() member function for adding a console
message that includes formatted arguments. I left the existing behavior of addMessageToConsole()
unchanged since layout tests expect to get the console message without these arguments.
        
New API test was added in TestWebKitAPI/Tests/WebKitCocoa/ConsoleMessageWithDetails.mm.

* loader/EmptyClients.h:
Added addMessageWithArgumentsToConsole().

* page/ChromeClient.h:
(WebCore::ChromeClient::addMessageWithArgumentsToConsole):
Added, subclasses can optionally override this.

* page/PageConsoleClient.cpp:
(WebCore::additionalArgumentsFromArgumentsVector):
Added, pulls out any additional arguments beyond the initial message.

(WebCore::PageConsoleClient::addMessage):
Create a Span of any message arguments and include it when calling the new
addMessageWithArgumentsToConsole() function.

(WebCore::PageConsoleClient::messageWithTypeAndLevel):
Ditto.

Source/WebKit:

Add a new ChromeClient addMessageWithArgumentsToConsole() member function for adding a console
message that includes formatted arguments. I left the existing behavior of addMessageToConsole()
unchanged since layout tests expect to get the console message without these arguments.

* Shared/API/APIArray.cpp:
(API::Array::createStringArray):
Added, creates an array from a Span.
        
* Shared/API/APIArray.h:
* WebProcess/InjectedBundle/API/APIInjectedBundlePageUIClient.h:
(API::InjectedBundle::PageUIClient::willAddMessageWithArgumentsToConsole):
Added.
        
* WebProcess/InjectedBundle/API/c/WKBundlePageUIClient.h:
Add WKBundlePageUIClientV5 with a new willAddMessageWithDetailsToConsole callback. This callback is
similar to the existing willAddMessageToConsole callback, but includes any message arguments, the
column number, and source URL.

* WebProcess/InjectedBundle/InjectedBundlePageUIClient.cpp:
(WebKit::InjectedBundlePageUIClient::willAddMessageWithArgumentsToConsole):
Added, invokes the new willAddMessageWithDetailsToConsole callback.

* WebProcess/InjectedBundle/InjectedBundlePageUIClient.h:
Add a new bundle page UI client version.

* WebProcess/WebCoreSupport/WebChromeClient.cpp:
(WebKit::WebChromeClient::addMessageWithArgumentsToConsole):
Added.

* WebProcess/WebCoreSupport/WebChromeClient.h:
Added addMessageWithArgumentsToConsole().

Tools:

Add a test for the new willAddMessageWithDetailsToConsole callback in WKBundlePageUIClient. This
includes a new WKWebProcessPlugIn subclass, BundlePageConsoleMessageWithDetails, that implements
this callback and formats the message and arguments into a single string which it sends to the UI
process.

* TestWebKitAPI/SourcesCocoa.txt:
* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* TestWebKitAPI/Tests/WebKitCocoa/BundlePageConsoleMessageWithDetails.mm: Added.
(willAddMessageWithDetailsToConsoleCallback):
(-[BundlePageConsoleMessageWithDetails webProcessPlugIn:didCreateBrowserContextController:]):
* TestWebKitAPI/Tests/WebKitCocoa/ConsoleMessageWithDetails.mm: Added.
(TestWebKitAPI::didReceivePageMessageFromInjectedBundle):
(TestWebKitAPI::setInjectedBundleClient):
(TestWebKitAPI::TEST):
* TestWebKitAPI/Tests/WebKitCocoa/console-message-with-details.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (292253 => 292254)


--- trunk/Source/_javascript_Core/ChangeLog	2022-04-02 02:14:07 UTC (rev 292253)
+++ trunk/Source/_javascript_Core/ChangeLog	2022-04-02 03:04:20 UTC (rev 292254)
@@ -1,3 +1,24 @@
+2022-04-01  Jeff Miller  <je...@apple.com>
+
+        WKBundlePageUIClient console message support should include source URL, column number, and console messages with arguments
+        https://bugs.webkit.org/show_bug.cgi?id=238032
+
+        Reviewed by Alex Christensen.
+
+        Add a function to ScriptArguments to get a vector of argument strings. As we do in
+        ScriptArguments::getFirstArgumentAsString(), avoid triggering Proxy traps on a Proxy object when
+        generating the vector.
+
+        * inspector/ScriptArguments.cpp:
+        (Inspector::ScriptArguments::getArgumentAtIndexAsString const):
+        Refactored from getFirstArgumentAsString().
+        
+        (Inspector::ScriptArguments::getFirstArgumentAsString const):
+        Use getArgumentAtIndexAsString().
+        
+        (Inspector::ScriptArguments::getArgumentsAsStrings const):
+        * inspector/ScriptArguments.h:
+
 2022-04-01  Diego Pino Garcia  <dp...@igalia.com>
 
         Unreviewed, fix non-unified build after r292191

Modified: trunk/Source/_javascript_Core/inspector/ScriptArguments.cpp (292253 => 292254)


--- trunk/Source/_javascript_Core/inspector/ScriptArguments.cpp	2022-04-02 02:14:07 UTC (rev 292253)
+++ trunk/Source/_javascript_Core/inspector/ScriptArguments.cpp	2022-04-02 03:04:20 UTC (rev 292254)
@@ -62,29 +62,49 @@
     return m_globalObject.get();
 }
 
-bool ScriptArguments::getFirstArgumentAsString(String& result) const
+std::optional<String> ScriptArguments::getArgumentAtIndexAsString(size_t argumentIndex) const
 {
-    if (!argumentCount())
-        return false;
+    if (argumentIndex >= argumentCount())
+        return std::nullopt;
 
     auto* globalObject = this->globalObject();
     if (!globalObject) {
         ASSERT_NOT_REACHED();
-        return false;
+        return std::nullopt;
     }
 
-    auto value = argumentAt(0);
-    if (JSC::jsDynamicCast<JSC::ProxyObject*>(globalObject->vm(), value)) {
-        result = "[object Proxy]"_s;
-        return true;
-    }
+    auto value = argumentAt(argumentIndex);
+    if (JSC::jsDynamicCast<JSC::ProxyObject*>(globalObject->vm(), value))
+        return "[object Proxy]"_s;
 
+    String result;
     auto scope = DECLARE_CATCH_SCOPE(globalObject->vm());
     result = value.toWTFString(globalObject);
     scope.clearException();
+    return result;
+}
+
+bool ScriptArguments::getFirstArgumentAsString(String& result) const
+{
+    auto argument = getArgumentAtIndexAsString(0);
+    if (!argument)
+        return false;
+
+    result = *argument;
     return true;
 }
 
+Vector<String> ScriptArguments::getArgumentsAsStrings() const
+{
+    Vector<String> result;
+    result.reserveInitialCapacity(argumentCount());
+    for (size_t i = 0; i < argumentCount(); ++i) {
+        if (auto currentArgumentString = getArgumentAtIndexAsString(i))
+            result.uncheckedAppend(WTFMove(*currentArgumentString));
+    }
+    return result;
+}
+
 bool ScriptArguments::isEqual(const ScriptArguments& other) const
 {
     auto size = m_arguments.size();

Modified: trunk/Source/_javascript_Core/inspector/ScriptArguments.h (292253 => 292254)


--- trunk/Source/_javascript_Core/inspector/ScriptArguments.h	2022-04-02 02:14:07 UTC (rev 292253)
+++ trunk/Source/_javascript_Core/inspector/ScriptArguments.h	2022-04-02 03:04:20 UTC (rev 292254)
@@ -54,6 +54,7 @@
     JSC::JSGlobalObject* globalObject() const;
 
     bool getFirstArgumentAsString(String& result) const;
+    Vector<String> getArgumentsAsStrings() const;
     bool isEqual(const ScriptArguments&) const;
 
     static String truncateStringForConsoleMessage(const String& message)
@@ -66,6 +67,7 @@
 
 private:
     ScriptArguments(JSC::JSGlobalObject*, Vector<JSC::Strong<JSC::Unknown>>&& arguments);
+    std::optional<String> getArgumentAtIndexAsString(size_t) const;
 
     JSC::Strong<JSC::JSGlobalObject> m_globalObject;
     Vector<JSC::Strong<JSC::Unknown>> m_arguments;

Modified: trunk/Source/WebCore/ChangeLog (292253 => 292254)


--- trunk/Source/WebCore/ChangeLog	2022-04-02 02:14:07 UTC (rev 292253)
+++ trunk/Source/WebCore/ChangeLog	2022-04-02 03:04:20 UTC (rev 292254)
@@ -1,3 +1,34 @@
+2022-04-01  Jeff Miller  <je...@apple.com>
+
+        WKBundlePageUIClient console message support should include source URL, column number, and console messages with arguments
+        https://bugs.webkit.org/show_bug.cgi?id=238032
+
+        Reviewed by Alex Christensen.
+
+        Add a new ChromeClient addMessageWithArgumentsToConsole() member function for adding a console
+        message that includes formatted arguments. I left the existing behavior of addMessageToConsole()
+        unchanged since layout tests expect to get the console message without these arguments.
+        
+        New API test was added in TestWebKitAPI/Tests/WebKitCocoa/ConsoleMessageWithDetails.mm.
+
+        * loader/EmptyClients.h:
+        Added addMessageWithArgumentsToConsole().
+
+        * page/ChromeClient.h:
+        (WebCore::ChromeClient::addMessageWithArgumentsToConsole):
+        Added, subclasses can optionally override this.
+
+        * page/PageConsoleClient.cpp:
+        (WebCore::additionalArgumentsFromArgumentsVector):
+        Added, pulls out any additional arguments beyond the initial message.
+
+        (WebCore::PageConsoleClient::addMessage):
+        Create a Span of any message arguments and include it when calling the new
+        addMessageWithArgumentsToConsole() function.
+
+        (WebCore::PageConsoleClient::messageWithTypeAndLevel):
+        Ditto.
+
 2022-04-01  Tim Horton  <timothy_hor...@apple.com>
 
         Fix the WebGPU-less build

Modified: trunk/Source/WebCore/loader/EmptyClients.h (292253 => 292254)


--- trunk/Source/WebCore/loader/EmptyClients.h	2022-04-02 02:14:07 UTC (rev 292253)
+++ trunk/Source/WebCore/loader/EmptyClients.h	2022-04-02 03:04:20 UTC (rev 292254)
@@ -83,6 +83,7 @@
     void setResizable(bool) final { }
 
     void addMessageToConsole(MessageSource, MessageLevel, const String&, unsigned, unsigned, const String&) final { }
+    void addMessageWithArgumentsToConsole(MessageSource, MessageLevel, const String&, Span<const String>, unsigned, unsigned, const String&) final { }
 
     bool canRunBeforeUnloadConfirmPanel() final { return false; }
     bool runBeforeUnloadConfirmPanel(const String&, Frame&) final { return true; }

Modified: trunk/Source/WebCore/page/ChromeClient.h (292253 => 292254)


--- trunk/Source/WebCore/page/ChromeClient.h	2022-04-02 02:14:07 UTC (rev 292253)
+++ trunk/Source/WebCore/page/ChromeClient.h	2022-04-02 03:04:20 UTC (rev 292254)
@@ -193,6 +193,7 @@
     virtual void setResizable(bool) = 0;
 
     virtual void addMessageToConsole(MessageSource, MessageLevel, const String& message, unsigned lineNumber, unsigned columnNumber, const String& sourceID) = 0;
+    virtual void addMessageWithArgumentsToConsole(MessageSource, MessageLevel, const String& message, Span<const String> messageArguments, unsigned lineNumber, unsigned columnNumber, const String& sourceID) { UNUSED_PARAM(message); UNUSED_PARAM(messageArguments); UNUSED_PARAM(lineNumber); UNUSED_PARAM(columnNumber); UNUSED_PARAM(sourceID); }
 
     virtual bool canRunBeforeUnloadConfirmPanel() = 0;
     virtual bool runBeforeUnloadConfirmPanel(const String& message, Frame&) = 0;

Modified: trunk/Source/WebCore/page/PageConsoleClient.cpp (292253 => 292254)


--- trunk/Source/WebCore/page/PageConsoleClient.cpp	2022-04-02 02:14:07 UTC (rev 292253)
+++ trunk/Source/WebCore/page/PageConsoleClient.cpp	2022-04-02 03:04:20 UTC (rev 292254)
@@ -121,12 +121,20 @@
 {
     if (!m_page.usesEphemeralSession()) {
         String message;
+        Span<const String> additionalArguments;
+        Vector<String> messageArgumentsVector;
         if (consoleMessage->type() == MessageType::Image) {
             ASSERT(consoleMessage->arguments());
-            consoleMessage->arguments()->getFirstArgumentAsString(message);
+            messageArgumentsVector = consoleMessage->arguments()->getArgumentsAsStrings();
+            if (!messageArgumentsVector.isEmpty()) {
+                message = messageArgumentsVector.first();
+                additionalArguments = messageArgumentsVector.span().subspan(1);
+            }
         } else
             message = consoleMessage->message();
+
         m_page.chrome().client().addMessageToConsole(consoleMessage->source(), consoleMessage->level(), message, consoleMessage->line(), consoleMessage->column(), consoleMessage->url());
+        m_page.chrome().client().addMessageWithArgumentsToConsole(consoleMessage->source(), consoleMessage->level(), message, additionalArguments, consoleMessage->line(), consoleMessage->column(), consoleMessage->url());
 
         if (UNLIKELY(m_page.settings().logsPageMessagesToSystemConsoleEnabled() || shouldPrintExceptions())) {
             if (consoleMessage->type() == MessageType::Image) {
@@ -171,11 +179,15 @@
     addMessage(WTFMove(message));
 }
 
-
 void PageConsoleClient::messageWithTypeAndLevel(MessageType type, MessageLevel level, JSC::JSGlobalObject* lexicalGlobalObject, Ref<Inspector::ScriptArguments>&& arguments)
 {
     String messageText;
-    bool gotMessage = arguments->getFirstArgumentAsString(messageText);
+    Span<const String> additionalArguments;
+    Vector<String> messageArgumentsVector = arguments->getArgumentsAsStrings();
+    if (!messageArgumentsVector.isEmpty()) {
+        messageText = messageArgumentsVector.first();
+        additionalArguments = messageArgumentsVector.span().subspan(1);
+    }
 
     auto message = makeUnique<Inspector::ConsoleMessage>(MessageSource::ConsoleAPI, type, level, messageText, arguments.copyRef(), lexicalGlobalObject);
 
@@ -188,8 +200,10 @@
     if (m_page.usesEphemeralSession())
         return;
 
-    if (gotMessage)
+    if (!messageArgumentsVector.isEmpty()) {
         m_page.chrome().client().addMessageToConsole(MessageSource::ConsoleAPI, level, messageText, lineNumber, columnNumber, url);
+        m_page.chrome().client().addMessageWithArgumentsToConsole(MessageSource::ConsoleAPI, level, messageText, additionalArguments, lineNumber, columnNumber, url);
+    }
 
     if (m_page.settings().logsPageMessagesToSystemConsoleEnabled() || PageConsoleClient::shouldPrintExceptions())
         ConsoleClient::printConsoleMessageWithArguments(MessageSource::ConsoleAPI, type, level, lexicalGlobalObject, WTFMove(arguments));

Modified: trunk/Source/WebKit/ChangeLog (292253 => 292254)


--- trunk/Source/WebKit/ChangeLog	2022-04-02 02:14:07 UTC (rev 292253)
+++ trunk/Source/WebKit/ChangeLog	2022-04-02 03:04:20 UTC (rev 292254)
@@ -1,3 +1,42 @@
+2022-04-01  Jeff Miller  <je...@apple.com>
+
+        WKBundlePageUIClient console message support should include source URL, column number, and console messages with arguments
+        https://bugs.webkit.org/show_bug.cgi?id=238032
+
+        Reviewed by Alex Christensen.
+
+        Add a new ChromeClient addMessageWithArgumentsToConsole() member function for adding a console
+        message that includes formatted arguments. I left the existing behavior of addMessageToConsole()
+        unchanged since layout tests expect to get the console message without these arguments.
+
+        * Shared/API/APIArray.cpp:
+        (API::Array::createStringArray):
+        Added, creates an array from a Span.
+        
+        * Shared/API/APIArray.h:
+        * WebProcess/InjectedBundle/API/APIInjectedBundlePageUIClient.h:
+        (API::InjectedBundle::PageUIClient::willAddMessageWithArgumentsToConsole):
+        Added.
+        
+        * WebProcess/InjectedBundle/API/c/WKBundlePageUIClient.h:
+        Add WKBundlePageUIClientV5 with a new willAddMessageWithDetailsToConsole callback. This callback is
+        similar to the existing willAddMessageToConsole callback, but includes any message arguments, the
+        column number, and source URL.
+
+        * WebProcess/InjectedBundle/InjectedBundlePageUIClient.cpp:
+        (WebKit::InjectedBundlePageUIClient::willAddMessageWithArgumentsToConsole):
+        Added, invokes the new willAddMessageWithDetailsToConsole callback.
+
+        * WebProcess/InjectedBundle/InjectedBundlePageUIClient.h:
+        Add a new bundle page UI client version.
+
+        * WebProcess/WebCoreSupport/WebChromeClient.cpp:
+        (WebKit::WebChromeClient::addMessageWithArgumentsToConsole):
+        Added.
+
+        * WebProcess/WebCoreSupport/WebChromeClient.h:
+        Added addMessageWithArgumentsToConsole().
+
 2022-04-01  Wenson Hsieh  <wenson_hs...@apple.com>
 
         [iOS] [WK2] Add plumbing for extracting video frames in element fullscreen

Modified: trunk/Source/WebKit/Shared/API/APIArray.cpp (292253 => 292254)


--- trunk/Source/WebKit/Shared/API/APIArray.cpp	2022-04-02 02:14:07 UTC (rev 292253)
+++ trunk/Source/WebKit/Shared/API/APIArray.cpp	2022-04-02 03:04:20 UTC (rev 292254)
@@ -48,6 +48,13 @@
     return create(WTFMove(elements));
 }
 
+Ref<Array> Array::createStringArray(const Span<const WTF::String> strings)
+{
+    return create(WTF::map(strings, [] (auto string) -> RefPtr<Object> {
+        return API::String::create(string);
+    }));
+}
+
 Vector<WTF::String> Array::toStringVector()
 {
     Vector<WTF::String> patternsVector;

Modified: trunk/Source/WebKit/Shared/API/APIArray.h (292253 => 292254)


--- trunk/Source/WebKit/Shared/API/APIArray.h	2022-04-02 02:14:07 UTC (rev 292253)
+++ trunk/Source/WebKit/Shared/API/APIArray.h	2022-04-02 03:04:20 UTC (rev 292254)
@@ -53,6 +53,7 @@
     static Ref<Array> create();
     static Ref<Array> create(Vector<RefPtr<Object>>&&);
     static Ref<Array> createStringArray(const Vector<WTF::String>&);
+    static Ref<Array> createStringArray(const Span<const WTF::String>);
     Vector<WTF::String> toStringVector();
     Ref<Array> copy();
 

Modified: trunk/Source/WebKit/WebProcess/InjectedBundle/API/APIInjectedBundlePageUIClient.h (292253 => 292254)


--- trunk/Source/WebKit/WebProcess/InjectedBundle/API/APIInjectedBundlePageUIClient.h	2022-04-02 02:14:07 UTC (rev 292253)
+++ trunk/Source/WebKit/WebProcess/InjectedBundle/API/APIInjectedBundlePageUIClient.h	2022-04-02 03:04:20 UTC (rev 292254)
@@ -51,6 +51,7 @@
     virtual ~PageUIClient() { }
 
     virtual void willAddMessageToConsole(WebKit::WebPage*, JSC::MessageSource, JSC::MessageLevel, const WTF::String& message, unsigned lineNumber, unsigned columnNumber, const WTF::String& sourceID) { UNUSED_PARAM(message); UNUSED_PARAM(lineNumber); UNUSED_PARAM(columnNumber); UNUSED_PARAM(sourceID); }
+    virtual void willAddMessageWithArgumentsToConsole(WebKit::WebPage*, JSC::MessageSource, JSC::MessageLevel, const WTF::String& message, Span<const WTF::String> messageArguments, unsigned lineNumber, unsigned columnNumber, const WTF::String& sourceID) { UNUSED_PARAM(message); UNUSED_PARAM(messageArguments); UNUSED_PARAM(lineNumber); UNUSED_PARAM(columnNumber); UNUSED_PARAM(sourceID); }
     virtual void willSetStatusbarText(WebKit::WebPage*, const WTF::String&) { }
     virtual void willRunJavaScriptAlert(WebKit::WebPage*, const WTF::String&, WebKit::WebFrame*) { }
     virtual void willRunJavaScriptConfirm(WebKit::WebPage*, const WTF::String&, WebKit::WebFrame*) { }

Modified: trunk/Source/WebKit/WebProcess/InjectedBundle/API/c/WKBundlePageUIClient.h (292253 => 292254)


--- trunk/Source/WebKit/WebProcess/InjectedBundle/API/c/WKBundlePageUIClient.h	2022-04-02 02:14:07 UTC (rev 292253)
+++ trunk/Source/WebKit/WebProcess/InjectedBundle/API/c/WKBundlePageUIClient.h	2022-04-02 03:04:20 UTC (rev 292254)
@@ -55,6 +55,7 @@
 typedef WKStringRef (*WKBundlePagePlugInCreateExtraScriptCallback)(const void *clientInfo);
 typedef void (*WKBundlePageDidClickAutoFillButtonCallback)(WKBundlePageRef page, WKBundleNodeHandleRef inputElement, WKTypeRef* userData, const void *clientInfo);
 typedef void (*WKBundlePageDidResignInputElementStrongPasswordAppearance)(WKBundlePageRef page, WKBundleNodeHandleRef inputElement, WKTypeRef* userData, const void *clientInfo);
+typedef void (*WKBundlePageWillAddMessageWithDetailsToConsoleCallback)(WKBundlePageRef page, WKStringRef message, WKArrayRef messageArguments, uint32_t lineNumber, uint32_t columnNumber, WKStringRef sourceID, const void *clientInfo);
 
 typedef struct WKBundlePageUIClientBase {
     int                                                                 version;
@@ -210,3 +211,46 @@
     // Version 4.
     WKBundlePageDidResignInputElementStrongPasswordAppearance           didResignInputElementStrongPasswordAppearance;
 } WKBundlePageUIClientV4;
+
+typedef struct WKBundlePageUIClientV5 {
+    WKBundlePageUIClientBase                                            base;
+
+    // Version 0.
+    WKBundlePageWillAddMessageToConsoleCallback                         willAddMessageToConsole;
+    WKBundlePageWillSetStatusbarTextCallback                            willSetStatusbarText;
+    WKBundlePageWillRunJavaScriptAlertCallback                          willRunJavaScriptAlert;
+    WKBundlePageWillRunJavaScriptConfirmCallback                        willRunJavaScriptConfirm;
+    WKBundlePageWillRunJavaScriptPromptCallback                         willRunJavaScriptPrompt;
+    WKBundlePageMouseDidMoveOverElementCallback                         mouseDidMoveOverElement;
+    WKBundlePageDidScrollCallback                                       pageDidScroll;
+    void*                                                               unused1;
+    WKBundlePageGenerateFileForUploadCallback                           shouldGenerateFileForUpload;
+    WKBundlePageGenerateFileForUploadCallback                           generateFileForUpload;
+    void*                                                               unused2;
+    WKBundlePageStatusBarIsVisibleCallback                              statusBarIsVisible;
+    WKBundlePageMenuBarIsVisibleCallback                                menuBarIsVisible;
+    WKBundlePageToolbarsAreVisibleCallback                              toolbarsAreVisible;
+
+    // Version 1.
+    WKBundlePageReachedAppCacheOriginQuotaCallback                      didReachApplicationCacheOriginQuota;
+
+    // Version 2.
+    WKBundlePageExceededDatabaseQuotaCallback                           didExceedDatabaseQuota;
+    WKBundlePagePlugInCreateStartLabelTitleCallback                     createPlugInStartLabelTitle;
+    WKBundlePagePlugInCreateStartLabelSubtitleCallback                  createPlugInStartLabelSubtitle;
+    WKBundlePagePlugInCreateExtraStyleSheetCallback                     createPlugInExtraStyleSheet;
+    WKBundlePagePlugInCreateExtraScriptCallback                         createPlugInExtraScript;
+
+    // Version 3.
+    void*                                                               unused3;
+    void*                                                               unused4;
+    void*                                                               unused5;
+
+    WKBundlePageDidClickAutoFillButtonCallback                          didClickAutoFillButton;
+
+    // Version 4.
+    WKBundlePageDidResignInputElementStrongPasswordAppearance           didResignInputElementStrongPasswordAppearance;
+
+    // Version 5.
+    WKBundlePageWillAddMessageWithDetailsToConsoleCallback              willAddMessageWithDetailsToConsole;
+} WKBundlePageUIClientV5;

Modified: trunk/Source/WebKit/WebProcess/InjectedBundle/InjectedBundlePageUIClient.cpp (292253 => 292254)


--- trunk/Source/WebKit/WebProcess/InjectedBundle/InjectedBundlePageUIClient.cpp	2022-04-02 02:14:07 UTC (rev 292253)
+++ trunk/Source/WebKit/WebProcess/InjectedBundle/InjectedBundlePageUIClient.cpp	2022-04-02 03:04:20 UTC (rev 292254)
@@ -26,6 +26,7 @@
 #include "config.h"
 #include "InjectedBundlePageUIClient.h"
 
+#include "APIArray.h"
 #include "APISecurityOrigin.h"
 #include "InjectedBundleHitTestResult.h"
 #include "InjectedBundleNodeHandle.h"
@@ -49,6 +50,12 @@
         m_client.willAddMessageToConsole(toAPI(page), toAPI(message.impl()), lineNumber, m_client.base.clientInfo);
 }
 
+void InjectedBundlePageUIClient::willAddMessageWithArgumentsToConsole(WebPage* page, MessageSource, MessageLevel, const String& message, Span<const String> messageArguments, unsigned lineNumber, unsigned columnNumber, const String& sourceID)
+{
+    if (m_client.willAddMessageWithDetailsToConsole)
+        m_client.willAddMessageWithDetailsToConsole(toAPI(page), toAPI(message.impl()), toAPI(&API::Array::createStringArray(messageArguments).leakRef()), lineNumber, columnNumber, toAPI(sourceID.impl()), m_client.base.clientInfo);
+}
+
 void InjectedBundlePageUIClient::willSetStatusbarText(WebPage* page, const String& statusbarText)
 {
     if (m_client.willSetStatusbarText)

Modified: trunk/Source/WebKit/WebProcess/InjectedBundle/InjectedBundlePageUIClient.h (292253 => 292254)


--- trunk/Source/WebKit/WebProcess/InjectedBundle/InjectedBundlePageUIClient.h	2022-04-02 02:14:07 UTC (rev 292253)
+++ trunk/Source/WebKit/WebProcess/InjectedBundle/InjectedBundlePageUIClient.h	2022-04-02 03:04:20 UTC (rev 292254)
@@ -35,7 +35,7 @@
 class Object;
 
 template<> struct ClientTraits<WKBundlePageUIClientBase> {
-    typedef std::tuple<WKBundlePageUIClientV0, WKBundlePageUIClientV1, WKBundlePageUIClientV2, WKBundlePageUIClientV3, WKBundlePageUIClientV4> Versions;
+    typedef std::tuple<WKBundlePageUIClientV0, WKBundlePageUIClientV1, WKBundlePageUIClientV2, WKBundlePageUIClientV3, WKBundlePageUIClientV4, WKBundlePageUIClientV5> Versions;
 };
 }
 
@@ -46,6 +46,7 @@
     explicit InjectedBundlePageUIClient(const WKBundlePageUIClientBase*);
 
     void willAddMessageToConsole(WebPage*, MessageSource, MessageLevel, const String& message, unsigned lineNumber, unsigned columnNumber, const String& sourceID) override;
+    void willAddMessageWithArgumentsToConsole(WebPage*, MessageSource, MessageLevel, const String& message, Span<const String> messageArguments, unsigned lineNumber, unsigned columnNumber, const String& sourceID) override;
     void willSetStatusbarText(WebPage*, const String&) override;
     void willRunJavaScriptAlert(WebPage*, const String&, WebFrame*) override;
     void willRunJavaScriptConfirm(WebPage*, const String&, WebFrame*) override;

Modified: trunk/Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.cpp (292253 => 292254)


--- trunk/Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.cpp	2022-04-02 02:14:07 UTC (rev 292253)
+++ trunk/Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.cpp	2022-04-02 03:04:20 UTC (rev 292254)
@@ -421,6 +421,11 @@
     m_page.injectedBundleUIClient().willAddMessageToConsole(&m_page, source, level, message, lineNumber, columnNumber, sourceID);
 }
 
+void WebChromeClient::addMessageWithArgumentsToConsole(MessageSource source, MessageLevel level, const String& message, Span<const String> messageArguments, unsigned lineNumber, unsigned columnNumber, const String& sourceID)
+{
+    m_page.injectedBundleUIClient().willAddMessageWithArgumentsToConsole(&m_page, source, level, message, messageArguments, lineNumber, columnNumber, sourceID);
+}
+
 bool WebChromeClient::canRunBeforeUnloadConfirmPanel()
 {
     return m_page.canRunBeforeUnloadConfirmPanel();

Modified: trunk/Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.h (292253 => 292254)


--- trunk/Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.h	2022-04-02 02:14:07 UTC (rev 292253)
+++ trunk/Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.h	2022-04-02 03:04:20 UTC (rev 292254)
@@ -99,6 +99,7 @@
     void setResizable(bool) final;
     
     void addMessageToConsole(JSC::MessageSource, JSC::MessageLevel, const String& message, unsigned lineNumber, unsigned columnNumber, const String& sourceID) final;
+    void addMessageWithArgumentsToConsole(JSC::MessageSource, JSC::MessageLevel, const String& message, Span<const String> messageArguments, unsigned lineNumber, unsigned columnNumber, const String& sourceID) final;
     
     bool canRunBeforeUnloadConfirmPanel() final;
     bool runBeforeUnloadConfirmPanel(const String& message, WebCore::Frame&) final;

Modified: trunk/Tools/ChangeLog (292253 => 292254)


--- trunk/Tools/ChangeLog	2022-04-02 02:14:07 UTC (rev 292253)
+++ trunk/Tools/ChangeLog	2022-04-02 03:04:20 UTC (rev 292254)
@@ -1,3 +1,26 @@
+2022-04-01  Jeff Miller  <je...@apple.com>
+
+        WKBundlePageUIClient console message support should include source URL, column number, and console messages with arguments
+        https://bugs.webkit.org/show_bug.cgi?id=238032
+
+        Reviewed by Alex Christensen.
+
+        Add a test for the new willAddMessageWithDetailsToConsole callback in WKBundlePageUIClient. This
+        includes a new WKWebProcessPlugIn subclass, BundlePageConsoleMessageWithDetails, that implements
+        this callback and formats the message and arguments into a single string which it sends to the UI
+        process.
+
+        * TestWebKitAPI/SourcesCocoa.txt:
+        * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+        * TestWebKitAPI/Tests/WebKitCocoa/BundlePageConsoleMessageWithDetails.mm: Added.
+        (willAddMessageWithDetailsToConsoleCallback):
+        (-[BundlePageConsoleMessageWithDetails webProcessPlugIn:didCreateBrowserContextController:]):
+        * TestWebKitAPI/Tests/WebKitCocoa/ConsoleMessageWithDetails.mm: Added.
+        (TestWebKitAPI::didReceivePageMessageFromInjectedBundle):
+        (TestWebKitAPI::setInjectedBundleClient):
+        (TestWebKitAPI::TEST):
+        * TestWebKitAPI/Tests/WebKitCocoa/console-message-with-details.html: Added.
+
 2022-04-01  Chris Dumez  <cdu...@apple.com>
 
         Prepare Tools/ for making the String(const char*) constructor explicit

Modified: trunk/Tools/TestWebKitAPI/SourcesCocoa.txt (292253 => 292254)


--- trunk/Tools/TestWebKitAPI/SourcesCocoa.txt	2022-04-02 02:14:07 UTC (rev 292253)
+++ trunk/Tools/TestWebKitAPI/SourcesCocoa.txt	2022-04-02 03:04:20 UTC (rev 292254)
@@ -58,6 +58,7 @@
 Tests/WebKitCocoa/BundleEditingDelegate.mm
 Tests/WebKitCocoa/BundleFormDelegate.mm
 Tests/WebKitCocoa/BundlePageConsoleMessage.mm
+Tests/WebKitCocoa/BundlePageConsoleMessageWithDetails.mm
 Tests/WebKitCocoa/BundleParameters.mm
 Tests/WebKitCocoa/BundleRangeHandle.mm
 Tests/WebKitCocoa/CSSViewportUnits.mm
@@ -70,6 +71,7 @@
 Tests/WebKitCocoa/Coding.mm
 Tests/WebKitCocoa/CommandBackForward.mm
 Tests/WebKitCocoa/Configuration.mm
+Tests/WebKitCocoa/ConsoleMessageWithDetails.mm
 Tests/WebKitCocoa/ContentFiltering.mm
 Tests/WebKitCocoa/ContentRuleListNotification.mm
 Tests/WebKitCocoa/ContentSecurityPolicy.mm

Modified: trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj (292253 => 292254)


--- trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj	2022-04-02 02:14:07 UTC (rev 292253)
+++ trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj	2022-04-02 03:04:20 UTC (rev 292254)
@@ -980,6 +980,8 @@
 		CEDA12412437C9FB00C28A9E /* editable-region-composited-and-non-composited-overlap.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = CEDA12402437C9EA00C28A9E /* editable-region-composited-and-non-composited-overlap.html */; };
 		DD0EDF8D2798A6AD005152AD /* libgtest.a in Product Dependencies */ = {isa = PBXBuildFile; fileRef = F3FC3EE213678B7300126A65 /* libgtest.a */; };
 		DDD2187627A21750002B7025 /* WebKit.framework in Product Dependencies */ = {isa = PBXBuildFile; fileRef = C081224813FC1B0300DC39AE /* WebKit.framework */; };
+		DF1C7CE927F5161D00D8145C /* BundlePageConsoleMessageWithDetails.mm in Sources */ = {isa = PBXBuildFile; fileRef = DF1C7CE827F5161D00D8145C /* BundlePageConsoleMessageWithDetails.mm */; };
+		DF1C7CEC27F5309700D8145C /* console-message-with-details.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = DF1C7CEB27F5305A00D8145C /* console-message-with-details.html */; };
 		DF6580942722168900B3F1C1 /* ASN1Utilities.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DF6580922722168900B3F1C1 /* ASN1Utilities.cpp */; };
 		DFB80E38261512C1002D4771 /* TestAwakener.mm in Sources */ = {isa = PBXBuildFile; fileRef = DFB80E362615124E002D4771 /* TestAwakener.mm */; };
 		E1220DCA155B28AA0013E2FC /* MemoryCacheDisableWithinResourceLoadDelegate.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = E1220DC9155B287D0013E2FC /* MemoryCacheDisableWithinResourceLoadDelegate.html */; };
@@ -1297,6 +1299,7 @@
 				31903C912765077400363472 /* color-scheme.html in Copy Resources */,
 				0F16BED82304A1F300B4A167 /* composited.html in Copy Resources */,
 				F4B825D81EF4DBFB006E417F /* compressed-files.zip in Copy Resources */,
+				DF1C7CEC27F5309700D8145C /* console-message-with-details.html in Copy Resources */,
 				5C9E56871DF914AE00C9EE33 /* contentBlockerCheck.html in Copy Resources */,
 				F469FB241F01804B00401539 /* contenteditable-and-target.html in Copy Resources */,
 				F41AB9A11EF4696B0083FA08 /* contenteditable-and-textarea.html in Copy Resources */,
@@ -2959,6 +2962,9 @@
 		CEDA12402437C9EA00C28A9E /* editable-region-composited-and-non-composited-overlap.html */ = {isa = PBXFileReference; lastKnownFileType = text.html; name = "editable-region-composited-and-non-composited-overlap.html"; path = "ios/editable-region-composited-and-non-composited-overlap.html"; sourceTree = SOURCE_ROOT; };
 		D3BE5E341E4CE85E00FD563A /* WKWebViewGetContents.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WKWebViewGetContents.mm; sourceTree = "<group>"; };
 		DC69AA621CF77C6500C6272F /* ScopedLambda.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ScopedLambda.cpp; sourceTree = "<group>"; };
+		DF1C7CE827F5161D00D8145C /* BundlePageConsoleMessageWithDetails.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = BundlePageConsoleMessageWithDetails.mm; sourceTree = "<group>"; };
+		DF1C7CEA27F5239F00D8145C /* ConsoleMessageWithDetails.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = ConsoleMessageWithDetails.mm; sourceTree = "<group>"; };
+		DF1C7CEB27F5305A00D8145C /* console-message-with-details.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "console-message-with-details.html"; sourceTree = "<group>"; };
 		DF4B273821A47727009BD1CA /* WKNSDictionaryEmptyDictionaryCrash.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WKNSDictionaryEmptyDictionaryCrash.mm; sourceTree = "<group>"; };
 		DF6580922722168900B3F1C1 /* ASN1Utilities.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ASN1Utilities.cpp; sourceTree = "<group>"; };
 		DF6580932722168900B3F1C1 /* ASN1Utilities.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ASN1Utilities.h; sourceTree = "<group>"; };
@@ -3468,6 +3474,7 @@
 				7A89BB662331635D0042CB1E /* BundleFormDelegatePlugIn.mm */,
 				7A89BB69233165650042CB1E /* BundleFormDelegateProtocol.h */,
 				5175C7A126F876230003AF5C /* BundlePageConsoleMessage.mm */,
+				DF1C7CE827F5161D00D8145C /* BundlePageConsoleMessageWithDetails.mm */,
 				A13EBBAC1B87436F00097110 /* BundleParameters.mm */,
 				A13EBBAE1B87436F00097110 /* BundleParametersPlugIn.mm */,
 				37A709AD1E3EA8B000CA5969 /* BundleRangeHandle.mm */,
@@ -3485,6 +3492,7 @@
 				1AAD19F51C7CE20300831E47 /* Coding.mm */,
 				7C3DB8E21D12129B00AE8CC3 /* CommandBackForward.mm */,
 				5C4A84941F7EEFD400ACFC54 /* Configuration.mm */,
+				DF1C7CEA27F5239F00D8145C /* ConsoleMessageWithDetails.mm */,
 				A18AA8CC1C3FA218009B2B97 /* ContentFiltering.h */,
 				A14FC5861B8991B600D107EB /* ContentFiltering.mm */,
 				A14FC5891B89927100D107EB /* ContentFilteringPlugIn.mm */,
@@ -4117,6 +4125,7 @@
 				9BAE177A22E2BB6B00DF3098 /* cocoa-writer-markup-with-system-fonts.html */,
 				E5036F77211BC22800BFDBE2 /* color-drop.html */,
 				F4B825D61EF4DBD4006E417F /* compressed-files.zip */,
+				DF1C7CEB27F5305A00D8145C /* console-message-with-details.html */,
 				F469FB231F01803500401539 /* contenteditable-and-target.html */,
 				F41AB99C1EF4692C0083FA08 /* contenteditable-and-textarea.html */,
 				F4A32ECA1F0642F40047C544 /* contenteditable-in-iframe.html */,
@@ -5999,6 +6008,7 @@
 				374B7A611DF371CF00ACCB6C /* BundleEditingDelegatePlugIn.mm in Sources */,
 				7A89BB682331643A0042CB1E /* BundleFormDelegatePlugIn.mm in Sources */,
 				5175C7A226F876230003AF5C /* BundlePageConsoleMessage.mm in Sources */,
+				DF1C7CE927F5161D00D8145C /* BundlePageConsoleMessageWithDetails.mm in Sources */,
 				A13EBBB01B87436F00097110 /* BundleParametersPlugIn.mm in Sources */,
 				37A709AF1E3EA97E00CA5969 /* BundleRangeHandlePlugIn.mm in Sources */,
 				5C75716122124C5200B9E5AC /* BundleRetainPagePlugIn.mm in Sources */,

Added: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/BundlePageConsoleMessageWithDetails.mm (0 => 292254)


--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/BundlePageConsoleMessageWithDetails.mm	                        (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/BundlePageConsoleMessageWithDetails.mm	2022-04-02 03:04:20 UTC (rev 292254)
@@ -0,0 +1,80 @@
+/*
+ * Copyright (C) 2022 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import "config.h"
+
+#if PLATFORM(MAC)
+
+#import "PlatformUtilities.h"
+#import <WebKit/WKBundlePage.h>
+#import <WebKit/WKBundlePageUIClient.h>
+#import <WebKit/WKRetainPtr.h>
+#import <WebKit/WKStringCF.h>
+#import <WebKit/WKWebProcessPlugIn.h>
+#import <WebKit/WKWebProcessPlugInBrowserContextControllerPrivate.h>
+
+static NSArray<NSString *> *stringsArrayFromWKArrayRef(WKArrayRef wkArray)
+{
+    size_t itemCount = WKArrayGetSize(wkArray);
+    NSMutableArray *array = [NSMutableArray arrayWithCapacity:itemCount];
+    for (size_t i = 0; i < itemCount; ++i)
+        [array addObject:TestWebKitAPI::Util::toNS((WKStringRef)WKArrayGetItemAtIndex(wkArray, i))];
+
+    return array;
+}
+
+static void willAddMessageWithDetailsToConsoleCallback(WKBundlePageRef page, WKStringRef message, WKArrayRef messageArguments, uint32_t lineNumber, uint32_t columnNumber, WKStringRef sourceID, const void *)
+{
+    WKRetainPtr<WKStringRef> messageName = adoptWK(WKStringCreateWithUTF8CString("ConsoleMessage"));
+
+    NSString *nsMessage = message ? TestWebKitAPI::Util::toNS(message) : @"";
+    NSArray<NSString *> *nsMessageArguments = stringsArrayFromWKArrayRef(messageArguments);
+    if (nsMessageArguments.count) {
+        nsMessage = [nsMessage stringByAppendingString:@", arguments: "];
+        nsMessage = [nsMessage stringByAppendingString:[nsMessageArguments componentsJoinedByString:@", "]];
+    }
+
+    WKRetainPtr<WKStringRef> fullMessage = adoptWK(WKStringCreateWithCFString((__bridge CFStringRef)nsMessage));
+
+    WKBundlePagePostMessage(page, messageName.get(), fullMessage.get());
+}
+
+@interface BundlePageConsoleMessageWithDetails : NSObject <WKWebProcessPlugIn>
+@end
+
+@implementation BundlePageConsoleMessageWithDetails
+
+- (void)webProcessPlugIn:(WKWebProcessPlugInController *)plugInController didCreateBrowserContextController:(WKWebProcessPlugInBrowserContextController *)browserContextController
+{
+    WKBundlePageUIClientV5 client;
+    memset(&client, 0, sizeof(client));
+    client.base.version = 5;
+    client.willAddMessageWithDetailsToConsole = willAddMessageWithDetailsToConsoleCallback;
+    WKBundlePageSetUIClient([browserContextController _bundlePageRef], &client.base);
+}
+
+@end
+
+#endif // PLATFORM(MAC)

Added: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/ConsoleMessageWithDetails.mm (0 => 292254)


--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/ConsoleMessageWithDetails.mm	                        (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/ConsoleMessageWithDetails.mm	2022-04-02 03:04:20 UTC (rev 292254)
@@ -0,0 +1,75 @@
+/*
+ * Copyright (C) 2022 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import "config.h"
+
+#if PLATFORM(MAC)
+
+#import "PlatformUtilities.h"
+#import "Test.h"
+#import "TestWKWebView.h"
+#import "WKWebViewConfigurationExtras.h"
+#import <WebKit/WKWebViewPrivate.h>
+#import <WebKit/WebKit.h>
+#import <wtf/text/WTFString.h>
+
+namespace TestWebKitAPI {
+
+static RetainPtr<NSMutableArray> consoleMessages;
+
+static void didReceivePageMessageFromInjectedBundle(WKPageRef, WKStringRef messageName, WKTypeRef message, const void*)
+{
+    if (WKStringIsEqualToUTF8CString(messageName, "ConsoleMessage"))
+        [consoleMessages addObject:Util::toNS((WKStringRef)message)];
+}
+
+static void setInjectedBundleClient(WKWebView *webView)
+{
+    WKPageInjectedBundleClientV0 injectedBundleClient = {
+        { 0, nullptr },
+        didReceivePageMessageFromInjectedBundle,
+        nullptr,
+    };
+    WKPageSetPageInjectedBundleClient(webView._pageRefForTransitionToWKWebView, &injectedBundleClient.base);
+}
+
+TEST(WebKit, ConsoleMessageWithDetails)
+{
+    WKWebViewConfiguration *configuration = [WKWebViewConfiguration _test_configurationWithTestPlugInClassName:@"BundlePageConsoleMessageWithDetails"];
+
+    auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:CGRectMake(0, 0, 800, 600) configuration:configuration]);
+    setInjectedBundleClient(webView.get());
+
+    consoleMessages = [NSMutableArray array];
+    [webView synchronouslyLoadTestPageNamed:@"console-message-with-details"];
+
+    EXPECT_EQ([consoleMessages count], 2u);
+    EXPECT_TRUE([consoleMessages.get()[0] isEqualToString:@"Hello world!"]);
+    EXPECT_TRUE([consoleMessages.get()[1] isEqualToString:@"Hello world!, arguments: argument1, argument2"]);
+}
+
+} // namespace TestWebKitAPI
+
+#endif // PLATFORM(MAC)

Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/FontAttributes.mm (292253 => 292254)


--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/FontAttributes.mm	2022-04-02 02:14:07 UTC (rev 292253)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/FontAttributes.mm	2022-04-02 03:04:20 UTC (rev 292254)
@@ -39,7 +39,7 @@
 #import <wtf/Vector.h>
 
 #if PLATFORM(IOS_FAMILY)
-#import <pal/spi/ios/UIKitSPI.h>
+#import "UIKitSPI.h"
 #endif
 
 @interface FontAttributesListener : NSObject <WKUIDelegatePrivate>

Added: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/console-message-with-details.html (0 => 292254)


--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/console-message-with-details.html	                        (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/console-message-with-details.html	2022-04-02 03:04:20 UTC (rev 292254)
@@ -0,0 +1,11 @@
+<!DOCTYPE html>
+<html>
+<head>
+    <script>
+    console.log("Hello world!");
+    console.log("Hello world!", "argument1", "argument2");
+    </script>
+</head>
+<body>
+</body>
+</html>

Modified: trunk/Tools/TestWebKitAPI/ios/UIKitSPI.h (292253 => 292254)


--- trunk/Tools/TestWebKitAPI/ios/UIKitSPI.h	2022-04-02 02:14:07 UTC (rev 292253)
+++ trunk/Tools/TestWebKitAPI/ios/UIKitSPI.h	2022-04-02 03:04:20 UTC (rev 292254)
@@ -73,6 +73,15 @@
 @property (readonly) BOOL isLowConfidence;
 @end
 
+@interface NSParagraphStyle ()
+- (NSArray *)textLists;
+@end
+
+@interface NSTextList : NSObject
+@property NSInteger startingItemNumber;
+@property (readonly, copy) NSString *markerFormat;
+@end
+
 WTF_EXTERN_C_BEGIN
 
 void UIApplicationInitialize(void);
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to