servo/tests/wpt/css-tests/css-regions-1_dev/xhtml1/mouse-events-004.xht

159 lines
No EOL
3.9 KiB
HTML

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html lang="en" xmlns="http://www.w3.org/1999/xhtml"><head>
<meta charset="UTF-8" />
<title>CSS Regions: Removing content nodes on mouse events</title>
<link href="mailto:mibalan@adobe.com" rel="author" title="Mihai Balan" />
<link href="http://www.w3.org/TR/css3-regions/#the-flow-into-property" rel="help" />
<link href="http://www.w3.org/TR/css3-regions/#flow-from" rel="help" />
<meta 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." name="assert" />
<meta content="dom interact" name="flags" />
<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 class="box" id="region">
<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>