| OLD | NEW | 
| (Empty) |  | 
 |   1 <!DOCTYPE html> | 
 |   2 <!--  Submitted from TestTWF Paris  --> | 
 |   3 <meta charset=utf-8"> | 
 |   4 <title>Valid key</title> | 
 |   5 <link rel=help href="http://dvcs.w3.org/hg/IndexedDB/raw-file/tip/Overview.html#
    key-construct"> | 
 |   6 <link rel=assert title="A value is said to be a valid key if it is one of the fo
    llowing types: Array JavaScript objects [ECMA-262], DOMString [WEBIDL], Date [EC
    MA-262] or float [WEBIDL]. However Arrays are only valid keys if every item in t
    he array is defined and is a valid key (i.e. sparse arrays can not be valid keys
    ) and if the Array doesn't directly or indirectly contain itself. Any non-numeri
    c properties are ignored, and thus does not affect whether the Array is a valid 
    key. Additionally, if the value is of type float, it is only a valid key if it i
    s not NaN, and if the value is of type Date it is only a valid key if its [[Prim
    itiveValue]] internal property, as defined by [ECMA-262], is not NaN. Conforming
     user agents must support all valid keys as keys."> | 
 |   7 <link rel=author href="mailto:batifon@yahoo.fr" title="Baptiste Fontaine"> | 
 |   8 <script src=../../../resources/testharness.js></script> | 
 |   9 <script src=../../../resources/testharnessreport.js></script> | 
 |  10 <script src=support.js></script> | 
 |  11  | 
 |  12 <script> | 
 |  13     function valid_key(desc, key) { | 
 |  14         var db; | 
 |  15         var t = async_test(document.title + " - " + desc); | 
 |  16         var open_rq = createdb(t); | 
 |  17  | 
 |  18         open_rq.onupgradeneeded = function(e) { | 
 |  19             db = e.target.result; | 
 |  20  | 
 |  21             store = db.createObjectStore("store"); | 
 |  22             assert_true(store.add('value', key) instanceof IDBRequest); | 
 |  23  | 
 |  24             store2 = db.createObjectStore("store2", { keyPath: ["x", "keypath"] 
    }); | 
 |  25             assert_true(store2.add({ x: 'v', keypath: key }) instanceof IDBReque
    st); | 
 |  26         }; | 
 |  27         open_rq.onsuccess = function(e) { | 
 |  28             var rq = db.transaction("store") | 
 |  29                        .objectStore("store") | 
 |  30                        .get(key) | 
 |  31             rq.onsuccess = t.step_func(function(e) { | 
 |  32                 assert_equals(e.target.result, 'value') | 
 |  33                 var rq = db.transaction("store2") | 
 |  34                            .objectStore("store2") | 
 |  35                            .get(['v', key]) | 
 |  36                 rq.onsuccess = t.step_func(function(e) { | 
 |  37                     assert_object_equals(e.target.result, { x: 'v', keypath: key
     }) | 
 |  38                     t.done() | 
 |  39                 }) | 
 |  40             }) | 
 |  41         } | 
 |  42     } | 
 |  43  | 
 |  44     // Date | 
 |  45     valid_key( 'new Date()'    , new Date() ); | 
 |  46     valid_key( 'new Date(0)'   , new Date(0) ); | 
 |  47  | 
 |  48     // Array | 
 |  49     valid_key( '[]'            , [] ); | 
 |  50     valid_key( 'new Array()'   , new Array() ); | 
 |  51  | 
 |  52     valid_key( '["undefined"]' , ['undefined'] ); | 
 |  53  | 
 |  54     // Float | 
 |  55     valid_key( 'Infinity'      , Infinity ); | 
 |  56     valid_key( '-Infinity'     , -Infinity ); | 
 |  57     valid_key( '0'             , 0 ); | 
 |  58     valid_key( '1.5'           , 1.5 ); | 
 |  59     valid_key( '3e38'          , 3e38 ); | 
 |  60     valid_key( '3e-38'         , 3e38 ); | 
 |  61  | 
 |  62     // String | 
 |  63     valid_key( '"foo"'         , "foo" ); | 
 |  64     valid_key( '"\\n"'         , "\n" ); | 
 |  65     valid_key( '""'            , "" ); | 
 |  66     valid_key( '"\\""'         , "\"" ); | 
 |  67     valid_key( '"\\u1234"'     , "\u1234" ); | 
 |  68     valid_key( '"\\u0000"'     , "\u0000" ); | 
 |  69     valid_key( '"NaN"'         , "NaN" ); | 
 |  70  | 
 |  71 </script> | 
 |  72  | 
 |  73 <div id=log></div> | 
| OLD | NEW |