Skip to content

Fallback base URL for detached IFRAME documents #2883

@tkent-google

Description

@tkent-google

WPT: http://w3c-test.org/html/infrastructure/urls/terminology-0/document-base-url.html
Specification: https://html.spec.whatwg.org/multipage/urls-and-fetching.html#fallback-base-url

  1. If document is an iframe srcdoc document, then return the document base URL of document's browsing context's browsing context container's node document.

A srcdoc document can loose its browsing context. The paragraph doesn't define a behavior in such case.

<script>
function showBase() {
  var doc = document.querySelector('iframe').contentDocument;
  document.querySelector('iframe').remove();
  alert(doc.baseURI);
}
</script>
<body onload="showBase()">
<iframe srcdoc="foo"></iframe>

Chrome, Edge, and Safari show the main document URL as doc.baseURI, and Firefox shows "about:srcdoc".

Same for step 2.

  1. If document's URL is about:blank, and document's browsing context has a creator browsing context, then return the creator base URL.
<script>
function showBase() {
  var doc = document.querySelector('iframe').contentDocument;
  document.querySelector('iframe').remove();
  alert(doc.baseURI);
}
</script>
<body onload="showBase()">
<iframe></iframe>

Chrome Stable and Safari show "about:blank". Edge, Firefox, and Chrome Canary show the main document URL.

They are edge-cases, and I don't think such documents are practically useful. IMO, adding phrases like "If the document has a browsing context, " would be acceptable.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions