| // Copyright 2017 The Chromium Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| |
| (async function() { |
| TestRunner.addResult(`Tests that WebInspector.CSSStyleSheet methods work as expected.\n`); |
| await TestRunner.loadModule('elements_test_runner'); |
| await TestRunner.showPanel('elements'); |
| await TestRunner.loadHTML(` |
| <style> |
| /* c1 */ |
| html |
| #inspected.bar /* c2 */, |
| /* c3 */ b |
| /* c4 */ { |
| text-decoration: none; |
| } |
| </style> |
| <h1 id="inspected" class="bar">Inspect Me</h1> |
| `); |
| |
| ElementsTestRunner.nodeWithId('inspected', nodeFound); |
| |
| async function nodeFound(node) { |
| var response = await TestRunner.CSSAgent.invoke_getMatchedStylesForNode({nodeId: node.id}); |
| if (response[Protocol.Error]) { |
| TestRunner.addResult('Failed to get styles: ' + response[Protocol.Error]); |
| return; |
| } |
| ElementsTestRunner.dumpRuleMatchesArray(response.matchedCSSRules); |
| TestRunner.completeTest(); |
| } |
| })(); |