Closed Bug 791225 Opened 12 years ago Closed 12 years ago

Interface object should probably stringify to "function Name() { [native code] }", not "[object Name]"

Categories

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

defect
Not set
minor

Tracking

()

RESOLVED WORKSFORME

People

(Reporter: ayg, Unassigned)

References

(Depends on 1 open bug)

Details

Test-case:

data:text/html,<!doctype html>
<script>
document.documentElement.textContent = NodeList;
</script>

IE 10 Developer Preview, recent-ish Firefox nightly: [object NodeList]
Recent-ish Chrome dev, Opera 12.50 internal: function NodeList() { [native code] }

"The interface object for a given non-callback interface is a function object."
http://dev.w3.org/2006/webapi/WebIDL/#interface-object

"""
If an object is defined to be a function object, then it has characteristics as follows:

. . .

Its [[NativeBrand]] internal property is “Function”.
"""
http://dev.w3.org/2006/webapi/WebIDL/#dfn-function-object

I don't think this is actually correct; it should maybe be "NativeFunction":

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

If that were the case, the stringification per current ES6 draft would be "[object Function]", but it seems like all browsers actually stringify native functions as "function foo() { [native code] }", so I think the WebKit/Opera behavior is what's really intended.

CCing heycam in case he has anything to add here, since I'm not totally sure what the intent is.
Fixed in Paris bindings.  Try it with XMLHttpRequest.  ;)
Depends on: ParisBindings
(In reply to :Aryeh Gregor from comment #0)
> If that were the case, the stringification per current ES6 draft would be
> "[object Function]", but it seems like all browsers actually stringify
> native functions as "function foo() { [native code] }", so I think the
> WebKit/Opera behavior is what's really intended.

I was confused -- we deliberately only test {}.toString, not String() on the thing itself, because the latter is undefined (sigh).  It all seems to work as expected with XHR.
Status: NEW → RESOLVED
Closed: 12 years ago
Resolution: --- → WORKSFORME
Component: DOM → DOM: Core & HTML
You need to log in before you can comment on or make changes to this bug.