Closed
Bug 953302
Opened 12 years ago
Closed 12 years ago
DOM binding creator method's constructor name is empty
Categories
(Core :: DOM: Core & HTML, defect)
Tracking
()
RESOLVED
DUPLICATE
of bug 1084001
People
(Reporter: stuartmemo, Unassigned)
Details
User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.5 Safari/537.36
Steps to reproduce:
Create a new AudioContext and print its constructor name.
var context = new AudioContext();
console.log(context.constructor.name);
Actual results:
Constructor name is empty string "".
Expected results:
Constructor name should be "AudioContext".
| Reporter | ||
Comment 1•12 years ago
|
||
This also appears to be the case for nodes as well...
var context = new webkitAudioContext();
var osc = context.createOscillator();
console.log(osc.constructor.name); // Should return "OscillatorNode", instead returns "".
Comment 2•12 years ago
|
||
This is also the case with the result of document.createRange(), so passing over to the DOM bindings people.
Component: Web Audio → DOM
Updated•12 years ago
|
Summary: AudioContext constructor name is empty → DOM binding creator method's constructor name is empty
Comment 3•12 years ago
|
||
http://people.mozilla.org/~jorendorff/es6-draft.html#sec-properties-of-the-function-prototype-object defines that Function.prototype.name must be the empty string, and nothing in http://heycam.github.io/webidl/ overrides that, AFAICT. What makes you think anything else should happen?
Comment 4•12 years ago
|
||
Probably the fact that in Chrome the interface object's .name is generally the interface name (as is the .name of a [NamedConstructor]). But yes, that seems to be a violation of the specs as written.
| Reporter | ||
Comment 5•12 years ago
|
||
Yeah, exactly. Web Audio JS code I had didn't work in Firefox and this was the problem. Looks like I wrongly assumed that Chrome's behaviour was correct. Sorry!
Comment 6•12 years ago
|
||
So I tested what various UAs do with Node.name and .name on random functions (see http://jsfiddle.net/AmP9f/1/ for the testcase). The results for Node:
Chrome: "Node"
Safari: undefined
Opera: "Function.prototype"
IE11: undefined
Firefox: ""
whereas for (function foo() {}) the results are:
Chrome: "foo"
Safari: "foo"
Opera: "foo"
IE11: undefined
Firefox: "foo"
So it looks like IE just has no support for .name at all, while Safari doesn't have such a property in interface objects (e.g. "name" in Node is false in Safari). Opera just does something weird with interface objects there, while we're following the spec as written.
Given the UA behaviors here, there doesn't seem to be much reason to change the spec, but if you think it should change, please mail public-script-coord@w3.org
Status: UNCONFIRMED → RESOLVED
Closed: 12 years ago
Resolution: --- → INVALID
Updated•12 years ago
|
Flags: needinfo?(Ms2ger)
Flags: in-testsuite?
Comment 7•12 years ago
|
||
(In reply to Vacation Dec 19 to Jan 1 from comment #6)
> Firefox: ""
...
> So it looks like IE just has no support for .name at all, while Safari
> doesn't have such a property in interface objects (e.g. "name" in Node is
> false in Safari). Opera just does something weird with interface objects
> there, while we're following the spec as written.
So I can't actually find where in the Web IDL spec a particular "name" property is required on an interface object. There is one for exception interface objects, where it's set to the identifier of the exception, but not for interface objects. I think I must have overlooked this, unless I just can't find it now.
> Given the UA behaviors here, there doesn't seem to be much reason to change
> the spec, but if you think it should change, please mail
> public-script-coord@w3.org
I'm wondering if we should make it be "Node" in this case, since that's what you'd get on the function object from writing |class Node { ... }| in ES6.
Comment 8•12 years ago
|
||
Cameron, right now WebIDL doesn't define a particular "name" property, which means they just inherit the one from the proto, since in ES6 functions have no own "name" property by default unless SetFunctionName happens.
But you're right that an ES6 class would pick up the class name as the .name. So maybe we should do that in WebIDL too. What about named constructors?
| Assignee | ||
Updated•7 years ago
|
Component: DOM → DOM: Core & HTML
Comment 9•2 years ago
|
||
This was changed in https://github.com/whatwg/webidl/pull/23 and tested in https://github.com/w3c/testharness.js/pull/166
Duplicate of bug: 1084001
Flags: needinfo?(Ms2ger)
Flags: in-testsuite?
Flags: in-testsuite+
Resolution: INVALID → DUPLICATE
You need to log in
before you can comment on or make changes to this bug.
Description
•