|
1 <!DOCTYPE HTML> |
|
2 <html> |
|
3 <!-- |
|
4 https://bugzilla.mozilla.org/show_bug.cgi?id=408838 |
|
5 --> |
|
6 <head> |
|
7 <title>Test for Bug 408838</title> |
|
8 <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> |
|
9 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> |
|
10 </head> |
|
11 <body> |
|
12 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=408838">Mozilla Bug 408838</a> |
|
13 <p id="display"></p> |
|
14 <div id="content" style="display: none"> |
|
15 |
|
16 </div> |
|
17 <pre id="test"> |
|
18 <script class="testbody" type="text/javascript"> |
|
19 |
|
20 /** Test for Bug 408838 **/ |
|
21 |
|
22 is(typeof JSON, "object", "JSON should be present"); |
|
23 is(typeof JSON.parse, "function", "JSON.parse should be present"); |
|
24 is(typeof JSON.stringify, "function", "JSON.stringify should be present"); |
|
25 |
|
26 var str = '{"foo":[1,{"bar":"baz"}],"qux":1234.1234,"quux":[true,false,null,"hmm",9,[]]}'; |
|
27 var x = JSON.parse(str); |
|
28 |
|
29 is(x.foo[0], 1, "JSON integer"); |
|
30 is(x.foo[1].bar, "baz", "JSON string in object"); |
|
31 is(x.qux, 1234.1234, "JSON float"); |
|
32 |
|
33 var y = JSON.stringify(x); |
|
34 is(y, str, "JSON round trip"); |
|
35 |
|
36 </script> |
|
37 </pre> |
|
38 </body> |
|
39 </html> |
|
40 |