Upstream version 5.34.104.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / LayoutTests / fast / css-grid-layout / resources / grid-definitions-parsing-utils.js
1 function testGridDefinitionsValues(element, columnValue, rowValue, computedColumnValue, computedRowValue)
2 {
3     window.element = element;
4     var elementID = element.id || "element";
5     shouldBeEqualToString("window.getComputedStyle(" + elementID + ", '').getPropertyValue('grid-template-columns')", computedColumnValue || columnValue);
6     shouldBeEqualToString("window.getComputedStyle(" + elementID + ", '').getPropertyValue('grid-template-rows')", computedRowValue || rowValue);
7 }
8
9 function testGridDefinitionsSetJSValues(columnValue, rowValue, computedColumnValue, computedRowValue, jsColumnValue, jsRowValue)
10 {
11     checkGridDefinitionsSetJSValues(true, columnValue, rowValue, computedColumnValue, computedRowValue, jsColumnValue, jsRowValue);
12 }
13
14 function testNonGridDefinitionsSetJSValues(columnValue, rowValue, computedColumnValue, computedRowValue, jsColumnValue, jsRowValue)
15 {
16     checkGridDefinitionsSetJSValues(false, columnValue, rowValue, computedColumnValue, computedRowValue, jsColumnValue, jsRowValue);
17 }
18
19 function checkGridDefinitionsSetJSValues(useGrid, columnValue, rowValue, computedColumnValue, computedRowValue, jsColumnValue, jsRowValue)
20 {
21     window.element = document.createElement("div");
22     document.body.appendChild(element);
23     if (useGrid) {
24         element.style.display = "grid";
25         element.style.width = "800px";
26         element.style.height = "600px";
27     }
28     element.style.font = "10px Ahem"; // Used to resolve em font consistently.
29     element.style.gridTemplateColumns = columnValue;
30     element.style.gridTemplateRows = rowValue;
31     shouldBeEqualToString("getComputedStyle(element, '').getPropertyValue('grid-template-columns')", computedColumnValue || columnValue);
32     shouldBeEqualToString("element.style.gridTemplateColumns", jsColumnValue || columnValue);
33     shouldBeEqualToString("getComputedStyle(element, '').getPropertyValue('grid-template-rows')", computedRowValue || rowValue);
34     shouldBeEqualToString("element.style.gridTemplateRows", jsRowValue || rowValue);
35     document.body.removeChild(element);
36 }
37
38 function testGridDefinitionsSetBadJSValues(columnValue, rowValue)
39 {
40     window.element = document.createElement("div");
41     document.body.appendChild(element);
42     element.style.gridTemplateColumns = columnValue;
43     element.style.gridTemplateRows = rowValue;
44     // We can't use testSetJSValues as element.style.gridTemplateRows returns "".
45     testGridDefinitionsValues(element, "none", "none");
46     document.body.removeChild(element);
47 }