Skip to content

Document fallback base URL should not rely on parent browsing context #37775

@jdm

Description

@jdm

https://html.spec.whatwg.org/multipage/urls-and-fetching.html#fallback-base-url describes how to use an initialized about base URL. Our current implementation relies on synchronously querying the parent, which is broken in our current implementation when the iframe is sandboxed.

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" {
if let Some(base_url) = container_base_url {
return base_url;
}
}
// 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();

Tests: ./mach test-wpt tests/wpt/tests/html/infrastructure/urls/terminology-0/document-base-url-about-srcdoc.https.window.html

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-content/domInteracting with the DOM from web content

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions