Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: d7b5fd6177ae697f03b4d080222b7b89cda88ced
https://github.com/WebKit/WebKit/commit/d7b5fd6177ae697f03b4d080222b7b89cda88ced
Author: Alex Christensen <[email protected]>
Date: 2026-02-02 (Mon, 02 Feb 2026)
Changed paths:
M Source/WebKit/Shared/JavaScriptEvaluationResult.cpp
M Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebViewEvaluateJavaScript.mm
Log Message:
-----------
Restore pre-JavaScriptEvaluationResult behavior with arrays and dictionaries
containing non-serializable types
https://bugs.webkit.org/show_bug.cgi?id=306814
rdar://169301353
Reviewed by Brady Eidson.
When we switched from using SerializedScriptValue to using
JavaScriptEvaluationResult, we inadvertently started
succeeding serializing arrays and dictionaries that contained non-serializable
types, like DOM nodes, but with
the non-serializable elements removed. This caused a change in behavior for
which we added a compatibility
check in 301986@main. With this change, that may no longer be needed, but I
keep it to reduce risk.
I manually verified with some pre-JavaScriptEvaluationResult OSes that this
change in behavior is restoring
previous behavior to increase compatibility.
In addition, in 303074@main we changed from a recursive algorithm to an
iterative algorithm that can handle
deeply nested JS objects, but the algorithm we introduced in 303074@main
serializes all members of all containers
before looking through them for members that can't be serialized, which
introduced a significant performance
overhead in some pathological cases. This PR replaces that algorithm with
another non-recursive algorithm
more similar to valueToObjectWithoutCopy where we check for non-serializable
members as we traverse instead
of at the end of the traversal. I verified with the app in the radar that this
performance issue is resolved.
Test: Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebViewEvaluateJavaScript.mm
* Source/WebKit/Shared/JavaScriptEvaluationResult.cpp:
(WebKit::JavaScriptEvaluationResult::JSExtractor::addObjectToMap):
(WebKit::JavaScriptEvaluationResult::JSExtractor::processContainersWithoutRecursion):
(WebKit::JavaScriptEvaluationResult::extract):
(WebKit::JavaScriptEvaluationResult::JSExtractor::jsValueToExtractedValue):
(WebKit::JavaScriptEvaluationResult::JSExtractor::extractJSValue): Deleted.
* Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebViewEvaluateJavaScript.mm:
(TEST(WKWebView, EvaluateJavaScriptErrorCases)):
((EvaluateJavaScript, Serialization)):
Canonical link: https://commits.webkit.org/306677@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications