blob: 25f6c7053743b1b37a06d20249576b96e2354374 [file] [log] [blame]
// 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 adding an @import with data URI does not lead to stylesheet collection crbug.com/644719\n`);
await TestRunner.loadModule('elements_test_runner');
await TestRunner.showPanel('elements');
await TestRunner.loadHTML(`
<!DOCTYPE html>
<style>span { color: red }</style>
<span id="styled-span"></span>
`);
var nodeId;
var sheetId;
ElementsTestRunner.selectNodeAndWaitForStyles('styled-span', nodeSelected);
function nodeSelected(node) {
nodeId = node.id;
TestRunner.cssModel.matchedStylesPromise(nodeId).then(matchedStylesBefore);
}
async function matchedStylesBefore(matchedResult) {
sheetId = matchedResult.nodeStyles()[1].styleSheetId;
TestRunner.addResult('\n== Matched rules before @import added ==\n');
await ElementsTestRunner.dumpSelectedElementStyles(true);
TestRunner.CSSAgent.setStyleSheetText(sheetId, '@import \'data:text/css,span{color:green}\';').then(sheetTextSet);
}
function sheetTextSet() {
ElementsTestRunner.selectNodeAndWaitForStyles('styled-span', matchedStylesAfter);
}
async function matchedStylesAfter() {
TestRunner.addResult('\n== Matched rules after @import added ==\n');
await ElementsTestRunner.dumpSelectedElementStyles(true);
TestRunner.completeTest();
}
})();