1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/content/base/test/test_bug333198.html Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,84 @@ 1.4 +<!DOCTYPE HTML> 1.5 +<html> 1.6 +<!-- 1.7 +https://bugzilla.mozilla.org/show_bug.cgi?id=333198 1.8 +--> 1.9 +<head> 1.10 + <title>Test for Bug 333198</title> 1.11 + <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> 1.12 + <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> 1.13 +</head> 1.14 +<!-- setTimeout so that the test starts after paint suppression ends --> 1.15 +<body onload="setTimeout(runTest,0);"> 1.16 +<iframe id="ifr"></iframe><br> 1.17 +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=333198">Mozilla Bug 333198</a> 1.18 +<p id="display"></p> 1.19 +<div id="content" style="display: none"> 1.20 + 1.21 +</div> 1.22 +<pre id="test"> 1.23 +<script type="application/javascript"> 1.24 + 1.25 +/** Test for Bug 333198 **/ 1.26 + 1.27 +var focusTester; 1.28 +var focusTester2; 1.29 +var focusCount = 0; 1.30 +var eventCount = 0; 1.31 +function clickHandler() { 1.32 + ++eventCount; 1.33 +} 1.34 + 1.35 +function suppressEvents(suppress) { 1.36 + SpecialPowers.DOMWindowUtils.suppressEventHandling(suppress); 1.37 +} 1.38 + 1.39 +function sendEvents() { 1.40 + windowUtils = SpecialPowers.getDOMWindowUtils(window); 1.41 + windowUtils.sendMouseEvent("mousedown", 1, 1, 0, 1, 0); 1.42 + windowUtils.sendMouseEvent("mouseup", 1, 1, 0, 1, 0); 1.43 + 1.44 + iframeUtils = SpecialPowers.getDOMWindowUtils(document.getElementById("ifr").contentWindow); 1.45 + iframeUtils.sendMouseEvent("mousedown", 1, 1, 0, 1, 0); 1.46 + iframeUtils.sendMouseEvent("mouseup", 1, 1, 0, 1, 0); 1.47 +} 1.48 + 1.49 +function runTest() { 1.50 + window.focus(); 1.51 + focusTester = document.getElementsByTagName("input")[0]; 1.52 + focusTester.blur(); 1.53 + window.addEventListener("click", clickHandler, true); 1.54 + var ifr = document.getElementById("ifr") 1.55 + ifr.contentWindow.addEventListener("click", clickHandler, true); 1.56 + sendEvents(); 1.57 + is(eventCount, 2, "Wrong event count(1)"); 1.58 + suppressEvents(true); 1.59 + sendEvents(); 1.60 + is(eventCount, 2, "Wrong event count(2)"); 1.61 + suppressEvents(false); 1.62 + sendEvents(); 1.63 + is(eventCount, 4, "Wrong event count(2)"); 1.64 + 1.65 + is(focusCount, 0, "Wrong focus count (1)"); 1.66 + var xhr = new XMLHttpRequest(); 1.67 + xhr.open("GET", window.location, false); 1.68 + xhr.onload = function() { 1.69 + focusTester.focus(); 1.70 + is(focusCount, 1, "Wrong focus count (2)"); 1.71 + focusTester.blur(); 1.72 + } 1.73 + xhr.send(); 1.74 + 1.75 + focusTester.focus(); 1.76 + is(focusCount, 2, "Wrong focus count (3)"); 1.77 + 1.78 + SimpleTest.finish(); 1.79 +} 1.80 + 1.81 +SimpleTest.waitForExplicitFinish(); 1.82 + 1.83 +</script> 1.84 +</pre> 1.85 +<input type="text" onfocus="++focusCount;"> 1.86 +</body> 1.87 +</html>