1 if (this.importScripts) {
2 importScripts('../../../resources/js-test.js');
3 importScripts('shared.js');
6 description("Test IndexedDB key comparison using IDBFactory.cmp().");
10 shouldBeEqualToString("typeof indexedDB.cmp", "function");
18 function testValidKeys()
21 debug("compare valid keys");
36 "new Date(1317399931023)",
45 "'\xA2'", // U+00A2 CENT SIGN
46 "'\u6C34'", // U+6C34 CJK UNIFIED IDEOGRAPH (water)
47 "'\uD834\uDD1E'", // U+1D11E MUSICAL SYMBOL G-CLEF (UTF-16 surrogate pair)
48 "'\uFFFD'", // U+FFFD REPLACEMENT CHARACTER
51 "new Uint8Array([0])",
52 "new Uint8Array([0, 0])",
53 "new Uint8Array([0, 1])",
54 "new Uint8Array([1])",
55 "new Uint8Array([1, 0])",
56 "new Uint8Array([1, 1])",
57 "new Uint8Array([255])",
62 "[-Number.MAX_VALUE]",
64 "[-Number.MIN_VALUE]",
73 "[new Date(1317399931023)]",
82 "['\xA2']", // U+00A2 CENT SIGN
83 "['\u6C34']", // U+6C34 CJK UNIFIED IDEOGRAPH (water)
84 "['\uD834\uDD1E']", // U+1D11E MUSICAL SYMBOL G-CLEF (UTF-16 surrogate pair)
85 "['\uFFFD']", // U+FFFD REPLACEMENT CHARACTER
88 "[new Uint8Array([0])]",
89 "[new Uint8Array([0, 0])]",
90 "[new Uint8Array([0, 1])]",
91 "[new Uint8Array([1])]",
92 "[new Uint8Array([1, 0])]",
93 "[new Uint8Array([1, 1])]",
94 "[new Uint8Array([255])]",
106 for (i = 0; i < keys.length - 1; i += 1) {
109 shouldBe("indexedDB.cmp(" + key1 + "," + key2 + ")", "-1");
110 shouldBe("indexedDB.cmp(" + key2 + "," + key1 + ")", "1");
111 shouldBe("indexedDB.cmp(" + key1 + "," + key1 + ")", "0");
112 shouldBe("indexedDB.cmp(" + key2 + "," + key2 + ")", "0");
116 function testInvalidKeys()
119 debug("compare invalid keys");
122 "void 0", // undefined
137 for (i = 0; i < invalidKeys.length - 1; i += 1) {
138 key1 = invalidKeys[i];
139 key2 = invalidKeys[i + 1];
140 evalAndExpectException("indexedDB.cmp(" + key1 + ", " + key2 + ")", "0", "'DataError'");
141 evalAndExpectException("indexedDB.cmp(" + key2 + ", " + key1 + ")", "0", "'DataError'");
142 evalAndExpectException("indexedDB.cmp(" + key1 + ", 'valid')", "0", "'DataError'");
143 evalAndExpectException("indexedDB.cmp('valid', " + key1 + ")", "0", "'DataError'");
144 evalAndExpectException("indexedDB.cmp(" + key2 + ", 'valid')", "0", "'DataError'");
145 evalAndExpectException("indexedDB.cmp('valid', " + key2 + ")", "0", "'DataError'");
149 function testIdenticalKeys()
152 debug("compare identical keys");
154 shouldBe("indexedDB.cmp(0, -0)", "0");