Commit 4cf1628c authored by tasak@google.com's avatar tasak@google.com

Added layout tests for all shorthand property.

This is a preparation patch for implementing all shorthand property.
This patch adds layout tests, which are currently failing.
After implementing all shorthand correctly, the tests will pass.

Spec: http://dev.w3.org/csswg/css-cascade/#all-shorthand

BUG=172051
TEST=fast/css/all-shorthand-css-text.html,fast/css/all-shorthand.html,fast/css/getComputedStyle/getComputedStyle-all.html

Review URL: https://codereview.chromium.org/335733003

git-svn-id: svn://svn.chromium.org/blink/trunk@176201 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent f1942458
Test for crbug.com/172051: all shorthand property.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS cssRules.length is 16
FAIL cssRules[0].cssText should be div { all: initial; }. Was div { }.
PASS cssRules[1].cssText is not "div { all: initial; color: red; }"
PASS contains(cssRules[1].cssText, "color: red;") is true
FAIL contains(cssRules[1].cssText, "background: initial;") should be true. Was false.
PASS contains(cssRules[1].cssText, "direction: ") is false
PASS contains(cssRules[1].cssText, "unicode-bidi: ") is false
FAIL cssRules[2].cssText should be div { all: initial; }. Was div { color: red; }.
FAIL cssRules[3].cssText should be div { all: initial !important; }. Was div { color: red; }.
PASS cssRules[4].cssText is not "div { all: initial; color: red !important; }"
PASS contains(cssRules[4].cssText, "color: red !important;") is true
FAIL contains(cssRules[4].cssText, "background: initial;") should be true. Was false.
PASS contains(cssRules[4].cssText, "direction: ") is false
PASS contains(cssRules[4].cssText, "unicode-bidi: ") is false
FAIL cssRules[5].cssText should be div { all: inherit; }. Was div { }.
PASS cssRules[6].cssText is not "div { all: inherit; color: red; }"
PASS contains(cssRules[6].cssText, "color: red;") is true
PASS contains(cssRules[6].cssText, "direction: ") is false
PASS contains(cssRules[6].cssText, "unicode-bidi: ") is false
FAIL cssRules[7].cssText should be div { all: inherit; }. Was div { color: red; }.
FAIL cssRules[8].cssText should be div { all: inherit !important; }. Was div { color: red; }.
PASS cssRules[9].cssText is not "div { all: inherit; color: red !important; }"
PASS contains(cssRules[9].cssText, "color: red !important") is true
FAIL contains(cssRules[9].cssText, "background: inherit;") should be true. Was false.
PASS contains(cssRules[9].cssText, "direction: ") is false
PASS contains(cssRules[9].cssText, "unicode-bidi: ") is false
PASS cssRules[10].cssText is "div { }"
FAIL cssRules[11].cssText should be div { all: initial; direction: rtl; }. Was div { direction: rtl; }.
FAIL cssRules[12].cssText should be div { direction: ltr; unicode-bidi: bidi-override; all: initial !important; }. Was div { direction: ltr; unicode-bidi: bidi-override; }.
PASS contains(cssRules[13].cssText, "all: initial;") is false
PASS contains(cssRules[13].cssText, "direction: ltr;") is true
PASS contains(cssRules[13].cssText, "color: red;") is true
PASS contains(cssRules[14].cssText, "all: initial;") is false
PASS contains(cssRules[14].cssText, "font: initial;") is false
FAIL contains(cssRules[14].cssText, "font-family: initial;") should be true. Was false.
PASS contains(cssRules[15].cssText, "all: initial;") is false
PASS contains(cssRules[14].cssText, "font: initial;") is false
PASS contains(cssRules[14].cssText, "marker: initial;") is false
PASS contains(cssRules[15].cssText, "width: inherit;") is true
FAIL contains(cssRules[15].cssText, "min-width: initial;") should be true. Was false.
FAIL contains(cssRules[15].cssText, "max-width: initial;") should be true. Was false.
FAIL contains(cssRules[15].cssText, "marker-start: initial;") should be true. Was false.
FAIL contains(cssRules[15].cssText, "marker-mid: initial;") should be true. Was false.
FAIL contains(cssRules[15].cssText, "marker-end: initial;") should be true. Was false.
PASS successfullyParsed is true
TEST COMPLETE
<!DOCTYPE html>
<script src="../../resources/js-test.js"></script>
<style>
div { all: initial; }
div { all: initial; color: red; }
div { color: red; all: initial; }
div { all: initial !important; color: red; }
div { all: initial; color: red !important; }
div { all: inherit; }
div { all: inherit; color: red; }
div { color: red; all: inherit; }
div { all: inherit !important; color: red; }
div { all: inherit; color: red !important; }
div { all: red; all: none; all: 10px; all: auto; all: url(about:blank); }
div { direction: ltr; all: initial; direction: rtl; }
div { direction: ltr; unicode-bidi: bidi-override; all: initial !important; }
div { direction: ltr; all: initial; color: red; }
div { all: initial; font-size: 10px; }
div { all: initial; width: inherit; }
</style>
<script>
description('Test for crbug.com/172051: all shorthand property.');
function contains(cssText, property) {
return cssText.indexOf(property) == 0 || cssText.indexOf(' ' + property) != -1;
}
var cssRules = document.styleSheets[1].cssRules;
shouldBe('cssRules.length', '16');
shouldBe('cssRules[0].cssText', '"div { all: initial; }"');
shouldNotBe('cssRules[1].cssText', '"div { all: initial; color: red; }"');
shouldBeTrue('contains(cssRules[1].cssText, "color: red;")');
shouldBeTrue('contains(cssRules[1].cssText, "background: initial;")');
shouldBeFalse('contains(cssRules[1].cssText, "direction: ")');
shouldBeFalse('contains(cssRules[1].cssText, "unicode-bidi: ")');
shouldBe('cssRules[2].cssText', '"div { all: initial; }"');
shouldBe('cssRules[3].cssText', '"div { all: initial !important; }"');
shouldNotBe('cssRules[4].cssText', '"div { all: initial; color: red !important; }"');
shouldBeTrue('contains(cssRules[4].cssText, "color: red !important;")');
shouldBeTrue('contains(cssRules[4].cssText, "background: initial;")');
shouldBeFalse('contains(cssRules[4].cssText, "direction: ")');
shouldBeFalse('contains(cssRules[4].cssText, "unicode-bidi: ")');
shouldBe('cssRules[5].cssText', '"div { all: inherit; }"');
shouldNotBe('cssRules[6].cssText', '"div { all: inherit; color: red; }"');
shouldBeTrue('contains(cssRules[6].cssText, "color: red;")');
shouldBeFalse('contains(cssRules[6].cssText, "direction: ")');
shouldBeFalse('contains(cssRules[6].cssText, "unicode-bidi: ")');
shouldBe('cssRules[7].cssText', '"div { all: inherit; }"');
shouldBe('cssRules[8].cssText', '"div { all: inherit !important; }"');
shouldNotBe('cssRules[9].cssText', '"div { all: inherit; color: red !important; }"');
shouldBeTrue('contains(cssRules[9].cssText, "color: red !important")');
shouldBeTrue('contains(cssRules[9].cssText, "background: inherit;")');
shouldBeFalse('contains(cssRules[9].cssText, "direction: ")');
shouldBeFalse('contains(cssRules[9].cssText, "unicode-bidi: ")');
shouldBe('cssRules[10].cssText', '"div { }"');
shouldBe('cssRules[11].cssText', '"div { all: initial; direction: rtl; }"');
shouldBe('cssRules[12].cssText', '"div { direction: ltr; unicode-bidi: bidi-override; all: initial !important; }"');
shouldBeFalse('contains(cssRules[13].cssText, "all: initial;")');
shouldBeTrue('contains(cssRules[13].cssText, "direction: ltr;")');
shouldBeTrue('contains(cssRules[13].cssText, "color: red;")');
shouldBeFalse('contains(cssRules[14].cssText, "all: initial;")');
shouldBeFalse('contains(cssRules[14].cssText, "font: initial;")');
shouldBeTrue('contains(cssRules[14].cssText, "font-family: initial;")');
shouldBeFalse('contains(cssRules[15].cssText, "all: initial;")');
shouldBeFalse('contains(cssRules[14].cssText, "font: initial;")');
shouldBeFalse('contains(cssRules[14].cssText, "marker: initial;")');
shouldBeTrue('contains(cssRules[15].cssText, "width: inherit;")');
shouldBeTrue('contains(cssRules[15].cssText, "min-width: initial;")');
shouldBeTrue('contains(cssRules[15].cssText, "max-width: initial;")');
shouldBeTrue('contains(cssRules[15].cssText, "marker-start: initial;")');
shouldBeTrue('contains(cssRules[15].cssText, "marker-mid: initial;")');
shouldBeTrue('contains(cssRules[15].cssText, "marker-end: initial;")');
</script>
<!DOCTYPE html>
<style>
#target1 { color: red; background-color: currentColor; }
#target1 { color: green; }
#parent { color: green; }
#target2 { color: red; background-color: currentColor; }
#target3 { color: green !important; }
#target4 { color: red !important; }
#target4 { background-color: red; }
#target5 { background-color: red; }
#target5 { color: green !important; }
#target6 { color: red !important; }
#target7 { direction: rtl; }
#target8 { direction: rtl !important; }
#parent9 { color: green; }
</style>
<div id='target1'>green color, green background-color</div>
<div id='parent'>
<div id='target2'>red color, red background-color</div>
</div>
<div id='target3'>green color</div>
<div id='target4'>red color, red background-color</div>
<div id='target5'>green color, red background-color</div>
<div id='target6'>red color</div>
<div id='target7'>direction is rtl</div>
<div id='target8'>direction is rtl</div>
<div id='parent9'>
<div id='target9'>green color</div>
</div>
<!DOCTYPE html>
<style>
#target1 { color: red; background-color: currentColor; }
#target1 { all: initial; }
#target1 { color: green; }
#parent { color: green; }
#target2 { color: red; background-color: currentColor; }
#target2 { all: inherit; }
#target3 { color: green !important; }
#target3 { all: initial; }
#target4 { color: red !important; }
#target4 { all: initial !important; }
#target4 { background-color: red; }
#target5 { all: initial !important; }
#target5 { background-color: red; }
#target5 { color: green !important; }
#target6 { all: initial !important; }
#target6 { color: red !important; }
#target6 { all: initial !important; }
#target7 { all: initial !important; }
#target7 { direction: rtl; }
#target8 { all: initial !important; }
#target8 { direction: rtl !important; }
#target8 { all: initial !important; }
#parent9 { color: green; }
#target9 { all: unset; }
</style>
<!-- Test for crbug.com/172051: all shorthand property -->
<!-- The following tests describes current behavior, -->
<!-- i.e. before implementing all. -->
<div id='target1'>green color, green background-color</div>
<div id='parent'>
<div id='target2'>red color, red background-color</div>
</div>
<div id='target3'>green color</div>
<div id='target4'>red color, red background-color</div>
<div id='target5'>green color, red background-color</div>
<div id='target6'>red color</div>
<div id='target7'>direction is rtl</div>
<div id='target8'>direction is rtl</div>
<div id='parent9'>
<div id='target9'>green color</div>
</div>
Test calling getPropertyValue on computed styles for all shorthand property.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
FAIL getComputedStyle(document.getElementById("initial")).all should be (of type string). Was undefined (of type undefined).
FAIL getComputedStyle(document.getElementById("inherit")).all should be (of type string). Was undefined (of type undefined).
FAIL getComputedStyle(document.getElementById("invalid")).all should be (of type string). Was undefined (of type undefined).
FAIL getComputedStyle(document.getElementById("notOnlyInitial")).all should be (of type string). Was undefined (of type undefined).
FAIL getComputedStyle(document.getElementById("notOnlyInherit")).all should be (of type string). Was undefined (of type undefined).
PASS successfullyParsed is true
TEST COMPLETE
<!DOCTYPE html>
<script src="../../../resources/js-test.js"></script>
<style>
#initial { all: initial; }
#inherit { all: inherit; }
#invalid { all: green; }
#notOnlyInitial { all: initial; color: green; }
#notOnlyInherit { all: inherit; color: green; }
</style>
<div id="initial"></div>
<div id="inherit"></div>
<div id="invalid"></div>
<div id="notOnlyInitial"></div>
<div id="notOnlyInherit"></div>
<script>
description('Test calling getPropertyValue on computed styles for all shorthand property.');
shouldBeEqualToString('getComputedStyle(document.getElementById("initial")).all', "");
shouldBeEqualToString('getComputedStyle(document.getElementById("inherit")).all', "");
shouldBeEqualToString('getComputedStyle(document.getElementById("invalid")).all', "");
shouldBeEqualToString('getComputedStyle(document.getElementById("notOnlyInitial")).all', "");
shouldBeEqualToString('getComputedStyle(document.getElementById("notOnlyInherit")).all', "");
</script>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment