test_ch_ex_no_infloops.html 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <!DOCTYPE HTML>
  2. <html>
  3. <!--
  4. https://bugzilla.mozilla.org/show_bug.cgi?id=678671
  5. -->
  6. <head>
  7. <title>Test for Bug 678671</title>
  8. <script type="application/javascript" src="/MochiKit/packed.js"></script>
  9. <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
  10. <script type="text/javascript" src="property_database.js"></script>
  11. <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
  12. </head>
  13. <body>
  14. <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=678671">Mozilla Bug 678671</a>
  15. <p id="display"></p>
  16. <div id="content"></div>
  17. <script type="application/javascript">
  18. /** Test for Bug 678671 **/
  19. /**
  20. * Test 'ex' and 'ch' units in every place we possible can to make
  21. * sure they don't cause an infinite loop.
  22. */
  23. var content = document.getElementById("content");
  24. var cs = getComputedStyle(content, "");
  25. for (var prop in gCSSProperties) {
  26. var info = gCSSProperties[prop];
  27. function test_val(v) {
  28. content.style.setProperty(prop, v, "");
  29. isnot(get_computed_value(cs, prop), "",
  30. "Setting '" + prop + "' to '" + v + "' should not cause infinite loop");
  31. }
  32. test_val('3ex');
  33. test_val('2ch');
  34. function test_replaced_values(value_list) {
  35. // For each item in value_list, if it looks like it has a dimension
  36. // in it, replace those dimensions with 3ex and 2ch and test it.
  37. for (var i = 0; i < value_list.length; ++i) {
  38. var value = value_list[i];
  39. function try_replace(withval) {
  40. var rep = value.replace(/[0-9.]+[a-zA-Z]+/g, withval)
  41. if (rep != value) {
  42. test_val(rep);
  43. }
  44. }
  45. try_replace('3ex');
  46. try_replace('2ch');
  47. }
  48. }
  49. test_replaced_values(info.initial_values);
  50. test_replaced_values(info.other_values);
  51. content.style.removeProperty(prop);
  52. }
  53. </script>
  54. </pre>
  55. </body>
  56. </html>