[whatwg] Question on iframe.srcdoc address (about:srcdoc)

Tab Atkins Jr. jackalmage at gmail.com
Tue Aug 10 10:30:33 PDT 2010


On Mon, Aug 9, 2010 at 6:39 PM, Justin Schuh <jschuh at chromium.org> wrote:
> I'm working on implementing iframe.srcdoc in WebKit, and section 2.5.1
> states:
>
> "This specification defines the URL about:srcdoc as a reserved, though
> unresolvable, about: URI, that is used as the document's address of iframe
> srcdoc documents."
>
> It seems like it would make more sense for the address to be the data URL of
> the frame's document. This would be easier to implement in WebKit, and I
> expect other data URL supporting browsers as well. Is there some reasoning
> I'm missing for the decision to use about:srcdoc?

A few (not necessarily valid) reasons I can think of off the top of my head:

1. data: urls are unique-origin automatically, and there's no special
handling of that wrt sandbox=allow-same-origin (that is, the flag does
nothing, because the url isn't same-origin to begin with).  @srcdoc,
on the other hand, should be same-origin by default (though behind a
sandbox, and thus *treated* as unique-origin unless the
allow-same-origin flag is set).  Thus, roundtripping the url back into
@src would produce a document with different behavior.

2. @srcdoc doesn't require a doctype for its document, but data: urls
need them or else they can trip into quirks mode.  Again,
roundtripping behavior becomes inconsistent (unless you detect for
no-doctype and add it to the data: url automatically).

~TJ



More information about the whatwg mailing list