blob: 70ee94675914c2155c2f59331e5aa1a3be1272ad [file] [log] [blame]
<!DOCTYPE html>
<html>
<head>
<script>
if (window.testRunner)
testRunner.overridePreference("WebKitCSSGridLayoutEnabled", 1);
</script>
<style>
.gridItemWithPositiveInteger {
grid-start: 10;
grid-before: 15;
}
.gridItemWithNegativeInteger {
grid-start: -10;
grid-before: -15;
}
.gridItemWithBeforeSpan {
grid-start: span 2;
grid-before: span 8;
}
.gridItemWithAfterSpan {
grid-start: 2 span;
grid-before: 8 span;
}
.gridItemWithOnlySpan {
grid-start: span;
grid-before: span;
}
.gridItemWithAuto {
grid-start: auto;
grid-before: auto;
}
.gridItemWithString {
grid-start: "first";
grid-before: "last";
}
.gridItemWithSpanString {
grid-start: "first" span;
grid-before: span "last";
}
.gridItemWithSpanNumberString {
grid-start: 2 "first" span;
grid-before: "last" 3 span;
}
</style>
<script src="resources/grid-item-column-row-parsing-utils.js"></script>
<script src="../js/resources/js-test-pre.js"></script>
</head>
<body>
<!-- The first has no properties set on it. -->
<div id="gridElement"></div>
<div class="gridItemWithPositiveInteger" id="gridItemWithPositiveInteger"></div>
<div class="gridItemWithNegativeInteger" id="gridItemWithNegativeInteger"></div>
<div class="gridItemWithBeforeSpan" id="gridItemWithBeforeSpan"></div>
<div class="gridItemWithAfterSpan" id="gridItemWithAfterSpan"></div>
<div class="gridItemWithOnlySpan" id="gridItemWithOnlySpan"></div>
<div class="gridItemWithAuto" id="gridItemWithAutoElement"></div>
<div class="gridItemWithString" id="gridItemWithStringElement"></div>
<div class="gridItemWithSpanString" id="gridItemWithSpanStringElement"></div>
<div class="gridItemWithSpanNumberString" id="gridItemWithSpanNumberStringElement"></div>
<script>
description('Test that setting and getting grid-start and grid-before works as expected');
debug("Test getting grid-start and grid-before set through CSS");
var gridElement = document.getElementById("gridElement");
shouldBe("getComputedStyle(gridElement, '').getPropertyValue('grid-start')", "'auto'");
shouldBe("getComputedStyle(gridElement, '').getPropertyValue('grid-column')", "'auto / auto'");
shouldBe("getComputedStyle(gridElement, '').getPropertyValue('grid-before')", "'auto'");
shouldBe("getComputedStyle(gridElement, '').getPropertyValue('grid-row')", "'auto / auto'");
testColumnRowCSSParsing("gridItemWithPositiveInteger", "10 / auto", "15 / auto");
testColumnRowCSSParsing("gridItemWithNegativeInteger", "-10 / auto", "-15 / auto");
testColumnRowCSSParsing("gridItemWithBeforeSpan", "span 2 / auto", "span 8 / auto");
testColumnRowCSSParsing("gridItemWithAfterSpan", "span 2 / auto", "span 8 / auto");
testColumnRowCSSParsing("gridItemWithOnlySpan", "span 1 / auto", "span 1 / auto");
testColumnRowCSSParsing("gridItemWithAutoElement", "auto / auto", "auto / auto");
testColumnRowCSSParsing("gridItemWithStringElement", "1 first / auto", "1 last / auto");
testColumnRowCSSParsing("gridItemWithSpanStringElement", "span 1 first / auto", "span 1 last / auto");
testColumnRowCSSParsing("gridItemWithSpanNumberStringElement", "span 2 first / auto", "span 3 last / auto");
debug("");
debug("Test the initial value");
var element = document.createElement("div");
document.body.appendChild(element);
shouldBe("getComputedStyle(element, '').getPropertyValue('grid-start')", "'auto'");
shouldBe("getComputedStyle(element, '').getPropertyValue('grid-column')", "'auto / auto'");
shouldBe("getComputedStyle(element, '').getPropertyValue('grid-before')", "'auto'");
shouldBe("getComputedStyle(element, '').getPropertyValue('grid-row')", "'auto / auto'");
debug("");
debug("Test getting and setting grid-start and grid-before through JS");
testStartBeforeJSParsing("18", "66");
testStartBeforeJSParsing("-55", "-40");
testStartBeforeJSParsing("'nav'", "'last'", "1 nav", "1 last");
testStartBeforeJSParsing("span 3", "span 20");
testStartBeforeJSParsing("span 'nav'", "span 'last'", "span 1 nav", "span 1 last");
testStartBeforeJSParsing("auto", "auto");
debug("");
debug("Test setting grid-start and grid-before to 'inherit' through JS");
testStartBeforeInheritJSParsing("inherit", "18");
testStartBeforeInheritJSParsing("2", "inherit");
testStartBeforeInheritJSParsing("inherit", "inherit");
debug("");
debug("Test setting grid-start and grid-before to 'initial' through JS");
testStartBeforeInitialJSParsing();
debug("");
debug("Test setting grid-start and grid-before back to 'auto' through JS");
element.style.gridStart = "18";
element.style.gridBefore = "66";
shouldBe("getComputedStyle(element, '').getPropertyValue('grid-start')", "'18'");
shouldBe("getComputedStyle(element, '').getPropertyValue('grid-column')", "'18 / auto'");
shouldBe("getComputedStyle(element, '').getPropertyValue('grid-before')", "'66'");
shouldBe("getComputedStyle(element, '').getPropertyValue('grid-row')", "'66 / auto'");
element.style.gridStart = "auto";
element.style.gridBefore = "auto";
shouldBe("getComputedStyle(element, '').getPropertyValue('grid-start')", "'auto'");
shouldBe("getComputedStyle(element, '').getPropertyValue('grid-column')", "'auto / auto'");
shouldBe("getComputedStyle(element, '').getPropertyValue('grid-before')", "'auto'");
shouldBe("getComputedStyle(element, '').getPropertyValue('grid-row')", "'auto / auto'");
</script>
<script src="../js/resources/js-test-post.js"></script>
</body>
</html>