⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 202667 in webkit


Ignore:
Timestamp:
Jun 29, 2016, 9:24:52 PM (10 years ago)
Author:
commit-queue@webkit.org
Message:

[JSC] Minor TypedArray fixes
https://bugs.webkit.org/show_bug.cgi?id=159286

Patch by Benjamin Poulain <bpoulain@apple.com> on 2016-06-29
Reviewed by Keith Miller.

Source/JavaScriptCore:

  • runtime/JSGenericTypedArrayViewConstructorInlines.h:

(JSC::JSGenericTypedArrayViewConstructor<ViewClass>::finishCreation):
See https://tc39.github.io/ecma262/#sec-%typedarray%

  • runtime/JSTypedArrayViewPrototype.cpp:

(JSC::typedArrayViewPrivateFuncLength):
See https://tc39.github.io/ecma262/#sec-get-%typedarray%.prototype.length

(JSC::typedArrayViewProtoGetterFuncToStringTag):
Yep, that's odd.
See https://tc39.github.io/ecma262/#sec-get-%typedarray%.prototype-@@tostringtag

(JSC::JSTypedArrayViewPrototype::finishCreation):
See the last paragraph of https://tc39.github.io/ecma262/#sec-ecmascript-standard-built-in-objects

LayoutTests:

  • js/script-tests/typedarray-constructors.js:
  • js/script-tests/typedarray-prototype.js:
  • js/typedarray-constructors-expected.txt:
  • js/typedarray-prototype-expected.txt:
