WebRTC: Update RTCPeerConnection overloaded legacy operations to return a Promise
https://bugs.webkit.org/show_bug.cgi?id=158114

Reviewed by Eric Carlson.

Source/WebCore:

Update overloaded operations so that the legacy callback versions also return a promise
and never throw [1].

[1] https://w3c.github.io/webrtc-pc/archives/20160513/webrtc.html#legacy-interface-extensions

Updated existing tests.
- fast/mediastream/RTCPeerConnection-overloaded-operations-params.html
- fast/mediastream/RTCPeerConnection-overloaded-operations.html

* Modules/mediastream/RTCPeerConnection.idl:
Updated legacy signatures (just for documentation purposes)
* Modules/mediastream/RTCPeerConnection.js:
Implements the promise overload and the legacy callbacks overload (using the promise version)
as specified in [1] (above).
(createOffer):
(createAnswer):
(setLocalDescription):
(setRemoteDescription):
(addIceCandidate):
(getStats):
* Modules/mediastream/RTCPeerConnectionInternals.js:
Added helper functions objectAndCallbacksOverload and callbacksAndDictionaryOverload that
process an argument list and determine which overloaded version to use.
(callbacksAndDictionaryOverload):
(setLocalOrRemoteDescription): Deleted.
(extractCallbackArg): Deleted.

LayoutTests:

Updated existing tests (see below).

* fast/mediastream/RTCPeerConnection-overloaded-operations-expected.txt:
* fast/mediastream/RTCPeerConnection-overloaded-operations-params-expected.txt:
* fast/mediastream/RTCPeerConnection-overloaded-operations-params.html:
Test various combinations of good and bad arguments and verify that no errors are thrown.
* fast/mediastream/RTCPeerConnection-overloaded-operations.html:
Test that all overloaded versions return a promise.
* fast/mediastream/resources/promise-utils.js: Added.
Shared utils to make it easier to test async promise APIs.
(ensurePromise):
(promiseShouldReject):
(promiseShouldNotRejectWithTypeError.):


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@201455 268f45cc-cd09-0410-ab3c-d52691b4dbfc
10 files changed