Auto merge of #26499 - utsavoza:ugo/issue-26287/10-05-2020, r=jdm

Add creator URL, creator base URL and creator origin to browsing context

- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors
- [x] These changes fix #24944 and fix (partially) #26287
- [x] There are tests for these changes
This commit is contained in:
bors-servo 2020-05-19 12:45:11 -04:00 committed by GitHub
commit cab9104d92
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
26 changed files with 216 additions and 107 deletions

View file

@ -683,10 +683,25 @@ impl Document {
// https://html.spec.whatwg.org/multipage/#fallback-base-url
pub fn fallback_base_url(&self) -> ServoUrl {
// Step 1: iframe srcdoc (#4767).
// Step 2: about:blank with a creator browsing context.
// Step 3.
self.url()
let document_url = self.url();
if let Some(browsing_context) = self.browsing_context() {
// Step 1: If document is an iframe srcdoc document, then return the
// document base URL of document's browsing context's container document.
let container_base_url = browsing_context
.parent()
.and_then(|parent| parent.document())
.map(|document| document.base_url());
if document_url.as_str() == "about:srcdoc" && container_base_url.is_some() {
return container_base_url.unwrap();
}
// Step 2: If document's URL is about:blank, and document's browsing
// context's creator base URL is non-null, then return that creator base URL.
if document_url.as_str() == "about:blank" && browsing_context.has_creator_base_url() {
return browsing_context.creator_base_url().unwrap();
}
}
// Step 3: Return document's URL.
document_url
}
// https://html.spec.whatwg.org/multipage/#document-base-url