test24.html 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  5. <title>Test 024</title>
  6. <script>
  7. var Hyphenopoly = {
  8. require: {
  9. "en-au": "FORCEHYPHENOPOLY",
  10. "en": "FORCEHYPHENOPOLY"
  11. },
  12. fallbacks: {
  13. "en-au": "en-gb",
  14. "en": "en-us"
  15. },
  16. setup: {
  17. safeCopy: false
  18. },
  19. handleEvent: {
  20. hyphenopolyEnd: function (e) {
  21. assert();
  22. }
  23. }
  24. };
  25. function assert() {
  26. var tests = 2;
  27. var i = 1;
  28. var test = "";
  29. var ref = "";
  30. var result = true;
  31. var lang = "";
  32. while (i <= tests) {
  33. lang = document.getElementById("test" + i).lang;
  34. if (Hyphenopoly.cf.langs[lang] === "CSS") {
  35. document.getElementById("result").innerHTML += "<p style=\"background-color: #d6ffd6\">" + i + " passed (CSS)</p>";
  36. result = result && true;
  37. } else {
  38. test = document.getElementById("test" + i).innerHTML;
  39. ref = document.getElementById("ref" + i).innerHTML;
  40. if (test === ref) {
  41. document.getElementById("result").innerHTML += "<p style=\"background-color: #d6ffd6\">" + i + " passed</p>";
  42. result = result && true;
  43. } else {
  44. document.getElementById("result").innerHTML += "<p style=\"background-color: #ffd6d6\">" + i + " failed</p>";
  45. result = false;
  46. }
  47. }
  48. i += 1;
  49. }
  50. if (parent != window) {
  51. parent.postMessage(JSON.stringify({
  52. desc: document.getElementById("desc").innerHTML,
  53. index: 24,
  54. result: (result ? "passed" : "failed")
  55. }), window.location.href);
  56. }
  57. }
  58. </script>
  59. <script src="../Hyphenopoly_Loader.js"></script>
  60. <style type="text/css">
  61. body {
  62. width:50%;
  63. margin-left:25%;
  64. margin-right:25%;
  65. }
  66. .test {
  67. background-color: #D8E2F9;
  68. }
  69. .ref {
  70. background-color: #FEEFC0;
  71. }
  72. .hyphenate {
  73. hyphens: auto;
  74. -ms-hyphens: auto;
  75. -moz-hyphens: auto;
  76. -webkit-hyphens: auto;
  77. }
  78. </style>
  79. </head>
  80. <body>
  81. <div id="navigate"><a href="index.html">&Larr;&nbsp;Index</a>&nbsp;|&nbsp;<a href="test23.html">&larr;&nbsp;Prev</a>&nbsp;|&nbsp;<a href="test25.html">Next&nbsp;&rarr;</a></div>
  82. <h1>Test 024</h1>
  83. <p id="desc">Hyphenate a text marked with lang 'en-au'. Hyphenopoly should use 'en-gb'-patterns.</p>
  84. <div id="result"></div>
  85. <hr>
  86. <h2>1: en-au</h2>
  87. <p id="test1" class="test hyphenate" lang="en-au">A hyphenation algorithm is a set of rules that decides at which points a word can be broken over two lines with a hyphen.</p>
  88. <p id="ref1" class="ref" lang="en-au">A hy&shy;phen&shy;a&shy;tion al&shy;gorithm is a set of rules that de&shy;cides at which points a word can be broken over two lines with a hy&shy;phen.</p>
  89. <h2>2: en</h2>
  90. <p id="test2" class="test hyphenate" lang="en">A hyphenation algorithm is a set of rules that decides at which points a word can be broken over two lines with a hyphen.</p>
  91. <p id="ref2" class="ref" lang="en">A hy&shy;phen&shy;ation al&shy;go&shy;rithm is a set of rules that de&shy;cides at which points a word can be bro&shy;ken over two lines with a hy&shy;phen.</p>
  92. <hr>
  93. <div><span class="test">Test</span> <span class="ref">Ref</span></div>
  94. </body>
  95. </html>