OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <!-- Submitted from TestTWF Paris --> |
| 3 <meta charset="utf-8"> |
| 4 <title>Invalid keypath</title> |
| 5 <link rel=help href="http://dvcs.w3.org/hg/IndexedDB/raw-file/tip/Overview.html#
key-path-construct"> |
| 6 <link rel=assert title="A key path is a DOMString that defines how to extract a
key from a value. A valid key path is either the empty string, a JavaScript iden
tifier, or multiple Javascript identifiers separated by periods (ASCII character
code 46) [ECMA-262]."> |
| 7 <script src="../../../resources/testharness.js"></script> |
| 8 <script src="../../../resources/testharnessreport.js"></script> |
| 9 <script src="support.js"></script> |
| 10 |
| 11 <script> |
| 12 |
| 13 var global_db = createdb_for_multiple_tests(); |
| 14 |
| 15 function invalid_keypath(keypath, desc) { |
| 16 var t = async_test("Invalid keyPath - " + (desc ? desc : format_value(ke
ypath)), undefined, 2); |
| 17 |
| 18 var openrq = global_db.setTest(t), |
| 19 store_name = "store-" + Date.now() + Math.random(); |
| 20 |
| 21 openrq.onupgradeneeded = function(e) { |
| 22 var db = e.target.result; |
| 23 assert_throws('SyntaxError', function() { |
| 24 db.createObjectStore(store_name, { keyPath: keypath }) |
| 25 }, "createObjectStore with keyPath"); |
| 26 |
| 27 store = db.createObjectStore(store_name); |
| 28 assert_throws('SyntaxError', function() { |
| 29 store.createIndex('index', keypath); |
| 30 }, "createIndex with keyPath"); |
| 31 |
| 32 db.close(); |
| 33 |
| 34 this.done(); |
| 35 }; |
| 36 } |
| 37 |
| 38 invalid_keypath('j a'); |
| 39 invalid_keypath('.yo'); |
| 40 invalid_keypath('yo,lo'); |
| 41 invalid_keypath([]); |
| 42 invalid_keypath(['array with space']); |
| 43 invalid_keypath(['multi_array', ['a', 'b']], "multidimensional array (invali
d toString)"); // => ['multi_array', 'a,b'] |
| 44 invalid_keypath('3m'); |
| 45 invalid_keypath({toString:function(){return '3m'}}, '{toString->3m}'); |
| 46 invalid_keypath('my.1337'); |
| 47 invalid_keypath('..yo'); |
| 48 invalid_keypath('y..o'); |
| 49 invalid_keypath('y.o.'); |
| 50 invalid_keypath('y.o..'); |
| 51 invalid_keypath('m.*'); |
| 52 invalid_keypath('"m"'); |
| 53 invalid_keypath('m%'); |
| 54 invalid_keypath('m/'); |
| 55 invalid_keypath('m/a'); |
| 56 invalid_keypath('m&'); |
| 57 invalid_keypath('m!'); |
| 58 invalid_keypath('*'); |
| 59 invalid_keypath('*.*'); |
| 60 invalid_keypath('^m'); |
| 61 invalid_keypath('/m/'); |
| 62 |
| 63 </script> |
| 64 |
| 65 <div id=log></div> |
OLD | NEW |