Title: [138393] trunk
Revision
138393
Author
[email protected]
Date
2012-12-21 11:38:28 -0800 (Fri, 21 Dec 2012)

Log Message

Expose ArrayBufferView constructor on DOMWindow
https://bugs.webkit.org/show_bug.cgi?id=105605

Reviewed by Sam Weinig.

Source/WebCore:

Update IDL to track recent spec change exposing ArrayBufferView
constructor on DOMWindow for instanceof checks. There are no
constructors exposed in the Web IDL, however, so calling it via
operator new throws TypeError.

Test (updated): fast/canvas/webgl/array-unit-tests.html

* html/canvas/ArrayBufferView.idl:
    Removed OmitConstructor attribute.
* page/DOMWindow.idl:
    Exposed ArrayBufferView constructor function attribute.

LayoutTests:

Updated test from Khronos repository.

* fast/canvas/webgl/array-unit-tests-expected.txt:
* fast/canvas/webgl/array-unit-tests.html:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (138392 => 138393)


--- trunk/LayoutTests/ChangeLog	2012-12-21 19:27:18 UTC (rev 138392)
+++ trunk/LayoutTests/ChangeLog	2012-12-21 19:38:28 UTC (rev 138393)
@@ -1,3 +1,15 @@
+2012-12-21  Kenneth Russell  <[email protected]>
+
+        Expose ArrayBufferView constructor on DOMWindow
+        https://bugs.webkit.org/show_bug.cgi?id=105605
+
+        Reviewed by Sam Weinig.
+
+        Updated test from Khronos repository.
+
+        * fast/canvas/webgl/array-unit-tests-expected.txt:
+        * fast/canvas/webgl/array-unit-tests.html:
+
 2012-12-21  Csaba Osztrogonác  <[email protected]>
 
         Unreviewed gardening, unskip now passing tests.

Modified: trunk/LayoutTests/fast/canvas/webgl/array-unit-tests-expected.txt (138392 => 138393)


--- trunk/LayoutTests/fast/canvas/webgl/array-unit-tests-expected.txt	2012-12-21 19:27:18 UTC (rev 138392)
+++ trunk/LayoutTests/fast/canvas/webgl/array-unit-tests-expected.txt	2012-12-21 19:38:28 UTC (rev 138393)
@@ -2,6 +2,21 @@
 
 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
 
+PASS testSlice
+test inheritance hierarchy of typed array views
+PASS ArrayBufferView does not have [NoInterfaceObject] extended attribute and should be defined
+PASS new Int8Array(1) instanceof ArrayBufferView is true
+PASS new Uint8Array(1) instanceof ArrayBufferView is true
+PASS new Uint8ClampedArray(1) instanceof ArrayBufferView is true
+PASS new Int16Array(1) instanceof ArrayBufferView is true
+PASS new Uint16Array(1) instanceof ArrayBufferView is true
+PASS new Int32Array(1) instanceof ArrayBufferView is true
+PASS new Uint32Array(1) instanceof ArrayBufferView is true
+PASS new Float32Array(1) instanceof ArrayBufferView is true
+PASS new Float64Array(1) instanceof ArrayBufferView is true
+PASS new DataView(new ArrayBuffer(8)) instanceof ArrayBufferView is true
+PASS new ArrayBufferView() threw TypeError
+PASS new Uint8ClampedArray(1) instanceof Uint8Array is true
 PASS test Float32Array SetAndGetPos10ToNeg10
 PASS test Float32Array ConstructWithArrayOfSignedValues
 PASS test Float32Array ConstructWithTypedArrayOfSignedValues

Modified: trunk/LayoutTests/fast/canvas/webgl/array-unit-tests.html (138392 => 138393)


--- trunk/LayoutTests/fast/canvas/webgl/array-unit-tests.html	2012-12-21 19:27:18 UTC (rev 138392)
+++ trunk/LayoutTests/fast/canvas/webgl/array-unit-tests.html	2012-12-21 19:38:28 UTC (rev 138393)
@@ -70,6 +70,7 @@
   }
 
   try {
+    running('testSlice');
     var buffer = new ArrayBuffer(32);
     var array = new Int8Array(buffer);
     for (var i = 0; i < 32; ++i)
@@ -102,6 +103,7 @@
     test("buffer.slice(-20, -8)", 12, 12);
     test("buffer.slice(-40, 16)", 0, 16);
     test("buffer.slice(-40, 40)", 0, 32);
+    pass();
   } catch (e) {
     fail(e);
   }
@@ -218,11 +220,11 @@
   var expectedResults;
 
   if (unsigned) {
-    sourceData = [0.6, 10.6];
+    sourceData = [0.6, 10.6, 0.2, 10.2, 10.5, 11.5];
     if (type === Uint8ClampedArray) {
-      expectedResults = [1, 11];
+      expectedResults = [1, 11, 0, 10, 10, 12];
     } else {
-      expectedResults = [0, 10];
+      expectedResults = [0, 10, 0, 10, 10, 11];
     }
   } else {
     sourceData = [0.6, 10.6, -0.6, -10.6];
@@ -552,6 +554,22 @@
     }
 }
 
+function shouldThrowTypeError(func, text) {
+    var ok = false;
+    try {
+        func();
+    } catch (e) {
+        if (e instanceof TypeError) {
+            ok = true;
+        }
+    }
+    if (ok) {
+        testPassed(text + " threw TypeError");
+    } else {
+        testFailed(text + " should throw TypeError");
+    }
+}
+
 function testConstructionWithOutOfRangeValues(type, name) {
     shouldThrowIndexSizeErr(function() {
         var buffer = new ArrayBuffer(4);
@@ -901,6 +919,34 @@
   }
 }
 
+function testInheritanceHierarchy() {
+  debug('test inheritance hierarchy of typed array views');
+
+  try {
+    var foo = ArrayBufferView;
+    testPassed('ArrayBufferView does not have [NoInterfaceObject] extended attribute and should be defined');
+
+    shouldBe('new Int8Array(1) instanceof ArrayBufferView', 'true');
+    shouldBe('new Uint8Array(1) instanceof ArrayBufferView', 'true');
+    shouldBe('new Uint8ClampedArray(1) instanceof ArrayBufferView', 'true');
+    shouldBe('new Int16Array(1) instanceof ArrayBufferView', 'true');
+    shouldBe('new Uint16Array(1) instanceof ArrayBufferView', 'true');
+    shouldBe('new Int32Array(1) instanceof ArrayBufferView', 'true');
+    shouldBe('new Uint32Array(1) instanceof ArrayBufferView', 'true');
+    shouldBe('new Float32Array(1) instanceof ArrayBufferView', 'true');
+    shouldBe('new Float64Array(1) instanceof ArrayBufferView', 'true');
+    shouldBe('new DataView(new ArrayBuffer(8)) instanceof ArrayBufferView', 'true');
+
+    shouldThrowTypeError(function() { new ArrayBufferView() }, "new ArrayBufferView()");
+  } catch (e) {
+    testFailed('ArrayBufferView does not have [NoInterfaceObject] extended attribute but was not defined');
+  }
+
+  // There is currently only one kind of view that inherits from another
+  shouldBe('new Uint8ClampedArray(1) instanceof Uint8Array', 'true');
+}
+
+
 //
 // Test driver
 //
@@ -909,6 +955,7 @@
   allPassed = true;
 
   testSlice();
+  testInheritanceHierarchy();
 
   // The "name" attribute is a concession to browsers which don't
   // implement the "name" property on function objects

Modified: trunk/Source/WebCore/ChangeLog (138392 => 138393)


--- trunk/Source/WebCore/ChangeLog	2012-12-21 19:27:18 UTC (rev 138392)
+++ trunk/Source/WebCore/ChangeLog	2012-12-21 19:38:28 UTC (rev 138393)
@@ -1,3 +1,22 @@
+2012-12-21  Kenneth Russell  <[email protected]>
+
+        Expose ArrayBufferView constructor on DOMWindow
+        https://bugs.webkit.org/show_bug.cgi?id=105605
+
+        Reviewed by Sam Weinig.
+
+        Update IDL to track recent spec change exposing ArrayBufferView
+        constructor on DOMWindow for instanceof checks. There are no
+        constructors exposed in the Web IDL, however, so calling it via
+        operator new throws TypeError.
+
+        Test (updated): fast/canvas/webgl/array-unit-tests.html
+
+        * html/canvas/ArrayBufferView.idl:
+            Removed OmitConstructor attribute.
+        * page/DOMWindow.idl:
+            Exposed ArrayBufferView constructor function attribute.
+
 2012-12-21  Brady Eidson  <[email protected]>
 
         Remove ResourceLoadScheduler::addMainResourceLoad and all related code

Modified: trunk/Source/WebCore/html/canvas/ArrayBufferView.idl (138392 => 138393)


--- trunk/Source/WebCore/html/canvas/ArrayBufferView.idl	2012-12-21 19:27:18 UTC (rev 138392)
+++ trunk/Source/WebCore/html/canvas/ArrayBufferView.idl	2012-12-21 19:38:28 UTC (rev 138393)
@@ -25,8 +25,7 @@
 
 [
     CustomToJSObject,
-    JSNoStaticTables,
-    OmitConstructor
+    JSNoStaticTables
 ] interface ArrayBufferView {
     readonly attribute ArrayBuffer buffer;
     readonly attribute unsigned long byteOffset;

Modified: trunk/Source/WebCore/page/DOMWindow.idl (138392 => 138393)


--- trunk/Source/WebCore/page/DOMWindow.idl	2012-12-21 19:27:18 UTC (rev 138392)
+++ trunk/Source/WebCore/page/DOMWindow.idl	2012-12-21 19:38:28 UTC (rev 138393)
@@ -529,6 +529,7 @@
     attribute DOMStringMapConstructor DOMStringMap;
 
     attribute ArrayBufferConstructor ArrayBuffer; // Usable with new operator
+    attribute ArrayBufferViewConstructor ArrayBufferView;
     attribute Int8ArrayConstructor Int8Array; // Usable with new operator
     attribute Uint8ArrayConstructor Uint8Array; // Usable with new operator
     attribute Uint8ClampedArrayConstructor Uint8ClampedArray; // Usable with new operator
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to