Location:
trunk
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r202666 r202667  
     12016-06-29  Benjamin Poulain  <bpoulain@apple.com>
     2
     3        [JSC] Minor TypedArray fixes
     4        https://bugs.webkit.org/show_bug.cgi?id=159286
     5
     6        Reviewed by Keith Miller.
     7
     8        * js/script-tests/typedarray-constructors.js:
     9        * js/script-tests/typedarray-prototype.js:
     10        * js/typedarray-constructors-expected.txt:
     11        * js/typedarray-prototype-expected.txt:
     12
    1132016-06-29  Joseph Pecoraro  <pecoraro@apple.com>
    214
  • trunk/LayoutTests/js/script-tests/typedarray-constructors.js

    r161789 r202667  
    44);
    55
    6 shouldThrow("Int8Array()");
    7 shouldNotThrow("new Int8Array()");
     6let arrayTypes = [
     7    Int8Array,
     8    Int16Array,
     9    Int32Array,
     10    Uint8Array,
     11    Uint8ClampedArray,
     12    Uint16Array,
     13    Uint32Array,
     14    Float32Array,
     15    Float64Array,
     16];
    817
    9 shouldThrow("Int16Array()");
    10 shouldNotThrow("new Int16Array()");
    11 
    12 shouldThrow("Int32Array()");
    13 shouldNotThrow("new Int32Array()");
    14 
    15 shouldThrow("Uint8Array()");
    16 shouldNotThrow("new Uint8Array()");
    17 
    18 shouldThrow("Uint16Array()");
    19 shouldNotThrow("new Uint16Array()");
    20 
    21 shouldThrow("Uint32Array()");
    22 shouldNotThrow("new Uint32Array()");
    23 
    24 shouldThrow("Uint8ClampedArray()");
    25 shouldNotThrow("new Uint8ClampedArray()");
    26 
    27 shouldThrow("Float32Array()");
    28 shouldNotThrow("new Float32Array()");
    29 
    30 shouldThrow("Float64Array()");
    31 shouldNotThrow("new Float64Array()");
     18// The prototype should be the same for every type of view.
     19for (let arrayType of arrayTypes) {
     20    shouldThrow("" + arrayType.name + "()");
     21    shouldNotThrow("new " + arrayType.name + "()");
     22    shouldBe("" + arrayType.name + ".length", "0");
     23}
    3224
    3325shouldThrow("DataView(new ArrayBuffer())");
    3426shouldNotThrow("new DataView(new ArrayBuffer())");
    35 
     27shouldBe("DataView.length", "0");
  • trunk/LayoutTests/js/script-tests/typedarray-prototype.js

    r202631 r202667  
    88    Int32Array,
    99    Uint8Array,
     10    Uint8ClampedArray,
    1011    Uint16Array,
    1112    Uint32Array,
     
    2324let TypedArray = Object.getPrototypeOf(Int8Array);
    2425
     26// buffer.
     27shouldBeEqualToString('Object.getOwnPropertyDescriptor(TypedArray.prototype, "buffer").get.name', 'get buffer');
     28shouldBe('Object.getOwnPropertyDescriptor(TypedArray.prototype, "buffer").get.length', '0');
     29shouldBeFalse('"writable" in Object.getOwnPropertyDescriptor(TypedArray.prototype, "buffer")');
     30shouldBeFalse('Object.getOwnPropertyDescriptor(TypedArray.prototype, "buffer").enumerable');
     31shouldBeTrue('Object.getOwnPropertyDescriptor(TypedArray.prototype, "buffer").configurable');
     32shouldBeEqualToString('typeof Object.getOwnPropertyDescriptor(TypedArray.prototype, "buffer").get', 'function');
     33shouldBe('Object.getOwnPropertyDescriptor(TypedArray.prototype, "buffer").set', 'undefined');
     34shouldThrow('Object.getOwnPropertyDescriptor(TypedArray.prototype, "buffer").get.call()', "'TypeError: Receiver should be a typed array view but was not an object'");
     35shouldThrow('Object.getOwnPropertyDescriptor(TypedArray.prototype, "buffer").get.call(undefined)', "'TypeError: Receiver should be a typed array view but was not an object'");
     36shouldThrow('Object.getOwnPropertyDescriptor(TypedArray.prototype, "buffer").get.call(null)', "'TypeError: Receiver should be a typed array view but was not an object'");
     37shouldThrow('Object.getOwnPropertyDescriptor(TypedArray.prototype, "buffer").get.call(5)', "'TypeError: Receiver should be a typed array view but was not an object'");
     38shouldThrow('Object.getOwnPropertyDescriptor(TypedArray.prototype, "buffer").get.call([])', "'TypeError: Receiver should be a typed array view'");
     39shouldThrow('Object.getOwnPropertyDescriptor(TypedArray.prototype, "buffer").get.call({ foo: "bar" })', "'TypeError: Receiver should be a typed array view'");
     40shouldThrow('Object.getOwnPropertyDescriptor(TypedArray.prototype, "buffer").get.call(new ArrayBuffer(42))', "'TypeError: Receiver should be a typed array view'");
     41shouldThrow('Object.getOwnPropertyDescriptor(TypedArray.prototype, "buffer").get.call(new DataView(new ArrayBuffer(8), 0, 1))', "'TypeError: Receiver should be a typed array view'");
     42
     43// byteLength.
     44shouldBeEqualToString('Object.getOwnPropertyDescriptor(TypedArray.prototype, "byteLength").get.name', 'get byteLength');
     45shouldBe('Object.getOwnPropertyDescriptor(TypedArray.prototype, "byteLength").get.length', '0');
     46shouldBeFalse('"writable" in Object.getOwnPropertyDescriptor(TypedArray.prototype, "byteLength")');
     47shouldBeFalse('Object.getOwnPropertyDescriptor(TypedArray.prototype, "byteLength").enumerable');
     48shouldBeTrue('Object.getOwnPropertyDescriptor(TypedArray.prototype, "byteLength").configurable');
     49shouldBeEqualToString('typeof Object.getOwnPropertyDescriptor(TypedArray.prototype, "byteLength").get', 'function');
     50shouldBe('Object.getOwnPropertyDescriptor(TypedArray.prototype, "byteLength").set', 'undefined');
     51shouldThrow('Object.getOwnPropertyDescriptor(TypedArray.prototype, "byteLength").get.call()', "'TypeError: Receiver should be a typed array view but was not an object'");
     52shouldThrow('Object.getOwnPropertyDescriptor(TypedArray.prototype, "byteLength").get.call(undefined)', "'TypeError: Receiver should be a typed array view but was not an object'");
     53shouldThrow('Object.getOwnPropertyDescriptor(TypedArray.prototype, "byteLength").get.call(null)', "'TypeError: Receiver should be a typed array view but was not an object'");
     54shouldThrow('Object.getOwnPropertyDescriptor(TypedArray.prototype, "byteLength").get.call(5)', "'TypeError: Receiver should be a typed array view but was not an object'");
     55shouldThrow('Object.getOwnPropertyDescriptor(TypedArray.prototype, "byteLength").get.call([])', "'TypeError: Receiver should be a typed array view'");
     56shouldThrow('Object.getOwnPropertyDescriptor(TypedArray.prototype, "byteLength").get.call({ foo: "bar" })', "'TypeError: Receiver should be a typed array view'");
     57shouldThrow('Object.getOwnPropertyDescriptor(TypedArray.prototype, "byteLength").get.call(new ArrayBuffer(42))', "'TypeError: Receiver should be a typed array view'");
     58shouldThrow('Object.getOwnPropertyDescriptor(TypedArray.prototype, "byteLength").get.call(new DataView(new ArrayBuffer(8), 0, 1))', "'TypeError: Receiver should be a typed array view'");
     59
     60// byteOffset.
     61shouldBeEqualToString('Object.getOwnPropertyDescriptor(TypedArray.prototype, "byteOffset").get.name', 'get byteOffset');
     62shouldBe('Object.getOwnPropertyDescriptor(TypedArray.prototype, "byteOffset").get.length', '0');
     63shouldBeFalse('"writable" in Object.getOwnPropertyDescriptor(TypedArray.prototype, "byteOffset")');
     64shouldBeFalse('Object.getOwnPropertyDescriptor(TypedArray.prototype, "byteOffset").enumerable');
     65shouldBeTrue('Object.getOwnPropertyDescriptor(TypedArray.prototype, "byteOffset").configurable');
     66shouldBeEqualToString('typeof Object.getOwnPropertyDescriptor(TypedArray.prototype, "byteOffset").get', 'function');
     67shouldBe('Object.getOwnPropertyDescriptor(TypedArray.prototype, "byteOffset").set', 'undefined');
     68shouldThrow('Object.getOwnPropertyDescriptor(TypedArray.prototype, "byteOffset").get.call()', "'TypeError: Receiver should be a typed array view but was not an object'");
     69shouldThrow('Object.getOwnPropertyDescriptor(TypedArray.prototype, "byteOffset").get.call(undefined)', "'TypeError: Receiver should be a typed array view but was not an object'");
     70shouldThrow('Object.getOwnPropertyDescriptor(TypedArray.prototype, "byteOffset").get.call(null)', "'TypeError: Receiver should be a typed array view but was not an object'");
     71shouldThrow('Object.getOwnPropertyDescriptor(TypedArray.prototype, "byteOffset").get.call(5)', "'TypeError: Receiver should be a typed array view but was not an object'");
     72shouldThrow('Object.getOwnPropertyDescriptor(TypedArray.prototype, "byteOffset").get.call([])', "'TypeError: Receiver should be a typed array view'");
     73shouldThrow('Object.getOwnPropertyDescriptor(TypedArray.prototype, "byteOffset").get.call({ foo: "bar" })', "'TypeError: Receiver should be a typed array view'");
     74shouldThrow('Object.getOwnPropertyDescriptor(TypedArray.prototype, "byteOffset").get.call(new ArrayBuffer(42))', "'TypeError: Receiver should be a typed array view'");
     75shouldThrow('Object.getOwnPropertyDescriptor(TypedArray.prototype, "byteOffset").get.call(new DataView(new ArrayBuffer(8), 0, 1))', "'TypeError: Receiver should be a typed array view'");
     76
     77// entries.
     78shouldBeTrue('Object.getOwnPropertyDescriptor(TypedArray.prototype, "entries").writable');
     79shouldBeFalse('Object.getOwnPropertyDescriptor(TypedArray.prototype, "entries").enumerable');
     80shouldBeTrue('Object.getOwnPropertyDescriptor(TypedArray.prototype, "entries").configurable');
     81shouldBeEqualToString('typeof Object.getOwnPropertyDescriptor(TypedArray.prototype, "entries").value', 'function');
     82shouldBe('Object.getOwnPropertyDescriptor(TypedArray.prototype, "entries").set', 'undefined');
     83shouldThrow('TypedArray.prototype.entries.call()', "'TypeError: Receiver should be a typed array view'");
     84shouldThrow('TypedArray.prototype.entries.call(undefined)', "'TypeError: Receiver should be a typed array view'");
     85shouldThrow('TypedArray.prototype.entries.call(null)', "'TypeError: Receiver should be a typed array view'");
     86shouldThrow('TypedArray.prototype.entries.call(5)', "'TypeError: Receiver should be a typed array view'");
     87shouldThrow('TypedArray.prototype.entries.call([])', "'TypeError: Receiver should be a typed array view'");
     88shouldThrow('TypedArray.prototype.entries.call({ foo: "bar" })', "'TypeError: Receiver should be a typed array view'");
     89shouldThrow('TypedArray.prototype.entries.call(new ArrayBuffer(42))', "'TypeError: Receiver should be a typed array view'");
     90shouldThrow('TypedArray.prototype.entries.call(new DataView(new ArrayBuffer(8), 0, 1))', "'TypeError: Receiver should be a typed array view'");
     91
    2592// length.
     93shouldBeEqualToString('Object.getOwnPropertyDescriptor(TypedArray.prototype, "length").get.name', 'get length');
     94shouldBe('Object.getOwnPropertyDescriptor(TypedArray.prototype, "length").get.length', '0');
    2695shouldBeFalse('"writable" in Object.getOwnPropertyDescriptor(TypedArray.prototype, "length")');
    2796shouldBeFalse('Object.getOwnPropertyDescriptor(TypedArray.prototype, "length").enumerable');
    2897shouldBeTrue('Object.getOwnPropertyDescriptor(TypedArray.prototype, "length").configurable');
    29 shouldBe('Object.getOwnPropertyDescriptor(TypedArray.prototype, "length").get.length', '0');
    3098shouldBeEqualToString('typeof Object.getOwnPropertyDescriptor(TypedArray.prototype, "length").get', 'function');
    3199shouldBe('Object.getOwnPropertyDescriptor(TypedArray.prototype, "length").set', 'undefined');
     100shouldThrow('Object.getOwnPropertyDescriptor(TypedArray.prototype, "length").get.call()', "'TypeError: Receiver should be a typed array view but was not an object'");
     101shouldThrow('Object.getOwnPropertyDescriptor(TypedArray.prototype, "length").get.call(undefined)', "'TypeError: Receiver should be a typed array view but was not an object'");
     102shouldThrow('Object.getOwnPropertyDescriptor(TypedArray.prototype, "length").get.call(null)', "'TypeError: Receiver should be a typed array view but was not an object'");
     103shouldThrow('Object.getOwnPropertyDescriptor(TypedArray.prototype, "length").get.call(5)', "'TypeError: Receiver should be a typed array view but was not an object'");
     104shouldThrow('Object.getOwnPropertyDescriptor(TypedArray.prototype, "length").get.call([])', "'TypeError: Receiver should be a typed array view'");
     105shouldThrow('Object.getOwnPropertyDescriptor(TypedArray.prototype, "length").get.call({ foo: "bar" })', "'TypeError: Receiver should be a typed array view'");
     106shouldThrow('Object.getOwnPropertyDescriptor(TypedArray.prototype, "length").get.call(new ArrayBuffer(42))', "'TypeError: Receiver should be a typed array view'");
     107shouldThrow('Object.getOwnPropertyDescriptor(TypedArray.prototype, "length").get.call(new DataView(new ArrayBuffer(8), 0, 1))', "'TypeError: Receiver should be a typed array view'");
     108
     109// toLocaleString.
     110shouldBeEqualToString('TypedArray.prototype.toLocaleString.name', 'toLocaleString');
     111shouldBe('TypedArray.prototype.toLocaleString.length', '0');
     112shouldBeTrue('Object.getOwnPropertyDescriptor(TypedArray.prototype, "toLocaleString").writable');
     113shouldBeFalse('Object.getOwnPropertyDescriptor(TypedArray.prototype, "toLocaleString").enumerable');
     114shouldBeTrue('Object.getOwnPropertyDescriptor(TypedArray.prototype, "toLocaleString").configurable');
     115shouldBeEqualToString('typeof Object.getOwnPropertyDescriptor(TypedArray.prototype, "toString").value', 'function');
    32116
    33117// toString.
     118shouldBeEqualToString('TypedArray.prototype.toString.name', 'toString');
     119shouldBe('TypedArray.prototype.toString.length', '0');
    34120shouldBe('TypedArray.prototype.toString', 'Array.prototype.toString');
    35121shouldBeTrue('Object.getOwnPropertyDescriptor(TypedArray.prototype, "toString").writable');
     
    38124shouldBeEqualToString('typeof Object.getOwnPropertyDescriptor(TypedArray.prototype, "toString").value', 'function');
    39125
    40 // toLocaleString.
    41 shouldBeTrue('Object.getOwnPropertyDescriptor(TypedArray.prototype, "toLocaleString").writable');
    42 shouldBeFalse('Object.getOwnPropertyDescriptor(TypedArray.prototype, "toLocaleString").enumerable');
    43 shouldBeTrue('Object.getOwnPropertyDescriptor(TypedArray.prototype, "toLocaleString").configurable');
    44 shouldBeEqualToString('typeof Object.getOwnPropertyDescriptor(TypedArray.prototype, "toString").value', 'function');
     126// toStringTag
     127shouldBeEqualToString('Object.getOwnPropertyDescriptor(TypedArray.prototype, Symbol.toStringTag).get.name', 'get [Symbol.toStringTag]');
     128shouldBe('Object.getOwnPropertyDescriptor(TypedArray.prototype, Symbol.toStringTag).get.length', '0');
     129shouldBeFalse('"writable" in Object.getOwnPropertyDescriptor(TypedArray.prototype, Symbol.toStringTag)');
     130shouldBeFalse('Object.getOwnPropertyDescriptor(TypedArray.prototype, Symbol.toStringTag).enumerable');
     131shouldBeTrue('Object.getOwnPropertyDescriptor(TypedArray.prototype, Symbol.toStringTag).configurable');
     132shouldBeEqualToString('typeof Object.getOwnPropertyDescriptor(TypedArray.prototype, Symbol.toStringTag).get', 'function');
     133shouldBe('Object.getOwnPropertyDescriptor(TypedArray.prototype, Symbol.toStringTag).set', 'undefined');
     134shouldBe('TypedArray.prototype[Symbol.toStringTag]', 'undefined');
     135shouldBe('Object.getOwnPropertyDescriptor(TypedArray.prototype, Symbol.toStringTag).get.call()', 'undefined');
     136shouldBe('Object.getOwnPropertyDescriptor(TypedArray.prototype, Symbol.toStringTag).get.call(undefined)', 'undefined');
     137shouldBe('Object.getOwnPropertyDescriptor(TypedArray.prototype, Symbol.toStringTag).get.call(null)', 'undefined');
     138shouldBe('Object.getOwnPropertyDescriptor(TypedArray.prototype, Symbol.toStringTag).get.call(5)', 'undefined');
     139shouldBe('Object.getOwnPropertyDescriptor(TypedArray.prototype, Symbol.toStringTag).get.call([])', 'undefined');
     140shouldBe('Object.getOwnPropertyDescriptor(TypedArray.prototype, Symbol.toStringTag).get.call({ foo: "bar" })', 'undefined');
     141shouldBe('Object.getOwnPropertyDescriptor(TypedArray.prototype, Symbol.toStringTag).get.call(new ArrayBuffer(42))', 'undefined');
     142shouldBe('Object.getOwnPropertyDescriptor(TypedArray.prototype, Symbol.toStringTag).get.call(new DataView(new ArrayBuffer(8), 0, 1))', 'undefined');
  • trunk/LayoutTests/js/typedarray-constructors-expected.txt

    r196986 r202667  
    66PASS Int8Array() threw exception TypeError: calling Int8Array constructor without new is invalid.
    77PASS new Int8Array() did not throw exception.
     8PASS Int8Array.length is 0
    89PASS Int16Array() threw exception TypeError: calling Int16Array constructor without new is invalid.
    910PASS new Int16Array() did not throw exception.
     11PASS Int16Array.length is 0
    1012PASS Int32Array() threw exception TypeError: calling Int32Array constructor without new is invalid.
    1113PASS new Int32Array() did not throw exception.
     14PASS Int32Array.length is 0
    1215PASS Uint8Array() threw exception TypeError: calling Uint8Array constructor without new is invalid.
    1316PASS new Uint8Array() did not throw exception.
     17PASS Uint8Array.length is 0
     18PASS Uint8ClampedArray() threw exception TypeError: calling Uint8ClampedArray constructor without new is invalid.
     19PASS new Uint8ClampedArray() did not throw exception.
     20PASS Uint8ClampedArray.length is 0
    1421PASS Uint16Array() threw exception TypeError: calling Uint16Array constructor without new is invalid.
    1522PASS new Uint16Array() did not throw exception.
     23PASS Uint16Array.length is 0
    1624PASS Uint32Array() threw exception TypeError: calling Uint32Array constructor without new is invalid.
    1725PASS new Uint32Array() did not throw exception.
    18 PASS Uint8ClampedArray() threw exception TypeError: calling Uint8ClampedArray constructor without new is invalid.
    19 PASS new Uint8ClampedArray() did not throw exception.
     26PASS Uint32Array.length is 0
    2027PASS Float32Array() threw exception TypeError: calling Float32Array constructor without new is invalid.
    2128PASS new Float32Array() did not throw exception.
     29PASS Float32Array.length is 0
    2230PASS Float64Array() threw exception TypeError: calling Float64Array constructor without new is invalid.
    2331PASS new Float64Array() did not throw exception.
     32PASS Float64Array.length is 0
    2433PASS DataView(new ArrayBuffer()) threw exception TypeError: calling DataView constructor without new is invalid.
    2534PASS new DataView(new ArrayBuffer()) did not throw exception.
     35PASS DataView.length is 0
    2636PASS successfullyParsed is true
    2737
  • trunk/LayoutTests/js/typedarray-prototype-expected.txt

    r202631 r202667  
    88PASS Object.getPrototypeOf(Int8Array) === Object.getPrototypeOf(Int32Array) is true
    99PASS Object.getPrototypeOf(Int8Array) === Object.getPrototypeOf(Uint8Array) is true
     10PASS Object.getPrototypeOf(Int8Array) === Object.getPrototypeOf(Uint8ClampedArray) is true
    1011PASS Object.getPrototypeOf(Int8Array) === Object.getPrototypeOf(Uint16Array) is true
    1112PASS Object.getPrototypeOf(Int8Array) === Object.getPrototypeOf(Uint32Array) is true
     
    1516PASS Object.getPrototypeOf(Int16Array) === Object.getPrototypeOf(Int32Array) is true
    1617PASS Object.getPrototypeOf(Int16Array) === Object.getPrototypeOf(Uint8Array) is true
     18PASS Object.getPrototypeOf(Int16Array) === Object.getPrototypeOf(Uint8ClampedArray) is true
    1719PASS Object.getPrototypeOf(Int16Array) === Object.getPrototypeOf(Uint16Array) is true
    1820PASS Object.getPrototypeOf(Int16Array) === Object.getPrototypeOf(Uint32Array) is true
     
    2123PASS Object.getPrototypeOf(Int32Array) === Object.getPrototypeOf(Int32Array) is true
    2224PASS Object.getPrototypeOf(Int32Array) === Object.getPrototypeOf(Uint8Array) is true
     25PASS Object.getPrototypeOf(Int32Array) === Object.getPrototypeOf(Uint8ClampedArray) is true
    2326PASS Object.getPrototypeOf(Int32Array) === Object.getPrototypeOf(Uint16Array) is true
    2427PASS Object.getPrototypeOf(Int32Array) === Object.getPrototypeOf(Uint32Array) is true
     
    2629PASS Object.getPrototypeOf(Int32Array) === Object.getPrototypeOf(Float64Array) is true
    2730PASS Object.getPrototypeOf(Uint8Array) === Object.getPrototypeOf(Uint8Array) is true
     31PASS Object.getPrototypeOf(Uint8Array) === Object.getPrototypeOf(Uint8ClampedArray) is true
    2832PASS Object.getPrototypeOf(Uint8Array) === Object.getPrototypeOf(Uint16Array) is true
    2933PASS Object.getPrototypeOf(Uint8Array) === Object.getPrototypeOf(Uint32Array) is true
    3034PASS Object.getPrototypeOf(Uint8Array) === Object.getPrototypeOf(Float32Array) is true
    3135PASS Object.getPrototypeOf(Uint8Array) === Object.getPrototypeOf(Float64Array) is true
     36PASS Object.getPrototypeOf(Uint8ClampedArray) === Object.getPrototypeOf(Uint8ClampedArray) is true
     37PASS Object.getPrototypeOf(Uint8ClampedArray) === Object.getPrototypeOf(Uint16Array) is true
     38PASS Object.getPrototypeOf(Uint8ClampedArray) === Object.getPrototypeOf(Uint32Array) is true
     39PASS Object.getPrototypeOf(Uint8ClampedArray) === Object.getPrototypeOf(Float32Array) is true
     40PASS Object.getPrototypeOf(Uint8ClampedArray) === Object.getPrototypeOf(Float64Array) is true
    3241PASS Object.getPrototypeOf(Uint16Array) === Object.getPrototypeOf(Uint16Array) is true
    3342PASS Object.getPrototypeOf(Uint16Array) === Object.getPrototypeOf(Uint32Array) is true
     
    4049PASS Object.getPrototypeOf(Float32Array) === Object.getPrototypeOf(Float64Array) is true
    4150PASS Object.getPrototypeOf(Float64Array) === Object.getPrototypeOf(Float64Array) is true
     51PASS Object.getOwnPropertyDescriptor(TypedArray.prototype, "buffer").get.name is "get buffer"
     52PASS Object.getOwnPropertyDescriptor(TypedArray.prototype, "buffer").get.length is 0
     53PASS "writable" in Object.getOwnPropertyDescriptor(TypedArray.prototype, "buffer") is false
     54PASS Object.getOwnPropertyDescriptor(TypedArray.prototype, "buffer").enumerable is false
     55PASS Object.getOwnPropertyDescriptor(TypedArray.prototype, "buffer").configurable is true
     56PASS typeof Object.getOwnPropertyDescriptor(TypedArray.prototype, "buffer").get is "function"
     57PASS Object.getOwnPropertyDescriptor(TypedArray.prototype, "buffer").set is undefined
     58PASS Object.getOwnPropertyDescriptor(TypedArray.prototype, "buffer").get.call() threw exception TypeError: Receiver should be a typed array view but was not an object.
     59PASS Object.getOwnPropertyDescriptor(TypedArray.prototype, "buffer").get.call(undefined) threw exception TypeError: Receiver should be a typed array view but was not an object.
     60PASS Object.getOwnPropertyDescriptor(TypedArray.prototype, "buffer").get.call(null) threw exception TypeError: Receiver should be a typed array view but was not an object.
     61PASS Object.getOwnPropertyDescriptor(TypedArray.prototype, "buffer").get.call(5) threw exception TypeError: Receiver should be a typed array view but was not an object.
     62PASS Object.getOwnPropertyDescriptor(TypedArray.prototype, "buffer").get.call([]) threw exception TypeError: Receiver should be a typed array view.
     63PASS Object.getOwnPropertyDescriptor(TypedArray.prototype, "buffer").get.call({ foo: "bar" }) threw exception TypeError: Receiver should be a typed array view.
     64PASS Object.getOwnPropertyDescriptor(TypedArray.prototype, "buffer").get.call(new ArrayBuffer(42)) threw exception TypeError: Receiver should be a typed array view.
     65PASS Object.getOwnPropertyDescriptor(TypedArray.prototype, "buffer").get.call(new DataView(new ArrayBuffer(8), 0, 1)) threw exception TypeError: Receiver should be a typed array view.
     66PASS Object.getOwnPropertyDescriptor(TypedArray.prototype, "byteLength").get.name is "get byteLength"
     67PASS Object.getOwnPropertyDescriptor(TypedArray.prototype, "byteLength").get.length is 0
     68PASS "writable" in Object.getOwnPropertyDescriptor(TypedArray.prototype, "byteLength") is false
     69PASS Object.getOwnPropertyDescriptor(TypedArray.prototype, "byteLength").enumerable is false
     70PASS Object.getOwnPropertyDescriptor(TypedArray.prototype, "byteLength").configurable is true
     71PASS typeof Object.getOwnPropertyDescriptor(TypedArray.prototype, "byteLength").get is "function"
     72PASS Object.getOwnPropertyDescriptor(TypedArray.prototype, "byteLength").set is undefined
     73PASS Object.getOwnPropertyDescriptor(TypedArray.prototype, "byteLength").get.call() threw exception TypeError: Receiver should be a typed array view but was not an object.
     74PASS Object.getOwnPropertyDescriptor(TypedArray.prototype, "byteLength").get.call(undefined) threw exception TypeError: Receiver should be a typed array view but was not an object.
     75PASS Object.getOwnPropertyDescriptor(TypedArray.prototype, "byteLength").get.call(null) threw exception TypeError: Receiver should be a typed array view but was not an object.
     76PASS Object.getOwnPropertyDescriptor(TypedArray.prototype, "byteLength").get.call(5) threw exception TypeError: Receiver should be a typed array view but was not an object.
     77PASS Object.getOwnPropertyDescriptor(TypedArray.prototype, "byteLength").get.call([]) threw exception TypeError: Receiver should be a typed array view.
     78PASS Object.getOwnPropertyDescriptor(TypedArray.prototype, "byteLength").get.call({ foo: "bar" }) threw exception TypeError: Receiver should be a typed array view.
     79PASS Object.getOwnPropertyDescriptor(TypedArray.prototype, "byteLength").get.call(new ArrayBuffer(42)) threw exception TypeError: Receiver should be a typed array view.
     80PASS Object.getOwnPropertyDescriptor(TypedArray.prototype, "byteLength").get.call(new DataView(new ArrayBuffer(8), 0, 1)) threw exception TypeError: Receiver should be a typed array view.
     81PASS Object.getOwnPropertyDescriptor(TypedArray.prototype, "byteOffset").get.name is "get byteOffset"
     82PASS Object.getOwnPropertyDescriptor(TypedArray.prototype, "byteOffset").get.length is 0
     83PASS "writable" in Object.getOwnPropertyDescriptor(TypedArray.prototype, "byteOffset") is false
     84PASS Object.getOwnPropertyDescriptor(TypedArray.prototype, "byteOffset").enumerable is false
     85PASS Object.getOwnPropertyDescriptor(TypedArray.prototype, "byteOffset").configurable is true
     86PASS typeof Object.getOwnPropertyDescriptor(TypedArray.prototype, "byteOffset").get is "function"
     87PASS Object.getOwnPropertyDescriptor(TypedArray.prototype, "byteOffset").set is undefined
     88PASS Object.getOwnPropertyDescriptor(TypedArray.prototype, "byteOffset").get.call() threw exception TypeError: Receiver should be a typed array view but was not an object.
     89PASS Object.getOwnPropertyDescriptor(TypedArray.prototype, "byteOffset").get.call(undefined) threw exception TypeError: Receiver should be a typed array view but was not an object.
     90PASS Object.getOwnPropertyDescriptor(TypedArray.prototype, "byteOffset").get.call(null) threw exception TypeError: Receiver should be a typed array view but was not an object.
     91PASS Object.getOwnPropertyDescriptor(TypedArray.prototype, "byteOffset").get.call(5) threw exception TypeError: Receiver should be a typed array view but was not an object.
     92PASS Object.getOwnPropertyDescriptor(TypedArray.prototype, "byteOffset").get.call([]) threw exception TypeError: Receiver should be a typed array view.
     93PASS Object.getOwnPropertyDescriptor(TypedArray.prototype, "byteOffset").get.call({ foo: "bar" }) threw exception TypeError: Receiver should be a typed array view.
     94PASS Object.getOwnPropertyDescriptor(TypedArray.prototype, "byteOffset").get.call(new ArrayBuffer(42)) threw exception TypeError: Receiver should be a typed array view.
     95PASS Object.getOwnPropertyDescriptor(TypedArray.prototype, "byteOffset").get.call(new DataView(new ArrayBuffer(8), 0, 1)) threw exception TypeError: Receiver should be a typed array view.
     96PASS Object.getOwnPropertyDescriptor(TypedArray.prototype, "entries").writable is true
     97PASS Object.getOwnPropertyDescriptor(TypedArray.prototype, "entries").enumerable is false
     98PASS Object.getOwnPropertyDescriptor(TypedArray.prototype, "entries").configurable is true
     99PASS typeof Object.getOwnPropertyDescriptor(TypedArray.prototype, "entries").value is "function"
     100PASS Object.getOwnPropertyDescriptor(TypedArray.prototype, "entries").set is undefined
     101PASS TypedArray.prototype.entries.call() threw exception TypeError: Receiver should be a typed array view.
     102PASS TypedArray.prototype.entries.call(undefined) threw exception TypeError: Receiver should be a typed array view.
     103PASS TypedArray.prototype.entries.call(null) threw exception TypeError: Receiver should be a typed array view.
     104PASS TypedArray.prototype.entries.call(5) threw exception TypeError: Receiver should be a typed array view.
     105PASS TypedArray.prototype.entries.call([]) threw exception TypeError: Receiver should be a typed array view.
     106PASS TypedArray.prototype.entries.call({ foo: "bar" }) threw exception TypeError: Receiver should be a typed array view.
     107PASS TypedArray.prototype.entries.call(new ArrayBuffer(42)) threw exception TypeError: Receiver should be a typed array view.
     108PASS TypedArray.prototype.entries.call(new DataView(new ArrayBuffer(8), 0, 1)) threw exception TypeError: Receiver should be a typed array view.
     109PASS Object.getOwnPropertyDescriptor(TypedArray.prototype, "length").get.name is "get length"
     110PASS Object.getOwnPropertyDescriptor(TypedArray.prototype, "length").get.length is 0
    42111PASS "writable" in Object.getOwnPropertyDescriptor(TypedArray.prototype, "length") is false
    43112PASS Object.getOwnPropertyDescriptor(TypedArray.prototype, "length").enumerable is false
    44113PASS Object.getOwnPropertyDescriptor(TypedArray.prototype, "length").configurable is true
    45 PASS Object.getOwnPropertyDescriptor(TypedArray.prototype, "length").get.length is 0
    46114PASS typeof Object.getOwnPropertyDescriptor(TypedArray.prototype, "length").get is "function"
    47115PASS Object.getOwnPropertyDescriptor(TypedArray.prototype, "length").set is undefined
     116PASS Object.getOwnPropertyDescriptor(TypedArray.prototype, "length").get.call() threw exception TypeError: Receiver should be a typed array view but was not an object.
     117PASS Object.getOwnPropertyDescriptor(TypedArray.prototype, "length").get.call(undefined) threw exception TypeError: Receiver should be a typed array view but was not an object.
     118PASS Object.getOwnPropertyDescriptor(TypedArray.prototype, "length").get.call(null) threw exception TypeError: Receiver should be a typed array view but was not an object.
     119PASS Object.getOwnPropertyDescriptor(TypedArray.prototype, "length").get.call(5) threw exception TypeError: Receiver should be a typed array view but was not an object.
     120PASS Object.getOwnPropertyDescriptor(TypedArray.prototype, "length").get.call([]) threw exception TypeError: Receiver should be a typed array view.
     121PASS Object.getOwnPropertyDescriptor(TypedArray.prototype, "length").get.call({ foo: "bar" }) threw exception TypeError: Receiver should be a typed array view.
     122PASS Object.getOwnPropertyDescriptor(TypedArray.prototype, "length").get.call(new ArrayBuffer(42)) threw exception TypeError: Receiver should be a typed array view.
     123PASS Object.getOwnPropertyDescriptor(TypedArray.prototype, "length").get.call(new DataView(new ArrayBuffer(8), 0, 1)) threw exception TypeError: Receiver should be a typed array view.
     124PASS TypedArray.prototype.toLocaleString.name is "toLocaleString"
     125PASS TypedArray.prototype.toLocaleString.length is 0
     126PASS Object.getOwnPropertyDescriptor(TypedArray.prototype, "toLocaleString").writable is true
     127PASS Object.getOwnPropertyDescriptor(TypedArray.prototype, "toLocaleString").enumerable is false
     128PASS Object.getOwnPropertyDescriptor(TypedArray.prototype, "toLocaleString").configurable is true
     129PASS typeof Object.getOwnPropertyDescriptor(TypedArray.prototype, "toString").value is "function"
     130PASS TypedArray.prototype.toString.name is "toString"
     131PASS TypedArray.prototype.toString.length is 0
    48132PASS TypedArray.prototype.toString is Array.prototype.toString
    49133PASS Object.getOwnPropertyDescriptor(TypedArray.prototype, "toString").writable is true
     
    51135PASS Object.getOwnPropertyDescriptor(TypedArray.prototype, "toString").configurable is true
    52136PASS typeof Object.getOwnPropertyDescriptor(TypedArray.prototype, "toString").value is "function"
    53 PASS Object.getOwnPropertyDescriptor(TypedArray.prototype, "toLocaleString").writable is true
    54 PASS Object.getOwnPropertyDescriptor(TypedArray.prototype, "toLocaleString").enumerable is false
    55 PASS Object.getOwnPropertyDescriptor(TypedArray.prototype, "toLocaleString").configurable is true
    56 PASS typeof Object.getOwnPropertyDescriptor(TypedArray.prototype, "toString").value is "function"
     137PASS Object.getOwnPropertyDescriptor(TypedArray.prototype, Symbol.toStringTag).get.name is "get [Symbol.toStringTag]"
     138PASS Object.getOwnPropertyDescriptor(TypedArray.prototype, Symbol.toStringTag).get.length is 0
     139PASS "writable" in Object.getOwnPropertyDescriptor(TypedArray.prototype, Symbol.toStringTag) is false
     140PASS Object.getOwnPropertyDescriptor(TypedArray.prototype, Symbol.toStringTag).enumerable is false
     141PASS Object.getOwnPropertyDescriptor(TypedArray.prototype, Symbol.toStringTag).configurable is true
     142PASS typeof Object.getOwnPropertyDescriptor(TypedArray.prototype, Symbol.toStringTag).get is "function"
     143PASS Object.getOwnPropertyDescriptor(TypedArray.prototype, Symbol.toStringTag).set is undefined
     144PASS TypedArray.prototype[Symbol.toStringTag] is undefined
     145PASS Object.getOwnPropertyDescriptor(TypedArray.prototype, Symbol.toStringTag).get.call() is undefined
     146PASS Object.getOwnPropertyDescriptor(TypedArray.prototype, Symbol.toStringTag).get.call(undefined) is undefined
     147PASS Object.getOwnPropertyDescriptor(TypedArray.prototype, Symbol.toStringTag).get.call(null) is undefined
     148PASS Object.getOwnPropertyDescriptor(TypedArray.prototype, Symbol.toStringTag).get.call(5) is undefined
     149PASS Object.getOwnPropertyDescriptor(TypedArray.prototype, Symbol.toStringTag).get.call([]) is undefined
     150PASS Object.getOwnPropertyDescriptor(TypedArray.prototype, Symbol.toStringTag).get.call({ foo: "bar" }) is undefined
     151PASS Object.getOwnPropertyDescriptor(TypedArray.prototype, Symbol.toStringTag).get.call(new ArrayBuffer(42)) is undefined
     152PASS Object.getOwnPropertyDescriptor(TypedArray.prototype, Symbol.toStringTag).get.call(new DataView(new ArrayBuffer(8), 0, 1)) is undefined
    57153PASS successfullyParsed is true
    58154
  • trunk/LayoutTests/platform/mac/js/dom/constructor-length-expected.txt

    r189841 r202667  
    1414FAIL DOMFormData.length should be 0. Threw exception ReferenceError: Can't find variable: DOMFormData
    1515PASS DOMParser.length is 0
    16 PASS DataView.length is 3
     16FAIL DataView.length should be 3. Was 0.
    1717PASS ErrorEvent.length is 1
    1818PASS Event.length is 1
    1919PASS EventSource.length is 1
    20 PASS Float32Array.length is 3
    21 PASS Float64Array.length is 3
     20FAIL Float32Array.length should be 3. Was 0.
     21FAIL Float64Array.length should be 3. Was 0.
    2222PASS FileReader.length is 0
    2323FAIL FileReaderSync.length should be 0. Threw exception ReferenceError: Can't find variable: FileReaderSync
    2424PASS HashChangeEvent.length is 1
    25 PASS Int16Array.length is 3
    26 PASS Int32Array.length is 3
    27 PASS Int8Array.length is 3
     25FAIL Int16Array.length should be 3. Was 0.
     26FAIL Int32Array.length should be 3. Was 0.
     27FAIL Int8Array.length should be 3. Was 0.
    2828FAIL Intent.length should be 3. Threw exception ReferenceError: Can't find variable: Intent
    2929PASS MediaController.length is 0
     
    4040PASS TextTrackCue.length is 3
    4141PASS TrackEvent.length is 1
    42 PASS Uint16Array.length is 3
    43 PASS Uint32Array.length is 3
    44 PASS Uint8Array.length is 3
    45 PASS Uint8ClampedArray.length is 3
     42FAIL Uint16Array.length should be 3. Was 0.
     43FAIL Uint32Array.length should be 3. Was 0.
     44FAIL Uint8Array.length should be 3. Was 0.
     45FAIL Uint8ClampedArray.length should be 3. Was 0.
    4646PASS VTTCue.length is 3
    4747PASS WebGLContextEvent.length is 1
  • trunk/Source/JavaScriptCore/ChangeLog

    r202666 r202667  
     12016-06-29  Benjamin Poulain  <bpoulain@apple.com>
     2
     3        [JSC] Minor TypedArray fixes
     4        https://bugs.webkit.org/show_bug.cgi?id=159286
     5
     6        Reviewed by Keith Miller.
     7
     8        * runtime/JSGenericTypedArrayViewConstructorInlines.h:
     9        (JSC::JSGenericTypedArrayViewConstructor<ViewClass>::finishCreation):
     10        See https://tc39.github.io/ecma262/#sec-%typedarray%
     11
     12        * runtime/JSTypedArrayViewPrototype.cpp:
     13        (JSC::typedArrayViewPrivateFuncLength):
     14        See https://tc39.github.io/ecma262/#sec-get-%typedarray%.prototype.length
     15
     16        (JSC::typedArrayViewProtoGetterFuncToStringTag):
     17        Yep, that's odd.
     18        See https://tc39.github.io/ecma262/#sec-get-%typedarray%.prototype-@@tostringtag
     19
     20        (JSC::JSTypedArrayViewPrototype::finishCreation):
     21        See the last paragraph of https://tc39.github.io/ecma262/#sec-ecmascript-standard-built-in-objects
     22
    1232016-06-29  Joseph Pecoraro  <pecoraro@apple.com>
    224
  • trunk/Source/JavaScriptCore/runtime/JSGenericTypedArrayViewConstructorInlines.h

    r202280 r202667  
    5050    Base::finishCreation(vm, name);
    5151    putDirectWithoutTransition(vm, vm.propertyNames->prototype, prototype, DontEnum | DontDelete | ReadOnly);
    52     putDirectWithoutTransition(vm, vm.propertyNames->length, jsNumber(3), DontEnum | DontDelete | ReadOnly);
     52    putDirectWithoutTransition(vm, vm.propertyNames->length, jsNumber(0), DontEnum | DontDelete | ReadOnly);
    5353    putDirectWithoutTransition(vm, vm.propertyNames->BYTES_PER_ELEMENT, jsNumber(ViewClass::elementSize), DontEnum | ReadOnly | DontDelete);
    5454
  • trunk/Source/JavaScriptCore/runtime/JSTypedArrayViewPrototype.cpp

    r202631 r202667  
    7373EncodedJSValue JSC_HOST_CALL typedArrayViewPrivateFuncLength(ExecState* exec)
    7474{
    75     JSArrayBufferView* thisObject = jsDynamicCast<JSArrayBufferView*>(exec->argument(0));
    76     if (!thisObject)
     75    JSValue argument = exec->argument(0);
     76    if (!argument.isCell() || !isTypedView(argument.asCell()->classInfo()->typedArrayStorageType))
     77        return throwVMTypeError(exec, "Receiver should be a typed array view");
     78
     79    JSArrayBufferView* thisObject = jsCast<JSArrayBufferView*>(argument);
     80    if (!thisObject || thisObject->mode() == DataViewMode)
    7781        return throwVMError(exec, createTypeError(exec, "Receiver should be a typed array view"));
    7882    if (thisObject->isNeutered())
     
    204208    JSValue thisValue = exec->thisValue();
    205209    if (!thisValue.isObject())
    206         return throwVMError(exec, createTypeError(exec, "Receiver should be a typed array view but was not an object"));
     210        return JSValue::encode(jsUndefined());
    207211
    208212    VM& vm = exec->vm();
     
    228232    case NotTypedArray:
    229233    case TypeDataView:
    230         return throwVMError(exec, createTypeError(exec, "Receiver should be a typed array view"));
     234        return JSValue::encode(jsUndefined());
    231235    }
    232236    RELEASE_ASSERT_NOT_REACHED();
     
    249253    putDirectWithoutTransition(vm, vm.propertyNames->toString, globalObject->arrayProtoToStringFunction(), DontEnum);
    250254
    251     JSC_NATIVE_GETTER(vm.propertyNames->buffer, typedArrayViewProtoGetterFuncBuffer, DontEnum | ReadOnly | DontDelete);
    252     JSC_NATIVE_INTRINSIC_GETTER(vm.propertyNames->byteLength, typedArrayViewProtoGetterFuncByteLength, DontEnum | ReadOnly | DontDelete, TypedArrayByteLengthIntrinsic);
    253     JSC_NATIVE_INTRINSIC_GETTER(vm.propertyNames->byteOffset, typedArrayViewProtoGetterFuncByteOffset, DontEnum | ReadOnly | DontDelete, TypedArrayByteOffsetIntrinsic);
     255    JSC_NATIVE_GETTER(vm.propertyNames->buffer, typedArrayViewProtoGetterFuncBuffer, DontEnum | ReadOnly);
     256    JSC_NATIVE_INTRINSIC_GETTER(vm.propertyNames->byteLength, typedArrayViewProtoGetterFuncByteLength, DontEnum | ReadOnly, TypedArrayByteLengthIntrinsic);
     257    JSC_NATIVE_INTRINSIC_GETTER(vm.propertyNames->byteOffset, typedArrayViewProtoGetterFuncByteOffset, DontEnum | ReadOnly, TypedArrayByteOffsetIntrinsic);
    254258    JSC_NATIVE_FUNCTION_WITHOUT_TRANSITION("copyWithin", typedArrayViewProtoFuncCopyWithin, DontEnum, 2);
    255259    JSC_BUILTIN_FUNCTION_WITHOUT_TRANSITION("every", typedArrayPrototypeEveryCodeGenerator, DontEnum);
     
    275279    JSC_NATIVE_FUNCTION_WITHOUT_TRANSITION(vm.propertyNames->subarray, typedArrayViewProtoFuncSubarray, DontEnum, 2);
    276280    JSC_BUILTIN_FUNCTION_WITHOUT_TRANSITION(vm.propertyNames->toLocaleString, typedArrayPrototypeToLocaleStringCodeGenerator, DontEnum);
    277     JSC_NATIVE_GETTER(vm.propertyNames->toStringTagSymbol, typedArrayViewProtoGetterFuncToStringTag, DontEnum | ReadOnly);
     281
     282    JSFunction* toStringTagFunction = JSFunction::create(vm, globalObject, 0, ASCIILiteral("get [Symbol.toStringTag]"), typedArrayViewProtoGetterFuncToStringTag, NoIntrinsic);
     283    GetterSetter* toStringTagAccessor = GetterSetter::create(vm, globalObject);
     284    toStringTagAccessor->setGetter(vm, globalObject, toStringTagFunction);
     285    putDirectNonIndexAccessor(vm, vm.propertyNames->toStringTagSymbol, toStringTagAccessor, DontEnum | ReadOnly);
    278286
    279287    JSFunction* valuesFunction = JSFunction::createBuiltinFunction(vm, typedArrayPrototypeValuesCodeGenerator(vm), globalObject);
Note: See TracChangeset for help on using the changeset viewer.