Auto merge of #17527 - cbrewster:iframe_cycles, r=asajeffrey

Don't return window proxy if it has been discarded

<!-- 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 #17479 (github issue number if applicable).

<!-- Either: -->
- [x] There are tests for these changes OR
- [ ] These changes do not require tests because _____

<!-- 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/17527)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2017-06-28 01:59:16 -07:00 committed by GitHub
commit 51dd0c65cd
3 changed files with 11 additions and 16 deletions

View file

@ -406,7 +406,7 @@ impl Document {
#[inline]
pub fn browsing_context(&self) -> Option<Root<WindowProxy>> {
if self.has_browsing_context {
self.window.maybe_window_proxy()
self.window.undiscarded_window_proxy()
} else {
None
}

View file

@ -345,8 +345,15 @@ impl Window {
self.window_proxy.get().unwrap()
}
pub fn maybe_window_proxy(&self) -> Option<Root<WindowProxy>> {
/// Returns the window proxy if it has not been discarded.
/// https://html.spec.whatwg.org/multipage/#a-browsing-context-is-discarded
pub fn undiscarded_window_proxy(&self) -> Option<Root<WindowProxy>> {
self.window_proxy.get()
.and_then(|window_proxy| if window_proxy.is_browsing_context_discarded() {
None
} else {
Some(window_proxy)
})
}
pub fn bluetooth_thread(&self) -> IpcSender<BluetoothRequest> {
@ -670,13 +677,10 @@ impl WindowMethods for Window {
// https://html.spec.whatwg.org/multipage/#dom-parent
fn GetParent(&self) -> Option<Root<WindowProxy>> {
// Steps 1-3.
let window_proxy = match self.maybe_window_proxy() {
let window_proxy = match self.undiscarded_window_proxy() {
Some(window_proxy) => window_proxy,
None => return None,
};
if window_proxy.is_browsing_context_discarded() {
return None;
}
// Step 4.
if let Some(parent) = window_proxy.parent() {
return Some(Root::from_ref(parent));
@ -688,13 +692,10 @@ impl WindowMethods for Window {
// https://html.spec.whatwg.org/multipage/#dom-top
fn GetTop(&self) -> Option<Root<WindowProxy>> {
// Steps 1-3.
let window_proxy = match self.maybe_window_proxy() {
let window_proxy = match self.undiscarded_window_proxy() {
Some(window_proxy) => window_proxy,
None => return None,
};
if window_proxy.is_browsing_context_discarded() {
return None;
}
// Steps 4-5.
Some(Root::from_ref(window_proxy.top()))
}

View file

@ -1,6 +0,0 @@
[iframe-append-to-child-document.html]
type: testharness
[Append iframe element to its own child document]
bug: https://github.com/servo/servo/issues/17479
expected: FAIL