aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/script_thread.rs
diff options
context:
space:
mode:
authorGeorge Roman <george.roman.99@gmail.com>2019-06-09 22:25:41 +0300
committerGeorge Roman <george.roman.99@gmail.com>2019-06-10 17:49:46 +0300
commit1dda774518489ab4727c4c3bdd17113fb5d962ae (patch)
tree9f062072eec841f3302db8fe5bf888790e792c58 /components/script/script_thread.rs
parent347d8bdf727d6b43ba7f94b744c9115bc6226aff (diff)
downloadservo-1dda774518489ab4727c4c3bdd17113fb5d962ae.tar.gz
servo-1dda774518489ab4727c4c3bdd17113fb5d962ae.zip
Fix already borrowed error in webdriver
Diffstat (limited to 'components/script/script_thread.rs')
-rw-r--r--components/script/script_thread.rs28
1 files changed, 17 insertions, 11 deletions
diff --git a/components/script/script_thread.rs b/components/script/script_thread.rs
index f284e14dd0c..7adaef5d352 100644
--- a/components/script/script_thread.rs
+++ b/components/script/script_thread.rs
@@ -1833,6 +1833,22 @@ impl ScriptThread {
}
fn handle_webdriver_msg(&self, pipeline_id: PipelineId, msg: WebDriverScriptCommand) {
+ // https://github.com/servo/servo/issues/23535
+ // These two messages need different treatment since the JS script might mutate
+ // `self.documents`, which would conflict with the immutable borrow of it that
+ // occurs for the rest of the messages
+ match msg {
+ WebDriverScriptCommand::ExecuteScript(script, reply) => {
+ let window = { self.documents.borrow().find_window(pipeline_id) };
+ return webdriver_handlers::handle_execute_script(window, script, reply);
+ },
+ WebDriverScriptCommand::ExecuteAsyncScript(script, reply) => {
+ let window = { self.documents.borrow().find_window(pipeline_id) };
+ return webdriver_handlers::handle_execute_async_script(window, script, reply);
+ },
+ _ => (),
+ }
+
let documents = self.documents.borrow();
match msg {
WebDriverScriptCommand::AddCookie(params, reply) => {
@@ -1841,9 +1857,6 @@ impl ScriptThread {
WebDriverScriptCommand::DeleteCookies(reply) => {
webdriver_handlers::handle_delete_cookies(&*documents, pipeline_id, reply)
},
- WebDriverScriptCommand::ExecuteScript(script, reply) => {
- webdriver_handlers::handle_execute_script(&*documents, pipeline_id, script, reply)
- },
WebDriverScriptCommand::FindElementCSS(selector, reply) => {
webdriver_handlers::handle_find_element_css(
&*documents,
@@ -1936,14 +1949,7 @@ impl ScriptThread {
WebDriverScriptCommand::GetTitle(reply) => {
webdriver_handlers::handle_get_title(&*documents, pipeline_id, reply)
},
- WebDriverScriptCommand::ExecuteAsyncScript(script, reply) => {
- webdriver_handlers::handle_execute_async_script(
- &*documents,
- pipeline_id,
- script,
- reply,
- )
- },
+ _ => (),
}
}