blob: 633c3bc721af5913a97cd894cf411682b89c4bf2 [file] [log] [blame]
<!doctype html>
<html>
<head>
<script src="../../resources/js-test-pre.js"></script>
<style>
* {
background-color: white;
color: black;
fill-opacity: 1;
min-width: 0px;
}
foo:first-child+padding+padding+padding+bar {
background-color: rgb(1, 2, 3);
}
foo:first-child~bar {
fill-opacity: 0.5;
}
foo:first-child+padding+padding+padding+bar baz {
color: rgb(4, 5, 6);
}
foo:first-child~bar baz {
min-width: 1px;
}
</style>
</head>
<body>
<div id="testcases-with-renderer">
<!-- Comments should be ignored by selectors. -->
<foo></foo>
<padding></padding>
<padding></padding>
<padding></padding>
<bar id="bar-with-renderer">
<baz id="baz-with-renderer"></baz>
</bar>
</div>
<div id="testcases-without-renderer" style="display:none;">
<!-- Comments should be ignored by selectors. -->
<foo></foo>
<padding></padding>
<padding></padding>
<padding></padding>
<bar id="bar-without-renderer">
<baz id="baz-without-renderer"></baz>
</bar>
</div>
</body>
<script>
description('Test style update caused by changes the positional property "first-child" on a sibling.');
function testColor(expectMatch) {
shouldBeEqualToString('getComputedStyle(document.getElementById("bar-with-renderer")).backgroundColor', expectMatch ? 'rgb(1, 2, 3)' : 'rgb(255, 255, 255)');
shouldBeEqualToString('getComputedStyle(document.getElementById("baz-with-renderer")).backgroundColor', 'rgb(255, 255, 255)');
shouldBeEqualToString('getComputedStyle(document.getElementById("bar-without-renderer")).backgroundColor', expectMatch ? 'rgb(1, 2, 3)' : 'rgb(255, 255, 255)');
shouldBeEqualToString('getComputedStyle(document.getElementById("baz-without-renderer")).backgroundColor', 'rgb(255, 255, 255)');
shouldBeEqualToString('getComputedStyle(document.getElementById("bar-with-renderer")).fillOpacity', expectMatch ? '0.5' : '1');
shouldBeEqualToString('getComputedStyle(document.getElementById("baz-with-renderer")).fillOpacity', '1');
shouldBeEqualToString('getComputedStyle(document.getElementById("bar-without-renderer")).fillOpacity', expectMatch ? '0.5' : '1');
shouldBeEqualToString('getComputedStyle(document.getElementById("baz-without-renderer")).fillOpacity', '1');
shouldBeEqualToString('getComputedStyle(document.getElementById("bar-with-renderer")).color', 'rgb(0, 0, 0)');
shouldBeEqualToString('getComputedStyle(document.getElementById("baz-with-renderer")).color', expectMatch ? 'rgb(4, 5, 6)' : 'rgb(0, 0, 0)');
shouldBeEqualToString('getComputedStyle(document.getElementById("bar-without-renderer")).color', 'rgb(0, 0, 0)');
shouldBeEqualToString('getComputedStyle(document.getElementById("baz-without-renderer")).color', expectMatch ? 'rgb(4, 5, 6)' : 'rgb(0, 0, 0)');
shouldBeEqualToString('getComputedStyle(document.getElementById("bar-with-renderer")).minWidth', '0px');
shouldBeEqualToString('getComputedStyle(document.getElementById("baz-with-renderer")).minWidth', expectMatch ? '1px': '0px');
shouldBeEqualToString('getComputedStyle(document.getElementById("bar-without-renderer")).minWidth', '0px');
shouldBeEqualToString('getComputedStyle(document.getElementById("baz-without-renderer")).minWidth', expectMatch ? '1px': '0px');
}
debug("The initial state has &lt;foo&gt; in first position, it should match.");
testColor(true);
debug("Adding an element as first child should clear the style.");
var testCasesWithRenderer = document.getElementById("testcases-with-renderer");
var divWithRenderer = document.createElement("div");
testCasesWithRenderer.insertBefore(divWithRenderer, testCasesWithRenderer.firstChild)
var testCasesWithoutRenderer = document.getElementById("testcases-without-renderer");
var divWithoutRenderer = document.createElement("div");
testCasesWithoutRenderer.insertBefore(divWithoutRenderer, testCasesWithoutRenderer.firstChild)
testColor(false);
debug("Removing that first element put back the style.");
divWithRenderer.remove();
divWithoutRenderer.remove();
testColor(true);
debug("Removing &lt;foo&gt; should clear the style.");
testCasesWithRenderer.querySelector("foo").remove();
testCasesWithoutRenderer.querySelector("foo").remove();
testColor(false);
</script>
<script src="../../resources/js-test-post.js"></script>
</html>