mirror of
https://github.com/servo/servo.git
synced 2025-09-29 16:19:14 +01:00
script: Return a Result from GlobalScope::evaluate_script_on_global_with_result (#38549)
Make GlobalScope::evaluate_script_on_global_with_result return a Result instead of a boolean. This is the first step to resolve issue #37810. Testing: Should not break or fix any existing tests --------- Signed-off-by: Rodion Borovyk <rodion.borovyk@gmail.com>
This commit is contained in:
parent
86c37a380b
commit
4f8731d562
11 changed files with 45 additions and 28 deletions
|
@ -524,17 +524,17 @@ pub(crate) fn handle_execute_script(
|
|||
|
||||
rooted!(in(*cx) let mut rval = UndefinedValue());
|
||||
let global = window.as_global_scope();
|
||||
let result = if global.evaluate_js_on_global_with_result(
|
||||
let evaluation_result = global.evaluate_js_on_global_with_result(
|
||||
&eval,
|
||||
rval.handle_mut(),
|
||||
ScriptFetchOptions::default_classic_script(global),
|
||||
global.api_base_url(),
|
||||
can_gc,
|
||||
None, // No known `introductionType` for JS code from WebDriver
|
||||
) {
|
||||
jsval_to_webdriver(cx, global, rval.handle(), realm, can_gc)
|
||||
} else {
|
||||
Err(WebDriverJSError::JSError)
|
||||
);
|
||||
let result = match evaluation_result {
|
||||
Ok(_) => jsval_to_webdriver(cx, global, rval.handle(), realm, can_gc),
|
||||
Err(_) => Err(WebDriverJSError::JSError),
|
||||
};
|
||||
|
||||
if reply.send(result).is_err() {
|
||||
|
@ -566,14 +566,17 @@ pub(crate) fn handle_execute_async_script(
|
|||
rooted!(in(*cx) let mut rval = UndefinedValue());
|
||||
|
||||
let global_scope = window.as_global_scope();
|
||||
if !global_scope.evaluate_js_on_global_with_result(
|
||||
&eval,
|
||||
rval.handle_mut(),
|
||||
ScriptFetchOptions::default_classic_script(global_scope),
|
||||
global_scope.api_base_url(),
|
||||
can_gc,
|
||||
None, // No known `introductionType` for JS code from WebDriver
|
||||
) {
|
||||
if global_scope
|
||||
.evaluate_js_on_global_with_result(
|
||||
&eval,
|
||||
rval.handle_mut(),
|
||||
ScriptFetchOptions::default_classic_script(global_scope),
|
||||
global_scope.api_base_url(),
|
||||
can_gc,
|
||||
None, // No known `introductionType` for JS code from WebDriver
|
||||
)
|
||||
.is_err()
|
||||
{
|
||||
reply_sender.send(Err(WebDriverJSError::JSError)).unwrap();
|
||||
}
|
||||
},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue