toolkit/xre/test/test_fpuhandler.html

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

michael@0 1 <head>
michael@0 2 <title>Floating-point exception handler test</title>
michael@0 3 <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
michael@0 4
michael@0 5 <body onload="runTest()">
michael@0 6 <embed id="plugin1" type="application/x-test" width="400" height="400"></embed>
michael@0 7
michael@0 8 <script class="testbody" type="application/javascript">
michael@0 9 SimpleTest.waitForExplicitFinish();
michael@0 10
michael@0 11 function doDiv(x, y) {
michael@0 12 var z;
michael@0 13 z = x / y;
michael@0 14
michael@0 15 for (i = 0 + x; i < 1000; ++i)
michael@0 16 z = y / x;
michael@0 17
michael@0 18 z = x / y;
michael@0 19 return z;
michael@0 20 }
michael@0 21
michael@0 22 function runTest()
michael@0 23 {
michael@0 24 ok(isNaN(doDiv(0.0, 0.0)), "Undefined division-by-zero doesn't crash");
michael@0 25
michael@0 26 try {
michael@0 27 document.getElementById('plugin1').enableFPExceptions();
michael@0 28 }
michael@0 29 catch (e) {
michael@0 30 ok(true, "No special code to set the FPU bit in the testplugin.");
michael@0 31 SimpleTest.finish();
michael@0 32 return;
michael@0 33 }
michael@0 34
michael@0 35 ok(isNaN(doDiv(0.0, 0.0)), "Undefined division-by-zero doesn't crash again.");
michael@0 36 SimpleTest.finish();
michael@0 37 }
michael@0 38 </script>

mercurial