Tue, 06 Jan 2015 21:39:09 +0100
Conditionally force memory storage according to privacy.thirdparty.isolate;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <title>nsIAccessible::childAtPoint() for canvas from browser tests</title>
5 <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css" />
7 <script type="application/javascript"
8 src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
10 <script type="application/javascript"
11 src="../common.js"></script>
12 <script type="application/javascript"
13 src="../layout.js"></script>
15 <script type="application/javascript">
16 SpecialPowers.setBoolPref("canvas.hitregions.enabled", true);
18 function redrawCheckbox(context, element, x, y)
19 {
20 context.save();
21 context.font = '10px sans-serif';
22 context.textAlign = 'left';
23 context.textBaseline = 'middle';
24 var metrics = context.measureText(element.parentNode.textContent);
25 context.beginPath();
26 context.strokeStyle = 'black';
27 context.rect(x-5, y-5, 10, 10);
28 context.stroke();
29 if (element.checked) {
30 context.fillStyle = 'black';
31 context.fill();
32 }
33 context.fillText(element.parentNode.textContent, x+5, y);
35 context.beginPath();
36 context.rect(x-7, y-7, 12 + metrics.width+2, 14);
38 if (document.activeElement == element)
39 context.drawFocusIfNeeded(element);
40 context.addHitRegion({control: element});
41 context.restore();
42 }
44 function doTest()
45 {
46 getNode("hitcanvas").scrollIntoView(true);
48 var context = document.getElementById("hitcanvas").getContext('2d');
49 redrawCheckbox(context, document.getElementById('hitcheck'), 20, 40);
51 var hitcanvas = getAccessible("hitcanvas");
52 var hitcheck = getAccessible("hitcheck");
54 var [hitX, hitY, hitWidth, hitHeight] = getBounds(hitcanvas);
56 var docAcc = getAccessible(document);
57 var tgtX = hitX+25;
58 var tgtY = hitY+45;
59 hitAcc = docAcc.getDeepestChildAtPoint(tgtX, tgtY);
60 // test if we hit the region associated with the shadow dom checkbox
61 is(hitAcc, hitcheck, "Hit match at " + tgtX + "," + tgtY +
62 ". Found: " + prettyName(hitAcc));
64 tgtY = hitY+75;
65 hitAcc = docAcc.getDeepestChildAtPoint(tgtX, tgtY);
66 // test that we don't hit the region associated with the shadow dom checkbox
67 is(hitAcc, hitcanvas, "Hit match at " + tgtX + "," + tgtY +
68 ". Found: " + prettyName(hitAcc));
70 SpecialPowers.setBoolPref("canvas.hitregions.enabled", false);
71 SimpleTest.finish();
72 }
74 SimpleTest.waitForExplicitFinish();
75 addA11yLoadEvent(doTest);
76 </script>
77 </head>
78 <body>
80 <a target="_blank"
81 href="https://bugzilla.mozilla.org/show_bug.cgi?id=966591"
82 title="nsIAccessible::childAtPoint() for canvas hit regions from browser tests">Mozilla Bug 966591</a>
84 <canvas id="hitcanvas">
85 <input id="hitcheck" type="checkbox"><label for="showA"> Show A </label>
86 </canvas>
87 </body>
88 </html>