Auto merge of #17323 - ibmandura:issue16057, r=jdm

Avoid panic when reloading a page with mouse event handlers

This PR fixes issue #16057, by nullifying `topmost_mouse_over_target` inside of the `handle_exit_pipeline_msg` method, in case owner document is the same as the pipeline document that is being destroyed.

- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors

Testing was done manually, by running `./mach run (-r|-d) "http://localhost:8000/minimal.html" `, where `minimal.html` contains `<div onmouseover="location.reload()" onmouseout="this.clientLeft">hi there</div>`.

r?@jdm

<!-- 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/17323)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2017-06-15 12:36:19 -07:00 committed by GitHub
commit 0c53ba318a

View file

@ -1650,6 +1650,13 @@ impl ScriptThread {
let load = self.incomplete_loads.borrow_mut().remove(idx);
load.layout_chan.clone()
} else if let Some(document) = self.documents.borrow_mut().remove(id) {
// We don't want to dispatch `mouseout` event pointing to non-existing element
if let Some(target) = self.topmost_mouse_over_target.get() {
if target.upcast::<Node>().owner_doc() == document {
self.topmost_mouse_over_target.set(None);
}
}
let window = document.window();
if discard_bc == DiscardBrowsingContext::Yes {
window.window_proxy().discard_browsing_context();