mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-21 09:49:21 +00:00
WebDriver: Handle script execution results without spinning event loops
We currently spin the platform event loop while awaiting scripts to complete. This causes WebContent to hang if another component is also spinning the event loop. The particular example that instigated this patch was the navigable's navigation loop (which spins until the fetch process is complete), triggered by a form submission to an iframe. So instead of spinning, we now return immediately from the script executors, after setting up listeners for either the script's promise to be resolved or for a timeout. The HTTP request to WebDriver must finish synchronously though, so now the WebDriver process spins its event loop until WebContent signals that the script completed. This should be ok - the WebDriver process isn't expected to be doing anything else in the meantime. Also, as a consequence of these changes, we now actually handle time outs. We were previously creating the timeout timer, but not starting it.
This commit is contained in:
parent
6f31a19c5f
commit
c2cf65adac
Notes:
github-actions[bot]
2024-09-13 14:12:19 +00:00
Author: https://github.com/trflynn89
Commit: c2cf65adac
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/1389
Reviewed-by: https://github.com/ADKaster
Reviewed-by: https://github.com/awesomekling ✅
10 changed files with 242 additions and 124 deletions
|
@ -9,6 +9,7 @@
|
|||
#include <AK/Forward.h>
|
||||
#include <AK/JsonValue.h>
|
||||
#include <LibJS/Forward.h>
|
||||
#include <LibJS/Heap/HeapFunction.h>
|
||||
#include <LibJS/Runtime/Value.h>
|
||||
#include <LibWeb/Forward.h>
|
||||
|
||||
|
@ -32,7 +33,9 @@ struct ExecuteScriptResultSerialized {
|
|||
JsonValue value;
|
||||
};
|
||||
|
||||
ExecuteScriptResultSerialized execute_script(Page& page, ByteString const& body, JS::MarkedVector<JS::Value> arguments, Optional<u64> const& timeout_ms);
|
||||
ExecuteScriptResultSerialized execute_async_script(Page& page, ByteString const& body, JS::MarkedVector<JS::Value> arguments, Optional<u64> const& timeout_ms);
|
||||
using OnScriptComplete = JS::HeapFunction<void(ExecuteScriptResultSerialized)>;
|
||||
|
||||
void execute_script(Page& page, ByteString body, JS::MarkedVector<JS::Value> arguments, Optional<u64> const& timeout_ms, JS::NonnullGCPtr<OnScriptComplete> on_complete);
|
||||
void execute_async_script(Page& page, ByteString body, JS::MarkedVector<JS::Value> arguments, Optional<u64> const& timeout_ms, JS::NonnullGCPtr<OnScriptComplete> on_complete);
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue