// Copyright 2017 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import {TestRunner} from 'test_runner';
import {ElementsTestRunner} from 'elements_test_runner';
(async function() {
TestRunner.addResult(`Tests that colors are not re-formatted inside url(...) when editing property values.\n`);
await TestRunner.showPanel('elements');
await TestRunner.loadHTML(`
<div id="inspected1" style="background: white">"white" background</div>
<div id="inspected2" style="background: url( white )">"url( white )" background</div>
<div id="inspected3" style="background: url(white.png)">"url(white.png)" background</div>
<div id="inspected4" style="background: url(../foo/white.png)">"url(../foo/white.png)" background</div>
<div id="inspected5" style="background: green url(white)">"green url(white)" background</div>
<div id="inspected6" style="background: url(white) green">"url(white) green" background</div>
<div id="inspected7" style="background: url(white) green, url(green)">"url(white) green, url(green)" background</div>
<div id="inspected8" style="background: url(white), url(green)">"url(white), url(green)" background</div>
<div id="inspected9" style="background: hsl(0, 50%, 50%) url(white)">"hsl(0, 50%, 50%) url(white)" background</div>
<div id="inspected10" style="background: url(white) hsl(0, 50%, 50%)">"url(white) hsl(0, 50%, 50%)" background</div>
<div id="inspected11" style="background: url(../black/white.png)">"url(../black/white.png)" background</div>
`);
var maxIndex = 11;
var idIndex = 1;
selectDivAndEditValue();
function selectDivAndEditValue() {
ElementsTestRunner.selectNodeAndWaitForStyles('inspected' + idIndex++, editCallback);
}
function editCallback() {
var treeElement = ElementsTestRunner.getMatchedStylePropertyTreeItem('background');
treeElement.startEditingValue();
TestRunner.addResult(treeElement.valueElement.textContent);
if (idIndex <= maxIndex)
selectDivAndEditValue();
else
TestRunner.completeTest();
}
})();