JS Built-ins should throw this-error messages consistently with binding generated code
https://bugs.webkit.org/show_bug.cgi?id=160191

Patch by Youenn Fablet <youennf@gmail.com> on 2016-07-26
Reviewed by Darin Adler.

Source/WebCore:

Introducing @makeThisTypeError and @makeGetterTypeError to create TypeError objects with a consistent error message.
Making use of these functions in streams API and fetch API related built-in code.

Refactored JSDOMBinding.cpp code by adding makeThisTypeErrorMessage and makeGetterTypeErrorMessage helper routines
These routines are used by both new built-in functions as well as binding generated code helper routine.

Tests: fetch/fetch-error-messages.html
       streams/readable-stream-error-messages.html

* Modules/fetch/FetchResponse.js:
(body): Adding an explicit check so that the error message is right. The previous error message was related to the call of Response.@isDisturbed.
* Modules/streams/ReadableStream.js:
(cancel):
(getReader):
(pipeTo):
(tee):
(locked):
* Modules/streams/ReadableStreamController.js:
(enqueue):
(error):
(close):
(desiredSize):
* Modules/streams/ReadableStreamReader.js:
(cancel):
(read):
(releaseLock):
(closed):
* bindings/js/JSDOMBinding.cpp:
(WebCore::makeGetterTypeErrorMessage):
(WebCore::throwGetterTypeError):
(WebCore::makeThisTypeErrorMessage):
(WebCore::throwThisTypeError):
(WebCore::throwSequenceTypeError): Deleted.
(WebCore::throwSetterTypeError): Deleted.
* bindings/js/JSDOMBinding.h:
* bindings/js/JSDOMGlobalObject.cpp:
(WebCore::makeThisTypeErrorForBuiltins):
(WebCore::makeGetterTypeErrorForBuiltins):
(WebCore::JSDOMGlobalObject::addBuiltinGlobals):
* bindings/js/WebCoreBuiltinNames.h:

LayoutTests:

* fetch/fetch-error-messages-expected.txt: Added.
* fetch/fetch-error-messages.html: Added.
* streams/readable-stream-error-messages-expected.txt: Added.
* streams/readable-stream-error-messages.html: Added.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@203766 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Source/WebCore/bindings/js/WebCoreBuiltinNames.h b/Source/WebCore/bindings/js/WebCoreBuiltinNames.h
index a5add94..1f45572 100644
--- a/Source/WebCore/bindings/js/WebCoreBuiltinNames.h
+++ b/Source/WebCore/bindings/js/WebCoreBuiltinNames.h
@@ -51,6 +51,8 @@
     macro(initializeWith) \
     macro(isDisturbed) \
     macro(localStreams) \
+    macro(makeThisTypeError) \
+    macro(makeGetterTypeError) \
     macro(operations) \
     macro(ownerReadableStream) \
     macro(privateGetStats) \