diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /dom/canvas/test/test_hitregion_canvas.html | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip |
Add m-esr52 at 52.6.0
Diffstat (limited to 'dom/canvas/test/test_hitregion_canvas.html')
-rw-r--r-- | dom/canvas/test/test_hitregion_canvas.html | 84 |
1 files changed, 84 insertions, 0 deletions
diff --git a/dom/canvas/test/test_hitregion_canvas.html b/dom/canvas/test/test_hitregion_canvas.html new file mode 100644 index 000000000..452cb33b6 --- /dev/null +++ b/dom/canvas/test/test_hitregion_canvas.html @@ -0,0 +1,84 @@ +<!DOCTYPE HTML> +<title>Canvas Tests</title> +<script src="/tests/SimpleTest/SimpleTest.js"></script> +<link rel="stylesheet" href="/tests/SimpleTest/test.css"> +<body> +<script> + +SimpleTest.waitForExplicitFinish(); +const Cc = SpecialPowers.Cc; +const Cr = SpecialPowers.Cr; +</script> + +<p>Canvas test: hit regions</p> +<canvas id="c1" width="150" height="50"> + <a id="c1_a"></a> +</canvas> +<a id="c1_b"></a> + +<script type="text/javascript"> + +function test_hitregions() { + var c = document.getElementById("c1"); + var d = document.getElementById("c1_a"); + var e = document.getElementById("c1_b"); + + var ctx = c.getContext("2d"); + var _thrown_outer = false; + try { + ctx.rect(10,10,100,100); + ctx.addHitRegion({control: d}); + ctx.addHitRegion({control: e}); + ctx.addHitRegion({id: "a", control: d}); + ctx.addHitRegion({id: "a", control: d}); + + ctx.removeHitRegion("a"); + ctx.removeHitRegion("a"); + ctx.removeHitRegion("b"); + + ctx.clearHitRegions(); + } catch (e) { + _thrown_outer = true; + } + ok(!_thrown_outer, ctx.canvas.id + ' should not throw exception'); + + var _thrown_outer = false; + try { + ctx.rect(10,10,100,100); + ctx.addHitRegion({control: d}); + ctx.addHitRegion({control: e}); + ctx.addHitRegion({id: "a", control: d}); + ctx.addHitRegion({id: "a", control: d}); + + ctx.clearHitRegions(); + } catch (e) { + _thrown_outer = true; + } + ok(!_thrown_outer, ctx.canvas.id + ' should not throw exception'); + + var _thrown = undefined; try { + ctx.beginPath(); + ctx.addHitRegion({control: d}); + } catch (ex) { _thrown = ex }; + + ok(_thrown && _thrown.name == "NotSupportedError", "should throw NotSupportedError"); + +} +</script> + +<script> + +function runTests() { + try { + test_hitregions(); + } catch(e) { + throw e; + ok(false, "unexpected exception thrown in: test_hitregions"); + } + SimpleTest.finish(); +} + +addLoadEvent(function() { + SpecialPowers.pushPrefEnv({"set":[["canvas.hitregions.enabled", true]]}, runTests); +}); +</script> |