OLD | NEW |
| (Empty) |
1 <!DOCTYPE html> | |
2 <meta charset="utf-8"> | |
3 <title>Recursive value</title> | |
4 <link rel="author" href="mailto:odinho@opera.com" title="Odin Hørthe Omdal"> | |
5 <script src="../../../resources/testharness.js"></script> | |
6 <script src="../../../resources/testharnessreport.js"></script> | |
7 <script src="support.js"></script> | |
8 | |
9 <script> | |
10 function recursive_value(desc, value) { | |
11 var db, t = async_test(document.title + " - " + desc); | |
12 | |
13 createdb(t).onupgradeneeded = function(e) { | |
14 db = e.target.result | |
15 db.createObjectStore("store") | |
16 .add(value, 1); | |
17 | |
18 e.target.onsuccess = t.step_func(function(e) { | |
19 db.transaction('store') | |
20 .objectStore('store') | |
21 .get(1) | |
22 .onsuccess = t.step_func(function(e) | |
23 { | |
24 | |
25 try | |
26 { | |
27 var fresh_value = JSON.stringify(value); | |
28 assert_unreached("Testcase is written wrongly, must supply s
omething recursive (that JSON won't stringify)."); | |
29 } | |
30 catch (e) | |
31 { | |
32 if (e.name == 'TypeError') | |
33 { | |
34 try | |
35 { | |
36 JSON.stringify(e.target.result); | |
37 assert_unreached("Expected a non-JSON-serializable v
alue back, didn't get that."); | |
38 } | |
39 catch (e) | |
40 { | |
41 t.done(); | |
42 return; | |
43 } | |
44 } | |
45 else | |
46 throw e; | |
47 } | |
48 }); | |
49 }); | |
50 }; | |
51 } | |
52 | |
53 var recursive = []; | |
54 recursive.push(recursive); | |
55 recursive_value('array directly contains self', recursive); | |
56 | |
57 var recursive2 = []; | |
58 recursive2.push([recursive2]); | |
59 recursive_value('array indirectly contains self', recursive2); | |
60 | |
61 var recursive3 = [recursive]; | |
62 recursive_value('array member contains self', recursive3); | |
63 | |
64 </script> | |
65 | |
66 <div id="log"></div> | |
OLD | NEW |