1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129
|
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>CSS Regions: mouse events don't trigger for region children</title>
<link rel="author" title="Mihai Balan" href="mailto:mibalan@adobe.com">
<link rel="help" href="http://www.w3.org/TR/css3-regions/#the-flow-into-property">
<link rel="help" href="http://www.w3.org/TR/css3-regions/#flow-from">
<meta name="assert" content="Children of regions (elements with flow-from) are removed from the document flow and JavaScript event handlers set on them should not fire">
<meta name="flags" content="dom interact">
<style>
body {
margin: 0;
padding: 20px;
}
p {
margin: 0;
}
.box {
width: 200px;
height: 200px;
float: left;
margin: 20px;
}
#source {
background-color: lightcyan;
}
#source p {
width: 100%;
height: 100px;
background-color: green;
flow-into: flow;
}
#region {
background-color: yellow;
flow-from: flow;
}
#region p {
margin-top: 100px;
width: 100%;
height: 100px;
background-color: red;
}
#result {
clear: both;
font-weight: bold;
}
.pass {
color: green;
}
.fail {
color: red;
}
</style>
</head>
<body>
<ol>
<li>Mouse over the green rectangle and click</li>
<li>Mouse over the yellow rectangle and click</li>
<li>You should see "PASS" appearing below</li>
<li>You should not see any red, or the word "FAIL"</li>
</ol>
<div id="source" class="box">
<p></p>
</div>
<div id="region" class="box">
<p></p>
</div>
<div id="result" class=""></div>
<script type="text/javascript">
var contentCalls = 0,
regionCalls = false;
function setResult(value) {
var tag = document.querySelector("#result");
tag.innerHTML = value;
tag.classList.add(value.toLowerCase());
}
function contentEventHandler(evt) {
contentCalls++;
if (contentCalls == 3) {
setResult("PASS");
finishTest();
}
}
function regionChildEventHandler(evt) {
regionCalls = true;
setResult("FAIL");
finishTest();
}
function finishTest() {
if (window.testRunner) {
testRunner.notifyDone();
}
}
function runScriptedTest() {
if (window.testRunner) {
testRunner.dumpAsText();
testRunner.waitUntilDone();
var boxLocation = document.querySelector("#region").getBoundingClientRect();
eventSender.mouseMoveTo(boxLocation.left + 40, boxLocation.top + 50);
eventSender.mouseDown();
eventSender.mouseUp();
eventSender.mouseMoveTo(boxLocation.left + boxLocation.width - 40, boxLocation.top + boxLocation.height - 40);
eventSender.mouseDown();
eventSender.mouseUp();
}
}
var events = [ "mouseover", "mouseout", "click" ],
regionChild = document.querySelector("#region p"),
content = document.querySelector("#source p");
events.forEach(function(item) {
regionChild.addEventListener(item, regionChildEventHandler);
content.addEventListener(item, contentEventHandler);
})
runScriptedTest();
</script>
</body>
</html>
|