Description
The text as https://html.spec.whatwg.org/#sandboxOrigin defines a document's origin in the case that "the Document's URL's scheme is a network scheme" and for data:
schemes, but declines to define behavior for non-network schemes like file:
. Unsurprisingly, different browsers have made different choices here. When a document is loaded from file:///directory/file.html
:
- Edge
- returns
file://
forlocation.origin
(it doesn't yet implementwindow.origin
) - allows DOM access to
file:///directory/other-file.html
,file:///directory/subdirectory/file.html
, andfile:///parent-directory.html
when framed. - shares
localStorage
across allfile:
URLs - times out for reasons I can't figure out when
fetch()
is called onfile:
URLs.
- returns
- Firefox
- returns
null
forwindow.origin
- allows DOM access to both
file:///directory/other-file.html
andfile:///directory/subdirectory/file.html
, and disallows DOM access tofile:///parent-directory.html
when framed. localStorage
seems scoped to the same-or-sub directory as well.- allows
fetch()
to access content fromfile:///directory/other-file.html
andfile:///directory/subdirectory/file.html
, and returns a network error when fetching fromfile:///parent-directory.html
- returns
- Safari
- returns
null
forwindow.origin
- opens Finder windows rather than framing
file:///directory/other-file.html
,file:///directory/subdirectory/file.html
, andfile:///parent-directory.html
(that is,<iframe src="file:///whatever/directory/file.html"></iframe>
stays inabout:blank
and pops a Finder window to/whatever/directory/
) - blocks
localStorage
for allfile:
URLs - returns a network error when calling
fetch()
onfile:///directory/other-file.html
,file:///directory/subdirectory/file.html
, andfile:///parent-directory.html
.
- returns
- Chrome
- returns
null
forwindow.origin
- disallows DOM access to
file:///directory/other-file.html
,file:///directory/subdirectory/file.html
, andfile:///parent-directory.html
when framed. - shares
localStorage
across allfile:
URLs - returns a network error when calling
fetch()
onfile:///directory/other-file.html
,file:///directory/subdirectory/file.html
, andfile:///parent-directory.html
.
- returns
I wonder if we could get more alignment if we talked about it a bit. There seems to be general agreement that the page should have an opaque origin, but a little bit of disagreement about what that should mean. I'd kinda like to keep Chrome's behavior for DOM access and Fetch, for instance, as it protects against scanning the entire disk or a user's downloads directory. I'm less enthusiastic about Chrome's localStorage
behavior. I'd prefer Safari's, I think, but could live with something less draconian if there's good reason to.
@annevk, @travisleithead, @johnwilander: Would y'all mind looping in relevant folks (or having opinions yourselves? :) )?