DevTools: add test to verify matched styles for :host selector

This patch adds test based on the regression issue with styles sidebar
pane not showing styles for :host selectors. This test was originally
added in r174963, but the commit got reverted.

BUG=363468
TBR=apavlov

Review URL: https://codereview.chromium.org/317703002

git-svn-id: svn://svn.chromium.org/blink/trunk@175553 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent daac6100
......@@ -120,14 +120,9 @@ InspectorTest.displayName = function(url)
return url.substr(url.lastIndexOf("/") + 1);
};
InspectorTest.loadAndDumpMatchingRules = function(nodeId, callback)
InspectorTest.loadAndDumpMatchingRulesForNode = function(nodeId, callback)
{
InspectorTest.requestNodeId(nodeId, nodeIdLoaded);
function nodeIdLoaded(nodeId)
{
InspectorTest.sendCommandOrDie("CSS.getMatchedStylesForNode", { "nodeId": nodeId }, matchingRulesLoaded);
}
InspectorTest.sendCommandOrDie("CSS.getMatchedStylesForNode", { "nodeId": nodeId }, matchingRulesLoaded);
function matchingRulesLoaded(result)
{
......@@ -144,4 +139,14 @@ InspectorTest.loadAndDumpMatchingRules = function(nodeId, callback)
}
}
InspectorTest.loadAndDumpMatchingRules = function(selector, callback)
{
InspectorTest.requestNodeId(selector, nodeIdLoaded);
function nodeIdLoaded(nodeId)
{
InspectorTest.loadAndDumpMatchingRulesForNode(nodeId, callback);
}
}
}
<html>
<head>
<script type="text/javascript" src="../../http/tests/inspector-protocol/inspector-protocol-test.js"></script>
<script type="text/javascript" src="css-protocol-test.js"></script>
<script type="text/javascript">
function test()
{
InspectorTest.sendCommandOrDie("CSS.enable", {}, onCSSEnabled);
function onCSSEnabled()
{
InspectorTest.requestNodeId("#shadow-host", onNodeReceived);
}
function onNodeReceived(nodeId)
{
InspectorTest.loadAndDumpMatchingRulesForNode(nodeId, InspectorTest.completeTest.bind(InspectorTest));
}
}
</script>
<template id="shadow-template">
<style>
:host {
color: red;
}
</style>
<div>Hi!</div>
</template>
</head>
<body>
<div id="shadow-host"></div>
<script>
var host = document.querySelector("#shadow-host").createShadowRoot();
var template = document.querySelector("#shadow-template");
host.appendChild(template.content);
template.remove();
runTest();
</script>
</body>
</html>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment