test_toJSON.html (2072B)
1 <!DOCTYPE HTML> 2 <html> 3 <!-- 4 https://bugzilla.mozilla.org/show_bug.cgi?id=1465602 5 --> 6 <head> 7 <meta charset="utf-8"> 8 <title>Test for Bug 1465602</title> 9 <script src="/tests/SimpleTest/SimpleTest.js"></script> 10 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> 11 </head> 12 <body> 13 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1465602">Mozilla Bug 1465602</a> 14 <p id="display"></p> 15 <div id="content" style="display: none"> 16 <iframe></iframe> 17 </div> 18 <pre id="test"> 19 </pre> 20 <script type="application/javascript"> 21 /* global TestFunctions */ 22 /** Test for Bug 1465602 */ 23 24 SimpleTest.waitForExplicitFinish(); 25 SpecialPowers.pushPrefEnv({set: [["dom.expose_test_interfaces", true]]}, go); 26 27 function go() { 28 var ourObj = new TestFunctions(); 29 is(ourObj.one, 1, "Basic sanity check for our 'one'"); 30 is(ourObj.two, undefined, "Basic sanity check for our 'two'"); 31 32 var otherObj = new frames[0].TestFunctions(); 33 is(otherObj.one, 1, "Basic sanity check for subframe 'one'"); 34 is(otherObj.two, 2, "Basic sanity check for subframe 'two'"); 35 36 var ourToJSON = ourObj.toJSON(); 37 is(ourToJSON.one, 1, "We should have correct value for 'one'"); 38 is(ourToJSON.two, undefined, "We should have correct value for 'two'"); 39 ok(!Object.hasOwnProperty(ourToJSON, "two"), 40 "We should not have a property named 'two'"); 41 42 var otherToJSON = otherObj.toJSON(); 43 is(otherToJSON.one, 1, "Subframe should have correct value for 'one'"); 44 is(otherToJSON.two, 2, "Subframe should have correct value for 'two'"); 45 46 var mixedToJSON = ourObj.toJSON.call(otherObj); 47 is(mixedToJSON.one, 1, "First test should have correct value for 'one'"); 48 is(mixedToJSON.two, 2, "First test should have correct value for 'two'"); 49 50 mixedToJSON = otherObj.toJSON.call(ourObj); 51 is(mixedToJSON.one, 1, "Second test should have correct value for 'one'"); 52 is(mixedToJSON.two, undefined, 53 "Second test should have correct value for 'two'"); 54 55 SimpleTest.finish(); 56 } 57 </script> 58 </body> 59 </html>