haikuwebkit/LayoutTests/fetch/fetch-error-messages.html

48 lines
1.5 KiB
HTML
Raw Permalink Normal View History

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. Canonical link: https://commits.webkit.org/178395@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@203766 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-07-27 06:37:49 +00:00
<!DOCTYPE html>
<script src='../resources/testharness.js'></script>
<script src='../resources/testharnessreport.js'></script>
<script>
function printMethodError(method, target)
{
try {
method.call(target);
assert_unreached();
} catch(e) {
console.log(e);
}
}
function printPromiseMethodError(method, target)
{
return method.call(target).then(assert_unreached, (e) => {
console.log("Promise rejected with: " + e);
});
}
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. Canonical link: https://commits.webkit.org/178395@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@203766 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-07-27 06:37:49 +00:00
function printGetterError(object, getterName, target)
{
const getter = Object.getOwnPropertyDescriptor(Object.getPrototypeOf(object), getterName).get;
printMethodError(getter, target);
}
promise_test(function(test) {
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. Canonical link: https://commits.webkit.org/178395@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@203766 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-07-27 06:37:49 +00:00
// This test prints exceptions to check the format of their messages.
var request = new Request("");
var response = new Response("");
var results = [
printMethodError(response.clone, request),
printPromiseMethodError(response.arrayBuffer, request),
printPromiseMethodError(response.blob, request),
printPromiseMethodError(response.formData, request),
printPromiseMethodError(response.json, request),
printPromiseMethodError(response.text, request),
printGetterError(response, "body", request),
printGetterError(request, "method", response),
printMethodError(request.clone, response),
];
return Promise.all(results);
}, "Exercising TypeError messages in Fetch Request and Response");
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. Canonical link: https://commits.webkit.org/178395@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@203766 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-07-27 06:37:49 +00:00
</script>