Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
michael@0 | 1 | <!DOCTYPE HTML> |
michael@0 | 2 | <html> |
michael@0 | 3 | <!-- |
michael@0 | 4 | https://bugzilla.mozilla.org/show_bug.cgi?id=333198 |
michael@0 | 5 | --> |
michael@0 | 6 | <head> |
michael@0 | 7 | <title>Test for Bug 333198</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 | <!-- setTimeout so that the test starts after paint suppression ends --> |
michael@0 | 12 | <body onload="setTimeout(runTest,0);"> |
michael@0 | 13 | <iframe id="ifr"></iframe><br> |
michael@0 | 14 | <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=333198">Mozilla Bug 333198</a> |
michael@0 | 15 | <p id="display"></p> |
michael@0 | 16 | <div id="content" style="display: none"> |
michael@0 | 17 | |
michael@0 | 18 | </div> |
michael@0 | 19 | <pre id="test"> |
michael@0 | 20 | <script type="application/javascript"> |
michael@0 | 21 | |
michael@0 | 22 | /** Test for Bug 333198 **/ |
michael@0 | 23 | |
michael@0 | 24 | var focusTester; |
michael@0 | 25 | var focusTester2; |
michael@0 | 26 | var focusCount = 0; |
michael@0 | 27 | var eventCount = 0; |
michael@0 | 28 | function clickHandler() { |
michael@0 | 29 | ++eventCount; |
michael@0 | 30 | } |
michael@0 | 31 | |
michael@0 | 32 | function suppressEvents(suppress) { |
michael@0 | 33 | SpecialPowers.DOMWindowUtils.suppressEventHandling(suppress); |
michael@0 | 34 | } |
michael@0 | 35 | |
michael@0 | 36 | function sendEvents() { |
michael@0 | 37 | windowUtils = SpecialPowers.getDOMWindowUtils(window); |
michael@0 | 38 | windowUtils.sendMouseEvent("mousedown", 1, 1, 0, 1, 0); |
michael@0 | 39 | windowUtils.sendMouseEvent("mouseup", 1, 1, 0, 1, 0); |
michael@0 | 40 | |
michael@0 | 41 | iframeUtils = SpecialPowers.getDOMWindowUtils(document.getElementById("ifr").contentWindow); |
michael@0 | 42 | iframeUtils.sendMouseEvent("mousedown", 1, 1, 0, 1, 0); |
michael@0 | 43 | iframeUtils.sendMouseEvent("mouseup", 1, 1, 0, 1, 0); |
michael@0 | 44 | } |
michael@0 | 45 | |
michael@0 | 46 | function runTest() { |
michael@0 | 47 | window.focus(); |
michael@0 | 48 | focusTester = document.getElementsByTagName("input")[0]; |
michael@0 | 49 | focusTester.blur(); |
michael@0 | 50 | window.addEventListener("click", clickHandler, true); |
michael@0 | 51 | var ifr = document.getElementById("ifr") |
michael@0 | 52 | ifr.contentWindow.addEventListener("click", clickHandler, true); |
michael@0 | 53 | sendEvents(); |
michael@0 | 54 | is(eventCount, 2, "Wrong event count(1)"); |
michael@0 | 55 | suppressEvents(true); |
michael@0 | 56 | sendEvents(); |
michael@0 | 57 | is(eventCount, 2, "Wrong event count(2)"); |
michael@0 | 58 | suppressEvents(false); |
michael@0 | 59 | sendEvents(); |
michael@0 | 60 | is(eventCount, 4, "Wrong event count(2)"); |
michael@0 | 61 | |
michael@0 | 62 | is(focusCount, 0, "Wrong focus count (1)"); |
michael@0 | 63 | var xhr = new XMLHttpRequest(); |
michael@0 | 64 | xhr.open("GET", window.location, false); |
michael@0 | 65 | xhr.onload = function() { |
michael@0 | 66 | focusTester.focus(); |
michael@0 | 67 | is(focusCount, 1, "Wrong focus count (2)"); |
michael@0 | 68 | focusTester.blur(); |
michael@0 | 69 | } |
michael@0 | 70 | xhr.send(); |
michael@0 | 71 | |
michael@0 | 72 | focusTester.focus(); |
michael@0 | 73 | is(focusCount, 2, "Wrong focus count (3)"); |
michael@0 | 74 | |
michael@0 | 75 | SimpleTest.finish(); |
michael@0 | 76 | } |
michael@0 | 77 | |
michael@0 | 78 | SimpleTest.waitForExplicitFinish(); |
michael@0 | 79 | |
michael@0 | 80 | </script> |
michael@0 | 81 | </pre> |
michael@0 | 82 | <input type="text" onfocus="++focusCount;"> |
michael@0 | 83 | </body> |
michael@0 | 84 | </html> |