Open Bug 903572 Opened 11 years ago Updated 2 years ago

Align the supported property names on the gsp and Document with the spec

Categories

(Core :: DOM: Core & HTML, defect, P5)

x86
macOS
defect

Tracking

()

People

(Reporter: bzbarsky, Unassigned)

References

(Blocks 1 open bug)

Details

Right now the gsp includes all of the document names plus named windows, which isn't actually right as the spec is currently written. On the other hand, do we think the spec should change?
Flags: needinfo?(peterv)
Blocks: 1010241
https://bugzilla.mozilla.org/show_bug.cgi?id=1472046 Move all DOM bugs that haven't been updated in more than 3 years and has no one currently assigned to P5. If you have questions, please contact :mdaly.
Priority: -- → P5
Component: DOM → DOM: Core & HTML

(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?

Flags: needinfo?(peterv) → needinfo?(bzbarsky)

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 nonempty name 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.

Flags: needinfo?(bzbarsky) → needinfo?(peterv)

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...

That said, there's a definite spec issue here around non-HTML documents. I filed https://github.com/whatwg/html/issues/5157 on that.

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 :-).

Flags: needinfo?(peterv)

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...

Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.