blob: 9e90a2bc295cab9adbab73636171f8f2501d785a [file] [log] [blame]
<!DOCTYPE html>
<html>
<head>
<script src="../../resources/js-test-pre.js"></script>
</head>
<body>
<script>
function testGradient(css)
{
var div = document.createElement('div');
div.setAttribute('style', css);
document.body.appendChild(div);
var result = getComputedStyle(div).backgroundImage;
document.body.removeChild(div);
return result;
}
debug('<p>linear-gradient</p>');
shouldBe('testGradient("background-image: linear-gradient(black 0%)")', '"none"');
shouldBe('testGradient("background-image: linear-gradient(top)")', '"none"');
shouldBe('testGradient("background-image: linear-gradient(to top)")', '"none"');
shouldBe('testGradient("background-image: linear-gradient(10deg)")', '"none"');
shouldBe('testGradient("background-image: linear-gradient(10deg black, white)")', '"none"');
shouldBe('testGradient("background-image: linear-gradient(to black, white)")', '"none"');
shouldBe('testGradient("background-image: linear-gradient(to left black, white)")', '"none"');
shouldBe('testGradient("background-image: linear-gradient(to top center, black 0%, white)")', '"none"');
shouldBe('testGradient("background-image: linear-gradient(10px 20%, black 0%)")', '"none"');
shouldBe('testGradient("background-image: linear-gradient(to left left)")', '"none"');
shouldBe('testGradient("background-image: linear-gradient(to left center)")', '"none"');
shouldBe('testGradient("background-image: linear-gradient(to left 10deg, black 0%, white)")', '"none"');
shouldBe('testGradient("background-image: linear-gradient(black)")', '"none"');
shouldBe('testGradient("background-image: linear-gradient(10deg, black 0%, 25%, 50%, white)")', '"none"');
shouldBe('testGradient("background-image: linear-gradient(10deg, black 0%, 50%)")', '"none"');
shouldBe('testGradient("background-image: linear-gradient(10deg, 50%, white)")', '"none"');
shouldBe('testGradient("background-image: linear-gradient(10deg, 0%, black, white)")', '"none"');
shouldBe('testGradient("background-image: linear-gradient(10deg, white, black, 80%)")', '"none"');
shouldBe('testGradient("background-image: linear-gradient(10deg, black, , white)")', '"none"');
shouldBe('testGradient("background-image: linear-gradient(black, white)")', '"linear-gradient(black, white)"');
shouldBe('testGradient("background-image: linear-gradient(black 0, white)")', '"linear-gradient(black 0px, white)"');
shouldBe('testGradient("background-image: linear-gradient(black 0%, white)")', '"linear-gradient(black 0%, white)"');
shouldBe('testGradient("background-image: linear-gradient(black 0%, white)")', '"linear-gradient(black 0%, white)"');
shouldBe('testGradient("background-image: linear-gradient(black 10px, white 20px)")', '"linear-gradient(black 10px, white 20px)"');
shouldBe('testGradient("background-image: linear-gradient(to top left, black 0%, white)")', '"linear-gradient(to left top, black 0%, white)"');
shouldBe('testGradient("background-image: linear-gradient(to top, black 0%, white)")', '"linear-gradient(to top, black 0%, white)"');
shouldBe('testGradient("background-image: linear-gradient(10deg, black 0%, white)")', '"linear-gradient(10deg, black 0%, white)"');
shouldBe('testGradient("background-image: linear-gradient(10deg, black 0%, 25%, white)")', '"linear-gradient(10deg, black 0%, 25%, white)"');
shouldBe('testGradient("background-image: linear-gradient(10deg, black 0%, 0%, white)")', '"linear-gradient(10deg, black 0%, 0%, white)"');
shouldBe('testGradient("background-image: linear-gradient(10deg, black 0%, 100%, white)")', '"linear-gradient(10deg, black 0%, 100%, white)"');
shouldBe('testGradient("background-image: linear-gradient(10deg, black 0%, 50%, green 50%, 50%, white)")', '"linear-gradient(10deg, black 0%, 50%, green 50%, 50%, white)"');
var s = "linear-gradient(";
for(var x = 0; x < 500; x++)
s += "white " + (x/500) + "%, " + ((2 * x + 1) / 1000) + "%, ";
s += "black)";
shouldBe('testGradient("background-image: ' + s + '")', '"' + s + '"');
debug('<p>repeating-linear-gradient</p>');
shouldBe('testGradient("background-image: repeating-linear-gradient(black, white)")', '"repeating-linear-gradient(black, white)"');
shouldBe('testGradient("background-image: repeating-linear-gradient(black, 35%, white)")', '"repeating-linear-gradient(black, 35%, white)"');
debug('<p>radial-gradient</p>');
shouldBe('testGradient("background-image: radial-gradient(white, black)")', '"radial-gradient(white, black)"');
shouldBe('testGradient("background-image: radial-gradient(at bottom right, white, black)")', '"radial-gradient(at right bottom, white, black)"');
shouldBe('testGradient("background-image: radial-gradient(farthest-corner, white, black)")', '"radial-gradient(white, black)"');
shouldBe('testGradient("background-image: radial-gradient(farthest-corner, white, 35%, black)")', '"radial-gradient(white, 35%, black)"');
shouldBe('testGradient("background-image: radial-gradient(closest-side, white, black)")', '"radial-gradient(closest-side, white, black)"');
shouldBe('testGradient("background-image: radial-gradient(ellipse, white, black)")', '"radial-gradient(white, black)"');
shouldBe('testGradient("background-image: radial-gradient(ellipse farthest-corner, white, black)")', '"radial-gradient(white, black)"');
shouldBe('testGradient("background-image: radial-gradient(ellipse closest-side, white, black)")', '"radial-gradient(closest-side, white, black)"');
shouldBe('testGradient("background-image: radial-gradient(circle, white, black)")', '"radial-gradient(circle, white, black)"');
shouldBe('testGradient("background-image: radial-gradient(circle farthest-corner, white, black)")', '"radial-gradient(circle, white, black)"');
shouldBe('testGradient("background-image: radial-gradient(circle closest-side, white, black)")', '"radial-gradient(circle closest-side, white, black)"');
shouldBe('testGradient("background-image: radial-gradient(circle closest-side at top, white, black)")', '"radial-gradient(circle closest-side at center top, white, black)"');
shouldBe('testGradient("background-image: radial-gradient(circle closest-side at top left, white, black)")', '"radial-gradient(circle closest-side at left top, white, black)"');
shouldBe('testGradient("background-image: radial-gradient(circle closest-side at 10px 20%, white, black)")', '"radial-gradient(circle closest-side at 10px 20%, white, black)"');
shouldBe('testGradient("background-image: radial-gradient(at 10px 20% circle closest-side, white, black)")', '"none"');
shouldBe('testGradient("background-image: radial-gradient(circle at 10px 20% circle, white, black)")', '"none"');
shouldBe('testGradient("background-image: radial-gradient(circle 10px closest-side, white, black)")', '"none"');
shouldBe('testGradient("background-image: radial-gradient(circle 10%, white, black)")', '"none"');
shouldBe('testGradient("background-image: radial-gradient(circle 10px 10px, white, black)")', '"none"');
shouldBe('testGradient("background-image: radial-gradient(ellipse 10%, white, black)")', '"none"');
shouldBe('testGradient("background-image: radial-gradient(ellipse 10px, white, black)")', '"none"');
shouldBe('testGradient("background-image: radial-gradient(25%, black)")', '"none"');
shouldBe('testGradient("background-image: radial-gradient(white, 25%)")', '"none"');
shouldBe('testGradient("background-image: radial-gradient(white, black, 25%)")', '"none"');
shouldBe('testGradient("background-image: radial-gradient(25%, white, black)")', '"none"');
shouldBe('testGradient("background-image: radial-gradient(white,, black)")', '"none"');
shouldBe('testGradient("background-image: radial-gradient(ellipse 10px, white, 25%, 75%, black)")', '"none"');
shouldBe('testGradient("background-image: radial-gradient(ellipse 10px 20px, white, black)")', '"radial-gradient(10px 20px, white, black)"');
shouldBe('testGradient("background-image: radial-gradient(circle 10px, white, black)")', '"radial-gradient(10px, white, black)"');
shouldBe('testGradient("background-image: radial-gradient(10px 10px at center, white, black)")', '"radial-gradient(10px 10px at center center, white, black)"');
shouldBe('testGradient("background-image: radial-gradient(10px 10px at center, white, 50%, black)")', '"radial-gradient(10px 10px at center center, white, 50%, black)"');
shouldBe('testGradient("background-image: radial-gradient(10px 10px at center, white, 0%, black)")', '"radial-gradient(10px 10px at center center, white, 0%, black)"');
shouldBe('testGradient("background-image: radial-gradient(10px 10px at center, white, 100%, black)")', '"radial-gradient(10px 10px at center center, white, 100%, black)"');
var s = "radial-gradient(10px 10px at 50% 50%, ";
for(var x = 0; x < 500; x++)
s += "white " + (x/500) + "%, " + ((2 * x + 1) / 1000) + "%, ";
s += "black)";
shouldBe('testGradient("background-image: ' + s + '")', '"' + s + '"');
debug('<p>repeating-radial-gradient</p>');
shouldBe('testGradient("background-image: repeating-radial-gradient(white, black)")', '"repeating-radial-gradient(white, black)"');
shouldBe('testGradient("background-image: repeating-radial-gradient(white, 81%, black)")', '"repeating-radial-gradient(white, 81%, black)"');
</script>
<script src="../../resources/js-test-post.js"></script>
</body>
</html>