| <!DOCTYPE html> |
| <html> |
| <head> |
| <script src="../resources/runner.js"></script> |
| <style> |
| [attr=root] [attr=child] {} |
| </style> |
| </head> |
| <body> |
| <div id="root"></div> |
| <script> |
| function addChildren(element, numChildren, idPrefix) |
| { |
| for (var i = 0; i < numChildren; i++) { |
| var child = document.createElement("div"); |
| child.id = idPrefix + i; |
| element.appendChild(child); |
| } |
| } |
| |
| function makeTree(element, depth, fanOut, idPrefix) |
| { |
| if (depth <= 0) |
| return; |
| addChildren(element, fanOut, idPrefix); |
| for (var child = element.firstChild; child.nextSibling; child = child.nextSibling) { |
| makeTree(child, depth - 1, fanOut, child.id); |
| } |
| if (child) |
| makeTree(child, depth - 1, fanOut, child.id); |
| } |
| |
| var root = document.querySelector("#root"); |
| makeTree(root, 6, 5, "child"); |
| |
| var child = document.querySelector("#child012341"); |
| child.setAttribute("attr", "child"); |
| var runFunction = function() |
| { |
| root.offsetHeight; // force recalc style |
| root.setAttribute("attr" , "root"); |
| root.offsetHeight; |
| root.removeAttribute("attr"); |
| } |
| |
| PerfTestRunner.measureRunsPerSecond({ |
| description: "Measures performance of the CSS attribute descendant selector ([a=b] [c=d]).", |
| run: runFunction |
| }); |
| |
| </script> |
| </body> |
| </html> |