Repository navigation
feat: expose pending JavaScript invocations without draining the queue - #26658
totally-not-ai[bot] wants to merge 4 commits into
Conversation
|
Replaced both |
| session.checkHasLock(); | ||
| return pendingJsInvocations.stream() | ||
| .filter(invocation -> !invocation.isCanceled()); | ||
| .filter(invocation -> !invocation.isCanceled()).toList() |
There was a problem hiding this comment.
If we anyway make a copy - wouldn't it be smarter to change the return type to List?
There was a problem hiding this comment.
@Artur- Yes, that's better. getPendingJavaScriptInvocations() now returns an unmodifiable List snapshot. The internal callers (dumpPendingJavaScriptInvocations(), isDirty(), containsPendingJavascript and containsPendingJsCall) use a private stream over the live queue instead, so they don't copy it on every call. The tests now use size() and stream().
|



Review risk: two-way door — widens one method of the internal-only
UIInternalsfrom package-private to public; no change for existing callers.missing API · flow-server · tools that drive the client side without a browser, such as server-side UI test frameworks
Code that simulates the browser had no way to look at the JavaScript queued for the client without taking all of it. The only public reader marks every invocation as sent, so picking out one call, for example a page reload, dropped all other queued JavaScript. The queue can now be read without changing it.
Risks:
UIInternals.getPendingJavaScriptInvocations()is now public; the class is documented as internal-onlyContext.
JsCallis documented as the way a driver without a browser recognises calls in the pending queue (definitionType(),methodName(),invokeOn(…)), andcontainsPendingJsCallcan already tell whether such a call is queued, but nothing public could hand the invocation over so it can be acted on and canceled.UIInternals.getPendingJavaScriptInvocations()public and changed its return type fromStreamtoListPendingJavaScriptInvocation.cancelExecution()(which reports a failure to the call's error handler), and leave the rest for the client; invocations of invisible owners are includedisDirty()and thecontainsPending…checks do not copy itConcurrentModificationExceptionWorking on behalf of Artur