Skip to content

Commit

Permalink
Define srcdoc documents as matching about:srcdoc URL
Browse files Browse the repository at this point in the history
Previously, the standard defined "an iframe srcdoc document" as being solely constructed from the contents of an iframe's srcdoc content attribute. However, it is possible to create documents that are not created in such a way, but do have a URL of about:srcdoc (or about:srcdoc#foo), using document.open() and javascript: URL navigation.

Remove the distinction between such nontraditional srcdoc documents and the classic "iframe srcdoc documents" by introducing the "matches about:srcdoc" concept for URLs, and defining "an iframe srcdoc document" as a thin alias over this concept. This proposal was described by #9514 (comment). This matches observed browser behavior, for referrer calculation (the only post-parsing case that is impacted by the "an iframe srcdoc document" concept).

Additionally, this new concept ensures that about:srcdoc#foo documents (e.g., created via history.replaceState(null, '', 'about:srcdoc#foo')) are also counted as normal srcdoc documents.

Fixes #9514.
  • Loading branch information
domfarolino authored Jul 20, 2023
1 parent 3185b37 commit 78496a4
Showing 1 changed file with 25 additions and 2 deletions.
27 changes: 25 additions & 2 deletions source
Original file line number Diff line number Diff line change
Expand Up @@ -6988,6 +6988,8 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
<span>tree order</span>.</p></li>
</ol>

<hr>

<p>A <span>URL</span> <dfn>matches <code>about:blank</code></dfn> if its <span
data-x="concept-url-scheme">scheme</span> is "<code data-x="">about</code>", its <span
data-x="concept-url-path">path</span> contains a single string "<code data-x="">blank</code>", its
Expand All @@ -7000,6 +7002,25 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
record</span> created by <span data-x="URL parser">parsing</span> "<code
data-x="">about:blank?foo#bar</code>" <span>matches <code>about:blank</code></span>.</p>

<p>A <span>URL</span> <dfn>matches <code>about:srcdoc</code></dfn> if its <span
data-x="concept-url-scheme">scheme</span> is "<code data-x="">about</code>", its <span
data-x="concept-url-path">path</span> contains a single string "<code data-x="">srcdoc</code>",
its <span data-x="concept-url-query">query</span> is null, its <span
data-x="concept-url-username">username</span> and <span
data-x="concept-url-password">password</span> are the empty string, and its <span
data-x="concept-url-host">host</span> is null.</p>

<p class="note">The reason that <span>matches <code>about:srcdoc</code></span> ensures that the
<span>URL</span>'s <span data-x="concept-url-query">query</span> is null is because it is not
possible to create <span data-x="an iframe srcdoc document">an <code>iframe</code> <code
data-x="attr-iframe-srcdoc">srcdoc</code> document</span> whose <span
data-x="concept-document-url">URL</span> has a non-null <span
data-x="concept-url-query">query</span>, unlike <code>Document</code>s whose <span
data-x="concept-document-url">URL</span> <span>matches <code>about:blank</code></span>. In other
words, the set of all <span>URL</span>s that <span data-x="matches about:srcdoc">match
<code>about:srcdoc</code></span> only vary in their <span
data-x="concept-url-fragment">fragment</span>.</p>


<div w-nodev>

Expand Down Expand Up @@ -32541,8 +32562,10 @@ interface <dfn interface>HTMLIFrameElement</dfn> : <span>HTMLElement</span> {

<p>The <dfn for="iframe" element-attr><code data-x="attr-iframe-srcdoc">srcdoc</code></dfn>
attribute gives the content of the page that the element's <span>content navigable</span> is to
contain. The value of the attribute is the source of <dfn export>an <code>iframe</code> <code
data-x="attr-iframe-srcdoc">srcdoc</code> document</dfn>.</p>
contain. The value of the attribute is used to <span data-x="create navigation params from a
srcdoc resource">construct</span> <dfn export>an <code>iframe</code> <code
data-x="attr-iframe-srcdoc">srcdoc</code> document</dfn>, which is a <code>Document</code> whose
<span data-x="concept-document-url">URL</span> <span>matches <code>about:srcdoc</code></span>.</p>

<p>The <code data-x="attr-iframe-srcdoc">srcdoc</code> attribute, if present, must have a value
using <span>the HTML syntax</span> that consists of the following syntactic components, in the
Expand Down

0 comments on commit 78496a4

Please sign in to comment.