Bug 158540 - First parameter to MessagePort / DedicatedWorkerGlobalScope.postMessage() should be mandatory
Summary: First parameter to MessagePort / DedicatedWorkerGlobalScope.postMessage() sho...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: DOM (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Chris Dumez
URL:
Keywords: WebExposed
Depends on:
Blocks:
 
Reported: 2016-06-08 14:12 PDT by Chris Dumez
Modified: 2016-06-09 20:08 PDT (History)
5 users (show)

See Also:


Attachments
Patch (7.53 KB, patch)
2016-06-08 14:37 PDT, Chris Dumez
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Chris Dumez 2016-06-08 14:12:40 PDT
First parameter to MessagePort / DedicatedWorkerGlobalScope.postMessage() should be mandatory:
- https://html.spec.whatwg.org/multipage/comms.html#messageport
- https://html.spec.whatwg.org/multipage/workers.html#dedicated-workers-and-the-dedicatedworkerglobalscope-interface

Currently, WebKit send a bogus MessageEvent whose data attribute is undefined. This causes a testharness error when running the following W3C test:
http://w3c-test.org/workers/interfaces.worker
Comment 1 Chris Dumez 2016-06-08 14:18:42 PDT
Firefox and Chrome already behave this way.

Also note that we already throw when calling window.postMessage() without parameter.
Comment 2 Chris Dumez 2016-06-08 14:37:29 PDT
Created attachment 280841 [details]
Patch
Comment 3 Geoffrey Garen 2016-06-08 14:40:59 PDT
Comment on attachment 280841 [details]
Patch

r=me
Comment 4 WebKit Commit Bot 2016-06-08 15:13:27 PDT
Comment on attachment 280841 [details]
Patch

Clearing flags on attachment: 280841

Committed r201835: <http://trac.webkit.org/changeset/201835>
Comment 5 WebKit Commit Bot 2016-06-08 15:13:31 PDT
All reviewed patches have been landed.  Closing bug.
Comment 6 Darin Adler 2016-06-09 20:08:41 PDT
Comment on attachment 280841 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=280841&action=review

> Source/WebCore/bindings/js/JSMessagePortCustom.h:54
> +        if (UNLIKELY(state.argumentCount() < 1))
> +            return state.vm().throwException(&state, createNotEnoughArgumentsError(&state));

What is correct behavior when there is one argument but it is undefined? Iā€™d like to see test coverage for that case.