Align the supported property names on the gsp and Document with the spec
Categories
(Core :: DOM: Core & HTML, defect, P5)
Tracking
()
People
(Reporter: bzbarsky, Unassigned)
References
(Blocks 1 open bug)
Details
Comment 1•7 years ago
|
||
Assignee | ||
Updated•6 years ago
|
Comment 2•5 years ago
|
||
(In reply to Boris Zbarsky [:bzbarsky, bz on IRC] from comment #0)
On the other hand, do we think the spec should change?
There seems to be a test for this (https://searchfox.org/mozilla-central/rev/690e903ef689a4eca335b96bd903580394864a1c/testing/web-platform/tests/html/browsers/the-window-object/named-access-on-the-window-object/window-named-properties.html#71) which Firefox, Safari and Chrome all pass, so it might be a good idea. Boris, do you happen to know if there's an existing spec bug for this?
Reporter | ||
Comment 3•5 years ago
|
||
Hmm. I'm not aware of spec bugs on this offhand. That said, the test comment 2 links to is not the sort of thing I am talking about. That test sets window.name
, which per spec sets the browsing context's name. So it would show up in the list of names on the window, per spec, and does in browsers.
The issue this bug is about is as follows (though the spec has changed some here in the last 6 years). The set of names defined on documents in the spec is:
- The name attribute for exposed embed, exposed object, form, iframe, img elements that have a nonempty
name
attribute. - The id attribute for exposed object elements that have a nonempty
id
attribute. - The id attribute for img elements that have a nonempty
id
attribute and also have a nonemptyname
attribute.
That's what nsHTMLDocument
implements, kinda, except we don't include <iframe>
and we don't do the "exposed" checks on <object>
and <embed>
.
The set of names defined on the named properties object in the spec is:
- Names of child browsing contexts.
- The name attribute of embed, form, frameset, img, object elements that have a nonempty
name
. - The id attribute of elements that have a nonempty
id
.
This both includes things the document case does not (includes unexposed embed and object, includes frameset) and excludes things the document case includes (exludes iframe names if those don't match the name of the browsing context inside). Our implementation just delegates all the name
attribute handling to the document, which means it looks nothing like the spec. The question is whether the spec could be changed to align things a bit better or whether we should just bite the bullet and implement the additional complexity here.
Reporter | ||
Comment 4•5 years ago
|
||
Though given that Chrome and Safari seem to implement the spec at least around iframe, per this testcase:
<!doctype html>
<iframe name="foo" srcdoc="<script>window.name = 'bar'</script>"></iframe>
<script>
onload = () => {
console.log(document.foo);
console.log(document.bar);
console.log(window.foo);
console.log(window.bar);
}
</script>
it might be hard to convince both the spec and them to change...
Reporter | ||
Comment 5•5 years ago
|
||
That said, there's a definite spec issue here around non-HTML documents. I filed https://github.com/whatwg/html/issues/5157 on that.
Comment 6•5 years ago
|
||
Ah, then it's actually https://searchfox.org/mozilla-central/source/testing/web-platform/tests/html/browsers/the-window-object/named-access-on-the-window-object/named-objects.html It doesn't cover everything, I'll see if I can add more. We're currently failing one test in it, which seems low :-).
Reporter | ||
Comment 7•5 years ago
|
||
Awesome, thank you!
I'd hope there's a test for the named getter on document too, but don't know what it is offhand. I guess we could do a try run with that named getter purposefully broken and see what fails...
Updated•2 years ago
|
Description
•