1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/editor/libeditor/html/tests/test_bug668599.html Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,73 @@ 1.4 +<!DOCTYPE HTML> 1.5 +<html> 1.6 +<!-- 1.7 +https://bugzilla.mozilla.org/show_bug.cgi?id=668599 1.8 +--> 1.9 +<head> 1.10 + <title>Test for Bug 668599</title> 1.11 + <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> 1.12 + <script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script> 1.13 + <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> 1.14 +</head> 1.15 +<body> 1.16 +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=668599">Mozilla Bug 668599</a> 1.17 +<p id="display"></p> 1.18 +<div id="content"> 1.19 + <div id="test1"> 1.20 + block <span contenteditable>type here</span> block 1.21 + </div> 1.22 + <div id="test2"> 1.23 + <p contenteditable> 1.24 + block <span>type here</span> block 1.25 + </p> 1.26 + </div> 1.27 +</div> 1.28 + 1.29 +<pre id="test"> 1.30 +<script type="application/javascript"> 1.31 + 1.32 +/** Test for Bug 668599 **/ 1.33 +SimpleTest.waitForExplicitFinish(); 1.34 +SimpleTest.waitForFocus(runTests); 1.35 + 1.36 +function select(element) { 1.37 + // select the element text content 1.38 + var userSelection = window.getSelection(); 1.39 + window.getSelection().removeAllRanges(); 1.40 + var range = document.createRange(); 1.41 + range.setStart(element.firstChild, 0); 1.42 + range.setEnd(element.firstChild, element.textContent.length); 1.43 + userSelection.addRange(range); 1.44 +}; 1.45 + 1.46 +function runTests() { 1.47 + var span = document.querySelector("#test1 span"); 1.48 + 1.49 + // editable <span> => the <span> *content* should be deleted 1.50 + select(span); 1.51 + span.focus(); 1.52 + synthesizeKey("x", {}); 1.53 + is(span.textContent, "x", "The <span> content should have been replaced by 'x'."); 1.54 + 1.55 + // same thing, but using [Del] instead of typing some text 1.56 + document.execCommand("Undo", false, null); 1.57 + select(span); 1.58 + span.focus(); 1.59 + synthesizeKey("VK_DELETE", {}); 1.60 + is(span.textContent, "", "The <span> content should have been deleted."); 1.61 + 1.62 + // <span> in editable block => the <span> *element* should be deleted 1.63 + select(document.querySelector("#test2 span")); 1.64 + document.querySelector("#test2 [contenteditable]").focus(); 1.65 + synthesizeKey("VK_DELETE", {}); 1.66 + is(document.querySelector("#test2 span"), null, 1.67 + "The <span> element should have been deleted."); 1.68 + 1.69 + // done 1.70 + SimpleTest.finish(); 1.71 +} 1.72 + 1.73 +</script> 1.74 +</pre> 1.75 +</body> 1.76 +</html>