Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
michael@0 | 1 | <!DOCTYPE HTML> |
michael@0 | 2 | <html> |
michael@0 | 3 | <!-- |
michael@0 | 4 | https://bugzilla.mozilla.org/show_bug.cgi?id=592592 |
michael@0 | 5 | --> |
michael@0 | 6 | <head> |
michael@0 | 7 | <title>Test for Bug 592592</title> |
michael@0 | 8 | <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> |
michael@0 | 9 | <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> |
michael@0 | 10 | <script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script> |
michael@0 | 11 | </head> |
michael@0 | 12 | <body> |
michael@0 | 13 | <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=592592">Mozilla Bug 592592</a> |
michael@0 | 14 | <p id="display"></p> |
michael@0 | 15 | <div id="content"> |
michael@0 | 16 | <div id="editor" contenteditable="true" style="white-space:pre-wrap">a b</div> |
michael@0 | 17 | <div id="editor2" contenteditable="true" style="white-space:pre-wrap">a b</div> |
michael@0 | 18 | </div> |
michael@0 | 19 | <pre id="test"> |
michael@0 | 20 | <script type="application/javascript"> |
michael@0 | 21 | |
michael@0 | 22 | /** Test for Bug 592592 **/ |
michael@0 | 23 | |
michael@0 | 24 | SimpleTest.waitForExplicitFinish(); |
michael@0 | 25 | SimpleTest.waitForFocus(function() { |
michael@0 | 26 | var ed = document.getElementById("editor"); |
michael@0 | 27 | |
michael@0 | 28 | // Put the selection right after "a" |
michael@0 | 29 | ed.focus(); |
michael@0 | 30 | window.getSelection().collapse(ed.firstChild, 1); |
michael@0 | 31 | |
michael@0 | 32 | // Press space |
michael@0 | 33 | synthesizeKey(" ", {}); |
michael@0 | 34 | |
michael@0 | 35 | // Make sure we haven't added an nbsp |
michael@0 | 36 | is(ed.innerHTML, "a b", "We should not be adding an for preformatted text"); |
michael@0 | 37 | |
michael@0 | 38 | // Remove the preformatted style |
michael@0 | 39 | ed.removeAttribute("style"); |
michael@0 | 40 | |
michael@0 | 41 | // Reset the DOM |
michael@0 | 42 | ed.innerHTML = "a b"; |
michael@0 | 43 | |
michael@0 | 44 | // Reset the selection |
michael@0 | 45 | ed.focus(); |
michael@0 | 46 | window.getSelection().collapse(ed.firstChild, 1); |
michael@0 | 47 | |
michael@0 | 48 | // Press space |
michael@0 | 49 | synthesizeKey(" ", {}); |
michael@0 | 50 | |
michael@0 | 51 | // Make sure that we have added an nbsp |
michael@0 | 52 | is(ed.innerHTML, "a b", "We should add an for non-preformatted text"); |
michael@0 | 53 | |
michael@0 | 54 | ed = document.getElementById("editor2"); |
michael@0 | 55 | |
michael@0 | 56 | // Put the selection after the second space in the second editable field |
michael@0 | 57 | ed.focus(); |
michael@0 | 58 | window.getSelection().collapse(ed.firstChild, 3); |
michael@0 | 59 | |
michael@0 | 60 | // Press the back-space key |
michael@0 | 61 | synthesizeKey("VK_BACK_SPACE", {}); |
michael@0 | 62 | |
michael@0 | 63 | // Make sure that we've only deleted a single space |
michael@0 | 64 | is(ed.innerHTML, "a b", "We should only be deleting a single space"); |
michael@0 | 65 | |
michael@0 | 66 | SimpleTest.finish(); |
michael@0 | 67 | }); |
michael@0 | 68 | |
michael@0 | 69 | </script> |
michael@0 | 70 | </pre> |
michael@0 | 71 | </body> |
michael@0 | 72 | </html> |