Changeset 109874 in webkit


Ignore:
Timestamp:
Mar 6, 2012 1:06:35 AM (12 years ago)
Author:
mikelawther@chromium.org
Message:

CSS3 calc: rewrite margin test to use getComputedStyle
https://bugs.webkit.org/show_bug.cgi?id=80379

Note that parts of this test still fail, due to yet-to-be-landed CSS3 calc()
functionality (see http://wkb.ug/16662)

Reviewed by Kent Tamura.

  • css3/calc/margin-expected.txt:
  • css3/calc/margin.html:
Location:
trunk/LayoutTests
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r109873 r109874  
     12012-03-06  Mike Lawther  <mikelawther@chromium.org>
     2
     3        CSS3 calc: rewrite margin test to use getComputedStyle
     4        https://bugs.webkit.org/show_bug.cgi?id=80379
     5
     6        Note that parts of this test still fail, due to yet-to-be-landed CSS3 calc()
     7        functionality (see http://wkb.ug/16662)
     8
     9        Reviewed by Kent Tamura.
     10
     11        * css3/calc/margin-expected.txt:
     12        * css3/calc/margin.html:
     13
    1142012-03-06  Philippe Normand  <pnormand@igalia.com>
    215
  • trunk/LayoutTests/css3/calc/margin-expected.txt

    r107688 r109874  
    1 PASS document.getElementById("simple-all").parentNode.offsetWidth is 250
    2 PASS document.getElementById("simple-all").parentNode.offsetHeight is 170
    3 PASS document.getElementById("simple-left").parentNode.offsetWidth is 225
    4 PASS document.getElementById("simple-left").parentNode.offsetHeight is 120
    5 PASS document.getElementById("simple-right").parentNode.offsetWidth is 225
    6 PASS document.getElementById("simple-right").parentNode.offsetHeight is 120
    7 PASS document.getElementById("simple-top").parentNode.offsetWidth is 200
    8 PASS document.getElementById("simple-top").parentNode.offsetHeight is 145
    9 PASS document.getElementById("simple-bottom").parentNode.offsetWidth is 200
    10 PASS document.getElementById("simple-bottom").parentNode.offsetHeight is 145
    11 FAIL document.getElementById("percent-all").parentNode.offsetWidth should be 250. Was 200.
    12 FAIL document.getElementById("percent-all").parentNode.offsetHeight should be 170. Was 120.
    13 FAIL document.getElementById("percent-left").parentNode.offsetWidth should be 225. Was 200.
    14 PASS document.getElementById("percent-left").parentNode.offsetHeight is 120
    15 FAIL document.getElementById("percent-right").parentNode.offsetWidth should be 225. Was 200.
    16 PASS document.getElementById("percent-right").parentNode.offsetHeight is 120
    17 PASS document.getElementById("percent-top").parentNode.offsetWidth is 200
    18 FAIL document.getElementById("percent-top").parentNode.offsetHeight should be 145. Was 120.
    19 PASS document.getElementById("percent-bottom").parentNode.offsetWidth is 200
    20 FAIL document.getElementById("percent-bottom").parentNode.offsetHeight should be 145. Was 120.
     1PASS computedMarginLeft("simple-all") is "25px"
     2PASS computedMarginTop("simple-all") is "25px"
     3PASS computedMarginRight("simple-all") is "25px"
     4PASS computedMarginBottom("simple-all") is "25px"
     5PASS computedMarginLeft("simple-left") is "25px"
     6PASS computedMarginTop("simple-left") is "0px"
     7PASS computedMarginRight("simple-left") is "0px"
     8PASS computedMarginBottom("simple-left") is "0px"
     9PASS computedMarginLeft("simple-right") is "0px"
     10PASS computedMarginTop("simple-right") is "0px"
     11PASS computedMarginRight("simple-right") is "25px"
     12PASS computedMarginBottom("simple-right") is "0px"
     13PASS computedMarginLeft("simple-top") is "0px"
     14PASS computedMarginTop("simple-top") is "25px"
     15PASS computedMarginRight("simple-top") is "0px"
     16PASS computedMarginBottom("simple-top") is "0px"
     17PASS computedMarginLeft("simple-bottom") is "0px"
     18PASS computedMarginTop("simple-bottom") is "0px"
     19PASS computedMarginRight("simple-bottom") is "0px"
     20PASS computedMarginBottom("simple-bottom") is "25px"
     21FAIL computedMarginLeft("percent-all") should be 25px. Was 0px.
     22FAIL computedMarginTop("percent-all") should be 25px. Was 0px.
     23FAIL computedMarginRight("percent-all") should be 25px. Was 0px.
     24FAIL computedMarginBottom("percent-all") should be 25px. Was 0px.
     25FAIL computedMarginLeft("percent-left") should be 25px. Was 0px.
     26PASS computedMarginTop("percent-left") is "0px"
     27PASS computedMarginRight("percent-left") is "0px"
     28PASS computedMarginBottom("percent-left") is "0px"
     29PASS computedMarginLeft("percent-right") is "0px"
     30PASS computedMarginTop("percent-right") is "0px"
     31FAIL computedMarginRight("percent-right") should be 25px. Was 0px.
     32PASS computedMarginBottom("percent-right") is "0px"
     33PASS computedMarginLeft("percent-top") is "0px"
     34FAIL computedMarginTop("percent-top") should be 25px. Was 0px.
     35PASS computedMarginRight("percent-top") is "0px"
     36PASS computedMarginBottom("percent-top") is "0px"
     37PASS computedMarginLeft("percent-bottom") is "0px"
     38PASS computedMarginTop("percent-bottom") is "0px"
     39PASS computedMarginRight("percent-bottom") is "0px"
     40FAIL computedMarginBottom("percent-bottom") should be 25px. Was 0px.
    2141PASS successfullyParsed is true
    2242
  • trunk/LayoutTests/css3/calc/margin.html

    r104783 r109874  
    1717
    1818<div id="test-container">
    19     <div><p id="simple-all">This element should have an overall margin of 25 pixels.</p></div><br/>
    20     <div><p id="simple-left">This element should have a left margin of 25 pixels.</p></div><br/>
    21     <div><p id="simple-right">This element should have a right margin of 25 pixels.</p></div><br/>
    22     <div><p id="simple-top">This element should have a top margin of 25 pixels.</p></div><br/>
    23     <div><p id="simple-bottom">This element should have a bottom margin of 25 pixels.</p></div><br/>
     19    <p id="simple-all">This element should have an overall margin of 25 pixels.</p><br/>
     20    <p id="simple-left">This element should have a left margin of 25 pixels.</p><br/>
     21    <p id="simple-right">This element should have a right margin of 25 pixels.</p><br/>
     22    <p id="simple-top">This element should have a top margin of 25 pixels.</p><br/>
     23    <p id="simple-bottom">This element should have a bottom margin of 25 pixels.</p><br/>
    2424    <div id="wrapper" style="width: 300px; background-color: cornsilk; display: block;">
    25         <div><p id="percent-all">This element should have an overall margin of 25 pixels (10% of parent width of 300px minus 5px).</p></div><br/>
    26         <div><p id="percent-left">This element should have a left margin of 25 pixels (10% of parent width of 300px minus 5px).</p></div><br/>
    27         <div><p id="percent-right">This element should have a right margin of 25 pixels (10% of parent width of 300px minus 5px).</p></div><br/>
    28         <div><p id="percent-top">This element should have a top margin of 25 pixels (10% of parent width of 300px minus 5px).</p></div><br/>
    29         <div><p id="percent-bottom">This element should have a bottom margin of 25 pixels (10% of parent width of 300px minus 5px).</p></div><br/>
     25        <p id="percent-all">This element should have an overall margin of 25 pixels (10% of parent width of 300px minus 5px).</p><br/>
     26        <p id="percent-left">This element should have a left margin of 25 pixels (10% of parent width of 300px minus 5px).</p><br/>
     27        <p id="percent-right">This element should have a right margin of 25 pixels (10% of parent width of 300px minus 5px).</p><br/>
     28        <p id="percent-top">This element should have a top margin of 25 pixels (10% of parent width of 300px minus 5px).</p><br/>
     29        <p id="percent-bottom">This element should have a bottom margin of 25 pixels (10% of parent width of 300px minus 5px).</p><br/>
    3030    </div>
    3131</div>
    3232<script>
     33
     34    function computedMarginLeft(id)
     35    {
     36        return getComputedStyle(document.getElementById(id), null).marginLeft;
     37    }
     38    function computedMarginRight(id)
     39    {
     40        return getComputedStyle(document.getElementById(id), null).marginRight;
     41    }
     42    function computedMarginTop(id)
     43    {
     44        return getComputedStyle(document.getElementById(id), null).marginTop;
     45    }
     46    function computedMarginBottom(id)
     47    {
     48        return getComputedStyle(document.getElementById(id), null).marginBottom;
     49    }
     50
    3351    var innerWidth = 200;
    3452    var innerHeight = 120;
    35     var margin = 25;
     53    var margin = "25px";
     54    var noMargin = "0px";
    3655
    3756    var tests = document.getElementsByTagName("p");
    3857    for (var i = 0; i < tests.length; ++i) {
    39         var outerElement = tests[i].parentNode;
    40         var innerElement = tests[i];
    41         var width = outerElement.offsetWidth;
    42         var height = outerElement.offsetHeight;
    43 
    44         var expectedWidth = innerWidth;
    45         var expectedHeight = innerHeight;
    46    
     58        var innerElement = tests[i]
     59        var expectedLeft = noMargin;
     60        var expectedTop = noMargin;
     61        var expectedRight = noMargin;
     62        var expectedBottom = noMargin;
    4763        switch (innerElement.id.split("-")[1]) {
    4864        case "all":
    49             expectedWidth += 2 * margin;
    50             expectedHeight += 2 * margin;
     65            expectedLeft = margin;
     66            expectedTop = margin;
     67            expectedRight = margin;
     68            expectedBottom = margin;
    5169            break;
    5270        case "top":
     71            expectedTop = margin;
     72            break;
    5373        case "bottom":
    54             expectedHeight += margin;
     74            expectedBottom = margin;
    5575            break;
    5676        case "left":
     77            expectedLeft = margin;
     78            break;
    5779        case "right":
    58             expectedWidth += margin;
     80            expectedRight = margin;
    5981            break;
    6082        }
    6183
    62         shouldEvaluateTo('document.getElementById("' + innerElement.id + '").parentNode.offsetWidth', expectedWidth);
    63         shouldEvaluateTo('document.getElementById("' + innerElement.id + '").parentNode.offsetHeight', expectedHeight);
    64    
    65         var error = [];
    66         if (width != expectedWidth)
    67             error.push("expected width " + expectedWidth + ", was " + width);
    68         if (height != expectedHeight)
    69             error.push("expected height " + expectedHeight + ", was " + height);
    70 
    71         if (error == "") {
    72             innerElement.style.backgroundColor = "green";
    73             innerElement.innerHTML += " => PASS";
    74         } else {
    75             innerElement.style.backgroundColor = "red";
    76             innerElement.innerHTML += " => FAIL: " + error.join(", ");
    77         }
     84        shouldBeEqualToString('computedMarginLeft("' + innerElement.id + '")', expectedLeft);
     85        shouldBeEqualToString('computedMarginTop("' + innerElement.id + '")', expectedTop);
     86        shouldBeEqualToString('computedMarginRight("' + innerElement.id + '")', expectedRight);
     87        shouldBeEqualToString('computedMarginBottom("' + innerElement.id + '")', expectedBottom);
    7888    }
    7989   
Note: See TracChangeset for help on using the changeset viewer.