1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/toolkit/xre/test/test_fpuhandler.html Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,38 @@ 1.4 +<head> 1.5 + <title>Floating-point exception handler test</title> 1.6 + <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> 1.7 + 1.8 +<body onload="runTest()"> 1.9 + <embed id="plugin1" type="application/x-test" width="400" height="400"></embed> 1.10 + 1.11 + <script class="testbody" type="application/javascript"> 1.12 + SimpleTest.waitForExplicitFinish(); 1.13 + 1.14 + function doDiv(x, y) { 1.15 + var z; 1.16 + z = x / y; 1.17 + 1.18 + for (i = 0 + x; i < 1000; ++i) 1.19 + z = y / x; 1.20 + 1.21 + z = x / y; 1.22 + return z; 1.23 + } 1.24 + 1.25 + function runTest() 1.26 + { 1.27 + ok(isNaN(doDiv(0.0, 0.0)), "Undefined division-by-zero doesn't crash"); 1.28 + 1.29 + try { 1.30 + document.getElementById('plugin1').enableFPExceptions(); 1.31 + } 1.32 + catch (e) { 1.33 + ok(true, "No special code to set the FPU bit in the testplugin."); 1.34 + SimpleTest.finish(); 1.35 + return; 1.36 + } 1.37 + 1.38 + ok(isNaN(doDiv(0.0, 0.0)), "Undefined division-by-zero doesn't crash again."); 1.39 + SimpleTest.finish(); 1.40 + } 1.41 + </script>