summaryrefslogtreecommitdiffstats
path: root/dom/canvas/test/test_canvas_focusring.html
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /dom/canvas/test/test_canvas_focusring.html
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-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_canvas_focusring.html')
-rw-r--r--dom/canvas/test/test_canvas_focusring.html100
1 files changed, 100 insertions, 0 deletions
diff --git a/dom/canvas/test/test_canvas_focusring.html b/dom/canvas/test/test_canvas_focusring.html
new file mode 100644
index 000000000..9e2e832b3
--- /dev/null
+++ b/dom/canvas/test/test_canvas_focusring.html
@@ -0,0 +1,100 @@
+<!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;
+SpecialPowers.setBoolPref("canvas.focusring.enabled", true);
+SpecialPowers.setBoolPref("canvas.customfocusring.enabled", true);
+</script>
+
+<p>Canvas test: drawCustomFocusRing</p>
+<canvas id="c688" class="output" width="100" height="50">+
+ <input id="button1" type="range" min="1" max="12"></input>
+ <input id="button2" type="range" min="1" max="12"></input>
+</canvas>
+<script type="text/javascript">
+function test_drawCustomFocusRing_canvas() {
+ var c = document.getElementById("c688");
+ var ctx = c.getContext("2d");
+ ctx.beginPath();
+ var b1 = document.getElementById('button1');
+ var b2 = document.getElementById('button2');
+ ok(!ctx.drawCustomFocusRing(b1), "button 1 is focused");
+ ok(!ctx.drawCustomFocusRing(b2), "button 2 is focused");
+ b1.focus();
+ ok(ctx.drawCustomFocusRing(b1), "button 1 should not be focused");
+}
+</script>
+
+<p>Canvas test: drawFocusIfNeeded</p>
+<canvas id="c689" class="output" width="50" height="25">
+ <input id="button3" type="range" min="1" max="12"></input>
+ <input id="button4" type="range" min="1" max="12"></input>
+</canvas>
+<script type="text/javascript">
+function isEmptyCanvas(ctx, w, h) {
+ var imgdata = ctx.getImageData(0, 0, w, h);
+ for(var x = 0; x < w*h*4; x++)
+ if(imgdata.data[x] != 0)
+ return false;
+ return true;
+}
+
+function test_drawFocusIfNeeded_canvas() {
+ var c = document.getElementById("c689");
+ var ctx = c.getContext("2d");
+ var b1 = document.getElementById('button3');
+ var b2 = document.getElementById('button4');
+ ctx.clearRect(0, 0, ctx.canvas.width, ctx.canvas.height);
+ ctx.beginPath();
+ ctx.rect(10, 10, 30, 30);
+ ctx.drawFocusIfNeeded(b1);
+ ok(isEmptyCanvas(ctx, ctx.canvas.width, ctx.canvas.height), "focus of button 1 is drawn");
+
+ ctx.clearRect(0, 0, ctx.canvas.width, ctx.canvas.height);
+ ctx.beginPath();
+ ctx.rect(50, 10, 30, 30);
+ ctx.drawFocusIfNeeded(b2);
+ ctx.rect(50, 10, 30, 30);
+ ctx.drawFocusIfNeeded(b2);
+ ok(isEmptyCanvas(ctx, ctx.canvas.width, ctx.canvas.height), "focus of button 2 is drawn");
+
+ b1.focus();
+ ctx.clearRect(0, 0, ctx.canvas.width, ctx.canvas.height);
+ ctx.beginPath();
+ ctx.rect(10, 10, 30, 30);
+ ctx.drawFocusIfNeeded(b1);
+ ok(!isEmptyCanvas(ctx, ctx.canvas.width, ctx.canvas.height) , "focus of button 1 is not drawn");
+}
+</script>
+
+
+<script>
+
+function runTests() {
+ try {
+ test_drawCustomFocusRing_canvas();
+ } catch(e) {
+ throw e;
+ ok(false, "unexpected exception thrown in: test_drawCustomFocusRing_canvas");
+ }
+ try {
+ test_drawFocusIfNeeded_canvas();
+ } catch(e) {
+ throw e;
+ ok(false, "unexpected exception thrown in: test_drawFocusIfNeeded_canvas");
+ }
+
+ SpecialPowers.setBoolPref("canvas.focusring.enabled", false);
+ SpecialPowers.setBoolPref("canvas.customfocusring.enabled", false);
+ SimpleTest.finish();
+}
+
+addLoadEvent(runTests);
+
+</script>