mirror of
https://github.com/servo/servo.git
synced 2025-08-04 21:20:23 +01:00
libservo: Allow embedders to execute JavaScript scripts via the API (#35720)
This change adds a new `WebView` API `evaluate_javascript()`, which allows embedders to execute JavaScript code and wait for a reply asynchronously. Ongoing script execution is tracked by a libservo `JavaScriptEvaluator` struct, which maps an id to the callback passed to the `evaluate_javascript()` method. The id is used to track the script and its execution through the other parts of Servo. Testing: This changes includes `WebView` unit tests. --------- Signed-off-by: Narfinger <Narfinger@users.noreply.github.com> Signed-off-by: Martin Robinson <mrobinson@igalia.com> Co-authored-by: Martin Robinson <mrobinson@igalia.com>
This commit is contained in:
parent
91c4c7b998
commit
991be359a3
12 changed files with 391 additions and 18 deletions
|
@ -15,8 +15,8 @@ use base::id::{
|
|||
use canvas_traits::canvas::{CanvasId, CanvasMsg};
|
||||
use devtools_traits::{DevtoolScriptControlMsg, ScriptToDevtoolsControlMsg, WorkerId};
|
||||
use embedder_traits::{
|
||||
AnimationState, EmbedderMsg, FocusSequenceNumber, MediaSessionEvent, TouchEventResult,
|
||||
ViewportDetails,
|
||||
AnimationState, EmbedderMsg, FocusSequenceNumber, JSValue, JavaScriptEvaluationError,
|
||||
JavaScriptEvaluationId, MediaSessionEvent, TouchEventResult, ViewportDetails,
|
||||
};
|
||||
use euclid::default::Size2D as UntypedSize2D;
|
||||
use http::{HeaderMap, Method};
|
||||
|
@ -644,6 +644,11 @@ pub enum ScriptToConstellationMessage {
|
|||
IFrameSizes(Vec<IFrameSizeMsg>),
|
||||
/// Request results from the memory reporter.
|
||||
ReportMemory(IpcSender<MemoryReportResult>),
|
||||
/// Return the result of the evaluated JavaScript with the given [`JavaScriptEvaluationId`].
|
||||
FinishJavaScriptEvaluation(
|
||||
JavaScriptEvaluationId,
|
||||
Result<JSValue, JavaScriptEvaluationError>,
|
||||
),
|
||||
}
|
||||
|
||||
impl fmt::Debug for ScriptToConstellationMessage {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue