Title: [122262] trunk/LayoutTests
Revision
122262
Author
[email protected]
Date
2012-07-10 14:21:34 -0700 (Tue, 10 Jul 2012)

Log Message

[Chromium] IndexedDB: Need test of Typed Arrays
https://bugs.webkit.org/show_bug.cgi?id=81979

Reviewed by Tony Chang.

Verify storage of Typed Arrays (Uint8Array and friends). Checks that
these types are stored and read back with types and data intact. Also
add an index to the object store, so that key paths are evaluated
against each type on every write operation.

* storage/indexeddb/structured-clone-expected.txt:
* storage/indexeddb/structured-clone.html:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (122261 => 122262)


--- trunk/LayoutTests/ChangeLog	2012-07-10 21:13:28 UTC (rev 122261)
+++ trunk/LayoutTests/ChangeLog	2012-07-10 21:21:34 UTC (rev 122262)
@@ -1,3 +1,18 @@
+2012-07-10  Joshua Bell  <[email protected]>
+
+        [Chromium] IndexedDB: Need test of Typed Arrays
+        https://bugs.webkit.org/show_bug.cgi?id=81979
+
+        Reviewed by Tony Chang.
+
+        Verify storage of Typed Arrays (Uint8Array and friends). Checks that
+        these types are stored and read back with types and data intact. Also
+        add an index to the object store, so that key paths are evaluated
+        against each type on every write operation.
+
+        * storage/indexeddb/structured-clone-expected.txt:
+        * storage/indexeddb/structured-clone.html:
+
 2012-07-10  Adam Barth  <[email protected]>
 
         Remove LayoutTestController and WebKitTestRunner support for Hixie76 WebSockets

Modified: trunk/LayoutTests/storage/indexeddb/structured-clone-expected.txt (122261 => 122262)


--- trunk/LayoutTests/storage/indexeddb/structured-clone-expected.txt	2012-07-10 21:13:28 UTC (rev 122261)
+++ trunk/LayoutTests/storage/indexeddb/structured-clone-expected.txt	2012-07-10 21:21:34 UTC (rev 122262)
@@ -12,7 +12,9 @@
 db = request.result
 PASS db.version is ""
 db.setVersion('1')
-db.createObjectStore('storeName')
+store = db.createObjectStore('storeName')
+This index is not used, but evaluating key path on each put() call will exercise (de)serialization:
+store.createIndex('indexName', 'dummyKeyPath')
 
 Running tests...
 
@@ -581,7 +583,145 @@
 PASS test_data["bar"] is result["bar"]
 PASS test_data[""] is result[""]
 
+Testing TypedArray
+value = new Uint8Array([])
+transaction = db.transaction('storeName', 'readwrite')
+store = transaction.objectStore('storeName')
+store.put(value, 'key')
+store.get('key')
+PASS test_data !== result is true
+PASS Object.prototype.toString.call(result) is Object.prototype.toString.call(test_data)
+PASS test_data.length === result.length is true
 
