Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 86d41771701417a87ec6243e65c9b769b49a35b4
      
https://github.com/WebKit/WebKit/commit/86d41771701417a87ec6243e65c9b769b49a35b4
  Author: Timothy Hatcher <[email protected]>
  Date:   2026-05-11 (Mon, 11 May 2026)

  Changed paths:
    M Source/WebCore/page/FrameConsoleClient.cpp
    M Source/WebCore/workers/WorkerConsoleClient.cpp
    M Tools/TestWebKitAPI/Tests/WebKit/WKWebView/WKWebExtensionContext.mm

  Log Message:
  -----------
  Loading any Web Extension breaks Cloudflare bot challenges
https://webkit.org/b/314458
rdar://176618014

Reviewed by Brian Weinstein.

When any web extension is loaded, 311150@main added script error reporting by 
calling
getArgumentsAsStrings() on the console.error() arguments after 
getFirstArgumentAsString()
had already evaluated the first argument. This caused toString() to be invoked 
twice on
the first argument and once on every extra argument.

Cloudflare's bot challenge passes a sentinel object to console.error() that 
counts
toString() invocations to detect unexpected evaluation. The extra call tripped 
that
detection and broke the challenge for any user with a web extension loaded.

The fix is to pass the first-argument message text directly to 
invokeScriptErrorCallbacks,
avoiding any re-evaluation of arguments.

Test: 
TestWebKitAPI.WKWebExtensionContext.ConsoleErrorDoesNotEvaluateArgumentsTwice

* Source/WebCore/page/FrameConsoleClient.cpp:
(WebCore::FrameConsoleClient::messageWithTypeAndLevel): Pass the 
already-computed
first-argument message text directly to invokeScriptErrorCallbacks instead of
re-evaluating all arguments via getArgumentsAsStrings().
* Source/WebCore/workers/WorkerConsoleClient.cpp:
(WebCore::WorkerConsoleClient::messageWithTypeAndLevel): Ditto.
* Tools/TestWebKitAPI/Tests/WebKit/WKWebView/WKWebExtensionContext.mm:
(TestWebKitAPI::TEST(WKWebExtensionContext, 
ConsoleErrorDoesNotEvaluateArgumentsTwice)): Added.
(TestWebKitAPI::TEST(WKWebExtensionContext, ConsoleErrorReportedNotLogOrWarn)): 
Removed second
Error argument since it is skipped now.

Canonical link: https://commits.webkit.org/313007@main



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications

Reply via email to