Fix already borrowed error in webdriver

This commit is contained in:
George Roman 2019-06-09 22:25:41 +03:00
parent 347d8bdf72
commit 1dda774518
2 changed files with 46 additions and 41 deletions

View file

@ -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,
)
},
_ => (),
}
}