content/canvas/test/test_hitregion_canvas.html

Thu, 15 Jan 2015 21:03:48 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 15 Jan 2015 21:03:48 +0100
branch
TOR_BUG_9701
changeset 11
deefc01c0e14
permissions
-rw-r--r--

Integrate friendly tips from Tor colleagues to make (or not) 4.5 alpha 3;
This includes removal of overloaded (but unused) methods, and addition of
a overlooked call to DataStruct::SetData(nsISupports, uint32_t, bool.)

michael@0 1 <!DOCTYPE HTML>
michael@0 2 <title>Canvas Tests</title>
michael@0 3 <script src="/tests/SimpleTest/SimpleTest.js"></script>
michael@0 4 <link rel="stylesheet" href="/tests/SimpleTest/test.css">
michael@0 5 <body>
michael@0 6 <script>
michael@0 7
michael@0 8 SimpleTest.waitForExplicitFinish();
michael@0 9 const Cc = SpecialPowers.Cc;
michael@0 10 const Cr = SpecialPowers.Cr;
michael@0 11 SpecialPowers.setBoolPref("canvas.hitregions.enabled", true);
michael@0 12
michael@0 13 </script>
michael@0 14
michael@0 15 <p>Canvas test: hit regions</p>
michael@0 16 <canvas id="c1" width="150" height="50">
michael@0 17 <a id="c1_a"></a>
michael@0 18 </canvas>
michael@0 19 <a id="c1_b"></a>
michael@0 20
michael@0 21 <script type="text/javascript">
michael@0 22
michael@0 23 function test_hitregions() {
michael@0 24 var c = document.getElementById("c1");
michael@0 25 var d = document.getElementById("c1_a");
michael@0 26 var e = document.getElementById("c1_b");
michael@0 27
michael@0 28 var ctx = c.getContext("2d");
michael@0 29 var _thrown_outer = false;
michael@0 30 try {
michael@0 31 ctx.rect(10,10,100,100);
michael@0 32 ctx.addHitRegion({control: d});
michael@0 33 ctx.addHitRegion({control: e});
michael@0 34 ctx.addHitRegion({id: "a", control: d});
michael@0 35 ctx.addHitRegion({id: "a", control: d});
michael@0 36
michael@0 37 ctx.removeHitRegion("a");
michael@0 38 ctx.removeHitRegion("a");
michael@0 39 ctx.removeHitRegion("b");
michael@0 40 } catch (e) {
michael@0 41 _thrown_outer = true;
michael@0 42 }
michael@0 43 ok(!_thrown_outer, ctx.canvas.id + ' should not throw exception');
michael@0 44
michael@0 45 var _thrown = undefined; try {
michael@0 46 ctx.beginPath();
michael@0 47 ctx.addHitRegion({control: d});
michael@0 48 } catch (ex) { _thrown = ex };
michael@0 49
michael@0 50 ok(_thrown && _thrown.name == "NotSupportedError", "should throw NotSupportedError");
michael@0 51
michael@0 52 }
michael@0 53 </script>
michael@0 54
michael@0 55 <script>
michael@0 56
michael@0 57 function runTests() {
michael@0 58 try {
michael@0 59 test_hitregions();
michael@0 60 } catch(e) {
michael@0 61 throw e;
michael@0 62 ok(false, "unexpected exception thrown in: test_hitregions");
michael@0 63 }
michael@0 64 SimpleTest.finish();
michael@0 65 SpecialPowers.setBoolPref("canvas.hitregions.enabled", false);
michael@0 66 }
michael@0 67
michael@0 68 addLoadEvent(runTests);
michael@0 69
michael@0 70 </script>

mercurial