layout/style/test/test_bug652486.html

Wed, 31 Dec 2014 13:27:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 13:27:57 +0100
branch
TOR_BUG_3246
changeset 6
8bccb770b82d
permissions
-rw-r--r--

Ignore runtime configuration files generated during quality assurance.

     1 <!DOCTYPE HTML>
     2 <html>
     3 <!--
     4 https://bugzilla.mozilla.org/show_bug.cgi?id=652486
     5 -->
     6 <head>
     7   <title>Test for Bug 652486</title>
     8   <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>        
     9   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
    10 </head>
    11 <body>
    12 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=652486">Mozilla Bug 652486</a>
    14 <p id="display"></p>
    15 <div id="content" style="display: none">
    16   <div id="t"></div>  
    17 </div>
    18 <pre id="test">
    19 <script class="testbody" type="text/javascript">
    21 /** Test for Bug 652486 **/
    23 function c() {
    24   return document.defaultView.getComputedStyle($('t'), "").
    25            getPropertyValue("text-decoration");
    26 }
    28 function cval() {
    29   var val = document.defaultView.getComputedStyle($('t'), "").
    30               getPropertyCSSValue("text-decoration");
    31   return val ? val.getStringValue() : val;
    32 }
    34 var tests = [
    35   // When only text-decoration was specified, text-decoration should look like
    36   // a longhand property.
    37   { decoration: "none",
    38     line: null, color: null, style: null,
    39     expectedValue: "none", expectedCSSValue: "none" },
    40   { decoration: "underline",
    41     line: null, color: null, style: null,
    42     expectedValue: "underline", expectedCSSValue: "underline" },
    43   { decoration: "overline",
    44     line: null, color: null, style: null,
    45     expectedValue: "overline", expectedCSSValue: "overline" },
    46   { decoration: "line-through",
    47     line: null, color: null, style: null,
    48     expectedValue: "line-through", expectedCSSValue: "line-through" },
    49   { decoration: "blink",
    50     line: null, color: null, style: null,
    51     expectedValue: "blink", expectedCSSValue: "blink" },
    52   { decoration: "underline overline",
    53     line: null, color: null, style: null,
    54     expectedValue: "underline overline",
    55     expectedCSSValue: "underline overline" },
    56   { decoration: "underline line-through",
    57     line: null, color: null, style: null,
    58     expectedValue: "underline line-through",
    59     expectedCSSValue: "underline line-through" },
    60   { decoration: "blink underline",
    61     line: null, color: null, style: null,
    62     expectedValue: "underline blink",
    63     expectedCSSValue: "underline blink" },
    64   { decoration: "underline blink",
    65     line: null, color: null, style: null,
    66     expectedValue: "underline blink",
    67     expectedCSSValue: "underline blink" },
    69   // When only text-decoration-line or text-blink was specified,
    70   // text-decoration should look like a longhand property.
    71   { decoration: null,
    72     line: "blink", color: null, style: null,
    73     expectedValue: "blink", expectedCSSValue: "blink" },
    74   { decoration: null,
    75     line: "underline", color: null, style: null,
    76     expectedValue: "underline", expectedCSSValue: "underline" },
    77   { decoration: null,
    78     line: "overline", color: null, style: null,
    79     expectedValue: "overline", expectedCSSValue: "overline" },
    80   { decoration: null,
    81     line: "line-through", color: null, style: null,
    82     expectedValue: "line-through", expectedCSSValue: "line-through" },
    83   { decoration: null,
    84     line: "blink underline", color: null, style: null,
    85     expectedValue: "underline blink", expectedCSSValue: "underline blink" },
    87   // When text-decoration-color isn't its initial value,
    88   // text-decoration should be a shorthand property.
    89   { decoration: "blink",
    90     line: null, color: "rgb(0, 0, 0)", style: null,
    91     expectedValue: "", expectedCSSValue: null },
    92   { decoration: "underline",
    93     line: null, color: "black", style: null,
    94     expectedValue: "", expectedCSSValue: null },
    95   { decoration: "overline",
    96     line: null, color: "#ff0000", style: null,
    97     expectedValue: "", expectedCSSValue: null },
    98   { decoration: "line-through",
    99     line: null, color: "initial", style: null,
   100     expectedValue: "line-through", expectedCSSValue: "line-through" },
   101   { decoration: "blink underline",
   102     line: null, color: "currentColor", style: null,
   103     expectedValue: "underline blink", expectedCSSValue: "underline blink" },
   104   { decoration: "underline line-through",
   105     line: null, color: "-moz-use-text-color", style: null,
   106     expectedValue: "underline line-through",
   107     expectedCSSValue: "underline line-through" },
   109   // When text-decoration-style isn't its initial value,
   110   // text-decoration should be a shorthand property.
   111   { decoration: "blink",
   112     line: null, color: null, style: "-moz-none",
   113     expectedValue: "", expectedCSSValue: null },
   114   { decoration: "underline",
   115     line: null, color: null, style: "dotted",
   116     expectedValue: "", expectedCSSValue: null },
   117   { decoration: "overline",
   118     line: null, color: null, style: "dashed",
   119     expectedValue: "", expectedCSSValue: null },
   120   { decoration: "line-through",
   121     line: null, color: null, style: "double",
   122     expectedValue: "", expectedCSSValue: null },
   123   { decoration: "blink underline",
   124     line: null, color: null, style: "wavy",
   125     expectedValue: "", expectedCSSValue: null },
   126   { decoration: "underline blink overline line-through",
   127     line: null, color: null, style: "solid",
   128     expectedValue: "underline overline line-through blink",
   129     expectedCSSValue: "underline overline line-through blink" },
   130   { decoration: "line-through overline underline",
   131     line: null, color: null, style: "initial",
   132     expectedValue: "underline overline line-through",
   133     expectedCSSValue: "underline overline line-through" }
   134 ];
   136 function makeDeclaration(aTest)
   137 {
   138   var str = "";
   139   if (aTest.decoration) {
   140     str += "text-decoration: " + aTest.decoration + "; ";
   141   }
   142   if (aTest.color) {
   143     str += "-moz-text-decoration-color: " + aTest.color + "; ";
   144   }
   145   if (aTest.line) {
   146     str += "-moz-text-decoration-line: " + aTest.line + "; ";
   147   }
   148   if (aTest.style) {
   149     str += "-moz-text-decoration-style: " + aTest.style + "; ";
   150   }
   151   return str;
   152 }
   154 function clearStyleObject()
   155 {
   156   $('t').style.textDecoration = null;
   157 }
   159 for (var i = 0; i < tests.length; ++i) {
   160   var test = tests[i];
   161   if (test.decoration) {
   162     $('t').style.textDecoration = test.decoration;
   163   }
   164   if (test.color) {
   165     $('t').style.MozTextDecorationColor = test.color;
   166   }
   167   if (test.line) {
   168     $('t').style.MozTextDecorationLine = test.line;
   169   }
   170   if (test.style) {
   171     $('t').style.MozTextDecorationStyle = test.style;
   172   }
   174   var dec = makeDeclaration(test);
   175   is(c(), test.expectedValue, "Test1 (computed value): " + dec);
   176   is(cval(), test.expectedCSSValue, "Test1 (CSS value): " + dec);
   178   clearStyleObject();
   180   $('t').setAttribute("style", dec);
   182   is(c(), test.expectedValue, "Test2 (computed value): " + dec);
   183   is(cval(), test.expectedCSSValue, "Test2 (CSS value): " + dec);
   185   $('t').removeAttribute("style");
   186 }
   188 </script>
   189 </pre>
   190 </body>
   191 </html>

mercurial