Title: [106279] trunk/LayoutTests
Revision
106279
Author
jsb...@chromium.org
Date
2012-01-30 13:07:25 -0800 (Mon, 30 Jan 2012)

Log Message

IndexedDB: Add tests for structured clone data
https://bugs.webkit.org/show_bug.cgi?id=74897

Validate that the types listed in the HTML5 "structured clone algorithm"
round trip properly through Indexed DB storage. Types with incomplete
support in the Chromium port are excluded (http://crbug.com/108012).
Landing disabled since cr-linux is failing test for unknown reasons.

Reviewed by Tony Chang.

* platform/chromium/test_expectations.txt:
* storage/indexeddb/resources/test-data.html: Added.
* storage/indexeddb/resources/test-data.txt: Added.
* storage/indexeddb/structured-clone-expected.txt: Added.
* storage/indexeddb/structured-clone.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (106278 => 106279)


--- trunk/LayoutTests/ChangeLog	2012-01-30 20:59:01 UTC (rev 106278)
+++ trunk/LayoutTests/ChangeLog	2012-01-30 21:07:25 UTC (rev 106279)
@@ -1,3 +1,21 @@
+2012-01-30  Joshua Bell  <jsb...@chromium.org>
+
+        IndexedDB: Add tests for structured clone data
+        https://bugs.webkit.org/show_bug.cgi?id=74897
+
+        Validate that the types listed in the HTML5 "structured clone algorithm"
+        round trip properly through Indexed DB storage. Types with incomplete
+        support in the Chromium port are excluded (http://crbug.com/108012).
+        Landing disabled since cr-linux is failing test for unknown reasons.
+
+        Reviewed by Tony Chang.
+
+        * platform/chromium/test_expectations.txt:
+        * storage/indexeddb/resources/test-data.html: Added.
+        * storage/indexeddb/resources/test-data.txt: Added.
+        * storage/indexeddb/structured-clone-expected.txt: Added.
+        * storage/indexeddb/structured-clone.html: Added.
+
 2012-01-30  Tommy Widenflycht  <tom...@google.com>
 
         Memory leak caused by PeerConnection add a NULL media stream

Modified: trunk/LayoutTests/platform/chromium/test_expectations.txt (106278 => 106279)


--- trunk/LayoutTests/platform/chromium/test_expectations.txt	2012-01-30 20:59:01 UTC (rev 106278)
+++ trunk/LayoutTests/platform/chromium/test_expectations.txt	2012-01-30 21:07:25 UTC (rev 106279)
@@ -4035,3 +4035,5 @@
 BUGWK77314 WIN MAC : fast/events/touch/send-oncancel-event.html = PASS TEXT
 BUGWK77315 WIN MAC : fast/events/touch/touch-gesture-scroll.html = PASS TEXT
 BUGWK77324 WIN MAC DEBUG SLOW : fast/js/dfg-int32array.html = PASS
+
+BUGWK77239 : storage/indexeddb/structured-clone.html = PASS TEXT

Added: trunk/LayoutTests/storage/indexeddb/resources/test-data.html (0 => 106279)


--- trunk/LayoutTests/storage/indexeddb/resources/test-data.html	                        (rev 0)
+++ trunk/LayoutTests/storage/indexeddb/resources/test-data.html	2012-01-30 21:07:25 UTC (rev 106279)
@@ -0,0 +1,4 @@
+<!DOCTYPE html>
+<title>This is some test data</title>
+<h1>Test data!</h1>
+<p>Get your test data here!

Added: trunk/LayoutTests/storage/indexeddb/resources/test-data.txt (0 => 106279)


--- trunk/LayoutTests/storage/indexeddb/resources/test-data.txt	                        (rev 0)
+++ trunk/LayoutTests/storage/indexeddb/resources/test-data.txt	2012-01-30 21:07:25 UTC (rev 106279)
@@ -0,0 +1 @@
+Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean laoreet dolor id urna eleifend aliquet. Nulla vel dolor ipsum. Aliquam ut turpis nisl, in vulputate sapien. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Sed congue magna vitae dolor feugiat vehicula. Sed volutpat, tellus vel varius vestibulum, purus quam mollis sapien, in condimentum leo neque sed nulla. Nunc quis porta elit. Pellentesque erat lectus, ultricies a lobortis id, faucibus id quam.

Added: trunk/LayoutTests/storage/indexeddb/structured-clone-expected.txt (0 => 106279)


--- trunk/LayoutTests/storage/indexeddb/structured-clone-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/storage/indexeddb/structured-clone-expected.txt	2012-01-30 21:07:25 UTC (rev 106279)
@@ -0,0 +1,692 @@
+
+Test structured clone permutations in IndexedDB. File/FileList tests require DumpRenderTree.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+indexedDB = window.indexedDB || window.webkitIndexedDB
+PASS indexedDB != null is true
+IDBTransaction = window.IDBTransaction || window.webkitIDBTransaction
+PASS IDBTransaction != null is true
+
+Prepare Database
+indexedDB.deleteDatabase('structured-clone')
+indexedDB.open('structured-clone')
+db = request.result
+PASS db.version is ""
+db.setVersion('1')
+db.createObjectStore('storeName')
+
+Running tests...
+
+Testing: undefined
+transaction = db.transaction('storeName', IDBTransaction.READ_WRITE)
+store = transaction.objectStore('storeName')
+value is: undefined (type: undefined)
+store.put(value, 'key')
+store.get('key')
+PASS is(test_data, result) is true
+
+
+Testing: null
+transaction = db.transaction('storeName', IDBTransaction.READ_WRITE)
+store = transaction.objectStore('storeName')
+value is: null (type: object)
+store.put(value, 'key')
+store.get('key')
+PASS is(test_data, result) is true
+
+
+Testing boolean primitives
+
+Testing: true
+transaction = db.transaction('storeName', IDBTransaction.READ_WRITE)
+store = transaction.objectStore('storeName')
+value is: true (type: boolean)
+store.put(value, 'key')
+store.get('key')
+PASS is(test_data, result) is true
+
+Testing: false
+transaction = db.transaction('storeName', IDBTransaction.READ_WRITE)
+store = transaction.objectStore('storeName')
+value is: false (type: boolean)
+store.put(value, 'key')
+store.get('key')
+PASS is(test_data, result) is true
+
+
+Testing number primitives
+
+Testing: NaN
+transaction = db.transaction('storeName', IDBTransaction.READ_WRITE)
+store = transaction.objectStore('storeName')
+value is: NaN (type: number)
+store.put(value, 'key')
+store.get('key')
+PASS is(test_data, result) is true
+
+Testing: -Infinity
+transaction = db.transaction('storeName', IDBTransaction.READ_WRITE)
+store = transaction.objectStore('storeName')
+value is: -Infinity (type: number)
+store.put(value, 'key')
+store.get('key')
+PASS is(test_data, result) is true
+
+Testing: -Number.MAX_VALUE
+transaction = db.transaction('storeName', IDBTransaction.READ_WRITE)
+store = transaction.objectStore('storeName')
+value is: -1.7976931348623157e+308 (type: number)
+store.put(value, 'key')
+store.get('key')
+PASS is(test_data, result) is true
+
+Testing: -Number.MIN_VALUE
+transaction = db.transaction('storeName', IDBTransaction.READ_WRITE)
+store = transaction.objectStore('storeName')
+value is: -5e-324 (type: number)
+store.put(value, 'key')
+store.get('key')
+PASS is(test_data, result) is true
+
+Testing: -0
+transaction = db.transaction('storeName', IDBTransaction.READ_WRITE)
+store = transaction.objectStore('storeName')
+value is: 0 (type: number)
+store.put(value, 'key')
+store.get('key')
+PASS is(test_data, result) is true
+
+Testing: 0
+transaction = db.transaction('storeName', IDBTransaction.READ_WRITE)
+store = transaction.objectStore('storeName')
+value is: 0 (type: number)
+store.put(value, 'key')
+store.get('key')
+PASS is(test_data, result) is true
+
+Testing: Number.MIN_VALUE
+transaction = db.transaction('storeName', IDBTransaction.READ_WRITE)
+store = transaction.objectStore('storeName')
+value is: 5e-324 (type: number)
+store.put(value, 'key')
+store.get('key')
+PASS is(test_data, result) is true
+
+Testing: Number.MAX_VALUE
+transaction = db.transaction('storeName', IDBTransaction.READ_WRITE)
+store = transaction.objectStore('storeName')
+value is: 1.7976931348623157e+308 (type: number)
+store.put(value, 'key')
+store.get('key')
+PASS is(test_data, result) is true
+
+Testing: Infinity
+transaction = db.transaction('storeName', IDBTransaction.READ_WRITE)
+store = transaction.objectStore('storeName')
+value is: Infinity (type: number)
+store.put(value, 'key')
+store.get('key')
+PASS is(test_data, result) is true
+
+
+Testing string primitives
+
+Testing: ''
+transaction = db.transaction('storeName', IDBTransaction.READ_WRITE)
+store = transaction.objectStore('storeName')
+value is:  (type: string)
+store.put(value, 'key')
+store.get('key')
+PASS is(test_data, result) is true
+
+Testing: 'this is a sample string'
+transaction = db.transaction('storeName', IDBTransaction.READ_WRITE)
+store = transaction.objectStore('storeName')
+value is: this is a sample string (type: string)
+store.put(value, 'key')
+store.get('key')
+PASS is(test_data, result) is true
+
+Testing: 'null(\0)'
+transaction = db.transaction('storeName', IDBTransaction.READ_WRITE)
+store = transaction.objectStore('storeName')
+value is: null() (type: string)
+store.put(value, 'key')
+store.get('key')
+PASS is(test_data, result) is true
+
+
+Testing Boolean objects
+
+Testing: new Boolean(true)
+transaction = db.transaction('storeName', IDBTransaction.READ_WRITE)
+store = transaction.objectStore('storeName')
+value is: true (type: object)
+store.put(value, 'key')
+store.get('key')
+String(result): true
+PASS typeof result is "object"
+PASS Object.prototype.toString.call(result) is Object.prototype.toString.call(test_data)
+PASS test_data !== result is true
+PASS result.toString() is test_data.toString()
+PASS is(test_data.valueOf(), result.valueOf()) is true
+
+Testing: new Boolean(false)
+transaction = db.transaction('storeName', IDBTransaction.READ_WRITE)
+store = transaction.objectStore('storeName')
+value is: false (type: object)
+store.put(value, 'key')
+store.get('key')
+String(result): false
+PASS typeof result is "object"
+PASS Object.prototype.toString.call(result) is Object.prototype.toString.call(test_data)
+PASS test_data !== result is true
+PASS result.toString() is test_data.toString()
+PASS is(test_data.valueOf(), result.valueOf()) is true
+
+
+Testing Number objects
+
+Testing: new Number(NaN)
+transaction = db.transaction('storeName', IDBTransaction.READ_WRITE)
+store = transaction.objectStore('storeName')
+value is: NaN (type: object)
+store.put(value, 'key')
+store.get('key')
+String(result): NaN
+PASS typeof result is "object"
+PASS Object.prototype.toString.call(result) is Object.prototype.toString.call(test_data)
+PASS test_data !== result is true
+PASS result.toString() is test_data.toString()
+PASS is(test_data.valueOf(), result.valueOf()) is true
+
+Testing: new Number(-Infinity)
+transaction = db.transaction('storeName', IDBTransaction.READ_WRITE)
+store = transaction.objectStore('storeName')
+value is: -Infinity (type: object)
+store.put(value, 'key')
+store.get('key')
+String(result): -Infinity
+PASS typeof result is "object"
+PASS Object.prototype.toString.call(result) is Object.prototype.toString.call(test_data)
+PASS test_data !== result is true
+PASS result.toString() is test_data.toString()
+PASS is(test_data.valueOf(), result.valueOf()) is true
+
+Testing: new Number(-Number.MAX_VALUE)
+transaction = db.transaction('storeName', IDBTransaction.READ_WRITE)
+store = transaction.objectStore('storeName')
+value is: -1.7976931348623157e+308 (type: object)
+store.put(value, 'key')
+store.get('key')
+String(result): -1.7976931348623157e+308
+PASS typeof result is "object"
+PASS Object.prototype.toString.call(result) is Object.prototype.toString.call(test_data)
+PASS test_data !== result is true
+PASS result.toString() is test_data.toString()
+PASS is(test_data.valueOf(), result.valueOf()) is true
+
+Testing: new Number(-Number.MIN_VALUE)
+transaction = db.transaction('storeName', IDBTransaction.READ_WRITE)
+store = transaction.objectStore('storeName')
+value is: -5e-324 (type: object)
+store.put(value, 'key')
+store.get('key')
+String(result): -5e-324
+PASS typeof result is "object"
+PASS Object.prototype.toString.call(result) is Object.prototype.toString.call(test_data)
+PASS test_data !== result is true
+PASS result.toString() is test_data.toString()
+PASS is(test_data.valueOf(), result.valueOf()) is true
+
+Testing: new Number(-0)
+transaction = db.transaction('storeName', IDBTransaction.READ_WRITE)
+store = transaction.objectStore('storeName')
+value is: 0 (type: object)
+store.put(value, 'key')
+store.get('key')
+String(result): 0
+PASS typeof result is "object"
+PASS Object.prototype.toString.call(result) is Object.prototype.toString.call(test_data)
+PASS test_data !== result is true
+PASS result.toString() is test_data.toString()
+PASS is(test_data.valueOf(), result.valueOf()) is true
+
+Testing: new Number(0)
+transaction = db.transaction('storeName', IDBTransaction.READ_WRITE)
+store = transaction.objectStore('storeName')
+value is: 0 (type: object)
+store.put(value, 'key')
+store.get('key')
+String(result): 0
+PASS typeof result is "object"
+PASS Object.prototype.toString.call(result) is Object.prototype.toString.call(test_data)
+PASS test_data !== result is true
+PASS result.toString() is test_data.toString()
+PASS is(test_data.valueOf(), result.valueOf()) is true
+
+Testing: new Number(Number.MIN_VALUE)
+transaction = db.transaction('storeName', IDBTransaction.READ_WRITE)
+store = transaction.objectStore('storeName')
+value is: 5e-324 (type: object)
+store.put(value, 'key')
+store.get('key')
+String(result): 5e-324
+PASS typeof result is "object"
+PASS Object.prototype.toString.call(result) is Object.prototype.toString.call(test_data)
+PASS test_data !== result is true
+PASS result.toString() is test_data.toString()
+PASS is(test_data.valueOf(), result.valueOf()) is true
+
+Testing: new Number(Number.MAX_VALUE)
+transaction = db.transaction('storeName', IDBTransaction.READ_WRITE)
+store = transaction.objectStore('storeName')
+value is: 1.7976931348623157e+308 (type: object)
+store.put(value, 'key')
+store.get('key')
+String(result): 1.7976931348623157e+308
+PASS typeof result is "object"
+PASS Object.prototype.toString.call(result) is Object.prototype.toString.call(test_data)
+PASS test_data !== result is true
+PASS result.toString() is test_data.toString()
+PASS is(test_data.valueOf(), result.valueOf()) is true
+
+Testing: new Number(Infinity)
+transaction = db.transaction('storeName', IDBTransaction.READ_WRITE)
+store = transaction.objectStore('storeName')
+value is: Infinity (type: object)
+store.put(value, 'key')
+store.get('key')
+String(result): Infinity
+PASS typeof result is "object"
+PASS Object.prototype.toString.call(result) is Object.prototype.toString.call(test_data)
+PASS test_data !== result is true
+PASS result.toString() is test_data.toString()
+PASS is(test_data.valueOf(), result.valueOf()) is true
+
+
+Testing String objects
+
+Testing: new String()
+transaction = db.transaction('storeName', IDBTransaction.READ_WRITE)
+store = transaction.objectStore('storeName')
+value is:  (type: object)
+store.put(value, 'key')
+store.get('key')
+String(result): 
+PASS typeof result is "object"
+PASS Object.prototype.toString.call(result) is Object.prototype.toString.call(test_data)
+PASS test_data !== result is true
+PASS result.toString() is test_data.toString()
+PASS is(test_data.valueOf(), result.valueOf()) is true
+
+Testing: new String('this is a sample string')
+transaction = db.transaction('storeName', IDBTransaction.READ_WRITE)
+store = transaction.objectStore('storeName')
+value is: this is a sample string (type: object)
+store.put(value, 'key')
+store.get('key')
+String(result): this is a sample string
+PASS typeof result is "object"
+PASS Object.prototype.toString.call(result) is Object.prototype.toString.call(test_data)
+PASS test_data !== result is true
+PASS result.toString() is test_data.toString()
+PASS is(test_data.valueOf(), result.valueOf()) is true
+
+Testing: new String('null(\0)')
+transaction = db.transaction('storeName', IDBTransaction.READ_WRITE)
+store = transaction.objectStore('storeName')
+value is: null() (type: object)
+store.put(value, 'key')
+store.get('key')
+String(result): null()
+PASS typeof result is "object"
+PASS Object.prototype.toString.call(result) is Object.prototype.toString.call(test_data)
+PASS test_data !== result is true
+PASS result.toString() is test_data.toString()
+PASS is(test_data.valueOf(), result.valueOf()) is true
+
+
+Testing Date objects
+
+Testing: new Date(-1e13)
+transaction = db.transaction('storeName', IDBTransaction.READ_WRITE)
+store = transaction.objectStore('storeName')
+value is: Sun Feb 09 1653 22:13:20 GMT-0800 (PST) (type: object)
+store.put(value, 'key')
+store.get('key')
+String(result): Sun Feb 09 1653 22:13:20 GMT-0800 (PST)
+PASS typeof result is "object"
+PASS Object.prototype.toString.call(result) is Object.prototype.toString.call(test_data)
+PASS test_data !== result is true
+PASS result.toString() is test_data.toString()
+PASS is(test_data.valueOf(), result.valueOf()) is true
+
+Testing: new Date(-1e12)
+transaction = db.transaction('storeName', IDBTransaction.READ_WRITE)
+store = transaction.objectStore('storeName')
+value is: Sun Apr 24 1938 15:13:20 GMT-0700 (PDT) (type: object)
+store.put(value, 'key')
+store.get('key')
+String(result): Sun Apr 24 1938 15:13:20 GMT-0700 (PDT)
+PASS typeof result is "object"
+PASS Object.prototype.toString.call(result) is Object.prototype.toString.call(test_data)
+PASS test_data !== result is true
+PASS result.toString() is test_data.toString()
+PASS is(test_data.valueOf(), result.valueOf()) is true
+
+Testing: new Date(-1e9)
+transaction = db.transaction('storeName', IDBTransaction.READ_WRITE)
+store = transaction.objectStore('storeName')
+value is: Sat Dec 20 1969 02:13:20 GMT-0800 (PST) (type: object)
+store.put(value, 'key')
+store.get('key')
+String(result): Sat Dec 20 1969 02:13:20 GMT-0800 (PST)
+PASS typeof result is "object"
+PASS Object.prototype.toString.call(result) is Object.prototype.toString.call(test_data)
+PASS test_data !== result is true
+PASS result.toString() is test_data.toString()
+PASS is(test_data.valueOf(), result.valueOf()) is true
+
+Testing: new Date(-1e6)
+transaction = db.transaction('storeName', IDBTransaction.READ_WRITE)
+store = transaction.objectStore('storeName')
+value is: Wed Dec 31 1969 15:43:20 GMT-0800 (PST) (type: object)
+store.put(value, 'key')
+store.get('key')
+String(result): Wed Dec 31 1969 15:43:20 GMT-0800 (PST)
+PASS typeof result is "object"
+PASS Object.prototype.toString.call(result) is Object.prototype.toString.call(test_data)
+PASS test_data !== result is true
+PASS result.toString() is test_data.toString()
+PASS is(test_data.valueOf(), result.valueOf()) is true
+
+Testing: new Date(-1e3)
+transaction = db.transaction('storeName', IDBTransaction.READ_WRITE)
+store = transaction.objectStore('storeName')
+value is: Wed Dec 31 1969 15:59:59 GMT-0800 (PST) (type: object)
+store.put(value, 'key')
+store.get('key')
+String(result): Wed Dec 31 1969 15:59:59 GMT-0800 (PST)
+PASS typeof result is "object"
+PASS Object.prototype.toString.call(result) is Object.prototype.toString.call(test_data)
+PASS test_data !== result is true
+PASS result.toString() is test_data.toString()
+PASS is(test_data.valueOf(), result.valueOf()) is true
+
+Testing: new Date(0)
+transaction = db.transaction('storeName', IDBTransaction.READ_WRITE)
+store = transaction.objectStore('storeName')
+value is: Wed Dec 31 1969 16:00:00 GMT-0800 (PST) (type: object)
+store.put(value, 'key')
+store.get('key')
+String(result): Wed Dec 31 1969 16:00:00 GMT-0800 (PST)
+PASS typeof result is "object"
+PASS Object.prototype.toString.call(result) is Object.prototype.toString.call(test_data)
+PASS test_data !== result is true
+PASS result.toString() is test_data.toString()
+PASS is(test_data.valueOf(), result.valueOf()) is true
+
+Testing: new Date(1e3)
+transaction = db.transaction('storeName', IDBTransaction.READ_WRITE)
+store = transaction.objectStore('storeName')
+value is: Wed Dec 31 1969 16:00:01 GMT-0800 (PST) (type: object)
+store.put(value, 'key')
+store.get('key')
+String(result): Wed Dec 31 1969 16:00:01 GMT-0800 (PST)
+PASS typeof result is "object"
+PASS Object.prototype.toString.call(result) is Object.prototype.toString.call(test_data)
+PASS test_data !== result is true
+PASS result.toString() is test_data.toString()
+PASS is(test_data.valueOf(), result.valueOf()) is true
+
+Testing: new Date(1e6)
+transaction = db.transaction('storeName', IDBTransaction.READ_WRITE)
+store = transaction.objectStore('storeName')
+value is: Wed Dec 31 1969 16:16:40 GMT-0800 (PST) (type: object)
+store.put(value, 'key')
+store.get('key')
+String(result): Wed Dec 31 1969 16:16:40 GMT-0800 (PST)
+PASS typeof result is "object"
+PASS Object.prototype.toString.call(result) is Object.prototype.toString.call(test_data)
+PASS test_data !== result is true
+PASS result.toString() is test_data.toString()
+PASS is(test_data.valueOf(), result.valueOf()) is true
+
+Testing: new Date(1e9)
+transaction = db.transaction('storeName', IDBTransaction.READ_WRITE)
+store = transaction.objectStore('storeName')
+value is: Mon Jan 12 1970 05:46:40 GMT-0800 (PST) (type: object)
+store.put(value, 'key')
+store.get('key')
+String(result): Mon Jan 12 1970 05:46:40 GMT-0800 (PST)
+PASS typeof result is "object"
+PASS Object.prototype.toString.call(result) is Object.prototype.toString.call(test_data)
+PASS test_data !== result is true
+PASS result.toString() is test_data.toString()
+PASS is(test_data.valueOf(), result.valueOf()) is true
+
+Testing: new Date(1e12)
+transaction = db.transaction('storeName', IDBTransaction.READ_WRITE)
+store = transaction.objectStore('storeName')
+value is: Sat Sep 08 2001 18:46:40 GMT-0700 (PDT) (type: object)
+store.put(value, 'key')
+store.get('key')
+String(result): Sat Sep 08 2001 18:46:40 GMT-0700 (PDT)
+PASS typeof result is "object"
+PASS Object.prototype.toString.call(result) is Object.prototype.toString.call(test_data)
+PASS test_data !== result is true
+PASS result.toString() is test_data.toString()
+PASS is(test_data.valueOf(), result.valueOf()) is true
+
+Testing: new Date(1e13)
+transaction = db.transaction('storeName', IDBTransaction.READ_WRITE)
+store = transaction.objectStore('storeName')
+value is: Sat Nov 20 2286 09:46:40 GMT-0800 (PST) (type: object)
+store.put(value, 'key')
+store.get('key')
+String(result): Sat Nov 20 2286 09:46:40 GMT-0800 (PST)
+PASS typeof result is "object"
+PASS Object.prototype.toString.call(result) is Object.prototype.toString.call(test_data)
+PASS test_data !== result is true
+PASS result.toString() is test_data.toString()
+PASS is(test_data.valueOf(), result.valueOf()) is true
+
+
+Testing RegExp objects
+
+Testing RegExp: new RegExp()
+transaction = db.transaction('storeName', IDBTransaction.READ_WRITE)
+store = transaction.objectStore('storeName')
+value is: /(?:)/ (type: object)
+store.put(value, 'key')
+store.get('key')
+PASS test_data !== result is true
+PASS Object.prototype.toString.call(result) is "[object RegExp]"
+PASS result.toString() is test_data.toString()
+
+Testing RegExp: /abc/
+transaction = db.transaction('storeName', IDBTransaction.READ_WRITE)
+store = transaction.objectStore('storeName')
+value is: /abc/ (type: object)
+store.put(value, 'key')
+store.get('key')
+PASS test_data !== result is true
+PASS Object.prototype.toString.call(result) is "[object RegExp]"
+PASS result.toString() is test_data.toString()
+
+Testing RegExp: /abc/g
+transaction = db.transaction('storeName', IDBTransaction.READ_WRITE)
+store = transaction.objectStore('storeName')
+value is: /abc/g (type: object)
+store.put(value, 'key')
+store.get('key')
+PASS test_data !== result is true
+PASS Object.prototype.toString.call(result) is "[object RegExp]"
+PASS result.toString() is test_data.toString()
+
+Testing RegExp: /abc/i
+transaction = db.transaction('storeName', IDBTransaction.READ_WRITE)
+store = transaction.objectStore('storeName')
+value is: /abc/i (type: object)
+store.put(value, 'key')
+store.get('key')
+PASS test_data !== result is true
+PASS Object.prototype.toString.call(result) is "[object RegExp]"
+PASS result.toString() is test_data.toString()
+
+Testing RegExp: /abc/gi
+transaction = db.transaction('storeName', IDBTransaction.READ_WRITE)
+store = transaction.objectStore('storeName')
+value is: /abc/gi (type: object)
+store.put(value, 'key')
+store.get('key')
+PASS test_data !== result is true
+PASS Object.prototype.toString.call(result) is "[object RegExp]"
+PASS result.toString() is test_data.toString()
+
+Testing RegExp: /abc/m
+transaction = db.transaction('storeName', IDBTransaction.READ_WRITE)
+store = transaction.objectStore('storeName')
+value is: /abc/m (type: object)
+store.put(value, 'key')
+store.get('key')
+PASS test_data !== result is true
+PASS Object.prototype.toString.call(result) is "[object RegExp]"
+PASS result.toString() is test_data.toString()
+
+Testing RegExp: /abc/mg
+transaction = db.transaction('storeName', IDBTransaction.READ_WRITE)
+store = transaction.objectStore('storeName')
+value is: /abc/gm (type: object)
+store.put(value, 'key')
+store.get('key')
+PASS test_data !== result is true
+PASS Object.prototype.toString.call(result) is "[object RegExp]"
+PASS result.toString() is test_data.toString()
+
+Testing RegExp: /abc/mi
+transaction = db.transaction('storeName', IDBTransaction.READ_WRITE)
+store = transaction.objectStore('storeName')
+value is: /abc/im (type: object)
+store.put(value, 'key')
+store.get('key')
+PASS test_data !== result is true
+PASS Object.prototype.toString.call(result) is "[object RegExp]"
+PASS result.toString() is test_data.toString()
+
+Testing RegExp: /abc/mgi
+transaction = db.transaction('storeName', IDBTransaction.READ_WRITE)
+store = transaction.objectStore('storeName')
+value is: /abc/gim (type: object)
+store.put(value, 'key')
+store.get('key')
+PASS test_data !== result is true
+PASS Object.prototype.toString.call(result) is "[object RegExp]"
+PASS result.toString() is test_data.toString()
+
+
+Testing ImageData
+canvas = document.createElement('canvas')
+canvas.width = 8
+canvas.height = 8
+test_data = canvas.getContext('2d').getImageData(0, 0, 8, 8)
+transaction = db.transaction('storeName', IDBTransaction.READ_WRITE)
+store = transaction.objectStore('storeName')
+value is: [object ImageData] (type: object)
+store.put(value, 'key')
+store.get('key')
+PASS test_data !== result is true
+PASS Object.prototype.toString.call(result) is "[object ImageData]"
+PASS result.width is test_data.width
+PASS result.height is test_data.height
+PASS result.data.length is test_data.data.length
+PASS result data matches
+
+Testing Blob
+Skipping test
+
+Testing File
+Skipping test
+
+Testing FileList
+Skipping test
+
+Testing Array
+test_data = []
+test_data[0] = 'foo'
+test_data[1] = 'bar'
+test_data[10] = true
+test_data[11] = false
+test_data[20] = 123
+test_data[21] = 456
+test_data[30] = null
+transaction = db.transaction('storeName', IDBTransaction.READ_WRITE)
+store = transaction.objectStore('storeName')
+value is: foo,bar,,,,,,,,,true,false,,,,,,,,,123,456,,,,,,,,, (type: object)
+store.put(value, 'key')
+store.get('key')
+PASS test_data !== result is true
+PASS test_data.length === result.length is true
+PASS test_data[0] is result[0]
+PASS test_data[1] is result[1]
+PASS test_data[10] is result[10]
+PASS test_data[11] is result[11]
+PASS test_data[20] is result[20]
+PASS test_data[21] is result[21]
+PASS test_data[30] is result[30]
+
+Testing Object
+test_data = []
+test_data[0] = 'foo'
+test_data[1] = 'bar'
+test_data['a'] = true
+test_data['b'] = false
+test_data['foo'] = 123
+test_data['bar'] = 456
+test_data[''] = null
+transaction = db.transaction('storeName', IDBTransaction.READ_WRITE)
+store = transaction.objectStore('storeName')
+value is: foo,bar (type: object)
+store.put(value, 'key')
+store.get('key')
+PASS test_data !== result is true
+PASS arrayCompare(Object.keys(result).sort(), Object.keys(test_data).sort()) is true
+PASS test_data["0"] is result["0"]
+PASS test_data["1"] is result["1"]
+PASS test_data["a"] is result["a"]
+PASS test_data["b"] is result["b"]
+PASS test_data["foo"] is result["foo"]
+PASS test_data["bar"] is result["bar"]
+PASS test_data[""] is result[""]
+
+
+Test types that can't be cloned:
+
+transaction = db.transaction('storeName', IDBTransaction.READ_WRITE)
+store = transaction.objectStore('storeName')
+
+Other _javascript_ object types:
+Expecting exception from store.put(new Error, 'key')
+PASS Exception was thrown.
+PASS code is DOMException.DATA_CLONE_ERR
+Expecting exception from store.put(new Function, 'key')
+PASS Exception was thrown.
+PASS code is DOMException.DATA_CLONE_ERR
+
+Other host object types:
+Expecting exception from store.put(window, 'key')
+PASS Exception was thrown.
+PASS code is DOMException.DATA_CLONE_ERR
+Expecting exception from store.put(document, 'key')
+PASS Exception was thrown.
+PASS code is DOMException.DATA_CLONE_ERR
+Expecting exception from store.put(document.body, 'key')
+PASS Exception was thrown.
+PASS code is DOMException.DATA_CLONE_ERR
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/storage/indexeddb/structured-clone.html (0 => 106279)


--- trunk/LayoutTests/storage/indexeddb/structured-clone.html	                        (rev 0)
+++ trunk/LayoutTests/storage/indexeddb/structured-clone.html	2012-01-30 21:07:25 UTC (rev 106279)
@@ -0,0 +1,550 @@
+<html>
+<head>
+<script src=""
+<script src=""
+</head>
+<body>
+<input type="file" id="fileInput" multiple></input>
+<p id="description"></p>
+<div id="console"></div>
+<script>
+
+description("Test structured clone permutations in IndexedDB. File/FileList tests require DumpRenderTree.");
+if (window.layoutTestController)
+    layoutTestController.waitUntilDone();
+
+if (window.eventSender) {
+    var fileInput = document.getElementById("fileInput");
+    var fileRect = fileInput.getClientRects()[0];
+    var targetX = fileRect.left + fileRect.width / 2;
+    var targetY = fileRect.top + fileRect.height / 2;
+    eventSender.beginDragWithFiles(['resources/test-data.html', 'resources/test-data.txt']);
+    eventSender.mouseMoveTo(targetX, targetY);
+    eventSender.mouseUp();
+}
+
+function test()
+{
+    evalAndLog("indexedDB = window.indexedDB || window.webkitIndexedDB");
+    shouldBeTrue("indexedDB != null");
+    evalAndLog("IDBTransaction = window.IDBTransaction || window.webkitIDBTransaction");
+    shouldBeTrue("IDBTransaction != null");
+    prepareDatabase();
+}
+
+function prepareDatabase()
+{
+    debug("");
+    debug("Prepare Database");
+    request = evalAndLog("indexedDB.deleteDatabase('structured-clone')");
+    request._onerror_ = unexpectedErrorCallback;
+    request._onsuccess_ = function(e) {
+        request = evalAndLog("indexedDB.open('structured-clone')");
+        request._onerror_ = unexpectedErrorCallback;
+        request._onsuccess_ = function(e) {
+            evalAndLog("db = request.result");
+            shouldBeEqualToString("db.version", "");
+            request = evalAndLog("db.setVersion('1')");
+            request._onerror_ = unexpectedErrorCallback;
+            request._onsuccess_ = function(e) {
+                evalAndLog("db.createObjectStore('storeName')");
+                var trans = request.result;
+                trans._onerror_ = unexpectedErrorCallback;
+                trans._onabort_ = unexpectedAbortCallback;
+                trans._oncomplete_ = startTests;
+            };
+        };
+    };
+}
+
+function startTests()
+{
+    debug("");
+    debug("Running tests...");
+    var tests_to_run = [
+        testUndefined,
+        testNull,
+        testBoolean,
+        testNumber,
+        testString,
+        testBooleanObject,
+        testNumberObject,
+        testStringObject,
+        testDateObject,
+        testRegExpObject,
+        testImageData,
+        testBlob,
+        testFile,
+        testFileList,
+        testArray,
+        testObject
+    ];
+
+    function nextTest() {
+        debug("");
+        if (tests_to_run.length) {
+            var test = tests_to_run.shift();
+            test(nextTest); // When done, call this again.
+        } else {
+            testBadTypes();
+        }
+    }
+    nextTest();
+}
+
+function forEachWithCallback(testFunction, values, callback)
+{
+    function nextValue() {
+        if (values.length) {
+            testFunction(values.shift(), nextValue);
+        } else {
+            callback();
+        }
+    }
+
+    nextValue();
+}
+
+function testValue(value, callback)
+{
+    // One transaction per test, since some tests require asynchronous
+    // operations to verify the result (e.g. via FileReader)
+    evalAndLog("transaction = db.transaction('storeName', IDBTransaction.READ_WRITE)");
+    transaction._onerror_ = unexpectedErrorCallback;
+    transaction._onabort_ = unexpectedAbortCallback;
+    evalAndLog("store = transaction.objectStore('storeName')");
+
+    debug("value is: " + String(value) + " (type: " + typeof value + ")");
+    window.value = value;
+    request = evalAndLog("store.put(value, 'key')");
+    request._onerror_ = unexpectedErrorCallback;
+    request._onsuccess_ = function(e) {
+        request = evalAndLog("store.get('key')");
+        request._onerror_ = unexpectedErrorCallback;
+        request._onsuccess_ = function(e) {
+            //debug("got back: " + String(request.result) + " (type: " + typeof request.result + ")");
+            callback(request.result);
+        };
+    };
+}
+
+// Identity testing, sensitive to NaN and -0
+function is(x, y) {
+    if (x === y) {
+        return x !== 0 || 1 / x === 1 / y;
+    }
+    return x !== x && y !== y;
+}
+
+function arrayCompare(a, b) {
+    if (a.length !== b.length) {
+        return false;
+    }
+    for (var i = 0; i < a.length; ++i) {
+        if (!is(a[i], b[i])) {
+            return false;
+        }
+    }
+    return true;
+}
+
+function testPrimitiveValue(string, callback)
+{
+    debug("Testing: " + string);
+    var value = eval("value = (" + string + ")");
+    test_data = value;
+    testValue(test_data, function(result) {
+        window.result = result;
+        shouldBeTrue("is(test_data, result)");
+        debug("");
+        callback();
+    });
+}
+
+function testObjectWithValue(string, callback)
+{
+    debug("Testing: " + string);
+    var value = eval("value = (" + string + ")");
+    test_data = value;
+    testValue(test_data, function(result) {
+        window.result = result;
+        debug("String(result): " + String(result));
+        shouldBeEqualToString("typeof result", "object");
+        shouldBe("Object.prototype.toString.call(result)", "Object.prototype.toString.call(test_data)");
+        shouldBeTrue("test_data !== result");
+        shouldBe("result.toString()", "test_data.toString()");
+        shouldBeTrue("is(test_data.valueOf(), result.valueOf())");
+        debug("");
+        callback();
+    });
+}
+
+function testUndefined(callback)
+{
+    testPrimitiveValue("undefined", callback);
+}
+
+function testNull(callback)
+{
+    testPrimitiveValue("null", callback);
+}
+
+function testBoolean(callback)
+{
+    debug("Testing boolean primitives");
+    debug("");
+    forEachWithCallback(testPrimitiveValue, ["true", "false"], callback);
+}
+
+function testBooleanObject(callback)
+{
+    debug("Testing Boolean objects");
+    debug("");
+    forEachWithCallback(testObjectWithValue, [
+        "new Boolean(true)",
+        "new Boolean(false)"
+    ], callback);
+}
+
+function testString(callback)
+{
+    debug("Testing string primitives");
+    debug("");
+    forEachWithCallback(testPrimitiveValue, [
+        "''",
+        "'this is a sample string'",
+        "'null(\\0)'"
+    ], callback);
+}
+
+function testStringObject(callback)
+{
+    debug("Testing String objects");
+    debug("");
+    forEachWithCallback(testObjectWithValue, [
+        "new String()",
+        "new String('this is a sample string')",
+        "new String('null(\\0)')"
+    ], callback);
+}
+
+function testNumber(callback)
+{
+    debug("Testing number primitives");
+    debug("");
+    forEachWithCallback(testPrimitiveValue, [
+        "NaN",
+        "-Infinity",
+        "-Number.MAX_VALUE",
+        "-Number.MIN_VALUE",
+        "-0",
+        "0",
+        "Number.MIN_VALUE",
+        "Number.MAX_VALUE",
+        "Infinity"
+    ], callback);
+}
+
+function testNumberObject(callback)
+{
+    debug("Testing Number objects");
+    debug("");
+    forEachWithCallback(testObjectWithValue, [
+        "new Number(NaN)",
+        "new Number(-Infinity)",
+        "new Number(-Number.MAX_VALUE)",
+        "new Number(-Number.MIN_VALUE)",
+        "new Number(-0)",
+        "new Number(0)",
+        "new Number(Number.MIN_VALUE)",
+        "new Number(Number.MAX_VALUE)",
+        "new Number(Infinity)"
+    ], callback);
+}
+
+function testDateObject(callback)
+{
+    debug("Testing Date objects");
+    debug("");
+    forEachWithCallback(testObjectWithValue, [
+        "new Date(-1e13)",
+        "new Date(-1e12)",
+        "new Date(-1e9)",
+        "new Date(-1e6)",
+        "new Date(-1e3)",
+        "new Date(0)",
+        "new Date(1e3)",
+        "new Date(1e6)",
+        "new Date(1e9)",
+        "new Date(1e12)",
+        "new Date(1e13)"
+    ], callback);
+}
+
+function testRegExpObject(callback)
+{
+    debug("Testing RegExp objects");
+    debug("");
+    function testRegExp(string, callback) {
+        debug("Testing RegExp: " + string);
+        var value = eval("value = (" + string + ")");
+        test_data = value;
+        testValue(test_data, function(result) {
+            window.result = result;
+            shouldBeTrue("test_data !== result");
+            shouldBeEqualToString("Object.prototype.toString.call(result)", "[object RegExp]");
+            shouldBe("result.toString()", "test_data.toString()");
+            debug("");
+            callback();
+        });
+    }
+
+    forEachWithCallback(testRegExp, [
+        "new RegExp()",
+        "/abc/",
+        "/abc/g",
+        "/abc/i",
+        "/abc/gi",
+        "/abc/m",
+        "/abc/mg",
+        "/abc/mi",
+        "/abc/mgi"
+    ], callback);
+}
+
+function testImageData(callback)
+{
+    debug("Testing ImageData");
+    evalAndLog("canvas = document.createElement('canvas')");
+    evalAndLog("canvas.width = 8");
+    evalAndLog("canvas.height = 8");
+    evalAndLog("test_data = canvas.getContext('2d').getImageData(0, 0, 8, 8)");
+
+    for (var i = 0; i < 256; ++i) {
+        test_data.data[i] = i;
+    }
+
+    testValue(test_data, function(result) {
+        window.result = result;
+        shouldBeTrue("test_data !== result");
+        shouldBeEqualToString("Object.prototype.toString.call(result)", "[object ImageData]");
+        shouldBe("result.width", "test_data.width");
+        shouldBe("result.height", "test_data.height");
+        shouldBe("result.data.length", "test_data.data.length");
+        if (arrayCompare(test_data.data, result.data)) {
+            testPassed("result data matches");
+        } else {
+            testFailed("result data doesn't match");
+        }
+        callback();
+    });
+}
+
+function readBlobAsText(blob, callback)
+{
+    var reader = new FileReader();
+    reader._onload_ = function(e) {
+        if (e.target.readyState === FileReader.DONE) {
+            callback(e.target.result);
+        }
+    };
+    reader._onerror_ = function(e) {
+        testFailed("Error reading blob as text: " + e);
+        done();
+    };
+    reader.readAsText(blob);
+}
+
+function checkBlobContents(blob, expected, callback)
+{
+    readBlobAsText(blob, function(text) {
+        window.text = text;
+        shouldBeEqualToString("text", expected);
+        callback();
+    });
+}
+
+function compareBlobs(blob1, blob2, callback)
+{
+    readBlobAsText(blob1, function(text1) {
+        readBlobAsText(blob2, function(text2) {
+            window.text1 = text1;
+            window.text2 = text2;
+            shouldBeEqualToString("text2", text1);
+            callback();
+        });
+    });
+}
+
+function testBlob(callback)
+{
+    debug("Testing Blob");
+
+    // FIXME: Blob, File, and FileList support is incomplete.
+    // http://crbug.com/108012
+    debug("Skipping test");
+    callback();
+    return;
+
+    evalAndLog("BlobBuilder = window.BlobBuilder || window.WebKitBlobBuilder");
+    shouldBeTrue("BlobBuilder != null");
+    shouldBeTrue("FileReader != null");
+    evalAndLog("builder = new BlobBuilder()");
+    evalAndLog("test_content = 'This is a test. This is only a test.'");
+    evalAndLog("builder.append(test_content)");
+    evalAndLog("test_data = builder.getBlob()");
+    testValue(test_data, function(result) {
+        window.result = result;
+        shouldBeTrue("test_data !== result");
+        shouldBeEqualToString("Object.prototype.toString.call(result)", "[object Blob]");
+        shouldBe("result.size", "test_data.size");
+        shouldBe("result.type", "test_data.type");
+        checkBlobContents(result, test_content, callback);
+    });
+}
+
+function compareFiles(file1, file2, callback)
+{
+    window.file1 = file1;
+    window.file2 = file2;
+    shouldBeTrue("file1 !== file2");
+    shouldBeEqualToString("Object.prototype.toString.call(file1)", "[object File]");
+    shouldBeEqualToString("Object.prototype.toString.call(file2)", "[object File]");
+    debug("file1.size: " + file1.size);
+    shouldBe("file1.size", "file2.size");
+    debug("file1.type: " + file1.type);
+    shouldBe("file1.type", "file2.type");
+    debug("file1.name: " + file1.name);
+    shouldBe("file1.name", "file2.name");
+    shouldBe("String(file1.lastModifiedDate)", "String(file2.lastModifiedDate)");
+    if (callback) {
+        compareBlobs(file1, file2, callback);
+    }
+}
+
+function testFile(callback)
+{
+    debug("Testing File");
+
+    // FIXME: Blob, File, and FileList support is incomplete.
+    // http://crbug.com/108012
+    debug("Skipping test");
+    callback();
+    return;
+
+    evalAndLog("test_content = fileInput.files[0]");
+
+    window.test_data = test_content;
+    testValue(test_data, function(result) {
+        window.result = result;
+        compareFiles(result, test_data, callback);
+    });
+}
+
+
+function testFileList(callback)
+{
+    debug("Testing FileList");
+
+    // FIXME: Blob, File, and FileList support is incomplete.
+    // http://crbug.com/108012
+    debug("Skipping test");
+    callback();
+    return;
+
+    evalAndLog("test_content = fileInput.files");
+
+    window.test_data = test_content;
+    testValue(test_data, function(result) {
+        window.result = result;
+        shouldBeTrue("test_data !== result");
+        shouldBeEqualToString("Object.prototype.toString.call(result)", "[object FileList]");
+        shouldBe("result.length", "test_data.length");
+        i = 0;
+        function doNext() {
+            if (i >= test_data.length) {
+                callback();
+            } else {
+                debug("comparing file[" + i + "]");
+                compareFiles(result[i], test_data[i++], doNext);
+            }
+        }
+        doNext();
+    });
+}
+
+function testArray(callback) {
+    debug("Testing Array");
+    evalAndLog("test_data = []");
+    evalAndLog("test_data[0] = 'foo'");
+    evalAndLog("test_data[1] = 'bar'");
+    evalAndLog("test_data[10] = true");
+    evalAndLog("test_data[11] = false");
+    evalAndLog("test_data[20] = 123");
+    evalAndLog("test_data[21] = 456");
+    evalAndLog("test_data[30] = null");
+
+    testValue(test_data, function(result) {
+        window.result = result;
+        shouldBeTrue("test_data !== result");
+        shouldBeTrue("test_data.length === result.length");
+        Object.keys(test_data).forEach(
+            function(key) {
+                shouldBe("test_data[" + key + "]", "result[" + key + "]");
+            });
+        callback();
+    });
+}
+
+function testObject(callback) {
+    debug("Testing Object");
+    evalAndLog("test_data = []");
+    evalAndLog("test_data[0] = 'foo'");
+    evalAndLog("test_data[1] = 'bar'");
+    evalAndLog("test_data['a'] = true");
+    evalAndLog("test_data['b'] = false");
+    evalAndLog("test_data['foo'] = 123");
+    evalAndLog("test_data['bar'] = 456");
+    evalAndLog("test_data[''] = null");
+
+    testValue(test_data, function(result) {
+        window.result = result;
+        shouldBeTrue("test_data !== result");
+        shouldBeTrue("arrayCompare(Object.keys(result).sort(), Object.keys(test_data).sort())");
+        Object.keys(test_data).forEach(
+            function(key) {
+                shouldBe("test_data[" + JSON.stringify(key) + "]", "result[" + JSON.stringify(key) + "]");
+            });
+        callback();
+    });
+}
+
+function testBadTypes()
+{
+    debug("");
+    debug("Test types that can't be cloned:");
+    debug("");
+
+    evalAndLog("transaction = db.transaction('storeName', IDBTransaction.READ_WRITE)");
+    evalAndLog("store = transaction.objectStore('storeName')");
+    transaction._onerror_ = unexpectedErrorCallback;
+    transaction._oncomplete_ = unexpectedCompleteCallback;
+    transaction._onabort_ = done;
+
+    debug("");
+    debug("Other _javascript_ object types:");
+    evalAndExpectException("store.put(new Error, 'key')", "DOMException.DATA_CLONE_ERR");
+    evalAndExpectException("store.put(new Function, 'key')", "DOMException.DATA_CLONE_ERR");
+
+    debug("");
+    debug("Other host object types:");
+    evalAndExpectException("store.put(window, 'key')", "DOMException.DATA_CLONE_ERR");
+    evalAndExpectException("store.put(document, 'key')", "DOMException.DATA_CLONE_ERR");
+    evalAndExpectException("store.put(document.body, 'key')", "DOMException.DATA_CLONE_ERR");
+}
+
+test();
+
+</script>
+</body>
+</html>
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to