evenodd-fill-sanity.html (1325B)
1 <html> 2 <head> 3 <script type="text/javascript"> 4 function assert(cond, msg) { if (!cond) { throw msg; } } 5 window.onload = function() { 6 try { 7 var ctx = document.getElementById("c1").getContext("2d"); 8 9 assert("nonzero" == ctx.mozFillRule, 10 "Default fillRule is 'nonzero'"); 11 12 ctx.mozFillRule = "evenodd"; 13 assert("evenodd" == ctx.mozFillRule, 14 "fillRule understands 'evenodd'"); 15 ctx.mozFillRule = "nonzero"; 16 17 ctx.mozFillRule = "garbageLSKJDF 29879234"; 18 assert("nonzero" == ctx.mozFillRule, 19 "Garbage fillRule string has no effect"); 20 21 ctx.mozFillRule = "evenodd"; 22 ctx.mozFillRule = "garbageLSKJDF 29879234"; 23 assert("evenodd" == ctx.mozFillRule, 24 "Garbage fillRule string has no effect"); 25 ctx.mozFillRule = "nonzero"; 26 27 ctx.save(); 28 ctx.mozFillRule = "evenodd"; 29 ctx.restore(); 30 assert("nonzero" == ctx.mozFillRule, 31 "fillRule was saved then restored"); 32 } catch (e) { 33 document.body.innerHTML = "FAIL: "+ e.toString(); 34 return; 35 } 36 document.body.innerHTML = "Pass"; 37 } 38 </script> 39 </head> 40 <body> 41 <div><canvas id="c1" width="300" height="300"></canvas></div> 42 </body> 43 </html>