blob: 40dad3799a50f83617f144bdeec5bcb52745f8e4 [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 injected user stylesheets are reflected in the Styles pane.\n`);
await TestRunner.loadModule('elements_test_runner');
await TestRunner.loadModule('console_test_runner');
await TestRunner.showPanel('elements');
await TestRunner.loadHTML(`
<style>
#main { background:blue; }
</style>
<div id="main"></div>
`);
await TestRunner.evaluateInPagePromise(`
function injectStyleSheet(context)
{
var styleSheet = "#main { color: red; border-style: solid; -webkit-border-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAQAAAC1+jfqAAAAiElEQVR42r2RsQrDMAxEBRdl8SDcX8lQPGg1GBI6lvz/h7QyRRXV0qUULwfvwZ1tenw5PxToRPWMC52eA9+WDnlh3HFQ/xBQl86NFYJqeGflkiogrOvVlIFhqURFVho3x1moGAa3deMs+LS30CAhBN5nNxeT5hbJ1zwmji2k+aF6NENIPf/hs54f0sZFUVAMigAAAABJRU5ErkJggg==) } #iframeBody { background: red }";
if (context.testRunner)
context.testRunner.insertStyleSheet(styleSheet);
}
injectStyleSheet(window);
function loadIframe()
{
var iframe = document.createElement("iframe");
iframe.src = "../styles/resources/inject-stylesheet-iframe-data.html";
document.getElementById("main").appendChild(iframe);
}
`);
ElementsTestRunner.selectNodeAndWaitForStylesWithComputed('main', step0);
function step0() {
TestRunner.addResult('Main frame style:');
ElementsTestRunner.dumpSelectedElementStyles();
TestRunner.evaluateInPage('loadIframe()');
ConsoleTestRunner.addConsoleSniffer(step1);
}
function step1() {
ElementsTestRunner.selectNodeAndWaitForStylesWithComputed('iframeBody', step2);
}
function step2() {
TestRunner.addResult('iframe style:');
ElementsTestRunner.dumpSelectedElementStyles();
TestRunner.completeTest();
}
})();