layout/style/test/test_bug319381.html

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/layout/style/test/test_bug319381.html	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,89 @@
     1.4 +<!DOCTYPE HTML>
     1.5 +<html>
     1.6 +<!--
     1.7 +https://bugzilla.mozilla.org/show_bug.cgi?id=319381
     1.8 +-->
     1.9 +<head>
    1.10 +  <title>Test for Bug 319381</title>
    1.11 +  <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>        
    1.12 +  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
    1.13 +</head>
    1.14 +<body>
    1.15 +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=319381">Mozilla Bug 319381</a>
    1.16 +<p id="display"></p>
    1.17 +<div id="content" style="display: none">
    1.18 +  <div id="t"></div>  
    1.19 +</div>
    1.20 +<pre id="test">
    1.21 +<script class="testbody" type="text/javascript">
    1.22 +
    1.23 +/** Test for Bug 319381 **/
    1.24 +
    1.25 +function c() {
    1.26 +  return document.defaultView.getComputedStyle($('t'), "").
    1.27 +    getPropertyValue("overflow");
    1.28 +}
    1.29 +
    1.30 +function cval() {
    1.31 +  return document.defaultView.getComputedStyle($('t'), "").
    1.32 +    getPropertyCSSValue("overflow");
    1.33 +}
    1.34 +
    1.35 +var vals = ["visible", "hidden", "auto", "scroll"];
    1.36 +var mozVals = ["-moz-scrollbars-vertical", "-moz-scrollbars-horizontal"];
    1.37 +var i, j;
    1.38 +
    1.39 +for (i = 0; i < vals.length; ++i) {
    1.40 +  $('t').style.overflow = vals[i];
    1.41 +  is($('t').style.overflow, vals[i], "Roundtrip");
    1.42 +  is(c(), vals[i], "Simple property set");
    1.43 +  isnot(cval(), null, "Simple property as CSSValue");
    1.44 +}
    1.45 +
    1.46 +$('t').style.overflow = mozVals[0];
    1.47 +is($('t').style.getPropertyValue("overflow-y"), "scroll", "Roundtrip");
    1.48 +is($('t').style.getPropertyValue("overflow-x"), "hidden", "Roundtrip");
    1.49 +is($('t').style.overflow, "", "Shorthand read directly");
    1.50 +is(c(), "", "Shorthand computed");
    1.51 +is(cval(), null, "Shorthand as CSSValue");
    1.52 +
    1.53 +$('t').style.overflow = mozVals[1];
    1.54 +is($('t').style.getPropertyValue("overflow-x"), "scroll", "Roundtrip");
    1.55 +is($('t').style.getPropertyValue("overflow-y"), "hidden", "Roundtrip");
    1.56 +is($('t').style.overflow, "", "Shorthand read directly");
    1.57 +is(c(), "", "Shorthand computed");
    1.58 +is(cval(), null, "Shorthand as CSSValue");
    1.59 +
    1.60 +for (i = 0; i < vals.length; ++i) {
    1.61 +  for (j = 0; j < vals.length; ++j) {
    1.62 +    $('t').setAttribute("style",
    1.63 +                        "overflow-x: " + vals[i] + "; overflow-y: " + vals[j]);
    1.64 +    is($('t').style.getPropertyValue("overflow-x"), vals[i], "Roundtrip");
    1.65 +    is($('t').style.getPropertyValue("overflow-y"), vals[j], "Roundtrip");
    1.66 +
    1.67 +    if (i == j) {
    1.68 +      is($('t').style.overflow, vals[i], "Shorthand serialization");
    1.69 +    } else {
    1.70 +      is($('t').style.overflow, "", "Shorthand serialization");
    1.71 +    }
    1.72 +
    1.73 +    // "visible" overflow-x and overflow-y become "auto" in computed style if
    1.74 +    // the other direction is not also "visible".
    1.75 +    if (i == j || (vals[i] == "visible" && vals[j] == "auto")) {
    1.76 +      is(c(), vals[j], "Shorthand computation");
    1.77 +      isnot(cval(), null, "Shorthand computation as CSSValue");
    1.78 +    } else if (vals[j] == "visible" && vals[i] == "auto") {
    1.79 +      is(c(), vals[i], "Shorthand computation");
    1.80 +      isnot(cval(), null, "Shorthand computation as CSSValue");    
    1.81 +    } else {
    1.82 +      is(c(), "", "Shorthand computation");
    1.83 +      is(cval(), null, "Shorthand computation as CSSValue");
    1.84 +    }
    1.85 +  }
    1.86 +}
    1.87 +
    1.88 +</script>
    1.89 +</pre>
    1.90 +</body>
    1.91 +</html>
    1.92 +

mercurial