aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/htmliframeelement.rs
diff options
context:
space:
mode:
authorPatrick Shaughnessy <pshaughn@comcast.net>2020-01-31 15:26:12 -0500
committerPatrick Shaughnessy <pshaughn@comcast.net>2020-02-12 16:22:27 -0500
commit89384ffec35529571be41882d77d4b0438c1f8b9 (patch)
treeb80469994aab58d77467c41c0548cf6e87b9a817 /components/script/dom/htmliframeelement.rs
parented9b5843443db7164bda6eb6f3cb7caff2ff5a3c (diff)
downloadservo-89384ffec35529571be41882d77d4b0438c1f8b9.tar.gz
servo-89384ffec35529571be41882d77d4b0438c1f8b9.zip
Iframes can't include an ancestor they know about
Diffstat (limited to 'components/script/dom/htmliframeelement.rs')
-rw-r--r--components/script/dom/htmliframeelement.rs25
1 files changed, 24 insertions, 1 deletions
diff --git a/components/script/dom/htmliframeelement.rs b/components/script/dom/htmliframeelement.rs
index b70663a6949..4f5108572e0 100644
--- a/components/script/dom/htmliframeelement.rs
+++ b/components/script/dom/htmliframeelement.rs
@@ -287,7 +287,30 @@ impl HTMLIFrameElement {
let url = self.get_url();
- // TODO: check ancestor browsing contexts for same URL
+ // TODO(#25748):
+ // By spec, we return early if there's an ancestor browsing context
+ // "whose active document's url, ignoring fragments, is equal".
+ // However, asking about ancestor browsing contexts is more nuanced than
+ // it sounds and not implemented here.
+ // Within a single origin, we can do it by walking window proxies,
+ // and this check covers only that single-origin case, protecting
+ // against simple typo self-includes but nothing more elaborate.
+ let mut ancestor = window.GetParent();
+ while let Some(a) = ancestor {
+ if let Some(ancestor_url) = a.document().map(|d| d.url()) {
+ if ancestor_url.scheme() == url.scheme() &&
+ ancestor_url.username() == url.username() &&
+ ancestor_url.password() == url.password() &&
+ ancestor_url.host() == url.host() &&
+ ancestor_url.port() == url.port() &&
+ ancestor_url.path() == url.path() &&
+ ancestor_url.query() == url.query()
+ {
+ return;
+ }
+ }
+ ancestor = a.parent().map(|p| DomRoot::from_ref(p));
+ }
let creator_pipeline_id = if url.as_str() == "about:blank" {
Some(window.upcast::<GlobalScope>().pipeline_id())