WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
238032
WKBundlePageUIClient console message support should include source URL, column number, and console messages with arguments
https://bugs.webkit.org/show_bug.cgi?id=238032
Summary
WKBundlePageUIClient console message support should include source URL, colum...
Jeff Miller
Reported
2022-03-17 11:19:45 PDT
WKBundlePageUIClient console message support should include source URL, column number, and console messages with arguments
Attachments
Patch
(10.69 KB, patch)
2022-03-17 13:32 PDT
,
Jeff Miller
no flags
Details
Formatted Diff
Diff
Patch
(10.71 KB, patch)
2022-03-17 18:39 PDT
,
Jeff Miller
no flags
Details
Formatted Diff
Diff
Patch
(10.71 KB, patch)
2022-03-17 19:54 PDT
,
Jeff Miller
ews-feeder
: commit-queue-
Details
Formatted Diff
Diff
Patch
(18.66 KB, patch)
2022-03-18 11:23 PDT
,
Jeff Miller
ews-feeder
: commit-queue-
Details
Formatted Diff
Diff
Patch
(19.42 KB, patch)
2022-03-29 15:18 PDT
,
Jeff Miller
no flags
Details
Formatted Diff
Diff
Patch
(38.42 KB, patch)
2022-03-31 18:47 PDT
,
Jeff Miller
no flags
Details
Formatted Diff
Diff
Patch
(42.49 KB, patch)
2022-04-01 16:40 PDT
,
Jeff Miller
no flags
Details
Formatted Diff
Diff
Patch
(42.97 KB, patch)
2022-04-01 19:24 PDT
,
Alex Christensen
ews-feeder
: commit-queue-
Details
Formatted Diff
Diff
Show Obsolete
(7)
View All
Add attachment
proposed patch, testcase, etc.
Jeff Miller
Comment 1
2022-03-17 11:20:43 PDT
rdar://90439983
Jeff Miller
Comment 2
2022-03-17 13:32:05 PDT
Created
attachment 455016
[details]
Patch
Jeff Miller
Comment 3
2022-03-17 18:36:12 PDT
It appears this change inserts an extra space in console messages, which breaks test expectations. For example: -CONSOLE MESSAGE: This test passes if it does not crash. +CONSOLE MESSAGE: This test passes if it does not crash. I'll fix this before landing.
Jeff Miller
Comment 4
2022-03-17 18:39:16 PDT
Created
attachment 455056
[details]
Patch
Jeff Miller
Comment 5
2022-03-17 19:54:36 PDT
Created
attachment 455063
[details]
Patch
Jeff Miller
Comment 6
2022-03-18 09:19:48 PDT
Not surprisingly, now that we include console message arguments, some existing test expectations are now incorrect. For example: -CONSOLE MESSAGE: [loadCrossOriginImage] +CONSOLE MESSAGE: [loadCrossOriginImage] trying
http://localhost:8000/webgl/resources/webgl_test_files/resources/opengl_logo.jpg
Also, I think the fact that we always call addMessageToConsole() now, even if the message is empty, is causing issues. For example, an expected result is: Test for the Console.messagesCleared event. and the actual result is: CONSOLE MESSAGE: CONSOLE MESSAGE: Test for the Console.messagesCleared event. The latter issue is a bug in this patch, but the former issue is trickier. Rather than changing the existing behavior of the willAddMessageToConsole callback, a more conservative change is to only include the message arguments when using the new willAddMessageWithDetailsToConsole callback.
Jeff Miller
Comment 7
2022-03-18 11:23:50 PDT
Created
attachment 455115
[details]
Patch
Jeff Miller
Comment 8
2022-03-18 14:54:16 PDT
The win bot passes now, but the console-log-proxy test on the gtk-wk2 bot is failing:
https://ews-build.s3-us-west-2.amazonaws.com/GTK-WK2-Tests-EWS/455115-11928/inspector/console/console-log-proxy-diff.txt
--- /home/ews/worker/GTK-WK2-Tests-EWS/build/layout-test-results/inspector/console/console-log-proxy-expected.txt +++ /home/ews/worker/GTK-WK2-Tests-EWS/build/layout-test-results/inspector/console/console-log-proxy-actual.txt @@ -1,14 +1,21 @@ CONSOLE MESSAGE: [object Proxy] CONSOLE MESSAGE: 0 CONSOLE MESSAGE: [object Proxy] +CONSOLE MESSAGE: 1 +CONSOLE MESSAGE: 1 +CONSOLE MESSAGE: 1 CONSOLE MESSAGE: 1 Tests for the console.log with Proxy objects. I'll leave the patch up, I want to see what happens with the mac-wk2 bot, but I definitely seem to have regressed the console-log-proxy, although I have no idea how.
Jeff Miller
Comment 9
2022-03-18 15:33:28 PDT
Tim Hatcher pointed out that the console-log-proxy is likely failing because I'm walking through all the arguments, fetching them, and converting them to strings. This causes the Proxy object to be fetched. I need to be implementing this more like ScriptArguments::getFirstArgumentAsString() and do special Proxy object handling.
Jeff Miller
Comment 10
2022-03-29 15:18:02 PDT
Created
attachment 456068
[details]
Patch
Alex Christensen
Comment 11
2022-03-29 16:22:49 PDT
Comment on
attachment 456068
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=456068&action=review
No test? BundlePageConsoleMessage uses willAddMessageToConsole, so a similar technique could be used to test this.
> Source/WebCore/ChangeLog:9 > + Add a new ChromeClient addMessageWithArgumentsToConsole() member function for adding a console > + message that includes formatted arguments. I left the existing behavior of addMessageToConsole()
I can't say I think this is a great API. I would expect a WKArrayRef rather than a space separated list inside the string with the message, for which you have to assume that none of the arguments have spaces in them if you want to do anything with them.
> Source/WebCore/page/PageConsoleClient.cpp:222 > + for (size_t i = 1; i < arguments->argumentCount(); ++i) {
This is basically duplicate code.
Jeff Miller
Comment 12
2022-03-30 07:52:18 PDT
Comment on
attachment 456068
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=456068&action=review
>> Source/WebCore/ChangeLog:9 >> + message that includes formatted arguments. I left the existing behavior of addMessageToConsole() > > I can't say I think this is a great API. I would expect a WKArrayRef rather than a space separated list inside the string with the message, for which you have to assume that none of the arguments have spaces in them if you want to do anything with them.
Since you mention WKArrayRef, I assume you're talking about the API exposed to the injected bundle: typedef void (*WKBundlePageWillAddMessageWithDetailsToConsoleCallback)(WKBundlePageRef page, WKStringRef message, uint32_t lineNumber, uint32_t columnNumber, WKStringRef sourceID, const void *clientInfo); The intent of this patch was to better support writing client-side tests that typically look for complete messages from JavaScript, but we can still do this while providing more information about the individual parameters as you suggested. I'll change this.
>> Source/WebCore/page/PageConsoleClient.cpp:222 >> + for (size_t i = 1; i < arguments->argumentCount(); ++i) { > > This is basically duplicate code.
Good point, I'll refactor this logic into a separate function.
Jeff Miller
Comment 13
2022-03-30 07:53:48 PDT
I'll add a test as well.
Jeff Miller
Comment 14
2022-03-31 18:47:55 PDT
Created
attachment 456304
[details]
Patch
Alex Christensen
Comment 15
2022-03-31 20:23:03 PDT
Comment on
attachment 456304
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=456304&action=review
> Source/JavaScriptCore/inspector/ScriptArguments.cpp:88 > +bool ScriptArguments::getArgumentsAsStrings(Vector<String>& result) const
Vector<String> ScriptArguments::getArgumentsAsStrings() const Can return an empty vector. Or it could return a std::optional<Vector<String>>
> Source/JavaScriptCore/inspector/ScriptArguments.cpp:108 > + if (JSC::jsDynamicCast<JSC::ProxyObject*>(globalObject->vm(), value)) { > + result.append("[object Proxy]"_s); > + continue; > + } > + > + auto scope = DECLARE_CATCH_SCOPE(globalObject->vm()); > + result.append(value.toWTFString(globalObject)); > + scope.clearException();
This is all duplicate code.
> Source/WebCore/page/PageConsoleClient.cpp:130 > + messageArguments.remove(0);
This is the least efficient place to remove in a Vector. Let's not do this. Could we instead make a createStringArray that takes a Span<String> and pass a Span<String> through addMessageWithArgumentsToConsole containing indices 1 through the end? We'd have to do a bounds check here.
> Source/WebCore/page/PageConsoleClient.cpp:188 > + messageText = messageArguments[0];
ditto.
Jeff Miller
Comment 16
2022-04-01 16:40:04 PDT
Created
attachment 456419
[details]
Patch
Alex Christensen
Comment 17
2022-04-01 16:46:12 PDT
Comment on
attachment 456419
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=456419&action=review
> Source/JavaScriptCore/inspector/ScriptArguments.cpp:111 > + auto* globalObject = this->globalObject(); > + if (!globalObject) { > + ASSERT_NOT_REACHED(); > + return std::nullopt; > + }
This should be removed. It's redundant and unused.
> Source/WebCore/page/PageConsoleClient.cpp:126 > + ASSERT(!argumentsVector.isEmpty()); > + if (size_t numberOfAdditionalArguments = argumentsVector.size() - 1) > + return argumentsVector.span().subspan(1, numberOfAdditionalArguments); > + > + return { };
I think it would be safer if you checked instead of asserted that the vector is empty. You also don't need to check if numberOfAdditionalArguments is nonzero because if it is zero it will just return an empty span. I also don't think subspan needs a second argument in this case.
> Source/WebKit/Shared/API/APIArray.cpp:53 > + return createStringArray(Vector<WTF::String>(strings));
This is an unneeded allocation
Jeff Miller
Comment 18
2022-04-01 18:23:01 PDT
Comment on
attachment 456419
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=456419&action=review
>> Source/JavaScriptCore/inspector/ScriptArguments.cpp:111 >> + } > > This should be removed. It's redundant and unused.
Yup, just missed this during the refactoring.
Alex Christensen
Comment 19
2022-04-01 19:24:07 PDT
Created
attachment 456428
[details]
Patch
EWS
Comment 20
2022-04-01 19:27:02 PDT
ChangeLog entry in Tools/ChangeLog contains OOPS!.
Alex Christensen
Comment 21
2022-04-01 20:04:28 PDT
r292254
Alex Christensen
Comment 22
2022-04-01 23:10:16 PDT
http://trac.webkit.org/r292259
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug