1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/editor/libeditor/html/tests/test_bug592592.html Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,72 @@ 1.4 +<!DOCTYPE HTML> 1.5 +<html> 1.6 +<!-- 1.7 +https://bugzilla.mozilla.org/show_bug.cgi?id=592592 1.8 +--> 1.9 +<head> 1.10 + <title>Test for Bug 592592</title> 1.11 + <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> 1.12 + <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> 1.13 + <script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script> 1.14 +</head> 1.15 +<body> 1.16 +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=592592">Mozilla Bug 592592</a> 1.17 +<p id="display"></p> 1.18 +<div id="content"> 1.19 + <div id="editor" contenteditable="true" style="white-space:pre-wrap">a b</div> 1.20 + <div id="editor2" contenteditable="true" style="white-space:pre-wrap">a b</div> 1.21 +</div> 1.22 +<pre id="test"> 1.23 +<script type="application/javascript"> 1.24 + 1.25 +/** Test for Bug 592592 **/ 1.26 + 1.27 +SimpleTest.waitForExplicitFinish(); 1.28 +SimpleTest.waitForFocus(function() { 1.29 + var ed = document.getElementById("editor"); 1.30 + 1.31 + // Put the selection right after "a" 1.32 + ed.focus(); 1.33 + window.getSelection().collapse(ed.firstChild, 1); 1.34 + 1.35 + // Press space 1.36 + synthesizeKey(" ", {}); 1.37 + 1.38 + // Make sure we haven't added an nbsp 1.39 + is(ed.innerHTML, "a b", "We should not be adding an for preformatted text"); 1.40 + 1.41 + // Remove the preformatted style 1.42 + ed.removeAttribute("style"); 1.43 + 1.44 + // Reset the DOM 1.45 + ed.innerHTML = "a b"; 1.46 + 1.47 + // Reset the selection 1.48 + ed.focus(); 1.49 + window.getSelection().collapse(ed.firstChild, 1); 1.50 + 1.51 + // Press space 1.52 + synthesizeKey(" ", {}); 1.53 + 1.54 + // Make sure that we have added an nbsp 1.55 + is(ed.innerHTML, "a b", "We should add an for non-preformatted text"); 1.56 + 1.57 + ed = document.getElementById("editor2"); 1.58 + 1.59 + // Put the selection after the second space in the second editable field 1.60 + ed.focus(); 1.61 + window.getSelection().collapse(ed.firstChild, 3); 1.62 + 1.63 + // Press the back-space key 1.64 + synthesizeKey("VK_BACK_SPACE", {}); 1.65 + 1.66 + // Make sure that we've only deleted a single space 1.67 + is(ed.innerHTML, "a b", "We should only be deleting a single space"); 1.68 + 1.69 + SimpleTest.finish(); 1.70 +}); 1.71 + 1.72 +</script> 1.73 +</pre> 1.74 +</body> 1.75 +</html>