test28.html 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  5. <title>Test 028</title>
  6. <script>
  7. let elCount = 0;
  8. let testresult = true;
  9. const hide_mode = window.sessionStorage.getItem("H9Y_hideMode") || "all";
  10. var Hyphenopoly = {
  11. require: {
  12. "en-us": "FORCEHYPHENOPOLY"
  13. },
  14. setup: {
  15. hide: hide_mode,
  16. selectors: {
  17. ".hyphenate1": {
  18. hyphen: "•"
  19. },
  20. ".hyphenate2": {
  21. hyphen: "|"
  22. }
  23. }
  24. },
  25. handleEvent: {
  26. beforeElementHyphenation: function (e) {
  27. assert(e.el);
  28. }
  29. }
  30. };
  31. </script>
  32. <script src="../Hyphenopoly_Loader.js"></script>
  33. <script>
  34. function assert(el) {
  35. elCount += 1;
  36. switch (hide_mode) {
  37. case "all":
  38. testresult = testresult && (document.getElementById("H9Y_Styles").innerHTML === "html {visibility: hidden !important}\n");
  39. break;
  40. case "element":
  41. testresult = testresult && (document.getElementById("H9Y_Styles").innerHTML === ".hyphenate1 {visibility: hidden !important}\n.hyphenate2 {visibility: hidden !important}\n");
  42. break;
  43. case "text":
  44. testresult = testresult && (document.getElementById("H9Y_Styles").innerHTML === ".hyphenate1 {color: transparent !important}\n.hyphenate2 {color: transparent !important}\n");
  45. break;
  46. default:
  47. testresult = testresult && (document.getElementById("H9Y_Styles") === null);
  48. break;
  49. }
  50. if (elCount === 2) {
  51. if (testresult) {
  52. document.getElementById("result").innerHTML = "<p style=\"background-color: #d6ffd6\">passed</p>";
  53. } else {
  54. document.getElementById("result").innerHTML = "<p style=\"background-color: #ffd6d6\">failed</p>";
  55. }
  56. if (parent != window) {
  57. parent.postMessage(JSON.stringify({
  58. desc: document.getElementById("desc").innerHTML,
  59. index: 28,
  60. result: (testresult ? "passed" : "failed")
  61. }), window.location.href);
  62. }
  63. }
  64. }
  65. if (!Hyphenopoly) {
  66. document.addEventListener("DOMContentLoaded", function() {
  67. assert();
  68. });
  69. }
  70. function changeHandler() {
  71. window.sessionStorage.setItem("H9Y_hideMode", document.getElementById("selHideMode").value);
  72. }
  73. </script>
  74. <style type="text/css">
  75. body {
  76. width:50%;
  77. margin-left:25%;
  78. margin-right:25%;
  79. }
  80. .test {
  81. background-color: #D8E2F9;
  82. text-align: justify;
  83. }
  84. .ref {
  85. background-color: #FEEFC0;
  86. }
  87. </style>
  88. </head>
  89. <body>
  90. <div id="navigate"><a href="index.html">&Larr;&nbsp;Index</a>&nbsp;|&nbsp;<a href="test27.html">&larr;&nbsp;Prev</a>&nbsp;|&nbsp;<a href="test29.html">Next&nbsp;&rarr;</a></div>
  91. <h1>Test 028</h1>
  92. <p id="desc">See what hiding does (change mode and reload to see flicker)</p>
  93. <select id="selHideMode" onchange="changeHandler();">
  94. <option id="all" value="all">all</option>
  95. <option id="element" value="element">element</option>
  96. <option id="text" value="text">text</option>
  97. <option id="none" value="none">none</option>
  98. </select>
  99. <div id="result"><p style="background-color: #d6ffd6">…</p></div>
  100. <hr>
  101. <p id="test1" class="test hyphenate1" lang="en-us">Hyphenation</p>
  102. <p id="test2" class="test hyphenate2" lang="en-us">Hyphenation</p>
  103. <hr>
  104. <script>
  105. document.getElementById(hide_mode).selected = "selected";
  106. </script>
  107. </body>
  108. </html>