Bug 94310

Summary: [JSC] window.postMessage() throws wrong exception types
Product: WebKit Reporter: Chris Dumez <cdumez>
Component: WebCore JavaScriptAssignee: Chris Dumez <cdumez>
Status: RESOLVED FIXED    
Severity: Normal CC: kenneth, s.choi
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
URL: http://www.w3.org/TR/html5/comms.html#dom-window-postmessage-2
Bug Depends on: 94493, 94581    
Bug Blocks:    

Description Chris Dumez 2012-08-17 01:09:19 PDT
According the HTML5 communication spec (http://www.w3.org/TR/html5/comms.html#dom-window-postmessage-2), window.postMessage() "Throws an INVALID_STATE_ERR if the ports array is not null and it contains either null entries or duplicate ports." but we currently throw a TypeError in this case.

According to the structured clone spec (http://www.w3.org/TR/html5/common-dom-interfaces.html#structured-clone), we are supposed to throw a DATA_CLONE_ERR exception and abort the overall structured clone algorithm if the input is an unsupported native object type (e.g. Error, Function) or a host object (e.g. a DOM node). We currently throw a TypeError in this case as well.

The V8 implementation behaves according to specification.

This is already tested by:
  fast/dom/Window/window-postmessage-clone-really-deep-array.html
  fast/events/message-port-multi.html
Comment 1 Chris Dumez 2012-09-03 01:09:59 PDT
Dependencies have landed. Closing this bug.