haikuwebkit/LayoutTests/streams/readable-stream-error-messa...

64 lines
2.0 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(e);
});
}
function printGetterError(object, getterName, target)
{
const getter = Object.getOwnPropertyDescriptor(Object.getPrototypeOf(object), getterName).get;
printMethodError(getter, target);
}
function printPromiseGetterError(object, getterName, target)
{
const getter = Object.getOwnPropertyDescriptor(Object.getPrototypeOf(object), getterName).get;
printPromiseMethodError(getter, target);
}
promise_test(function(test) {
// This test prints exceptions to check the format of their messages.
var controller;
var stream = new ReadableStream({
start: (c) => {
controller = c;
}
});
var reader = stream.getReader();
var results = [];
results.push(printPromiseMethodError(stream.cancel, controller));
results.push(printMethodError(stream.getReader, controller));
results.push(printMethodError(stream.tee, controller));
results.push(printGetterError(stream, "locked", controller));
results.push(printMethodError(controller.enqueue, reader));
results.push(printMethodError(controller.error, reader));
results.push(printMethodError(controller.close, reader));
results.push(printGetterError(controller, "desiredSize", reader));
results.push(printPromiseMethodError(reader.cancel, stream));
results.push(printPromiseMethodError(reader.read, stream));
results.push(printMethodError(reader.releaseLock, stream));
results.push(printPromiseGetterError(reader, "closed", stream));
return Promise.all(results);
[Streams API] Replace ReadableStreamController by ReadableStreamDefaultController https://bugs.webkit.org/show_bug.cgi?id=160242 Patch by Romain Bellessort <romain.bellessort@crf.canon.fr> on 2016-07-28 Reviewed by Youenn Fablet. Replaced ReadableStreamController by ReadableStreamDefaultController to align with updated Streams API specification. No change in functionality. Source/WebCore: * CMakeLists.txt: * DerivedSources.cpp: * DerivedSources.make: * Modules/streams/ReadableStream.js: (initializeReadableStream): * Modules/streams/ReadableStreamDefaultController.idl: Renamed from Source/WebCore/Modules/streams/ReadableStreamController.idl. * Modules/streams/ReadableStreamDefaultController.js: Renamed from Source/WebCore/Modules/streams/ReadableStreamController.js. (enqueue): (error): (close): (desiredSize): * Modules/streams/ReadableStreamInternals.js: (privateInitializeReadableStreamDefaultController): (isReadableStreamDefaultController): * Modules/streams/ReadableStreamSource.h: (WebCore::ReadableStreamSource::controller): (WebCore::ReadableStreamSource::start): * Modules/streams/ReadableStreamSource.idl: * WebCore.xcodeproj/project.pbxproj: * bindings/js/JSDOMGlobalObject.cpp: (WebCore::JSDOMGlobalObject::addBuiltinGlobals): * bindings/js/JSReadableStreamPrivateConstructors.cpp: (WebCore::constructJSReadableStreamDefaultController): (WebCore::JSBuiltinReadableStreamDefaultControllerPrivateConstructor::initializeExecutable): (WebCore::createReadableStreamDefaultControllerPrivateConstructor): * bindings/js/JSReadableStreamPrivateConstructors.h: * bindings/js/JSReadableStreamSourceCustom.cpp: (WebCore::JSReadableStreamSource::start): * bindings/js/ReadableStreamDefaultController.cpp: Renamed from Source/WebCore/bindings/js/ReadableStreamController.cpp. (WebCore::callFunction): (WebCore::ReadableStreamDefaultController::invoke): (WebCore::ReadableStreamDefaultController::isControlledReadableStreamLocked): * bindings/js/ReadableStreamDefaultController.h: Renamed from Source/WebCore/bindings/js/ReadableStreamController.h. (WebCore::ReadableStreamDefaultController::ReadableStreamDefaultController): (WebCore::ReadableStreamDefaultController::close): (WebCore::ReadableStreamDefaultController::error): (WebCore::ReadableStreamDefaultController::enqueue): (WebCore::ReadableStreamDefaultController::globalObject): (WebCore::ReadableStreamDefaultController::error<String>): * bindings/js/WebCoreBuiltinNames.h: LayoutTests: * streams/readable-stream-default-controller-error-expected.txt: Renamed from LayoutTests/streams/readable-stream-controller-error-expected.txt. * streams/readable-stream-default-controller-error.html: Renamed from LayoutTests/streams/readable-stream-controller-error.html. * streams/readable-stream-error-messages-expected.txt: * streams/readable-stream-error-messages.html: * streams/reference-implementation/readable-stream-expected.txt: Canonical link: https://commits.webkit.org/178446@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@203818 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-07-28 15:43:42 +00:00
}, "Exercising TypeError messages in ReadableStream, ReadableStreamDefaultController and ReadableStreamDefaultReader");
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>