diff options
author | bors-servo <lbergstrom+bors@mozilla.com> | 2019-06-10 14:26:17 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-06-10 14:26:17 -0400 |
commit | b3eed5b5bdb39138bab07ca18b77e4b622179756 (patch) | |
tree | 148b65b2c55e3fd47bd6ded9371ccbdefb408a9c /components/script/script_thread.rs | |
parent | 4c776f33d407c1ef84952967925318476ac9e3f6 (diff) | |
parent | 1dda774518489ab4727c4c3bdd17113fb5d962ae (diff) | |
download | servo-b3eed5b5bdb39138bab07ca18b77e4b622179756.tar.gz servo-b3eed5b5bdb39138bab07ca18b77e4b622179756.zip |
Auto merge of #23544 - georgeroman:fix_borrow_mut_error_in_webdriver, r=asajeffrey
Fix already borrowed error in webdriver
<!-- Please describe your changes on the following line: -->
---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] These changes fix #23535
<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->
<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/23544)
<!-- Reviewable:end -->
Diffstat (limited to 'components/script/script_thread.rs')
-rw-r--r-- | components/script/script_thread.rs | 28 |
1 files changed, 17 insertions, 11 deletions
diff --git a/components/script/script_thread.rs b/components/script/script_thread.rs index d0dad1cd9ba..d05e38569fc 100644 --- a/components/script/script_thread.rs +++ b/components/script/script_thread.rs @@ -1834,6 +1834,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) => { @@ -1842,9 +1858,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, @@ -1937,14 +1950,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, - ) - }, + _ => (), } } |