Thu, 15 Jan 2015 21:03:48 +0100
Integrate friendly tips from Tor colleagues to make (or not) 4.5 alpha 3;
This includes removal of overloaded (but unused) methods, and addition of
a overlooked call to DataStruct::SetData(nsISupports, uint32_t, bool.)
michael@0 | 1 | <!DOCTYPE html> |
michael@0 | 2 | <html> |
michael@0 | 3 | <head> |
michael@0 | 4 | <meta charset=utf-8> |
michael@0 | 5 | <title>Test parsing of grid item shorthands (grid-column, grid-row, grid-area)</title> |
michael@0 | 6 | <link rel="author" title="Simon Sapin" href="mailto:simon.sapin@exyr.org"> |
michael@0 | 7 | <script src="/resources/testharness.js"></script> |
michael@0 | 8 | <script src="/resources/testharnessreport.js"></script> |
michael@0 | 9 | <link rel='stylesheet' href='/resources/testharness.css'> |
michael@0 | 10 | </head> |
michael@0 | 11 | <body> |
michael@0 | 12 | |
michael@0 | 13 | <script> |
michael@0 | 14 | |
michael@0 | 15 | // For various specified values of the grid-column and grid-row shorthands, |
michael@0 | 16 | // test the computed values of the corresponding longhands. |
michael@0 | 17 | var grid_column_row_test_cases = [ |
michael@0 | 18 | { |
michael@0 | 19 | specified: "3 / 4", |
michael@0 | 20 | expected_start: "3", |
michael@0 | 21 | expected_end: "4", |
michael@0 | 22 | }, |
michael@0 | 23 | { |
michael@0 | 24 | specified: "foo / span bar", |
michael@0 | 25 | expected_start: "foo", |
michael@0 | 26 | expected_end: "span bar", |
michael@0 | 27 | }, |
michael@0 | 28 | // http://dev.w3.org/csswg/css-grid/#placement-shorthands |
michael@0 | 29 | // "When the second value is omitted, |
michael@0 | 30 | // if the first value is a <custom-ident>, |
michael@0 | 31 | // the grid-row-end/grid-column-end longhand |
michael@0 | 32 | // is also set to that <custom-ident>; |
michael@0 | 33 | // otherwise, it is set to auto." |
michael@0 | 34 | { |
michael@0 | 35 | specified: "foo", |
michael@0 | 36 | expected_start: "foo", |
michael@0 | 37 | expected_end: "foo", |
michael@0 | 38 | }, |
michael@0 | 39 | { |
michael@0 | 40 | specified: "7", |
michael@0 | 41 | expected_start: "7", |
michael@0 | 42 | expected_end: "auto", |
michael@0 | 43 | }, |
michael@0 | 44 | { |
michael@0 | 45 | specified: "foo 7", |
michael@0 | 46 | expected_start: "7 foo", |
michael@0 | 47 | expected_end: "auto", |
michael@0 | 48 | }, |
michael@0 | 49 | { |
michael@0 | 50 | specified: "span foo", |
michael@0 | 51 | expected_start: "span foo", |
michael@0 | 52 | expected_end: "auto", |
michael@0 | 53 | }, |
michael@0 | 54 | { |
michael@0 | 55 | specified: "foo 7 span", |
michael@0 | 56 | expected_start: "span 7 foo", |
michael@0 | 57 | expected_end: "auto", |
michael@0 | 58 | }, |
michael@0 | 59 | { |
michael@0 | 60 | specified: "7 span", |
michael@0 | 61 | expected_start: "span 7", |
michael@0 | 62 | expected_end: "auto", |
michael@0 | 63 | }, |
michael@0 | 64 | ]; |
michael@0 | 65 | |
michael@0 | 66 | // For various specified values of the grid-area shorthand, |
michael@0 | 67 | // test the computed values of the corresponding longhands. |
michael@0 | 68 | var grid_area_test_cases = [ |
michael@0 | 69 | { |
michael@0 | 70 | specified: "10 / 20 / 30 / 40", |
michael@0 | 71 | gridRowStart: "10", |
michael@0 | 72 | gridColumnStart: "20", |
michael@0 | 73 | gridRowEnd: "30", |
michael@0 | 74 | gridColumnEnd: "40", |
michael@0 | 75 | }, |
michael@0 | 76 | { |
michael@0 | 77 | specified: "foo / bar / baz", |
michael@0 | 78 | gridRowStart: "foo", |
michael@0 | 79 | gridColumnStart: "bar", |
michael@0 | 80 | gridRowEnd: "baz", |
michael@0 | 81 | gridColumnEnd: "bar", |
michael@0 | 82 | }, |
michael@0 | 83 | { |
michael@0 | 84 | specified: "foo / span bar / baz", |
michael@0 | 85 | gridRowStart: "foo", |
michael@0 | 86 | gridColumnStart: "span bar", |
michael@0 | 87 | gridRowEnd: "baz", |
michael@0 | 88 | gridColumnEnd: "auto", |
michael@0 | 89 | }, |
michael@0 | 90 | { |
michael@0 | 91 | specified: "foo / bar", |
michael@0 | 92 | gridRowStart: "foo", |
michael@0 | 93 | gridColumnStart: "bar", |
michael@0 | 94 | gridRowEnd: "foo", |
michael@0 | 95 | gridColumnEnd: "bar", |
michael@0 | 96 | }, |
michael@0 | 97 | { |
michael@0 | 98 | specified: "foo / 4", |
michael@0 | 99 | gridRowStart: "foo", |
michael@0 | 100 | gridColumnStart: "4", |
michael@0 | 101 | gridRowEnd: "foo", |
michael@0 | 102 | gridColumnEnd: "auto", |
michael@0 | 103 | }, |
michael@0 | 104 | { |
michael@0 | 105 | specified: "foo", |
michael@0 | 106 | gridRowStart: "foo", |
michael@0 | 107 | gridColumnStart: "foo", |
michael@0 | 108 | gridRowEnd: "foo", |
michael@0 | 109 | gridColumnEnd: "foo", |
michael@0 | 110 | }, |
michael@0 | 111 | { |
michael@0 | 112 | specified: "7", |
michael@0 | 113 | gridRowStart: "7", |
michael@0 | 114 | gridColumnStart: "auto", |
michael@0 | 115 | gridRowEnd: "auto", |
michael@0 | 116 | gridColumnEnd: "auto", |
michael@0 | 117 | }, |
michael@0 | 118 | ] |
michael@0 | 119 | |
michael@0 | 120 | grid_column_row_test_cases.forEach(function(test_case) { |
michael@0 | 121 | ["Column", "Row"].forEach(function(axis) { |
michael@0 | 122 | var shorthand = "grid" + axis; |
michael@0 | 123 | var start_longhand = "grid" + axis + "Start"; |
michael@0 | 124 | var end_longhand = "grid" + axis + "End"; |
michael@0 | 125 | test(function() { |
michael@0 | 126 | var element = document.createElement('div'); |
michael@0 | 127 | document.body.appendChild(element); |
michael@0 | 128 | element.style[shorthand] = test_case.specified; |
michael@0 | 129 | var computed = window.getComputedStyle(element); |
michael@0 | 130 | assert_equals(computed[start_longhand], test_case.expected_start); |
michael@0 | 131 | assert_equals(computed[end_longhand], test_case.expected_end); |
michael@0 | 132 | }, "test parsing of '" + shorthand + ": " + test_case.specified + "'"); |
michael@0 | 133 | }); |
michael@0 | 134 | }); |
michael@0 | 135 | |
michael@0 | 136 | grid_area_test_cases.forEach(function(test_case) { |
michael@0 | 137 | test(function() { |
michael@0 | 138 | var element = document.createElement('div'); |
michael@0 | 139 | document.body.appendChild(element); |
michael@0 | 140 | element.style.gridArea = test_case.specified; |
michael@0 | 141 | var computed = window.getComputedStyle(element); |
michael@0 | 142 | [ |
michael@0 | 143 | "gridRowStart", "gridColumnStart", "gridRowEnd", "gridColumnEnd" |
michael@0 | 144 | ].forEach(function(longhand) { |
michael@0 | 145 | assert_equals(computed[longhand], test_case[longhand], longhand); |
michael@0 | 146 | }); |
michael@0 | 147 | }, "test parsing of 'grid-area: " + test_case.specified + "'"); |
michael@0 | 148 | }); |
michael@0 | 149 | |
michael@0 | 150 | </script> |
michael@0 | 151 | |
michael@0 | 152 | </body> |
michael@0 | 153 | </html> |