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