Changeset 182140 in webkit


Ignore:
Timestamp:
Mar 30, 2015 8:23:24 AM (9 years ago)
Author:
youenn.fablet@crf.canon.fr
Message:

[Streams API] Error storage should be moved from source to stream/reader
https://bugs.webkit.org/show_bug.cgi?id=143048

Reviewed by Benjamin Poulain.

This patch removes error storage from the source as it should be stored at the stream level as error access goes through the reader.
It removes abstract ReadableStreamSource::isErrored and the storage of JavaScript errors from ReadableStreamJSSource.

Existing tests cover most of the changes.
Added test case for creating readable stream from empty JS object.

  • Modules/streams/ReadableStreamSource.h: Removing isErrored().
  • bindings/js/JSReadableStreamCustom.cpp:

(WebCore::constructJSReadableStream): Added JS stream constructor parameters checking.

  • bindings/js/ReadableStreamJSSource.cpp:

(WebCore::ReadableStreamJSSource::ReadableStreamJSSource): Removed JS stream constructor parameters checking.
(WebCore::ReadableStreamJSSource::start): Changed prototype of start so that start can throw errors directly.
(WebCore::ReadableStreamJSSource::setInternalError): Deleted.

  • bindings/js/ReadableStreamJSSource.h: Removed m_error, setInternalError and updated start declaration.
Location:
trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/streams/readablestream-constructor-expected.txt

    r181736 r182140  
    33PASS ReadableStream can be constructed with no arguments
    44PASS ReadableStream instances should have the correct list of properties
     5PASS ReadableStream can be constructed with an empty object as argument
    56
  • trunk/LayoutTests/streams/readablestream-constructor.html

    r181736 r182140  
    4646}, 'ReadableStream instances should have the correct list of properties');
    4747
     48test(function() {
     49    new ReadableStream({ });
     50}, 'ReadableStream can be constructed with an empty object as argument');
     51
    4852</script>
  • trunk/Source/WebCore/ChangeLog

    r182139 r182140  
     12015-03-25 Xabier Rodriguez Calvar <calvaris@igalia.com> and Youenn Fablet <youenn.fablet@crf.canon.fr>
     2
     3        [Streams API] Error storage should be moved from source to stream/reader
     4        https://bugs.webkit.org/show_bug.cgi?id=143048
     5
     6        Reviewed by Benjamin Poulain.
     7
     8        This patch removes error storage from the source as it should be stored at the stream level as error access goes through the reader.
     9        It removes abstract ReadableStreamSource::isErrored and the storage of JavaScript errors from ReadableStreamJSSource.
     10
     11        Existing tests cover most of the changes.
     12        Added test case for creating readable stream from empty JS object.
     13
     14        * Modules/streams/ReadableStreamSource.h: Removing isErrored().
     15        * bindings/js/JSReadableStreamCustom.cpp:
     16        (WebCore::constructJSReadableStream): Added JS stream constructor parameters checking.
     17        * bindings/js/ReadableStreamJSSource.cpp:
     18        (WebCore::ReadableStreamJSSource::ReadableStreamJSSource): Removed JS stream constructor parameters checking.
     19        (WebCore::ReadableStreamJSSource::start): Changed prototype of start so that start can throw errors directly.
     20        (WebCore::ReadableStreamJSSource::setInternalError): Deleted.
     21        * bindings/js/ReadableStreamJSSource.h: Removed m_error, setInternalError and updated start declaration.
     22
    1232015-03-30  Philippe Normand  <pnormand@igalia.com>
    224
  • trunk/Source/WebCore/Modules/streams/ReadableStreamSource.h

    r179687 r182140  
    5656        return true;
    5757    }
    58 
    59     virtual bool isErrored() { return false; }
    6058};
    6159
  • trunk/Source/WebCore/bindings/js/JSReadableStreamCustom.cpp

    r181736 r182140  
    6969EncodedJSValue JSC_HOST_CALL constructJSReadableStream(ExecState* exec)
    7070{
     71    if (exec->argumentCount() && !exec->argument(0).isObject())
     72        return throwVMError(exec, createTypeError(exec, ASCIILiteral("ReadableStream constructor should get an object as argument.")));
     73
    7174    DOMConstructorObject* jsConstructor = jsCast<DOMConstructorObject*>(exec->callee());
    7275    ASSERT(jsConstructor);
    7376    ScriptExecutionContext* scriptExecutionContext = jsConstructor->scriptExecutionContext();
    7477
     78
    7579    Ref<ReadableStreamJSSource> source = ReadableStreamJSSource::create(exec);
    76     if (source->isErrored())
    77         return throwVMError(exec, source->error());
    78 
    7980    RefPtr<ReadableStream> readableStream = ReadableStream::create(*scriptExecutionContext, Ref<ReadableStreamSource>(source.get()));
    8081
     
    8384    JSReadableStream* jsReadableStream = JSReadableStream::create(JSReadableStream::createStructure(vm, globalObject, JSReadableStream::createPrototype(vm, globalObject)), jsCast<JSDOMGlobalObject*>(globalObject), readableStream.releaseNonNull());
    8485
    85     if (!source->start())
    86         return throwVMError(exec, source->error());
     86    source->start(exec);
    8787
    8888    return JSValue::encode(jsReadableStream);
  • trunk/Source/WebCore/bindings/js/ReadableStreamJSSource.cpp

    r181814 r182140  
    3535#include "JSDOMPromise.h"
    3636#include "JSReadableStream.h"
     37#include "NotImplemented.h"
    3738#include <runtime/Error.h>
    3839#include <runtime/JSCJSValueInlines.h>
     
    6970ReadableStreamJSSource::ReadableStreamJSSource(JSC::ExecState* exec)
    7071{
    71     if (!exec->argumentCount())
    72         return;
    73 
    74     if (!exec->argument(0).isObject()) {
    75         setInternalError(exec, ASCIILiteral("ReadableStream constructor should get an object as argument."));
    76         return;
     72    if (exec->argumentCount()) {
     73        ASSERT(exec->argument(0).isObject());
     74        // FIXME: Implement parameters support;
    7775    }
    78 
    79     // FIXME: Implement parameters support
    80     setInternalError(exec, ASCIILiteral("ReadableStream constructor does not support parameter yet."));
    8176}
    8277
    83 void ReadableStreamJSSource::setInternalError(JSC::ExecState* exec, const String& message)
     78void ReadableStreamJSSource::start(JSC::ExecState*)
    8479{
    85     m_error.set(exec->vm(), createTypeError(exec, message));
     80    notImplemented();
    8681}
    8782
  • trunk/Source/WebCore/bindings/js/ReadableStreamJSSource.h

    r181264 r182140  
    4949    ~ReadableStreamJSSource() { }
    5050
    51     JSC::JSValue error() { return m_error.get(); }
    52     bool start() { return true; }
    53 
    54     // ReadableStreamSource API.
    55     virtual bool isErrored() { return !!m_error; }
     51    void start(JSC::ExecState*);
    5652
    5753private:
    58     void setInternalError(JSC::ExecState*, const String&);
    59 
    6054    ReadableStreamJSSource(JSC::ExecState*);
    61     // m_error may be an error generated from ReadableStreamJSSource or from JS callbacks.
    62     JSC::Strong<JSC::Unknown> m_error;
    6355};
    6456
Note: See TracChangeset for help on using the changeset viewer.