https://bugs.webkit.org/show_bug.cgi?id=146455
Reviewed by Darin Adler.
Made enqueue not custom. Updated error to use Default=Undefined in IDL.
No change in behavior.
* Modules/streams/ReadableStreamController.h:
(WebCore::ReadableStreamController::error): Removed unneeded variation of error.
(WebCore::ReadableStreamController::enqueue): Calling ReadableJSStream enqueue method.
* Modules/streams/ReadableStreamController.idl: Updated error with Default=Undefined and made enqueue not custom.
* bindings/js/JSDOMBinding.cpp:
(WebCore::createDOMException): Adding support for RangeError exceptions.
* bindings/js/JSReadableStreamControllerCustom.cpp:
(WebCore::constructJSReadableStreamController): Deleted.
* bindings/js/ReadableJSStream.cpp:
(WebCore::ReadableJSStream::error): Updated to pass error value as parameter.
(WebCore::ReadableJSStream::enqueue): Added exception throwing through ExceptionCode.
(WebCore::ReadableJSStream::retrieveChunkSize): Ditto.
* bindings/js/ReadableJSStream.h:
* dom/ExceptionCode.h: Adding RangeError.
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@186231
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2015-07-02 Youenn Fablet <youenn.fablet@crf.canon.fr>
+
+ [Streams API] Remove ReadableStreamController.enqueue() custom binding
+ https://bugs.webkit.org/show_bug.cgi?id=146455
+
+ Reviewed by Darin Adler.
+
+ Made enqueue not custom. Updated error to use Default=Undefined in IDL.
+
+ No change in behavior.
+
+ * Modules/streams/ReadableStreamController.h:
+ (WebCore::ReadableStreamController::error): Removed unneeded variation of error.
+ (WebCore::ReadableStreamController::enqueue): Calling ReadableJSStream enqueue method.
+ * Modules/streams/ReadableStreamController.idl: Updated error with Default=Undefined and made enqueue not custom.
+ * bindings/js/JSDOMBinding.cpp:
+ (WebCore::createDOMException): Adding support for RangeError exceptions.
+ * bindings/js/JSReadableStreamControllerCustom.cpp:
+ (WebCore::constructJSReadableStreamController): Deleted.
+ * bindings/js/ReadableJSStream.cpp:
+ (WebCore::ReadableJSStream::error): Updated to pass error value as parameter.
+ (WebCore::ReadableJSStream::enqueue): Added exception throwing through ExceptionCode.
+ (WebCore::ReadableJSStream::retrieveChunkSize): Ditto.
+ * bindings/js/ReadableJSStream.h:
+ * dom/ExceptionCode.h: Adding RangeError.
+
2015-07-02 Brady Eidson <beidson@apple.com>
[Content Extensions] Block synchronous XMLHTTPRequest.
ReadableJSStream& stream() { return m_stream; }
- void error(JSC::ExecState* state, ExceptionCode& ec) { m_stream.error(*state, ec); }
- void error(JSC::ExecState* state, JSC::JSValue, ExceptionCode& ec) { m_stream.error(*state, ec); }
+ void error(JSC::ExecState* state, JSC::JSValue value, ExceptionCode& ec) { m_stream.error(*state, value, ec); }
+
+ void enqueue(JSC::ExecState* state, JSC::JSValue value) { m_stream.enqueue(*state, value); }
void ref() { m_stream.ref(); }
void deref() { m_stream.deref(); }
ImplementationLacksVTable,
NoInterfaceObject
] interface ReadableStreamController {
- [Custom, RaisesException] boolean enqueue(any chunk);
+ [CallWith=ScriptState] void enqueue([Default=Undefined] optional any chunk);
[RaisesException] void close();
- [CallWith=ScriptState, RaisesException] void error(optional any error);
+ [CallWith=ScriptState, RaisesException] void error([Default=Undefined] optional any error);
readonly attribute double desiredSize;
};
// FIXME: Handle other WebIDL exception types.
if (ec == TypeError)
return createTypeError(exec);
+ if (ec == RangeError)
+ return createRangeError(exec, ASCIILiteral("Bad value"));
+
// FIXME: All callers to setDOMException need to pass in the right global object
// for now, we're going to assume the lexicalGlobalObject. Which is wrong in cases like this:
namespace WebCore {
-JSValue JSReadableStreamController::enqueue(ExecState* exec)
-{
- ReadableJSStream& stream = impl().stream();
- if (stream.isErrored())
- return exec->vm().throwException(exec, stream.error());
- if (stream.isCloseRequested())
- return exec->vm().throwException(exec, createTypeError(exec, ASCIILiteral("Calling enqueue on a stream which is closing")));
- stream.enqueue(*exec);
- return jsUndefined();
-}
-
EncodedJSValue JSC_HOST_CALL constructJSReadableStreamController(ExecState* exec)
{
return throwVMError(exec, createTypeError(exec, ASCIILiteral("ReadableStreamController constructor should not be called directly")));
changeStateToClosed();
}
-void ReadableJSStream::error(JSC::ExecState& state, ExceptionCode& ec)
+void ReadableJSStream::error(JSC::ExecState& state, JSC::JSValue value, ExceptionCode& ec)
{
if (!isReadable()) {
ec = TypeError;
return;
}
- storeError(state, state.argument(0));
+ storeError(state, value);
}
void ReadableJSStream::storeException(JSC::ExecState& state)
return chunk.value.get();
}
-void ReadableJSStream::enqueue(ExecState& state)
+void ReadableJSStream::enqueue(JSC::ExecState& state, JSC::JSValue chunk)
{
- ASSERT(!isCloseRequested());
-
+ if (isErrored()) {
+ throwVMError(&state, error());
+ return;
+ }
+ if (isCloseRequested()) {
+ throwVMError(&state, createDOMException(&state, TypeError));
+ return;
+ }
if (!isReadable())
return;
- JSValue chunk = state.argument(0);
if (resolveReadCallback(chunk)) {
pull();
return;
}
double size = retrieveChunkSize(state, chunk);
- if (state.hadException()) {
- storeError(state, state.exception()->value());
+ if (state.hadException())
return;
- }
m_chunkQueue.append({ JSC::Strong<JSC::Unknown>(state.vm(), chunk), size });
m_totalQueueSize += size;
arguments.append(chunk);
JSValue sizeValue = callFunction(state, m_sizeFunction.get(), jsUndefined(), arguments);
- if (state.hadException())
+ if (state.hadException()) {
+ storeError(state, state.exception()->value());
return 0;
+ }
double size = sizeValue.toNumber(&state);
- if (state.hadException())
+ if (state.hadException()) {
+ storeError(state, state.exception()->value());
return 0;
+ }
if (!std::isfinite(size) || size < 0) {
- throwVMError(&state, createRangeError(&state, ASCIILiteral("Incorrect double value")));
+ storeError(state, createDOMException(&state, RangeError));
+ throwVMError(&state, error());
return 0;
}
void storeError(JSC::ExecState&, JSC::JSValue);
JSC::JSValue error() override { return m_error.get(); }
- void enqueue(JSC::ExecState&);
- void error(JSC::ExecState&, ExceptionCode&);
+ void enqueue(JSC::ExecState&, JSC::JSValue);
+ void error(JSC::ExecState&, JSC::JSValue, ExceptionCode&);
double desiredSize() const { return m_highWaterMark - m_totalQueueSize; }
// WebIDL exception types, handled by the binding layer.
// FIXME: Add GeneralError, EvalError, etc. when implemented in the bindings.
TypeError = 105,
+ RangeError = 106,
};
} // namespace WebCore