Skip to content

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

Merged
bors-servo merged 1 commit intoservo:masterfrom
asajeffrey:script-iframe-check-document-browsing-context
Nov 3, 2016
Merged

Check that an iframe is in a document with a browsing context before processing src#13965
bors-servo merged 1 commit intoservo:masterfrom
asajeffrey:script-iframe-check-document-browsing-context

Conversation

@asajeffrey
Copy link
Copy Markdown
Contributor

@asajeffrey asajeffrey commented Oct 28, 2016

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



This change is Reviewable

@asajeffrey asajeffrey added the A-content/script Related to the script thread label Oct 28, 2016
@highfive
Copy link
Copy Markdown

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
Copy Markdown

warning Warning warning

  • These commits modify script code, but no tests are modified. Please consider adding a test!

@highfive highfive added the S-awaiting-review There is new code that needs to be reviewed. label Oct 28, 2016
@asajeffrey
Copy link
Copy Markdown
Contributor Author

cc @Ms2ger

Copy link
Copy Markdown
Contributor

@Ms2ger Ms2ger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

r? @Ms2ger

}

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This duplicates is_in_doc() very slowly; please remove.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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()
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same problem.

@Ms2ger Ms2ger assigned Ms2ger and unassigned mbrubeck Oct 31, 2016
@jdm jdm added S-needs-code-changes Changes have not yet been made that were requested by a reviewer. and removed S-awaiting-review There is new code that needs to be reviewed. labels Oct 31, 2016
@asajeffrey
Copy link
Copy Markdown
Contributor Author

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

@Ms2ger
Copy link
Copy Markdown
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
Copy Markdown
Contributor

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
Copy Markdown
Contributor Author

OK, I'll go and check.

@asajeffrey
Copy link
Copy Markdown
Contributor Author

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
Copy Markdown
Contributor Author

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.

@highfive highfive added S-awaiting-review There is new code that needs to be reviewed. and removed S-needs-code-changes Changes have not yet been made that were requested by a reviewer. labels Nov 2, 2016
@asajeffrey asajeffrey added the S-needs-squash Some (or all) of the commits in the PR should be combined. label Nov 3, 2016

pub fn is_in_html_doc(&self) -> bool {
self.owner_doc().is_html_document()
self.is_in_doc() && self.owner_doc().is_html_document()
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

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

Ms2ger commented Nov 3, 2016

r=me if you squash all commits

@asajeffrey asajeffrey force-pushed the script-iframe-check-document-browsing-context branch from 5ea60c0 to 330953a Compare November 3, 2016 15:06
@asajeffrey
Copy link
Copy Markdown
Contributor Author

@Ms2ger thanks! @bors-servo r=Ms2ger

@bors-servo
Copy link
Copy Markdown
Contributor

📌 Commit 330953a has been approved by Ms2ger

@highfive highfive removed S-awaiting-review There is new code that needs to be reviewed. S-needs-squash Some (or all) of the commits in the PR should be combined. labels Nov 3, 2016
@highfive highfive added the S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. label Nov 3, 2016
@bors-servo
Copy link
Copy Markdown
Contributor

⌛ Testing commit 330953a with merge 06e3ed9...

bors-servo pushed 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
Copy Markdown
Contributor

@bors-servo clean force retry

@asajeffrey asajeffrey force-pushed the script-iframe-check-document-browsing-context branch from 330953a to 1803a58 Compare November 3, 2016 17:51
@highfive highfive added S-awaiting-review There is new code that needs to be reviewed. and removed S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. labels Nov 3, 2016
@asajeffrey
Copy link
Copy Markdown
Contributor Author

Rebased to unstick homu.

@KiChjang
Copy link
Copy Markdown
Contributor

KiChjang commented Nov 3, 2016

@bors-servo r=Ms2ger

@bors-servo
Copy link
Copy Markdown
Contributor

📌 Commit 1803a58 has been approved by Ms2ger

@highfive highfive added S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. and removed S-awaiting-review There is new code that needs to be reviewed. labels Nov 3, 2016
@bors-servo
Copy link
Copy Markdown
Contributor

⌛ Testing commit 1803a58 with merge 4984a83...

bors-servo pushed 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
Copy Markdown
Contributor

@bors-servo bors-servo merged commit 1803a58 into servo:master Nov 3, 2016
@highfive highfive removed the S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. label Nov 3, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-content/script Related to the script thread

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

9 participants