+value = new Uint8Array([0, 1, 254, 255])
+transaction = db.transaction('storeName', 'readwrite')
+store = transaction.objectStore('storeName')
+store.put(value, 'key')
+store.get('key')
+PASS test_data !== result is true
+PASS Object.prototype.toString.call(result) is Object.prototype.toString.call(test_data)
+PASS test_data.length === result.length is true
+PASS is(test_data[0], result[0]) is true
+PASS is(test_data[1], result[1]) is true
+PASS is(test_data[2], result[2]) is true
+PASS is(test_data[3], result[3]) is true
+
+value = new Uint16Array([0x0000, 0x0001, 0xFFFE, 0xFFFF])
+transaction = db.transaction('storeName', 'readwrite')
+store = transaction.objectStore('storeName')
+store.put(value, 'key')
+store.get('key')
+PASS test_data !== result is true
+PASS Object.prototype.toString.call(result) is Object.prototype.toString.call(test_data)
+PASS test_data.length === result.length is true
+PASS is(test_data[0], result[0]) is true
+PASS is(test_data[1], result[1]) is true
+PASS is(test_data[2], result[2]) is true
+PASS is(test_data[3], result[3]) is true
+
+value = new Uint32Array([0x00000000, 0x00000001, 0xFFFFFFFE, 0xFFFFFFFF])
+transaction = db.transaction('storeName', 'readwrite')
+store = transaction.objectStore('storeName')
+store.put(value, 'key')
+store.get('key')
+PASS test_data !== result is true
+PASS Object.prototype.toString.call(result) is Object.prototype.toString.call(test_data)
+PASS test_data.length === result.length is true
+PASS is(test_data[0], result[0]) is true
+PASS is(test_data[1], result[1]) is true
+PASS is(test_data[2], result[2]) is true
+PASS is(test_data[3], result[3]) is true
+
+value = new Int8Array([0, 1, 254, 255])
+transaction = db.transaction('storeName', 'readwrite')
+store = transaction.objectStore('storeName')
+store.put(value, 'key')
+store.get('key')
+PASS test_data !== result is true
+PASS Object.prototype.toString.call(result) is Object.prototype.toString.call(test_data)
+PASS test_data.length === result.length is true
+PASS is(test_data[0], result[0]) is true
+PASS is(test_data[1], result[1]) is true
+PASS is(test_data[2], result[2]) is true
+PASS is(test_data[3], result[3]) is true
+
+value = new Int16Array([0x0000, 0x0001, 0xFFFE, 0xFFFF])
+transaction = db.transaction('storeName', 'readwrite')
+store = transaction.objectStore('storeName')
+store.put(value, 'key')
+store.get('key')
+PASS test_data !== result is true
+PASS Object.prototype.toString.call(result) is Object.prototype.toString.call(test_data)
+PASS test_data.length === result.length is true
+PASS is(test_data[0], result[0]) is true
+PASS is(test_data[1], result[1]) is true
+PASS is(test_data[2], result[2]) is true
+PASS is(test_data[3], result[3]) is true
+
+value = new Int32Array([0x00000000, 0x00000001, 0xFFFFFFFE, 0xFFFFFFFF])
+transaction = db.transaction('storeName', 'readwrite')
+store = transaction.objectStore('storeName')
+store.put(value, 'key')
+store.get('key')
+PASS test_data !== result is true
+PASS Object.prototype.toString.call(result) is Object.prototype.toString.call(test_data)
+PASS test_data.length === result.length is true
+PASS is(test_data[0], result[0]) is true
+PASS is(test_data[1], result[1]) is true
+PASS is(test_data[2], result[2]) is true
+PASS is(test_data[3], result[3]) is true
+
+value = new Uint8ClampedArray([0, 1, 254, 255])
+transaction = db.transaction('storeName', 'readwrite')
+store = transaction.objectStore('storeName')
+store.put(value, 'key')
+store.get('key')
+PASS test_data !== result is true
+PASS Object.prototype.toString.call(result) is Object.prototype.toString.call(test_data)
+PASS test_data.length === result.length is true
+PASS is(test_data[0], result[0]) is true
+PASS is(test_data[1], result[1]) is true
+PASS is(test_data[2], result[2]) is true
+PASS is(test_data[3], result[3]) is true
+
+value = new Float32Array([-Infinity, -1.5, -1, -0.5, 0, 0.5, 1, 1.5, Infinity, NaN])
+transaction = db.transaction('storeName', 'readwrite')
+store = transaction.objectStore('storeName')
+store.put(value, 'key')
+store.get('key')
+PASS test_data !== result is true
+PASS Object.prototype.toString.call(result) is Object.prototype.toString.call(test_data)
+PASS test_data.length === result.length is true
+PASS is(test_data[0], result[0]) is true
+PASS is(test_data[1], result[1]) is true
+PASS is(test_data[2], result[2]) is true
+PASS is(test_data[3], result[3]) is true
+PASS is(test_data[4], result[4]) is true
+PASS is(test_data[5], result[5]) is true
+PASS is(test_data[6], result[6]) is true
+PASS is(test_data[7], result[7]) is true
+PASS is(test_data[8], result[8]) is true
+PASS is(test_data[9], result[9]) is true
+
+value = new Float64Array([-Infinity, -Number.MAX_VALUE, -Number.MIN_VALUE, 0, Number.MIN_VALUE, Number.MAX_VALUE, Infinity, NaN])
+transaction = db.transaction('storeName', 'readwrite')
+store = transaction.objectStore('storeName')
+store.put(value, 'key')
+store.get('key')
+PASS test_data !== result is true
+PASS Object.prototype.toString.call(result) is Object.prototype.toString.call(test_data)
+PASS test_data.length === result.length is true
+PASS is(test_data[0], result[0]) is true
+PASS is(test_data[1], result[1]) is true
+PASS is(test_data[2], result[2]) is true
+PASS is(test_data[3], result[3]) is true
+PASS is(test_data[4], result[4]) is true
+PASS is(test_data[5], result[5]) is true
+PASS is(test_data[6], result[6]) is true
+PASS is(test_data[7], result[7]) is true
+
+
+
 Test types that can't be cloned:
 
 transaction = db.transaction('storeName', 'readwrite')

