AudioContext resume/close/suspend should reject promises with a DOM exception in...
authoryouenn.fablet@crf.canon.fr <youenn.fablet@crf.canon.fr@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 20 May 2015 20:20:09 +0000 (20:20 +0000)
committeryouenn.fablet@crf.canon.fr <youenn.fablet@crf.canon.fr@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 20 May 2015 20:20:09 +0000 (20:20 +0000)
commit1f486ede56d337d8945995d7c6b25a6114c7fe4f
tree6a17aa31bfb7ee4d2812332cb1e450c701bc7b16
parent8cbd74ac6f31ece945842e41fe8d66c1ef4f1797
AudioContext resume/close/suspend should reject promises with a DOM exception in lieu of throwing exceptions
https://bugs.webkit.org/show_bug.cgi?id=145064

Reviewed by Darin Adler.

Source/JavaScriptCore:

Added default message for TypeError.

* runtime/Error.cpp:
(JSC::throwTypeError):
* runtime/Error.h:

Source/WebCore:

Rejecting resume/suspend/close promises with InvalidStateError values in case context is offline.
Removed unneeded calls to postTask for resolving/rejecting promises.
Adding promise rejection of DOM Exception values, 0 being equivalent of no error passed to reject callback.

Test: webaudio/audiocontext-promise-throwing.html

* Modules/webaudio/AudioContext.cpp:
(WebCore::AudioContext::suspendContext): Rejecting promise in lieu of throwing exception.
(WebCore::AudioContext::resumeContext): Ditto.
(WebCore::AudioContext::closeContext): Ditto.
* Modules/webaudio/AudioContext.h:
* bindings/js/JSAudioContextCustom.cpp:
(WebCore::JSAudioContext::suspend): Removing ExceptionCode handling.
(WebCore::JSAudioContext::resume): Ditto.
(WebCore::JSAudioContext::close): Ditto.
* bindings/js/JSDOMBinding.cpp:
(WebCore::createDOMException): Splitting DOM exception creation from throwing.
(WebCore::setDOMException): Ditto.
* bindings/js/JSDOMBinding.h: Adding createDOMException prototype.
* bindings/js/JSDOMPromise.h:
(WebCore::DeferredWrapper::reject<ExceptionCode>):

LayoutTests:

Adding test to cover resume/close/suspend rejecting with InvalidStateError.
Updating existing test to cover resume and suspend rejection with no error.

* webaudio/audiocontext-promise-throwing-expected.txt: Added.
* webaudio/audiocontext-promise-throwing.html: Added.
* webaudio/audiocontext-state-expected.txt:
* webaudio/audiocontext-state.html:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@184651 268f45cc-cd09-0410-ab3c-d52691b4dbfc
15 files changed:
LayoutTests/ChangeLog
LayoutTests/webaudio/audiocontext-promise-throwing-expected.txt [new file with mode: 0644]
LayoutTests/webaudio/audiocontext-promise-throwing.html [new file with mode: 0644]
LayoutTests/webaudio/audiocontext-state-expected.txt
LayoutTests/webaudio/audiocontext-state.html
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/runtime/Error.cpp
Source/JavaScriptCore/runtime/Error.h
Source/WebCore/ChangeLog
Source/WebCore/Modules/webaudio/AudioContext.cpp
Source/WebCore/Modules/webaudio/AudioContext.h
Source/WebCore/bindings/js/JSAudioContextCustom.cpp
Source/WebCore/bindings/js/JSDOMBinding.cpp
Source/WebCore/bindings/js/JSDOMBinding.h
Source/WebCore/bindings/js/JSDOMPromise.h