blob: 790c1432560c2afb57a34a98a143f93537083ffc [file] [log] [blame] [edit]
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>CSS Regions: Removing content nodes on mouse events</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="Altering the contents of the named flow via DOM manipulation in response to user gestures (mouse move, mouse click) should works as without regions.">
<meta name="flags" content="dom interact">
<style>
body {
margin: 0;
padding: 20px;
}
p {
margin: 0;
}
.box {
width: 200px;
height: 200px;
float: left;
margin: 20px;
}
#content {
background-color: red;
}
#content p {
width: 100%;
height: 100px;
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;
}
.phase0 {
background-color: green;
}
.phase1 {
background-color: seagreen;
}
.phase2 {
background-color: lime;
}
.phase3 {
background-color: lightgreen;
}
</style>
</head>
<body>
The test fails if you see any red, the text "FAIL" below the two rectangles below or if any of the expected results below don't happen.
<ol>
<li>You should see a green and a yellow rectangle, stacked vertically.</li>
<li>Move the mouse over the green rectangle. <strong>Expected: </strong>The color should change to a lighter green.</li>
<li>Click in the green rectangle. <strong>Expected: </strong>The color should change again to a yet lighter green.</li>
<li>Move the mouse over the yellow rectangle.</li>
<li><strong>Expected: </strong>The color of the green rectangle should change yet again to a pale green. There should be a green text below that says "PASS".</li>
</ol>
<div id="content">
<p class="phase0"></p>
</div>
<div id="region" class="box">
<p></p>
</div>
<div id="result"></div>
<script type="text/javascript">
var events = [ {
name: "mouseover",
hit: false
}, {
name: "click",
hit: false
}, {
name: "mouseout",
hit: false
} ],
target = document.querySelector("#content"),
callCount = 0;
function setResult(value) {
var tag = document.querySelector("#result");
tag.innerHTML = value;
tag.classList.add(value.toLowerCase());
}
function finishTest() {
if (window.testRunner) {
testRunner.notifyDone();
}
}
function handlerForEvent(eventName, index) {
return function(evt) {
if ((evt.target === evt.currentTarget) || (events[index].hit))
return;
callCount++;
events[index].hit = true;
var nodeToRemove = document.querySelector("#content p"),
nodeParent = nodeToRemove.parentNode;
nodeParent.removeChild(nodeToRemove);
document.body.offsetTop;
var newNode = document.createElement("p");
newNode.classList.add("phase" + callCount);
nodeParent.appendChild(newNode);
if (callCount == 3) {
setResult("PASS");
finishTest();
}
}
}
function runScript() {
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();
}
}
events.forEach(function(item, index) {
target.addEventListener(item.name, handlerForEvent(item, index));
});
runScript();
</script>
</body>
</html>