layout/style/test/test_bug413958.html
author Sandor Molnar <smolnar@mozilla.com>
Fri, 24 Sep 2021 00:43:42 +0300
changeset 593102 4eda9eb8926bdd50f4b80128ce3475eb7c6d9a4d
parent 466334 de3403c1d70449a352f0774fe68d47f83a9113b0
permissions -rw-r--r--
Merge autoland to mozilla-central. a=merge

<!doctype html>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=413958
-->
<head>
  <title>Test for Bug 413958</title>
  <meta charset="UTF-8">
  <script src="/tests/SimpleTest/SimpleTest.js"></script>
  <link rel="stylesheet" href="/tests/SimpleTest/test.css">
</head>
<body>
<style>span { color: red }</style><!-- backstop -->
<p><a target="_blank"
      href="https://bugzilla.mozilla.org/show_bug.cgi?id=413958"
      >Mozilla Bug 413958</a>. All text below should be black on white.</p>
<p>Sheet: <span id="s1">1</span>
          <span id="s2">2</span>
          <span id="s3">3</span>.
   Style attr: <span id="setStyle">4</span>.
   Properties: <span id="setStyleProp" style="">5</span>.</p>
<script>
SpecialPowers.wrap(window).docShell.cssErrorReportingEnabled = true;

var tests = [
  function() {
    var s = document.createTextNode(
"#s1{nosuchprop:auto; color:black}\n"+
"#s2{nosuchprop:auto; color:black}invalid?sel{}#s3{color:black}"),
        e = document.createElement("style");
    e.appendChild(s);
    document.body.appendChild(e);
  },
  function() {
    document.getElementById("setStyle")
            .setAttribute("style", "width:200;color:black");
  },
  function() {
    var s = document.getElementById("setStyleProp").style;
    s.width = "200";
    s.color = "black";
  },
];
var results = [
  [ { errorMessage: /Unknown property \u2018nosuchprop\u2019/,
      lineNumber: 1, columnNumber: 16, sourceLine: "", cssSelectors: "#s1" },
    { errorMessage: /Unknown property \u2018nosuchprop\u2019/,
      lineNumber: 2, columnNumber: 16, sourceLine: "", cssSelectors: "#s2" },
    { errorMessage: /Ruleset ignored due to bad selector/,
      lineNumber: 2, columnNumber: 41, sourceLine: "", cssSelectors: "" } ],
  [ { errorMessage: /parsing value for \u2018width\u2019/,
      lineNumber: 0, columnNumber: 7, sourceLine: "", cssSelectors: "" } ],
  [ { errorMessage: /parsing value for \u2018width\u2019/,
      lineNumber: 0, columnNumber: 1, sourceLine: "", cssSelectors: "" } ],
];
var curTest = -1;

function doTest() {
  if (++curTest == tests.length) {
    var ss = document.getElementsByTagName("span");
    for (var i = 0; i < ss.length; i++) {
      is(window.getComputedStyle(ss[i]).color, "rgb(0, 0, 0)",
         "recovery | " + ss[i].id);
    }
    SimpleTest.finish();
  } else {
    SimpleTest.expectConsoleMessages(tests[curTest], results[curTest], doTest);
  }
}

SimpleTest.waitForExplicitFinish();
doTest();
</script>
</body>
</html>