forked from WebKit/WebKit-http
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnested-combined-selectors.html
65 lines (55 loc) · 1.63 KB
/
nested-combined-selectors.html
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
<!DOCTYPE html>
<html>
<body>
<div id='sandbox'></div>
<div id="console"></div>
<script src="../resources/magnitude-perf.js"></script>
<script>
if (window.testRunner)
testRunner.dumpAsText();
var list;
var stack;
var sandbox = document.getElementById('sandbox');
// Check that long sequences of combined selectors has linear performance (per styled element)
function setupList(magnitude)
{
if (sandbox.firstChild)
sandbox.removeChild(sandbox.firstChild);
list = document.createElement('ul');
for (var i = 0; i < magnitude; ++i) {
var li = document.createElement('li');
li.setAttribute('id','unique'+i); // add unique id ensure the styles are not auto-shared
list.appendChild(li);
}
sandbox.appendChild(list);
}
function setupStack(magnitude)
{
if (sandbox.firstChild)
sandbox.removeChild(sandbox.firstChild);
stack = document.createElement('div');
var cur = stack;
for (var i = 0; i < magnitude; ++i) {
var div = document.createElement('div');
div.setAttribute('id','unique'+i);
cur.appendChild(div);
cur = div;
}
sandbox.appendChild(stack);
}
function testListStyling(magnitude)
{
document.querySelectorAll("la ~ li ~ li");
}
function testStackStyling(magnitude)
{
document.querySelectorAll("dav div div");
}
Magnitude.description('Tests styling multiple combinators have linear performance');
Magnitude.run(setupStack, testStackStyling, Magnitude.LINEAR);
sandbox.removeChild(sandbox.firstChild);
Magnitude.run(setupList, testListStyling, Magnitude.LINEAR);
sandbox.removeChild(sandbox.firstChild);
</script>
</body>
</html>