Closed Bug 789022 Opened 8 years ago Closed 8 years ago

Interface object's prototype should be Function.prototype, not Object.prototype

Categories

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

defect
Not set
minor

Tracking

()

RESOLVED FIXED

People

(Reporter: ayg, Unassigned)

References

Details

See W3C bug:

https://www.w3.org/Bugs/Public/show_bug.cgi?id=14813

Test-case:

data:text/html,<!doctype html>
<script>
document.documentElement.textContent =
Function.prototype.isPrototypeOf(NodeList)
+ " " +
Object.prototype.isPrototypeOf(NodeList);
</script>

IE10 Developer Preview, recent Firefox nightly, and Chrome 22 dev all output "false true".  (Opera 12.50 outputs "true true", which is . . . creative.)  The spec says it should be "true false".  We should either change to match the spec, or reopen the aforesaid W3C bug and ask for the spec to change.

This is tested by:

http://w3c-test.org/webapps/DOMCore/tests/approved/interfaces.html

which we have imported as dom/imptests/webapps/DOMCore/tests/approved/test_interfaces.html, so in principle no new test should be needed (unless a different assert causes the same test to fail currently).
See comments in bug 789020.  Again, the switch to WebIDL bindings will fix it.
Just to clarify: smaug told me to submit bugs any bugs I found on NodeList just in case they were fixed in the new new (Paris) bindings, because NodeList uses the old new bindings.  If this issue is fixed in the Paris bindings, the bug may as well be duped.

Do the patches from bug 788532 work well enough that I can apply them locally and check how we do on IDL tests after they're applied?  Or should I not bother filing any bugs on this kind of thing for now, and test other things?
Oh, I wasn't saying you shouldn't file the bugs.  Just saying we do have a plan to fix.  We should retest this once that plan lands.

The patches in bug 788532 don't flip the switch yet, so testing with them won't get you very far at the moment, unfortunately.

In terms of things to test, it'd be nice to come up with tests for the bits of IDL functionality that we don't already test in the idlharness (e.g. overload stuff).
Depends on: 788532
Depends on: 791774
With the checkin for bug 791774 we now return "true true", like Opera.  This is the correct behavior per spec. isPrototypeOf checks everything in the proto chain, not just the immediate proto.

If you wanted to test the immediate proto, you should have done:

data:text/html,<!doctype html>
<script>
document.documentElement.textContent =
(Object.getPrototypeOf(NodeList) == Function.prototype)
+ " " +
(Object.getPrototypeOf(NodeList) == Object.prototype);
</script>

which does output "true false".

Luckily, test_interfaces does not in fact test for "true false" in the scenario described in comment 0.  ;)

Fixed by bug 791774.
Status: NEW → RESOLVED
Closed: 8 years ago
Flags: in-testsuite+
Resolution: --- → FIXED
Yeah, because I figured out what isPrototypeOf() actually did a couple of weeks ago and updated it to use getPrototypeOf() instead.  :)  (It still didn't ever check that the prototype was *not* Object, so the actual test wasn't actually wrong before, just imprecise.)
Component: DOM → DOM: Core & HTML
You need to log in before you can comment on or make changes to this bug.