Bug 1304012 -- Part 3: mochitest updated to match new spec behavior, and updated property database. r=dholbert

MozReview-Commit-ID: o5ENMMRLZF
This commit is contained in:
Brad Werth 2016-09-29 15:47:36 -07:00
Родитель 2fe8e4a753
Коммит b093f83db4
2 изменённых файлов: 89 добавлений и 164 удалений

Просмотреть файл

@ -4403,9 +4403,8 @@ var gCSSProperties = {
domProp: "alignSelf",
inherited: false,
type: CSS_TYPE_LONGHAND,
// (Assuming defaults on the parent, 'auto' will compute to 'normal'.)
initial_values: [ "auto", "normal" ],
other_values: [ "start", "flex-start", "flex-end", "center", "stretch",
initial_values: [ "auto" ],
other_values: [ "normal", "start", "flex-start", "flex-end", "center", "stretch",
"baseline", "last-baseline", "right safe", "unsafe center",
"self-start", "self-end safe" ],
invalid_values: [ "space-between", "abc", "30px", "stretch safe", "safe" ]
@ -4444,8 +4443,8 @@ var gCSSProperties = {
domProp: "justifySelf",
inherited: false,
type: CSS_TYPE_LONGHAND,
initial_values: [ "auto", "normal" ],
other_values: [ "start", "end", "flex-start", "flex-end", "self-start",
initial_values: [ "auto" ],
other_values: [ "normal", "start", "end", "flex-start", "flex-end", "self-start",
"self-end", "center", "left", "right", "baseline",
"last-baseline", "stretch", "left unsafe", "unsafe right",
"safe right", "center safe" ],

Просмотреть файл

@ -51,36 +51,15 @@ function getComputedJustifyContent(elem) {
}
/**
* Test behavior of 'align-self:auto' (Bug 696253)
* Test behavior of 'align-self:auto' (Bug 696253 and Bug 1304012)
* ===============================================
*
* The value "align-self: auto" is special. It's the initial value for
* "align-self", and it's supposed to compute to the parent's "align-items" value.
*
* However, to allow its style-struct to be shared by default, we internally
* make it compute to a special "auto" enumerated value, and then we resolve that
* to the correct value by examining the parent's style struct whenever we actually
* need to use it.
*
* This test makes sure that optimization isn't detectable to content.
*
* One special case of this is inheritance -- e.g.:
*
* <html style="align-items: baseline">
* <body style="align-self: auto; align-items: center">
* <div style="align-self: inherit">
*
* In that example, the child div's "inherit" should get the _computed_ value
* of "align-self" on the body. That, in turn, is "auto", so it should compute to
* its parent's "align-items" value, which is "baseline". So we need to end up
* with a computed "align-self" value of "baseline" on the child.
*
* (NOTE: if we instead allowed the child div to directly inherit the value "auto"
* from its parent, then we'd get different & incorrect behavior. The div would
* resolve that inherited "auto" value to its own parent's "align-items" value,
* which is "center" -- not "baseline".)
*
* This mochitest tests that situation and a few other similar tricky situations.
* In a previous revision of the CSS Alignment spec, align-self:auto
* was required to actually *compute* to the parent's align-items value --
* but now, the spec says it simply computes to itself, and it should
* only get converted into the parent's align-items value when it's used
* in layout. This test verifies that we do indeed have it compute to
* itself, regardless of the parent's align-items value.
*/
/*
@ -88,23 +67,27 @@ function getComputedJustifyContent(elem) {
*/
function testGeneralNode(elem) {
// Test initial computed style
// (Initial value should be 'auto', which should compute to 'normal')
is(getComputedAlignSelf(elem), "normal", elem.tagName + ": " +
"initial computed value of 'align-self' should be 'normal', " +
"if we haven't explicitly set any style on the parent");
// (Initial value should be 'auto', which should compute to itself)
is(getComputedAlignSelf(elem), "auto", elem.tagName + ": " +
"initial computed value of 'align-self' should be 'auto'");
// Test value after setting align-self explicitly to "auto"
elem.style.alignSelf = "auto";
is(getComputedAlignSelf(elem), "normal", elem.tagName + ": " +
"computed value of 'align-self: auto' should be 'normal', " +
"if we haven't explicitly set any style on the parent");
is(getComputedAlignSelf(elem), "auto", elem.tagName + ": " +
"computed value of 'align-self: auto' should be 'auto'");
elem.style.alignSelf = ""; // clean up
// Test value after setting align-self explicitly to "inherit"
elem.style.alignSelf = "inherit";
is(getComputedAlignSelf(elem), "normal", elem.tagName + ": " +
"computed value of 'align-self: inherit' should be 'normal', " +
"if we haven't explicitly set any style on the parent");
if (elem.parentNode && elem.parentNode.style) {
is(getComputedAlignSelf(elem), getComputedAlignSelf(elem.parentNode),
elem.tagName + ": computed value of 'align-self: inherit' " +
"should match the value on the parent");
} else {
is(getComputedAlignSelf(elem), "auto", elem.tagName + ": " +
"computed value of 'align-self: inherit' should be 'auto', " +
"when there is no parent");
}
elem.style.alignSelf = ""; // clean up
}
@ -120,75 +103,30 @@ function testNodeThatHasParent(elem) {
// (elem's initial "align-self" value should be "auto", which should compute
// to its parent's "align-items" value, which in this case is "center".)
elem.parentNode.style.alignItems = "center";
is(getComputedAlignSelf(elem), "center", elem.tagName + ": " +
"initial computed value of 'align-self' should match parent's " +
"specified 'align-items' value");
is(getComputedAlignSelf(elem), "auto", elem.tagName + ": " +
"initial computed value of 'align-self' should be 'auto', even " +
"after changing parent's 'align-items' value");
// ...and now test computed style after setting "align-self" explicitly to
// "auto" (with parent "align-items" still at "center")
elem.style.alignSelf = "auto";
is(getComputedAlignSelf(elem), "center", elem.tagName + ": " +
"computed value of 'align-self: auto' should match parent's " +
"specified 'align-items' value");
is(getComputedAlignSelf(elem), "auto", elem.tagName + ": " +
"computed value of 'align-self: auto' should remain 'auto', after " +
"being explicitly set");
elem.style.alignSelf = ""; // clean up
elem.parentNode.style.alignItems = ""; // clean up
// Finally: test computed style after setting "align-self" to "inherit"
// and leaving parent at its initial value (which should be "auto", which
// should compute to "normal")
// and leaving parent at its initial value which should be "auto".
elem.style.alignSelf = "inherit";
is(getComputedAlignSelf(elem), "normal", elem.tagName + ": " +
is(getComputedAlignSelf(elem), "auto", elem.tagName + ": " +
"computed value of 'align-self: inherit' should take parent's " +
"computed 'align-self' value (which should be 'normal', " +
"computed 'align-self' value (which should be 'auto', " +
"if we haven't explicitly set any other style");
elem.style.alignSelf = ""; // clean up
}
/*
* Tests that depend on us having a grandparent node:
*/
function testNodeThatHasGrandparent(elem) {
// Sanity-check that we actually do have a styleable grandparent:
ok(elem.parentNode && elem.parentNode.parentNode &&
elem.parentNode.parentNode.style, elem.tagName + ": " +
"bug in test -- should be getting a node with a grandparent");
// Test computed "align-self" after we set "align-self" to "inherit" on our elem
// and to "auto" on its parent, and "align-items" to "baseline" on its
// grandparent. The parent's "auto" value should resolve to "baseline", and
// that's what our elem should inherit.
elem.style.alignSelf = "inherit";
elem.parentNode.style.alignSelf = "auto";
elem.parentNode.parentNode.style.alignItems = "baseline";
is(getComputedAlignSelf(elem), "baseline", elem.tagName + ": " +
"computed value of 'align-self:inherit' on node when parent has " +
"'align-self:auto' and grandparent has 'align-items:baseline'")
// clean up:
elem.style.alignSelf = "";
elem.parentNode.style.alignSelf = "";
elem.parentNode.parentNode.style.alignItems = "";
// Test computed "align-self" after we set it to "auto" on our node, set
// "align-items" to "inherit" on its parent, and "align-items" to "baseline"
// on its grandparent. The parent's "inherit" should compute to "baseline",
// and our elem's "auto" value should resolve to that.
elem.style.alignSelf = "auto";
elem.parentNode.style.alignItems = "inherit";
elem.parentNode.parentNode.style.alignItems = "baseline";
is(getComputedAlignSelf(elem), "baseline", elem.tagName + ": " +
"computed value of 'align-self:auto on node when parent has " +
"'align-items:inherit' and grandparent has 'align-items:baseline'")
// clean up:
elem.style.alignSelf = "";
elem.parentNode.style.alignItems = "";
elem.parentNode.parentNode.style.alignItems = "";
}
/*
* Main test function
*/
@ -218,18 +156,6 @@ function main() {
testGeneralNode(body);
testNodeThatHasParent(body);
// Test the <div id="display"> node
// ================================
// (It has both a parent and a grandparent style context.)
var displayNode = document.getElementById("display");
is(displayNode.parentNode.parentNode, document.documentElement,
"expecting 'display' node's grandparent to be the root node");
testGeneralNode(displayNode);
testNodeThatHasParent(displayNode);
testNodeThatHasGrandparent(displayNode);
//
// align-items/self tests:
//
@ -238,39 +164,39 @@ function main() {
var child = document.getElementById("display");
var abs = document.getElementById("absChild");
is(getComputedAlignItems(elem), 'normal', "default align-items value for block container");
is(getComputedAlignSelf(child), 'normal', "default align-self value for block child");
is(getComputedAlignSelf(abs), 'normal', "default align-self value for block container abs.pos. child");
is(getComputedAlignSelf(child), 'auto', "default align-self value for block child");
is(getComputedAlignSelf(abs), 'auto', "default align-self value for block container abs.pos. child");
elem.style.alignItems = "end";
is(getComputedAlignSelf(child), 'end', "auto value copies align-items of parent");
is(getComputedAlignSelf(abs), 'end', "align-self:auto is affected by parent align-items value for block container abs.pos. child");
is(getComputedAlignSelf(child), 'auto', "align-self:auto value persists for block child");
is(getComputedAlignSelf(abs), 'auto', "align-self:auto value persists for block container abs.pos. child");
elem.style.alignItems = "left";
is(getComputedAlignItems(elem), 'left', "align-items:left computes to itself on a block");
is(getComputedAlignSelf(child), 'left', "align-self:left computes to left on block child");
is(getComputedAlignSelf(abs), 'left', "align-self:auto is affected by parent align-items value for block container abs.pos. child");
is(getComputedAlignItems(elem), 'left', "align-items:left computes to itself for a block");
is(getComputedAlignSelf(child), 'auto', "align-self:auto persists for block child");
is(getComputedAlignSelf(abs), 'auto', "align-self:auto value persists for block container abs.pos. child");
elem.style.alignItems = "right";
is(getComputedAlignSelf(child), 'right', "align-self:right computes to right on block child");
is(getComputedAlignSelf(abs), 'right', "align-self:auto is affected by parent align-items value for block container abs.pos. child");
is(getComputedAlignSelf(child), 'auto', "align-self:auto value persists for block child");
is(getComputedAlignSelf(abs), 'auto', "align-self:auto value persists for block container abs.pos. child");
elem.style.alignItems = "right safe";
is(getComputedAlignSelf(child), 'right safe', "align-items:'right safe' computes to 'align-self:right safe' on block child");
is(getComputedAlignSelf(child), 'auto', "align-self:auto value persists for block child");
elem.style.alignItems = "";
child.style.alignSelf = "left";
is(getComputedAlignSelf(child), 'left', "align-self:left computes to left on block child");
is(getComputedAlignSelf(child), 'left', "align-self:left computes to left for block child");
child.style.alignSelf = "right";
is(getComputedAlignSelf(child), 'right', "align-self:right computes to right on block child");
is(getComputedAlignSelf(child), 'right', "align-self:right computes to right for block child");
child.style.alignSelf = "";
abs.style.alignSelf = "right";
is(getComputedAlignSelf(abs), 'right', "align-self:right computes to right on block container abs.pos. child");
is(getComputedAlignSelf(abs), 'right', "align-self:right computes to right for block container abs.pos. child");
//// Flexbox tests
function testFlexAlignItemsSelf(elem) {
var item = elem.firstChild;
var abs = elem.children[1];
is(getComputedAlignItems(elem), 'normal', "default align-items value for flex container");
is(getComputedAlignSelf(item), 'normal', "default align-self value for flex item");
is(getComputedAlignSelf(abs), 'normal', "default align-self value for flex container abs.pos. child");
is(getComputedAlignSelf(item), 'auto', "default align-self value for flex item");
is(getComputedAlignSelf(abs), 'auto', "default align-self value for flex container abs.pos. child");
elem.style.alignItems = "flex-end";
is(getComputedAlignSelf(item), 'flex-end', "auto value copies align-items of parent");
is(getComputedAlignSelf(abs), 'flex-end', "align-self:auto is affected by parent align-items value for flex container abs.pos. child");
is(getComputedAlignSelf(item), 'auto', "align-self:auto value persists for flex container child");
is(getComputedAlignSelf(abs), 'auto', "align-self:auto value persists for flex container abs.pos. child");
elem.style.alignItems = "left";
is(getComputedAlignItems(elem), 'left', "align-items:left computes to itself for flex container");
// XXX TODO: add left/right tests (bug 1221565)
@ -284,20 +210,20 @@ function main() {
var item = elem.firstChild;
var abs = elem.children[1];
is(getComputedAlignItems(elem), 'normal', "default align-items value for grid container");
is(getComputedAlignSelf(item), 'normal', "default align-self value for grid item");
is(getComputedAlignSelf(abs), 'normal', "default align-self value for grid container abs.pos. child");
is(getComputedAlignSelf(item), 'auto', "default align-self value for grid item");
is(getComputedAlignSelf(abs), 'auto', "default align-self value for grid container abs.pos. child");
elem.style.alignItems = "end";
is(getComputedAlignSelf(item), 'end', "auto value copies align-items of parent");
is(getComputedAlignSelf(abs), 'end', "align-self:auto is affected by parent align-items value for grid container abs.pos. child");
is(getComputedAlignSelf(item), 'auto', "align-self:auto value persists for grid container child");
is(getComputedAlignSelf(abs), 'auto', "align-self:auto value persists for grid container abs.pos. child");
elem.style.alignItems = "left";
is(getComputedAlignItems(elem), 'left', "align-items:left computes to itself for grid container");
is(getComputedAlignSelf(item), 'left', "align-self:left computes to left on grid item");
is(getComputedAlignSelf(abs), 'left', "align-self:auto is affected by parent align-items value for grid container abs.pos. child");
is(getComputedAlignSelf(item), 'auto', "align-self:auto value persists for grid container child");
is(getComputedAlignSelf(abs), 'auto', "align-self:auto value persists for grid container abs.pos. child");
elem.style.alignItems = "right";
is(getComputedAlignSelf(item), 'right', "align-self:right computes to right on grid item");
is(getComputedAlignSelf(abs), 'right', "align-self:auto is affected by parent align-items value for grid container abs.pos. child");
is(getComputedAlignSelf(item), 'auto', "align-self:auto value persists for grid container child");
is(getComputedAlignSelf(abs), 'auto', "align-self:auto value persists for grid container abs.pos. child");
elem.style.alignItems = "right safe";
is(getComputedAlignSelf(item), 'right safe', "align-items:'right safe' computes to 'align-self:right safe' on grid item");
is(getComputedAlignSelf(item), 'auto', "align-self:auto value persists for grid container child");
item.style.alignSelf = "left";
is(getComputedAlignSelf(item), 'left', "align-self:left computes to left on grid item");
item.style.alignSelf = "right";
@ -322,20 +248,20 @@ function main() {
var child = document.getElementById("display");
var abs = document.getElementById("absChild");
is(getComputedJustifyItems(elem), 'normal', "default justify-items value for block container");
is(getComputedJustifySelf(child), 'normal', "default justify-self value for block child");
is(getComputedJustifySelf(abs), 'normal', "default justify-self value for block container abs.pos. child");
is(getComputedJustifySelf(child), 'auto', "default justify-self value for block container child");
is(getComputedJustifySelf(abs), 'auto', "default justify-self value for block container abs.pos. child");
elem.style.justifyItems = "end";
is(getComputedJustifySelf(child), 'end', "auto value copies justify-items of parent");
is(getComputedJustifySelf(abs), 'end', "justify-self:auto ist affected by parent justify-items value for block container abs.pos. child");
is(getComputedJustifySelf(child), 'auto', "justify-self:auto value persists for block child");
is(getComputedJustifySelf(abs), 'auto', "justify-self:auto value persists for block container abs.pos. child");
elem.style.justifyItems = "left";
is(getComputedJustifyItems(elem), 'left', "justify-items:left computes to itself on a block");
is(getComputedJustifySelf(child), 'left', "justify-self:left computes to left on block child");
is(getComputedJustifySelf(abs), 'left', "justify-self:auto is affected by parent justify-items value for block container abs.pos. child");
is(getComputedJustifySelf(child), 'auto', "justify-self:auto value persists for block child");
is(getComputedJustifySelf(abs), 'auto', "justify-self:auto value persists for block container abs.pos. child");
elem.style.justifyItems = "right";
is(getComputedJustifySelf(child), 'right', "justify-self:right computes to right on block child");
is(getComputedJustifySelf(abs), 'right', "justify-self:auto is affected by parent justify-items value for block container abs.pos. child");
is(getComputedJustifySelf(child), 'auto', "justify-self:auto value persists for block child");
is(getComputedJustifySelf(abs), 'auto', "justify-self:auto value persists for block container abs.pos. child");
elem.style.justifyItems = "right safe";
is(getComputedJustifySelf(child), 'right safe', "justify-items:'right safe' computes to 'justify-self:right safe' on block child");
is(getComputedJustifySelf(child), 'auto', "justify-self:auto value persists for block child");
elem.style.justifyItems = "";
child.style.justifySelf = "left";
is(getComputedJustifySelf(child), 'left', "justify-self:left computes to left on block child");
@ -350,15 +276,15 @@ function main() {
var item = elem.firstChild;
var abs = elem.children[1];
is(getComputedJustifyItems(elem), 'normal', "default justify-items value for flex container");
is(getComputedJustifySelf(item), 'normal', "default justify-self value for flex item");
is(getComputedJustifySelf(abs), 'normal', "default justify-self value for flex container abs.pos. child");
is(getComputedJustifySelf(item), 'auto', "default justify-self value for flex item");
is(getComputedJustifySelf(abs), 'auto', "default justify-self value for flex container abs.pos. child");
elem.style.justifyItems = "flex-end";
is(getComputedJustifySelf(item), 'flex-end', "auto value copies justify-items of parent");
is(getComputedJustifySelf(abs), 'flex-end', "default justify-self value for flex container abs.pos. child");
is(getComputedJustifySelf(item), 'auto', "justify-self:auto value persists for flex container child");
is(getComputedJustifySelf(abs), 'auto', "justify-self:auto value persists for flex container abs.pos. child");
elem.style.justifyItems = "left";
is(getComputedJustifyItems(elem), 'left', "justify-items:left computes to itself for flex container");
elem.style.justifyItems = "right safe";
is(getComputedJustifySelf(item), 'right safe', "justify-items:'right safe' computes to 'justify-self:right safe' on flex item");
is(getComputedJustifySelf(item), 'auto', "justify-self:auto value persists for flex container child");
// XXX TODO: add left/right tests (bug 1221565)
elem.style.justifyItems = "";
}
@ -370,31 +296,31 @@ function main() {
var item = elem.firstChild;
var abs = elem.children[1];
is(getComputedJustifyItems(elem), 'normal', "default justify-items value for grid container");
is(getComputedJustifySelf(item), 'normal', "default justify-self value for grid item");
is(getComputedJustifySelf(abs), 'normal', "default justify-self value for grid container abs.pos. child");
is(getComputedJustifySelf(item), 'auto', "default justify-self value for grid item");
is(getComputedJustifySelf(abs), 'auto', "default justify-self value for grid container abs.pos. child");
elem.style.justifyItems = "end";
is(getComputedJustifySelf(item), 'end', "auto value copies justify-items of parent");
is(getComputedJustifySelf(abs), 'end', "default justify-self value for grid container abs.pos. child");
is(getComputedJustifySelf(item), 'auto', "justify-self:auto value persists for grid container child");
is(getComputedJustifySelf(abs), 'auto', "justify-self:auto value persists for grid container abs.pos. child");
elem.style.justifyItems = "left";
is(getComputedJustifyItems(elem), 'left', "justify-items:left computes to itself for grid container");
is(getComputedJustifySelf(item), 'left', "justify-self:left computes to left on grid item");
is(getComputedJustifySelf(abs), 'left', "justify-self:auto is affected by parent justify-items value for grid container abs.pos. child");
is(getComputedJustifySelf(item), 'auto', "justify-self:auto value persists for grid container child");
is(getComputedJustifySelf(abs), 'auto', "justify-self:auto value persists for grid container abs.pos. child");
elem.style.justifyItems = "legacy left";
is(getComputedJustifySelf(item), 'left', "justify-self inherits without the legacy keyword on grid item");
is(getComputedJustifySelf(abs), 'left', "justify-self:auto is affected by parent justify-items value for grid container abs.pos. child");
is(getComputedJustifySelf(item), 'auto', "justify-self:auto value persists for grid container child");
is(getComputedJustifySelf(abs), 'auto', "justify-self:auto value persists for grid container abs.pos. child");
elem.style.justifyItems = "right";
is(getComputedJustifySelf(item), 'right', "justify-self:right computes to right on grid item");
is(getComputedJustifySelf(abs), 'right', "justify-self:auto is affected by parent justify-items value for grid container abs.pos. child");
is(getComputedJustifySelf(item), 'auto', "justify-self:auto value persists for grid container child");
is(getComputedJustifySelf(abs), 'auto', "justify-self:auto value persists for grid container abs.pos. child");
elem.style.justifyItems = "right safe";
is(getComputedJustifySelf(item), 'right safe', "justify-items:'right safe' computes to 'justify-self:right safe' on grid item");
is(getComputedJustifySelf(item), 'auto', "justify-self:auto value persists for grid container child");
elem.style.justifyItems = "legacy right";
is(getComputedJustifySelf(item), 'right', "justify-self inherits without the legacy keyword on grid item");
is(getComputedJustifySelf(abs), 'right', "justify-self:auto is affected by parent justify-items value for grid container abs.pos. child");
is(getComputedJustifySelf(item), 'auto', "justify-self:auto value persists for grid container child");
is(getComputedJustifySelf(abs), 'auto', "justify-self:auto value persists for grid container abs.pos. child");
elem.style.justifyItems = "legacy center";
item.style.justifyItems = "inherit";
abs.style.justifyItems = "inherit";
is(getComputedJustifySelf(item), 'center', "justify-self inherits without the legacy keyword on grid item");
is(getComputedJustifySelf(abs), 'center', "justify-self:auto isn't affected by parent justify-items value for grid container abs.pos. child");
is(getComputedJustifySelf(item), 'auto', "justify-self:auto value persists for grid container child");
is(getComputedJustifySelf(abs), 'auto', "justify-self:auto value persists for grid container abs.pos. child");
is(getComputedJustifyItems(elem), 'legacy center', "justify-items computes to itself grid container");
is(getComputedJustifyItems(item), 'legacy center', "justify-items inherits including legacy keyword to grid item");
is(getComputedJustifyItems(abs), 'legacy center', "justify-items inherits including legacy keyword to grid container abs.pos. child");