Changeset 159323 in webkit


Ignore:
Timestamp:
Nov 14, 2013 4:55:45 PM (10 years ago)
Author:
commit-queue@webkit.org
Message:

Clean up sequence handling in Blob constructor
https://bugs.webkit.org/show_bug.cgi?id=124343

Patch by Victor Costan <costan@gmail.com> on 2013-11-14
Reviewed by Alexey Proskuryakov.

Source/WebCore:

Added test case to LayoutTests/fast/files/blob-constructor.html

  • bindings/js/JSBlobCustom.cpp:

(WebCore::JSBlobConstructor::constructJSBlob):

Handle exceptions in sequences, eliminate double type-checking for
ArrayBuffer, ArrayBufferView and Blob parts.

LayoutTests:

  • fast/files/blob-constructor-expected.txt:
  • fast/files/script-tests/blob-constructor.js:

Add test with sequence that throws an error on property access.

(get Object):

Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r159317 r159323  
     12013-11-14  Victor Costan  <costan@gmail.com>
     2
     3        Clean up sequence handling in Blob constructor
     4        https://bugs.webkit.org/show_bug.cgi?id=124343
     5
     6        Reviewed by Alexey Proskuryakov.
     7
     8        * fast/files/blob-constructor-expected.txt:
     9        * fast/files/script-tests/blob-constructor.js:
     10            Add test with sequence that throws an error on property access.
     11        (get Object):
     12
    1132013-11-14  Tim Horton  <timothy_horton@apple.com>
    214
  • trunk/LayoutTests/fast/files/blob-constructor-expected.txt

    r159275 r159323  
    7979PASS new Blob({length: 1, 0: 'string'}, {type: 'text/html'}).type is 'text/html'
    8080PASS new Blob({length: 0}, {endings:'illegal'}) threw exception TypeError: The endings property must be either "transparent" or "native".
     81PASS new Blob(throwingSequence) threw exception Error: Misbehaving property.
    8182PASS successfullyParsed is true
    8283
  • trunk/LayoutTests/fast/files/script-tests/blob-constructor.js

    r159275 r159323  
    107107shouldBe("new Blob({length: 1, 0: 'string'}, {type: 'text/html'}).type", "'text/html'");
    108108shouldThrow("new Blob({length: 0}, {endings:'illegal'})", "'TypeError: The endings property must be either \"transparent\" or \"native\"'");
     109
     110// Test passing blog parts in a sequence-like object that throws on property access.
     111var throwingSequence = {length: 4, 0: 'hello', 3: 'world'};
     112Object.defineProperty(throwingSequence, "1", {
     113    get: function() { throw new Error("Misbehaving property"); },
     114    enumerable: true, configurable: true
     115});
     116Object.defineProperty(throwingSequence, "2", {
     117    get: function() { throw new Error("This should not be thrown"); },
     118    enumerable: true, configurable: true
     119});
     120shouldThrow("new Blob(throwingSequence)", "'Error: Misbehaving property'");
  • trunk/Source/WebCore/ChangeLog

    r159321 r159323  
     12013-11-14  Victor Costan  <costan@gmail.com>
     2
     3        Clean up sequence handling in Blob constructor
     4        https://bugs.webkit.org/show_bug.cgi?id=124343
     5
     6        Reviewed by Alexey Proskuryakov.
     7
     8        Added test case to LayoutTests/fast/files/blob-constructor.html
     9
     10        * bindings/js/JSBlobCustom.cpp:
     11        (WebCore::JSBlobConstructor::constructJSBlob):
     12            Handle exceptions in sequences, eliminate double type-checking for
     13            ArrayBuffer, ArrayBufferView and Blob parts.
     14
    1152013-11-14  Oliver Hunt  <oliver@apple.com>
    216
  • trunk/Source/WebCore/bindings/js/JSBlobCustom.cpp

    r159275 r159323  
    115115    for (unsigned i = 0; i < blobPartsLength; ++i) {
    116116        JSValue item = blobParts->get(exec, i);
     117        if (exec->hadException())
     118            return JSValue::encode(jsUndefined());
     119
    117120#if ENABLE(BLOB)
    118         if (item.inherits(JSArrayBuffer::info()))
    119             blobBuilder.append(toArrayBuffer(item));
    120         else if (item.inherits(JSArrayBufferView::info()))
    121             blobBuilder.append(toArrayBufferView(item));
     121        if (ArrayBuffer* arrayBuffer = toArrayBuffer(item))
     122            blobBuilder.append(arrayBuffer);
     123        else if (RefPtr<ArrayBufferView> arrayBufferView = toArrayBufferView(item))
     124            blobBuilder.append(arrayBufferView.release());
    122125        else
    123126#endif
    124         if (item.inherits(JSBlob::info()))
    125             blobBuilder.append(toBlob(item));
     127        if (Blob* blob = toBlob(item))
     128            blobBuilder.append(blob);
    126129        else {
    127130            String string = item.toString(exec)->value(exec);
Note: See TracChangeset for help on using the changeset viewer.