layout/style/test/test_ch_ex_no_infloops.html

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/layout/style/test/test_ch_ex_no_infloops.html	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,64 @@
     1.4 +<!DOCTYPE HTML>
     1.5 +<html>
     1.6 +<!--
     1.7 +https://bugzilla.mozilla.org/show_bug.cgi?id=678671
     1.8 +-->
     1.9 +<head>
    1.10 +  <title>Test for Bug 678671</title>
    1.11 +  <script type="application/javascript" src="/MochiKit/packed.js"></script>
    1.12 +  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
    1.13 +  <script type="text/javascript" src="property_database.js"></script>
    1.14 +  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
    1.15 +</head>
    1.16 +<body>
    1.17 +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=678671">Mozilla Bug 678671</a>
    1.18 +<p id="display"></p>
    1.19 +<div id="content"></div>
    1.20 +<script type="application/javascript">
    1.21 +
    1.22 +/** Test for Bug 678671 **/
    1.23 +
    1.24 +/**
    1.25 + * Test 'ex' and 'ch' units in every place we possible can to make
    1.26 + * sure they don't cause an infinite loop.
    1.27 + */
    1.28 +
    1.29 +var content = document.getElementById("content");
    1.30 +var cs = getComputedStyle(content, "");
    1.31 +
    1.32 +for (var prop in gCSSProperties) {
    1.33 +  var info = gCSSProperties[prop];
    1.34 +  if (info.backend_only) {
    1.35 +    continue;
    1.36 +  }
    1.37 +  function test_val(v) {
    1.38 +    content.style.setProperty(prop, v, "");
    1.39 +    isnot(get_computed_value(cs, prop), "",
    1.40 +      "Setting '" + prop + "' to '" + v + "' should not cause infinite loop");
    1.41 +  }
    1.42 +  test_val('3ex');
    1.43 +  test_val('2ch');
    1.44 +  function test_replaced_values(value_list) {
    1.45 +    // For each item in value_list, if it looks like it has a dimension
    1.46 +    // in it, replace those dimensions with 3ex and 2ch and test it.
    1.47 +    for (var i = 0; i < value_list.length; ++i) {
    1.48 +      var value = value_list[i];
    1.49 +      function try_replace(withval) {
    1.50 +        var rep = value.replace(/[0-9.]+[a-zA-Z]+/g, withval)
    1.51 +        if (rep != value) {
    1.52 +          test_val(rep);
    1.53 +        }
    1.54 +      }
    1.55 +      try_replace('3ex');
    1.56 +      try_replace('2ch');
    1.57 +    }
    1.58 +  }
    1.59 +  test_replaced_values(info.initial_values);
    1.60 +  test_replaced_values(info.other_values);
    1.61 +  content.style.removeProperty(prop);
    1.62 +}
    1.63 +
    1.64 +</script>
    1.65 +</pre>
    1.66 +</body>
    1.67 +</html>

mercurial