Modified: trunk/LayoutTests/storage/indexeddb/structured-clone.html (122261 => 122262)


--- trunk/LayoutTests/storage/indexeddb/structured-clone.html	2012-07-10 21:13:28 UTC (rev 122261)
+++ trunk/LayoutTests/storage/indexeddb/structured-clone.html	2012-07-10 21:21:34 UTC (rev 122262)
@@ -40,7 +40,9 @@
             request = evalAndLog("db.setVersion('1')");
             request._onerror_ = unexpectedErrorCallback;
             request._onsuccess_ = function(e) {
-                evalAndLog("db.createObjectStore('storeName')");
+                evalAndLog("store = db.createObjectStore('storeName')");
+                debug("This index is not used, but evaluating key path on each put() call will exercise (de)serialization:");
+                evalAndLog("store.createIndex('indexName', 'dummyKeyPath')");
                 var trans = request.result;
                 trans._onerror_ = unexpectedErrorCallback;
                 trans._onabort_ = unexpectedAbortCallback;
@@ -70,7 +72,8 @@
         testFile,
         testFileList,
         testArray,
-        testObject
+        testObject,
+        testTypedArray
     ];
 
     function nextTest() {
@@ -505,6 +508,39 @@
     });
 }
 
+function testTypedArray(callback) {
+    debug("Testing TypedArray");
+
+    function testTypedArrayValue(string, callback) {
+        evalAndLog("value = " + string);
+        test_data = value;
+        testValue(test_data, function(result) {
+            self.result = result;
+            shouldBeTrue("test_data !== result");
+            shouldBe("Object.prototype.toString.call(result)", "Object.prototype.toString.call(test_data)");
+            shouldBeTrue("test_data.length === result.length");
+            for (i = 0; i < test_data.length; ++i) {
+                shouldBeTrue("is(test_data[" + i + "], result[" + i + "])");
+            }
+            debug("");
+            callback();
+        });
+    }
+
+    forEachWithCallback(testTypedArrayValue, [
+        "new Uint8Array([])",
+        "new Uint8Array([0, 1, 254, 255])",
+        "new Uint16Array([0x0000, 0x0001, 0xFFFE, 0xFFFF])",
+        "new Uint32Array([0x00000000, 0x00000001, 0xFFFFFFFE, 0xFFFFFFFF])",
+        "new Int8Array([0, 1, 254, 255])",
+        "new Int16Array([0x0000, 0x0001, 0xFFFE, 0xFFFF])",
+        "new Int32Array([0x00000000, 0x00000001, 0xFFFFFFFE, 0xFFFFFFFF])",
+        "new Uint8ClampedArray([0, 1, 254, 255])",
+        "new Float32Array([-Infinity, -1.5, -1, -0.5, 0, 0.5, 1, 1.5, Infinity, NaN])",
+        "new Float64Array([-Infinity, -Number.MAX_VALUE, -Number.MIN_VALUE, 0, Number.MIN_VALUE, Number.MAX_VALUE, Infinity, NaN])"
+    ], callback);
+}
+
 function testBadTypes()
 {
     debug("");
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to