Summary: | Wrong argument order in window.postMessage | ||
---|---|---|---|
Product: | WebKit | Reporter: | Yury Semikhatsky <yurys> |
Component: | WebCore Misc. | Assignee: | Nobody <webkit-unassigned> |
Status: | RESOLVED FIXED | ||
Severity: | Normal | CC: | abarth, andersca, ap, arv, ian, johnjbarton, paulirish, sam |
Priority: | P2 | ||
Version: | 528+ (Nightly build) | ||
Hardware: | Unspecified | ||
OS: | Unspecified |
Description
Yury Semikhatsky
2011-06-22 08:27:06 PDT
Sorry, messages ports were introduced in r36891: http://trac.webkit.org/changeset/36891/trunk/WebCore/bindings/js/JSDOMWindowCustom.cpp Ouch. I wonder if we should change the spec. Does Firefox match the spec? We certainly matched the spec at the time of adding the code. If you plan to change this, hold off a few days because I'm about to update this API anyway and I wouldn't want to end up changing it around and having you waste your time. The problem with the order (message, ports, targetOrigin) is that it means you don't know what the second argument is unless you check its type or check the number of arguments. With the order (message, targetOrigin, ports) the optional argument is the last one, not the middle one. Does anyone else support sending ports yet? If not this might be a moot point and we might be able to change it easily. How much WebKit-specific content is there out there using this? (In reply to comment #4) > > Does anyone else support sending ports yet? If not this might be a moot point and we might be able to change it easily. How much WebKit-specific content is there out there using this? Checked with Firefox 5.0 on Mac. LayoutTests/fast/events/message-port.html fails on attempt to create MessageChannel - there is no such constructor. Firefox doesn't support SharedWorkers either. So I don't see any way even to create a MessagePort in Firefox. It looks like the WebKit API is otherWindow.postMessage(message, ports); Specifically a third argument is not allowed. V8 at least requires the |ports| to be an Array. (In reply to comment #6) > It looks like the WebKit API is > otherWindow.postMessage(message, ports); > Specifically a third argument is not allowed. V8 at least requires the |ports| to be an Array. At least in Chrome (V8), the third argument is required and is checked as a targetOrigin. So perhaps I am not reading the WebKit source correctly. Looks like WebKit actually supports the second and third arguments in either order. Is that intentional? I've put that in the spec, to hopefully end this confusion about which argument is second and which is third once and for all. Looks like only WebKit implements MessagePort through postMessage() correctly enough for this to matter, and the spec now matches WebKit. Actually nevermind, my testing was bogus. Opera implements the spec as written here. Having the optional argument in the middle (as WebKit has it) seems generally bad, so if we're not going to support either order, I guess we should just go with what's in the spec now. Please let me know if this causes compat issues. Fixed in r209303: <http://trac.webkit.org/changeset/209303> |