| <!-- |
| Test converted from WebKit: |
| http://trac.webkit.org/browser/trunk/LayoutTests/storage/indexeddb/resources/list-ordering.js |
| --> |
| |
| <!DOCTYPE html> |
| <!-- Submitted from TestTWF Paris --> |
| <meta charset=utf-8> |
| <title>Test string list ordering in IndexedDB</title> |
| <link rel=help href="http://dvcs.w3.org/hg/IndexedDB/raw-file/tip/Overview.html#widl-IDBDatabase-objectStoreNames"> |
| <link rel=assert title="The list must be sorted in ascending order using the algorithm defined by step 4 of section 11.8.5, The Abstract Relational Comparison Algorithm of the ECMAScript Language Specification [ECMA-262]."> |
| <link rel=author href="mailto:romain.huet@gmail.com" title="Romain Huet"> |
| |
| <script src="../../../resources/testharness.js"></script> |
| <script src="../../../resources/testharnessreport.js"></script> |
| <script src=support.js></script> |
| |
| <script> |
| |
| var expectedOrder = [ |
| "", |
| "\x00", // 'NULL' (U+0000) |
| "0", |
| "1", |
| "A", |
| "B", |
| "a", |
| "b", |
| "\x7F", // 'DELETE' (U+007F) |
| "\xC0", // 'LATIN CAPITAL LETTER A WITH GRAVE' (U+00C0) |
| "\xC1", // 'LATIN CAPITAL LETTER A WITH ACUTE' (U+00C1) |
| "\xE0", // 'LATIN SMALL LETTER A WITH GRAVE' (U+00E0) |
| "\xE1", // 'LATIN SMALL LETTER A WITH ACUTE' (U+00E1) |
| "\xFF", // 'LATIN SMALL LETTER Y WITH DIAERESIS' (U+00FF) |
| "\u0100", // 'LATIN CAPITAL LETTER A WITH MACRON' (U+0100) |
| "\u1000", // 'MYANMAR LETTER KA' (U+1000) |
| "\uD834\uDD1E", // 'MUSICAL SYMBOL G-CLEF' (U+1D11E), UTF-16 surrogate pairs |
| "\uFFFD" // 'REPLACEMENT CHARACTER' (U+FFFD) |
| ]; |
| |
| var i, tmp, permutedOrder = expectedOrder.slice(); |
| permutedOrder.reverse(); |
| for (i = 0; i < permutedOrder.length - 2; i += 2) { |
| tmp = permutedOrder[i]; |
| permutedOrder[i] = permutedOrder[i + 1]; |
| permutedOrder[i + 1] = tmp; |
| } |
| |
| var objStore, db; |
| var t = async_test(); |
| |
| // Check that the expected order is the canonical JS sort order. |
| var sortedOrder = expectedOrder.slice(); |
| sortedOrder.sort(); |
| assert_array_equals(sortedOrder, expectedOrder); |
| |
| var request = createdb(t); |
| |
| request.onupgradeneeded = function(e) { |
| db = e.target.result; |
| |
| // Object stores. |
| for (var i = 0; i < permutedOrder.length; i++) { |
| objStore = db.createObjectStore(permutedOrder[i]); |
| } |
| assert_array_equals(db.objectStoreNames, expectedOrder); |
| |
| // Indexes. |
| for (var i = 0; i < permutedOrder.length; i++) { |
| objStore.createIndex(permutedOrder[i], "keyPath"); |
| } |
| assert_array_equals(objStore.indexNames, expectedOrder); |
| }; |
| |
| request.onsuccess = function(e) { |
| // Object stores. |
| assert_array_equals(db.objectStoreNames, expectedOrder); |
| // Indexes. |
| assert_array_equals(objStore.indexNames, expectedOrder); |
| t.done(); |
| }; |
| |
| </script> |
| |
| <div id=log></div> |