test39.html 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  5. <title>Test 039</title>
  6. <script>
  7. document.addEventListener("DOMContentLoaded", function(event) {
  8. document.getElementById("myTextField").focus();
  9. });
  10. var Hyphenopoly = {
  11. require: {
  12. "en-us": "FORCEHYPHENOPOLY"
  13. },
  14. setup: {
  15. hide: "element"
  16. },
  17. handleEvent: {
  18. hyphenopolyEnd: function (e) {
  19. assert();
  20. }
  21. }
  22. };
  23. function assert() {
  24. var tests = 1;
  25. var i = 1;
  26. var test = "";
  27. var ref = "";
  28. var result = true;
  29. while (i <= tests) {
  30. test = document.getElementById("myTextField");
  31. ref = document.activeElement;
  32. if (test === ref) {
  33. document.getElementById("result").innerHTML += "<p style=\"background-color: #d6ffd6\">" + i + " passed</p>";
  34. result = result && true;
  35. } else {
  36. document.getElementById("result").innerHTML += "<p style=\"background-color: #ffd6d6\">" + i + " failed</p>";
  37. result = false;
  38. }
  39. i += 1;
  40. }
  41. if (parent != window) {
  42. parent.postMessage(JSON.stringify({
  43. desc: document.getElementById("desc").innerHTML,
  44. index: 39,
  45. result: (result ? "passed" : "failed")
  46. }), window.location.href);
  47. }
  48. }
  49. </script>
  50. <script src="../Hyphenopoly_Loader.js"></script>
  51. <style type="text/css">
  52. body {
  53. width:50%;
  54. margin-left:25%;
  55. margin-right:25%;
  56. }
  57. .test {
  58. background-color: #D8E2F9;
  59. }
  60. .ref {
  61. background-color: #FEEFC0;
  62. }
  63. .hyphenate {
  64. hyphens: auto;
  65. -ms-hyphens: auto;
  66. -moz-hyphens: auto;
  67. -webkit-hyphens: auto;
  68. }
  69. </style>
  70. </head>
  71. <body>
  72. <div id="navigate"><a href="index.html">&Larr;&nbsp;Index</a>&nbsp;|&nbsp;<a href="test38.html">&larr;&nbsp;Prev</a>&nbsp;|&nbsp;<a href="test40.html">Next&nbsp;&rarr;</a></div>
  73. <h1>Test 039</h1>
  74. <p id="desc">Focus an element.</p>
  75. <div id="result"></div>
  76. <hr>
  77. <h2>1: en-us</h2>
  78. <input type="text" id="myTextField" value="Text field.">
  79. <div id="test1" class="test hyphenate" lang="en-us">A hyphenation algorithm is a set of rules that decides at which points a word can be broken over two lines with a hyphen.</div>
  80. <div id="ref1" class="ref" lang="en-us">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.</div>
  81. <hr>
  82. <div><span class="test">Test</span> <span class="ref">Ref</span></div>
  83. </body>
  84. </html>