Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | <!DOCTYPE HTML> |
michael@0 | 2 | <html> |
michael@0 | 3 | <!-- |
michael@0 | 4 | https://bugzilla.mozilla.org/show_bug.cgi?id=545268 |
michael@0 | 5 | --> |
michael@0 | 6 | <head> |
michael@0 | 7 | <title>Test for Bug 545268</title> |
michael@0 | 8 | <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> |
michael@0 | 9 | <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> |
michael@0 | 10 | </head> |
michael@0 | 11 | <body> |
michael@0 | 12 | <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=545268">Mozilla Bug 545268</a> |
michael@0 | 13 | <p id="display"> |
michael@0 | 14 | </p> |
michael@0 | 15 | <div id="content" style="display: none"> |
michael@0 | 16 | |
michael@0 | 17 | </div> |
michael@0 | 18 | <pre id="test"> |
michael@0 | 19 | <script type="application/javascript"> |
michael@0 | 20 | |
michael@0 | 21 | /** Test for Bug 545268 |
michael@0 | 22 | Like the test for bug 493251, but we test that suppressing events in |
michael@0 | 23 | a parent window stops the events from reaching the child window. */ |
michael@0 | 24 | |
michael@0 | 25 | var win; |
michael@0 | 26 | var subwin; |
michael@0 | 27 | |
michael@0 | 28 | var mouseDown = 0; |
michael@0 | 29 | var mouseUp = 0; |
michael@0 | 30 | var mouseClick = 0; |
michael@0 | 31 | |
michael@0 | 32 | var keyDown = 0; |
michael@0 | 33 | var keyPress = 0; |
michael@0 | 34 | var keyUp = 0; |
michael@0 | 35 | |
michael@0 | 36 | function dispatchKeyEvent(type) { |
michael@0 | 37 | var utils = SpecialPowers.getDOMWindowUtils(subwin); |
michael@0 | 38 | utils.sendKeyEvent(type, |
michael@0 | 39 | SpecialPowers.Ci.nsIDOMKeyEvent.DOM_VK_A, |
michael@0 | 40 | 0, 0); |
michael@0 | 41 | } |
michael@0 | 42 | |
michael@0 | 43 | function doTest() { |
michael@0 | 44 | var utils = SpecialPowers.getDOMWindowUtils(win); |
michael@0 | 45 | var f = win.document.getElementById("f"); |
michael@0 | 46 | subwin = f.contentWindow; |
michael@0 | 47 | subwin.document.getElementsByTagName("input")[0].focus(); |
michael@0 | 48 | subwin.addEventListener("keydown", function(e) { ++keyDown; }, true); |
michael@0 | 49 | subwin.addEventListener("keypress", function(e) { ++keyPress; }, true); |
michael@0 | 50 | subwin.addEventListener("keyup", function(e) { ++keyUp; }, true); |
michael@0 | 51 | subwin.addEventListener("mousedown", function(e) { ++mouseDown; }, true); |
michael@0 | 52 | subwin.addEventListener("mouseup", function(e) { ++mouseUp; }, true); |
michael@0 | 53 | subwin.addEventListener("click", function(e) { ++mouseClick; }, true); |
michael@0 | 54 | |
michael@0 | 55 | dispatchKeyEvent("keydown"); |
michael@0 | 56 | dispatchKeyEvent("keypress"); |
michael@0 | 57 | dispatchKeyEvent("keyup"); |
michael@0 | 58 | is(keyDown, 1, "Wrong number events (1)"); |
michael@0 | 59 | is(keyPress, 1, "Wrong number events (2)"); |
michael@0 | 60 | is(keyUp, 1, "Wrong number events (3)"); |
michael@0 | 61 | |
michael@0 | 62 | // Test that suppressing events on the parent window prevents key |
michael@0 | 63 | // events in the subdocument window |
michael@0 | 64 | utils.suppressEventHandling(true); |
michael@0 | 65 | dispatchKeyEvent("keydown"); |
michael@0 | 66 | dispatchKeyEvent("keypress"); |
michael@0 | 67 | dispatchKeyEvent("keyup"); |
michael@0 | 68 | is(keyDown, 1, "Wrong number events (4)"); |
michael@0 | 69 | is(keyPress, 1, "Wrong number events (5)"); |
michael@0 | 70 | is(keyUp, 1, "Wrong number events (6)"); |
michael@0 | 71 | utils.suppressEventHandling(false); |
michael@0 | 72 | is(keyDown, 1, "Wrong number events (7)"); |
michael@0 | 73 | is(keyPress, 1, "Wrong number events (8)"); |
michael@0 | 74 | is(keyUp, 1, "Wrong number events (9)"); |
michael@0 | 75 | |
michael@0 | 76 | setTimeout(continueTest1, 0); |
michael@0 | 77 | } |
michael@0 | 78 | |
michael@0 | 79 | function continueTest1() { |
michael@0 | 80 | var utils = SpecialPowers.getDOMWindowUtils(win); |
michael@0 | 81 | dispatchKeyEvent("keydown"); |
michael@0 | 82 | utils.suppressEventHandling(true); |
michael@0 | 83 | dispatchKeyEvent("keypress"); |
michael@0 | 84 | dispatchKeyEvent("keyup"); |
michael@0 | 85 | is(keyDown, 2, "Wrong number events (10)"); |
michael@0 | 86 | is(keyPress, 1, "Wrong number events (11)"); |
michael@0 | 87 | is(keyUp, 1, "Wrong number events (12)"); |
michael@0 | 88 | utils.suppressEventHandling(false); |
michael@0 | 89 | setTimeout(continueTest2, 0); |
michael@0 | 90 | } |
michael@0 | 91 | |
michael@0 | 92 | function continueTest2() { |
michael@0 | 93 | var utils = SpecialPowers.getDOMWindowUtils(win); |
michael@0 | 94 | is(keyDown, 2, "Wrong number events (13)"); |
michael@0 | 95 | is(keyPress, 2, "Wrong number events (14)"); |
michael@0 | 96 | is(keyUp, 2, "Wrong number events (15)"); |
michael@0 | 97 | |
michael@0 | 98 | utils.sendMouseEvent("mousedown", 5, 5, 0, 1, 0); |
michael@0 | 99 | utils.sendMouseEvent("mouseup", 5, 5, 0, 1, 0); |
michael@0 | 100 | is(mouseDown, 1, "Wrong number events (16)"); |
michael@0 | 101 | is(mouseUp, 1, "Wrong number events (17)"); |
michael@0 | 102 | is(mouseClick, 1, "Wrong number events (18)"); |
michael@0 | 103 | |
michael@0 | 104 | utils.suppressEventHandling(true); |
michael@0 | 105 | utils.sendMouseEvent("mousedown", 5, 5, 0, 1, 0); |
michael@0 | 106 | utils.sendMouseEvent("mouseup", 5, 5, 0, 1, 0); |
michael@0 | 107 | utils.suppressEventHandling(false); |
michael@0 | 108 | is(mouseDown, 1, "Wrong number events (19)"); |
michael@0 | 109 | is(mouseUp, 1, "Wrong number events (20)"); |
michael@0 | 110 | is(mouseClick, 1, "Wrong number events (21)"); |
michael@0 | 111 | |
michael@0 | 112 | setTimeout(continueTest3, 0); |
michael@0 | 113 | } |
michael@0 | 114 | |
michael@0 | 115 | function continueTest3() { |
michael@0 | 116 | var utils = SpecialPowers.getDOMWindowUtils(win); |
michael@0 | 117 | utils.sendMouseEvent("mousedown", 5, 5, 0, 1, 0); |
michael@0 | 118 | utils.suppressEventHandling(true); |
michael@0 | 119 | utils.sendMouseEvent("mouseup", 5, 5, 0, 1, 0); |
michael@0 | 120 | utils.suppressEventHandling(false); |
michael@0 | 121 | setTimeout(continueTest4, 1000); |
michael@0 | 122 | } |
michael@0 | 123 | |
michael@0 | 124 | function continueTest4() { |
michael@0 | 125 | is(mouseDown, 2, "Wrong number events (19)"); |
michael@0 | 126 | is(mouseUp, 2, "Wrong number events (20)"); |
michael@0 | 127 | is(mouseClick, 2, "Wrong number events (21)"); |
michael@0 | 128 | win.close(); |
michael@0 | 129 | SimpleTest.finish(); |
michael@0 | 130 | } |
michael@0 | 131 | |
michael@0 | 132 | |
michael@0 | 133 | SimpleTest.waitForExplicitFinish(); |
michael@0 | 134 | win = window.open("data:text/html,<iframe id='f' style='position:absolute; border:none; width:100%; height:100%; left:0; top:0' src='data:text/html,<input>'>", "" , ""); |
michael@0 | 135 | win.onload = doTest; |
michael@0 | 136 | |
michael@0 | 137 | </script> |
michael@0 | 138 | </pre> |
michael@0 | 139 | </body> |
michael@0 | 140 | </html> |