OLD | NEW |
(Empty) | |
| 1 <html> |
| 2 <head> |
| 3 <script type="text/javascript" src="../../http/tests/inspector-protocol/inspecto
r-protocol-test.js"></script> |
| 4 <script type="text/javascript" src="css-protocol-test.js"></script> |
| 5 <script type="text/javascript"> |
| 6 function test() |
| 7 { |
| 8 setTimeout(InspectorTest.completeTest.bind(InspectorTest), 2000); |
| 9 var nodeInfo = {}; |
| 10 InspectorTest.eventHandler["DOM.setChildNodes"] = setChildNodes; |
| 11 InspectorTest.sendCommandOrDie("CSS.enable", {}, onCSSEnabled); |
| 12 |
| 13 function onCSSEnabled() |
| 14 { |
| 15 InspectorTest.requestNodeId("#redlink", onNodeReceived); |
| 16 } |
| 17 |
| 18 function onNodeReceived(nodeId) |
| 19 { |
| 20 dumpVisitedAndLinkRules(nodeId, onLinkDumped); |
| 21 } |
| 22 |
| 23 function onLinkDumped() |
| 24 { |
| 25 InspectorTest.requestNodeId("#shadow-host", onShadowHost); |
| 26 } |
| 27 |
| 28 function onShadowHost(nodeId) |
| 29 { |
| 30 var node = nodeInfo[nodeId]; |
| 31 if (!node) { |
| 32 InspectorTest.log("ERROR: didn't get node from backend"); |
| 33 InspectorTest.completeTest(); |
| 34 return; |
| 35 } |
| 36 var shadowRoots = node.shadowRoots || []; |
| 37 if (shadowRoots.length !== 1) { |
| 38 InspectorTest.log("ERROR: shadow host doesn't have any shadow roots"
); |
| 39 InspectorTest.completeTest(); |
| 40 return; |
| 41 } |
| 42 var shadowRoot = shadowRoots[0]; |
| 43 InspectorTest.sendCommandOrDie("DOM.querySelector", { |
| 44 nodeId: shadowRoot.nodeId, |
| 45 selector: ".shadow-link" |
| 46 }, onShadowAnchor); |
| 47 } |
| 48 |
| 49 function onShadowAnchor(result) |
| 50 { |
| 51 dumpVisitedAndLinkRules(result.nodeId, InspectorTest.completeTest.bind(I
nspectorTest)); |
| 52 } |
| 53 |
| 54 function setChildNodes(message) |
| 55 { |
| 56 var nodes = message.params.nodes; |
| 57 for (var i = 0; i < nodes.length; ++i) { |
| 58 nodeInfo[nodes[i].nodeId] = nodes[i]; |
| 59 delete nodes[i].nodeId; |
| 60 } |
| 61 } |
| 62 |
| 63 function dumpVisitedAndLinkRules(nodeId, callback) |
| 64 { |
| 65 InspectorTest.log("==== Styles for unvisited link ===="); |
| 66 InspectorTest.loadAndDumpMatchingRulesForNode(nodeId, onUnvisitedLinkDum
ped); |
| 67 function onUnvisitedLinkDumped() |
| 68 { |
| 69 InspectorTest.sendCommandOrDie("CSS.forcePseudoState", { |
| 70 nodeId: nodeId, |
| 71 forcedPseudoClasses: [ "visited" ] |
| 72 }, onVisitedForced); |
| 73 } |
| 74 |
| 75 function onVisitedForced() |
| 76 { |
| 77 InspectorTest.log("==== Styles for visited link ===="); |
| 78 InspectorTest.loadAndDumpMatchingRulesForNode(nodeId, callback); |
| 79 } |
| 80 } |
| 81 |
| 82 } |
| 83 </script> |
| 84 <style> |
| 85 #redlink:visited { |
| 86 color: red; |
| 87 } |
| 88 #redlink:link { |
| 89 color: blue; |
| 90 } |
| 91 |
| 92 #redlink { |
| 93 color: gray; |
| 94 } |
| 95 </style> |
| 96 <template id="shadow"> |
| 97 <style> |
| 98 .shadow-link:visited { |
| 99 color: blue; |
| 100 } |
| 101 .shadow-link:link { |
| 102 color: green; |
| 103 } |
| 104 .shadow-link { |
| 105 color: lightgray; |
| 106 } |
| 107 </style> |
| 108 <a class="shadow-link" href="definitely-unvisited-shadow-link-2232">This is shad
ow link</a> |
| 109 </template> |
| 110 </head> |
| 111 <body> |
| 112 <a id="redlink" href="definitely-unvisited-link-address-1989-42.html">This i
s visited link</a> |
| 113 <div id="shadow-host"></div> |
| 114 <script> |
| 115 runTest(); |
| 116 var host = document.querySelector("#shadow-host").createShadowRoot(); |
| 117 var template = document.querySelector("#shadow"); |
| 118 host.appendChild(template.content); |
| 119 template.remove(); |
| 120 </script> |
| 121 </body> |
| 122 </html> |
OLD | NEW |