File: mouse-events-004.html

package info (click to toggle)
firefox-esr 68.10.0esr-1~deb9u1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 3,143,932 kB
  • sloc: cpp: 5,227,879; javascript: 4,315,531; ansic: 2,467,042; python: 794,975; java: 349,993; asm: 232,034; xml: 228,320; sh: 82,008; lisp: 41,202; makefile: 22,347; perl: 15,555; objc: 5,277; cs: 4,725; yacc: 1,778; ada: 1,681; pascal: 1,673; lex: 1,417; exp: 527; php: 436; ruby: 225; awk: 162; sed: 53; csh: 44
file content (159 lines) | stat: -rw-r--r-- 3,826 bytes parent folder | download | duplicates (4)
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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
<!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>