blob: 9e9d6d96142b1ea4c533afe1fd29d39ef78e2932 [file] [log] [blame]
Test IndexedDB key types
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
dbname = "key-type-array.html"
indexedDB.deleteDatabase(dbname)
indexedDB.open(dbname)
db.createObjectStore('store');
trans = db.transaction('store', 'readwrite')
store = trans.objectStore('store')
long_array = []; for (i = 0; i < 1000; ++i) { long_array.push('abc', 123, new Date(0), []); }
array that contains non-numeric self-reference
self_referrential_array = []; self_referrential_array.self = self_referrential_array;
testing array key: []
store.put('value1', []);
store.get([]);
PASS getreq.result is "value1"
testing array key: [-Infinity]
store.put('value2', [-Infinity]);
store.get([-Infinity]);
PASS getreq.result is "value2"
testing array key: [-Number.MAX_VALUE]
store.put('value3', [-Number.MAX_VALUE]);
store.get([-Number.MAX_VALUE]);
PASS getreq.result is "value3"
testing array key: [-1]
store.put('value4', [-1]);
store.get([-1]);
PASS getreq.result is "value4"
testing array key: [-Number.MIN_VALUE]
store.put('value5', [-Number.MIN_VALUE]);
store.get([-Number.MIN_VALUE]);
PASS getreq.result is "value5"
testing array key: [0]
store.put('value6', [0]);
store.get([0]);
PASS getreq.result is "value6"
testing array key: [Number.MIN_VALUE]
store.put('value7', [Number.MIN_VALUE]);
store.get([Number.MIN_VALUE]);
PASS getreq.result is "value7"
testing array key: [1]
store.put('value8', [1]);
store.get([1]);
PASS getreq.result is "value8"
testing array key: [Number.MAX_VALUE]
store.put('value9', [Number.MAX_VALUE]);
store.get([Number.MAX_VALUE]);
PASS getreq.result is "value9"
testing array key: [Infinity]
store.put('value10', [Infinity]);
store.get([Infinity]);
PASS getreq.result is "value10"
testing array key: [1,2,3]
store.put('value11', [1,2,3]);
store.get([1,2,3]);
PASS getreq.result is "value11"
testing array key: [new Date(0)]
store.put('value12', [new Date(0)]);
store.get([new Date(0)]);
PASS getreq.result is "value12"
testing array key: [new Date('2525-01-01T00:00:00Z')]
store.put('value13', [new Date('2525-01-01T00:00:00Z')]);
store.get([new Date('2525-01-01T00:00:00Z')]);
PASS getreq.result is "value13"
testing array key: [new Date(0), new Date('2525-01-01T00:00:00Z')]
store.put('value14', [new Date(0), new Date('2525-01-01T00:00:00Z')]);
store.get([new Date(0), new Date('2525-01-01T00:00:00Z')]);
PASS getreq.result is "value14"
testing array key: ['']
store.put('value15', ['']);
store.get(['']);
PASS getreq.result is "value15"
testing array key: ['']
store.put('value16', ['']);
store.get(['']);
PASS getreq.result is "value16"
testing array key: ['abc123']
store.put('value17', ['abc123']);
store.get(['abc123']);
PASS getreq.result is "value17"
testing array key: ['abc', 123]
store.put('value18', ['abc', 123]);
store.get(['abc', 123]);
PASS getreq.result is "value18"
testing array key: [[]]
store.put('value19', [[]]);
store.get([[]]);
PASS getreq.result is "value19"
testing array key: [[], []]
store.put('value20', [[], []]);
store.get([[], []]);
PASS getreq.result is "value20"
testing array key: [[], [], []]
store.put('value21', [[], [], []]);
store.get([[], [], []]);
PASS getreq.result is "value21"
testing array key: [[[]]]
store.put('value22', [[[]]]);
store.get([[[]]]);
PASS getreq.result is "value22"
testing array key: [[[[]]]]
store.put('value23', [[[[]]]]);
store.get([[[[]]]]);
PASS getreq.result is "value23"
testing array key: [123, 'abc', new Date(0), []]
store.put('value24', [123, 'abc', new Date(0), []]);
store.get([123, 'abc', new Date(0), []]);
PASS getreq.result is "value24"
testing array key: [[123, 'abc', new Date(0), []], [456, 'def', new Date(999), [[]]]]
store.put('value25', [[123, 'abc', new Date(0), []], [456, 'def', new Date(999), [[]]]]);
store.get([[123, 'abc', new Date(0), []], [456, 'def', new Date(999), [[]]]]);
PASS getreq.result is "value25"
testing array key: long_array
store.put('value26', long_array);
store.get(long_array);
PASS getreq.result is "value26"
testing array key: self_referrential_array
store.put('value27', self_referrential_array);
store.get(self_referrential_array);
PASS getreq.result is "value27"
trans = db.transaction('store', 'readwrite')
store = trans.objectStore('store')
array that contains itself: array = [ array ]
cyclic_array = []; cyclic_array.push(cyclic_array)
array that contains itself, one level down: array = [ [ array ] ]
cyclic_array2 = []; cyclic_array2.push([cyclic_array2])
array that contains itself, not as first element: array = [1, 'b', [], array]
cyclic_array3 = [1, 'b', []]; cyclic_array3.push(cyclic_array3)
array that contains array that contains itself
cyclic_array4 = [cyclic_array];
testing invalid array key: [ void 0 ]
Expecting exception from store.put('value', [ void 0 ]);
PASS Exception was thrown.
PASS code is 0
PASS ename is 'DataError'
Exception message: Failed to execute 'put' on 'IDBObjectStore': The parameter is not a valid key.
testing invalid array key: [ true ]
Expecting exception from store.put('value', [ true ]);
PASS Exception was thrown.
PASS code is 0
PASS ename is 'DataError'
Exception message: Failed to execute 'put' on 'IDBObjectStore': The parameter is not a valid key.
testing invalid array key: [ false ]
Expecting exception from store.put('value', [ false ]);
PASS Exception was thrown.
PASS code is 0
PASS ename is 'DataError'
Exception message: Failed to execute 'put' on 'IDBObjectStore': The parameter is not a valid key.
testing invalid array key: [ NaN ]
Expecting exception from store.put('value', [ NaN ]);
PASS Exception was thrown.
PASS code is 0
PASS ename is 'DataError'
Exception message: Failed to execute 'put' on 'IDBObjectStore': The parameter is not a valid key.
testing invalid array key: [ null ]
Expecting exception from store.put('value', [ null ]);
PASS Exception was thrown.
PASS code is 0
PASS ename is 'DataError'
Exception message: Failed to execute 'put' on 'IDBObjectStore': The parameter is not a valid key.
testing invalid array key: [ {} ]
Expecting exception from store.put('value', [ {} ]);
PASS Exception was thrown.
PASS code is 0
PASS ename is 'DataError'
Exception message: Failed to execute 'put' on 'IDBObjectStore': The parameter is not a valid key.
testing invalid array key: [ function () {} ]
Expecting exception from store.put('value', [ function () {} ]);
PASS Exception was thrown.
PASS code is 0
PASS ename is 'DataError'
Exception message: Failed to execute 'put' on 'IDBObjectStore': The parameter is not a valid key.
testing invalid array key: [ /regex/ ]
Expecting exception from store.put('value', [ /regex/ ]);
PASS Exception was thrown.
PASS code is 0
PASS ename is 'DataError'
Exception message: Failed to execute 'put' on 'IDBObjectStore': The parameter is not a valid key.
testing invalid array key: [ self ]
Expecting exception from store.put('value', [ self ]);
PASS Exception was thrown.
PASS code is 0
PASS ename is 'DataError'
Exception message: Failed to execute 'put' on 'IDBObjectStore': The parameter is not a valid key.
testing invalid array key: [ self.document ]
Expecting exception from store.put('value', [ self.document ]);
PASS Exception was thrown.
PASS code is 0
PASS ename is 'DataError'
Exception message: Failed to execute 'put' on 'IDBObjectStore': The parameter is not a valid key.
testing invalid array key: [ self.document.body ]
Expecting exception from store.put('value', [ self.document.body ]);
PASS Exception was thrown.
PASS code is 0
PASS ename is 'DataError'
Exception message: Failed to execute 'put' on 'IDBObjectStore': The parameter is not a valid key.
testing invalid array key: cyclic_array
Expecting exception from store.put('value', cyclic_array);
PASS Exception was thrown.
PASS code is 0
PASS ename is 'DataError'
Exception message: Failed to execute 'put' on 'IDBObjectStore': The parameter is not a valid key.
testing invalid array key: cyclic_array2
Expecting exception from store.put('value', cyclic_array2);
PASS Exception was thrown.
PASS code is 0
PASS ename is 'DataError'
Exception message: Failed to execute 'put' on 'IDBObjectStore': The parameter is not a valid key.
testing invalid array key: cyclic_array3
Expecting exception from store.put('value', cyclic_array3);
PASS Exception was thrown.
PASS code is 0
PASS ename is 'DataError'
Exception message: Failed to execute 'put' on 'IDBObjectStore': The parameter is not a valid key.
testing invalid array key: cyclic_array4
Expecting exception from store.put('value', cyclic_array4);
PASS Exception was thrown.
PASS code is 0
PASS ename is 'DataError'
Exception message: Failed to execute 'put' on 'IDBObjectStore': The parameter is not a valid key.
testing invalid array key: Array(1000)
Expecting exception from store.put('value', Array(1000));
PASS Exception was thrown.
PASS code is 0
PASS ename is 'DataError'
Exception message: Failed to execute 'put' on 'IDBObjectStore': The parameter is not a valid key.
PASS indexedDB.cmp(makeArrayOfDepth(25), 0) is 1
PASS indexedDB.cmp(makeArrayOfDepth(250), 0) is 1
Expecting exception from indexedDB.cmp(makeArrayOfDepth(2500), 0)
PASS Exception was thrown.
PASS code is 0
PASS ename is 'DataError'
Exception message: Failed to execute 'cmp' on 'IDBFactory': The parameter is not a valid key.
PASS successfullyParsed is true
TEST COMPLETE