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.)

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

mercurial