whatwg / html

HTML Standard
https://html.spec.whatwg.org/multipage/
Other
8.05k stars 2.64k forks source link

"appropriate template contents owner document" does not define its origin #2109

Open Ms2ger opened 7 years ago

Ms2ger commented 7 years ago

https://html.spec.whatwg.org/multipage/scripting.html#appropriate-template-contents-owner-document

zcorpan commented 7 years ago

It's defined to be an opaque origin, AFAICT

https://dom.spec.whatwg.org/#concept-document-origin

But is should be the template element's node document's origin, right?

annevk commented 7 years ago

It seems like it also inherits URL in Gecko, but not in Chrome. This actually results in URL parsing differences for descendants.

Encoding and mode do not get copied in either.

Agreed that it should just be the origin of doc in the algorithm that creates this document.

annevk commented 7 years ago

I'm not sure how we can actually test it's the identical origin though. We can test the serialization, but not really the document.domain implications I think.

We might also want to test the "cookie URL" thing (not yet properly defined).

annevk commented 7 years ago

Chrome does actually put the document in an opaque origin. document.origin returns "null" there.

annevk commented 7 years ago

I don't think that necessarily affects anything so that might be okay to do.

annevk commented 7 years ago

Based on my test, making origin an opaque origin and making document.domain fail don't seem such bad options. That's more or less what Chrome does already and pretty close to Safari.

Safari returns "http_www.web-platform.test_8000" for document.origin which seems super weird. @cdumez?

Who has opinions here on behalf of Gecko? @smaug----?

smaug---- commented 7 years ago

So Chrome inherits domain and origin from creator when doing document.implementation.createHTMLDocument("", "")

Why would template owner document do something else.

Having opaque origin document somewhere in a context where origin isn't opaque feels odd.

annevk commented 7 years ago

@foolip opinions on behalf of Chrome?

foolip commented 7 years ago

Sorry for the delay, but I'll have to defer to @dominiccooney, I know next to nothing about the template element.

nox commented 6 years ago

Any news on that? Is this fixed?

annevk commented 6 years ago

No, we still need to define the origin (which affects document.domain's getter). document.origin will be removed hopefully as per https://github.com/whatwg/dom/issues/410.

annevk commented 5 years ago

https://bugzilla.mozilla.org/show_bug.cgi?id=1507849 suggests contentType and the type internal slot (HTML vs XML) also need testing.