Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check that an iframe is in a document with a browsing context before processing src #13965

Conversation

@asajeffrey
Copy link
Member

asajeffrey commented Oct 28, 2016

Check that an iframe is in a document with a browsing context before processing src.



This change is Reviewable

@highfive
Copy link

highfive commented Oct 28, 2016

Heads up! This PR modifies the following files:

  • @fitzgen: components/script/dom/htmliframeelement.rs, components/script/dom/node.rs
  • @KiChjang: components/script/dom/htmliframeelement.rs, components/script/dom/node.rs
@highfive
Copy link

highfive commented Oct 28, 2016

warning Warning warning

  • These commits modify script code, but no tests are modified. Please consider adding a test!
@asajeffrey
Copy link
Member Author

asajeffrey commented Oct 28, 2016

cc @Ms2ger

@asajeffrey asajeffrey mentioned this pull request Oct 28, 2016
3 of 3 tasks complete
Copy link
Contributor

Ms2ger left a comment

r? @Ms2ger

@@ -771,6 +771,20 @@ impl Node {
self.owner_doc().is_html_document()
}

// https://dom.spec.whatwg.org/#in-a-document-tree
pub fn is_in_a_document_tree(&self) -> bool {

This comment has been minimized.

@Ms2ger

Ms2ger Oct 31, 2016

Contributor

This duplicates is_in_doc() very slowly; please remove.

This comment has been minimized.

@asajeffrey

asajeffrey Oct 31, 2016

Author Member

The problem is that is_in_doc returns true if the node is in a document fragment.

}

pub fn is_in_a_document_tree_with_a_browsing_context(&self) -> bool {
self.inclusive_ancestors().last()

This comment has been minimized.

@Ms2ger

Ms2ger Oct 31, 2016

Contributor

This can be self.is_in_doc() && self.owner_doc().browsing_context().is_some()

This comment has been minimized.

@asajeffrey

asajeffrey Oct 31, 2016

Author Member

Same problem.

@Ms2ger Ms2ger assigned Ms2ger and unassigned mbrubeck Oct 31, 2016
@asajeffrey
Copy link
Member Author

asajeffrey commented Nov 1, 2016

@Ms2ger should I fix is_in_doc so that it returns false when it's in a DocumentFragment?

@Ms2ger
Copy link
Contributor

Ms2ger commented Nov 2, 2016

The problem is that is_in_doc returns true if the node is in a document fragment.

That sounds like a pretty serious bug. Are you sure?

CC @nox.

@nox
Copy link
Member

nox commented Nov 2, 2016

The problem is that is_in_doc returns true if the node is in a document fragment.

That doesn't sound true to me. Where did you find that?

@asajeffrey
Copy link
Member Author

asajeffrey commented Nov 2, 2016

OK, I'll go and check.

@asajeffrey
Copy link
Member Author

asajeffrey commented Nov 2, 2016

Unsurprisingly, you are both right. Hmm. I could have sworn I was getting an error because of this. Oh well, I'll fix this.

@asajeffrey
Copy link
Member Author

asajeffrey commented Nov 2, 2016

I remember what the issue was! It's that owner_doc is Some(document) even when the node is in a document fragment. is_in_doc is fine.

@@ -768,7 +768,11 @@ impl Node {
}

pub fn is_in_html_doc(&self) -> bool {
self.owner_doc().is_html_document()
self.is_in_doc() && self.owner_doc().is_html_document()

This comment has been minimized.

@Ms2ger

Ms2ger Nov 3, 2016

Contributor

Unfortunately this needs to return true if is_in_doc() is false. Maybe you should just inline it into its only caller, to avoid confusion.

This comment has been minimized.

@asajeffrey

asajeffrey Nov 3, 2016

Author Member

Fixed.

@asajeffrey asajeffrey force-pushed the asajeffrey:script-iframe-check-document-browsing-context branch from 75845b2 to 5ea60c0 Nov 3, 2016
@Ms2ger
Copy link
Contributor

Ms2ger commented Nov 3, 2016

r=me if you squash all commits

@Ms2ger
Ms2ger approved these changes Nov 3, 2016
@asajeffrey asajeffrey force-pushed the asajeffrey:script-iframe-check-document-browsing-context branch from 5ea60c0 to 330953a Nov 3, 2016
@asajeffrey
Copy link
Member Author

asajeffrey commented Nov 3, 2016

@Ms2ger thanks! @bors-servo r=Ms2ger

@bors-servo
Copy link
Contributor

bors-servo commented Nov 3, 2016

📌 Commit 330953a has been approved by Ms2ger

@bors-servo
Copy link
Contributor

bors-servo commented Nov 3, 2016

Testing commit 330953a with merge 06e3ed9...

bors-servo added a commit that referenced this pull request Nov 3, 2016
…ng-context, r=Ms2ger

Check that an iframe is in a document with a browsing context before processing src

<!-- Please describe your changes on the following line: -->

Check that an iframe is in a document with a browsing context before processing src.
---

<!-- 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 #13964.
- [X] These changes do not require tests because this is already tested by https://github.com/servo/servo/blob/master/tests/wpt/web-platform-tests/old-tests/submission/Opera/script_scheduling/034.html

<!-- 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/13965)

<!-- Reviewable:end -->
@larsbergstrom
Copy link
Contributor

larsbergstrom commented Nov 3, 2016

@bors-servo clean force retry

@asajeffrey asajeffrey force-pushed the asajeffrey:script-iframe-check-document-browsing-context branch from 330953a to 1803a58 Nov 3, 2016
@asajeffrey
Copy link
Member Author

asajeffrey commented Nov 3, 2016

Rebased to unstick homu.

@KiChjang
Copy link
Member

KiChjang commented Nov 3, 2016

@bors-servo r=Ms2ger

@bors-servo
Copy link
Contributor

bors-servo commented Nov 3, 2016

📌 Commit 1803a58 has been approved by Ms2ger

@bors-servo
Copy link
Contributor

bors-servo commented Nov 3, 2016

Testing commit 1803a58 with merge 4984a83...

bors-servo added a commit that referenced this pull request Nov 3, 2016
…ng-context, r=Ms2ger

Check that an iframe is in a document with a browsing context before processing src

<!-- Please describe your changes on the following line: -->

Check that an iframe is in a document with a browsing context before processing src.
---

<!-- 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 #13964.
- [X] These changes do not require tests because this is already tested by https://github.com/servo/servo/blob/master/tests/wpt/web-platform-tests/old-tests/submission/Opera/script_scheduling/034.html

<!-- 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/13965)

<!-- Reviewable:end -->
@bors-servo
Copy link
Contributor

bors-servo commented Nov 3, 2016

@bors-servo bors-servo merged commit 1803a58 into servo:master Nov 3, 2016
2 of 3 checks passed
2 of 3 checks passed
continuous-integration/appveyor/pr AppVeyor build failed
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
homu Test successful
Details
@bors-servo bors-servo mentioned this pull request Nov 3, 2016
3 of 3 tasks complete
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

9 participants
You can’t perform that action at this time.