1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/dom/src/json/test/test_json.html Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,40 @@ 1.4 +<!DOCTYPE HTML> 1.5 +<html> 1.6 +<!-- 1.7 +https://bugzilla.mozilla.org/show_bug.cgi?id=408838 1.8 +--> 1.9 +<head> 1.10 + <title>Test for Bug 408838</title> 1.11 + <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> 1.12 + <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> 1.13 +</head> 1.14 +<body> 1.15 +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=408838">Mozilla Bug 408838</a> 1.16 +<p id="display"></p> 1.17 +<div id="content" style="display: none"> 1.18 + 1.19 +</div> 1.20 +<pre id="test"> 1.21 +<script class="testbody" type="text/javascript"> 1.22 + 1.23 +/** Test for Bug 408838 **/ 1.24 + 1.25 +is(typeof JSON, "object", "JSON should be present"); 1.26 +is(typeof JSON.parse, "function", "JSON.parse should be present"); 1.27 +is(typeof JSON.stringify, "function", "JSON.stringify should be present"); 1.28 + 1.29 +var str = '{"foo":[1,{"bar":"baz"}],"qux":1234.1234,"quux":[true,false,null,"hmm",9,[]]}'; 1.30 +var x = JSON.parse(str); 1.31 + 1.32 +is(x.foo[0], 1, "JSON integer"); 1.33 +is(x.foo[1].bar, "baz", "JSON string in object"); 1.34 +is(x.qux, 1234.1234, "JSON float"); 1.35 + 1.36 +var y = JSON.stringify(x); 1.37 +is(y, str, "JSON round trip"); 1.38 + 1.39 +</script> 1.40 +</pre> 1.41 +</body> 1.42 +</html> 1.43 +