Auto merge of #6131 - glennw:jquery-exit-fix, r=jdm

This fixes a hang found while testing the jQuery test suite.

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/6131)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2015-05-19 21:44:45 -05:00
commit c51e9f0455
7 changed files with 74 additions and 21 deletions

View file

@ -584,6 +584,17 @@ impl<'a> WindowHelpers for JSRef<'a, Window> {
let document = self.Document().root();
NodeCast::from_ref(document.r()).teardown();
// The above code may not catch all DOM objects
// (e.g. DOM objects removed from the tree that haven't
// been collected yet). Forcing a GC here means that
// those DOM objects will be able to call dispose()
// to free their layout data before the layout task
// exits. Without this, those remaining objects try to
// send a message to free their layout data to the
// layout task when the script task is dropped,
// which causes a panic!
self.Gc();
*self.js_runtime.borrow_mut() = None;
*self.browser_context.borrow_mut() = None;
}