Bug 68002
Summary: | Some interface attributes do not appear on the prototype as required by WebIDL | ||
---|---|---|---|
Product: | WebKit | Reporter: | Joel Martin <webkit> |
Component: | WebCore JavaScript | Assignee: | Nobody <webkit-unassigned> |
Status: | RESOLVED DUPLICATE | ||
Severity: | Normal | CC: | andyearnshaw, ap, haraken, sam, yutak, zcorpan |
Priority: | P2 | ||
Version: | 528+ (Nightly build) | ||
Hardware: | All | ||
OS: | All | ||
URL: | http://dev.w3.org/2006/webapi/WebIDL/#es-attributes | ||
Bug Depends on: | |||
Bug Blocks: | 67335 |
Joel Martin
I was attempting to object detect support for binary type support in the WebSocket object and discovered that the binaryType attribute is not visible in the prototype (https://bugs.webkit.org/show_bug.cgi?id=67335#add_comment). For WebSocket object detection this is a blocking issue because instantiating the object triggers a network connection (even if you immediately call close() and null the websocket object in the same execution context).
However, it seems like a more general issue of efficiency (object detection without needing instantiantion) and also of compliance with the WebIDL definition of attributes: http://dev.w3.org/2006/webapi/WebIDL/#es-attributes:
"For each attribute defined on the interface, there must exist a corresponding property. If the attribute was declared with the [Unforgeable] extended attribute, then the property exists on every object that implements the interface. Otherwise, it exists on the interface’s interface prototype object."
I'm not sure how widely this problem exists Chrome, but at least for WebSocket attributes, firefox and opera are correct and have the attributes names visible on the prototype.
Attachments | ||
---|---|---|
Add attachment proposed patch, testcase, etc. |
Simon Pieters (:zcorpan)
I don't have "canconfirm" permission but I can nonetheless confirm that WebKit violates the spec here.
Yuta Kitamura
For example, what should happen if you call "WebSocket.prototype.readyState" without creating a WebSocket instance?
Firefox Aurora raises a cryptic exception, which actually made me get surprised.
> MozWebSocket.prototype.readyState
[Exception... "Illegal operation on WrappedNative prototype object" nsresult: "0x8057000c (NS_ERROR_XPC_BAD_OP_ON_WN_PROTO)" location: "JS frame :: Web Console :: <TOP_LEVEL> :: line 1" data: no]
Does this match what the spec expects?
Yuta Kitamura
Pasting Sam's comment at https://bugs.webkit.org/show_bug.cgi?id=67335#c10 for the record
> For the record, it is currently our intention to eventually put attributes on the prototype, we just need to figure out a way to do it with regressing performance (which is a bit difficult). In the mean time, one can always construct a dummy object and test for the attributes presence to do feature detection.
Alexey Proskuryakov
*** Bug 70929 has been marked as a duplicate of this bug. ***
Alexey Proskuryakov
Is this the same as bug 49739?
Kentaro Hara
*** This bug has been marked as a duplicate of bug 49739 ***