1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/editor/libeditor/html/tests/test_bug410986.html Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,80 @@ 1.4 +<!DOCTYPE HTML> 1.5 +<html> 1.6 +<!-- 1.7 +https://bugzilla.mozilla.org/show_bug.cgi?id=410986 1.8 +--> 1.9 +<head> 1.10 + <title>Test for Bug 410986</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=410986">Mozilla Bug 410986</a> 1.17 +<p id="display"></p> 1.18 +<div id="content"> 1.19 + <div id="contents"><span style="color: green;">green text</span></div> 1.20 + <div id="editor" contenteditable="true"></div> 1.21 +</div> 1.22 +<pre id="test"> 1.23 +<script type="application/javascript"> 1.24 + 1.25 +/** Test for Bug 410986 **/ 1.26 + 1.27 +var gPasteEvents = 0; 1.28 +document.getElementById("editor").addEventListener("paste", function() { 1.29 + ++gPasteEvents; 1.30 +}, false); 1.31 + 1.32 +SimpleTest.waitForExplicitFinish(); 1.33 +SimpleTest.waitForFocus(function() { 1.34 + getSelection().selectAllChildren(document.getElementById("contents")); 1.35 + SimpleTest.waitForClipboard("green text", 1.36 + function() { 1.37 + synthesizeKey("C", {accelKey: true}); 1.38 + }, 1.39 + function() { 1.40 + var ed = document.getElementById("editor"); 1.41 + ed.focus(); 1.42 + if (navigator.platform.indexOf("Mac") >= 0) { 1.43 + synthesizeKey("V", {accelKey: true, shiftKey: true, altKey: true}); 1.44 + } else { 1.45 + synthesizeKey("V", {accelKey: true, shiftKey: true}); 1.46 + } 1.47 + is(ed.innerHTML, "green text", "Content should be pasted in plaintext format"); 1.48 + is(gPasteEvents, 1, "One paste event must be fired"); 1.49 + 1.50 + ed.innerHTML = ""; 1.51 + ed.blur(); 1.52 + getSelection().selectAllChildren(document.getElementById("contents")); 1.53 + SimpleTest.waitForClipboard("green text", 1.54 + function() { 1.55 + synthesizeKey("C", {accelKey: true}); 1.56 + }, 1.57 + function() { 1.58 + var ed = document.getElementById("editor"); 1.59 + ed.focus(); 1.60 + synthesizeKey("V", {accelKey: true}); 1.61 + isnot(ed.innerHTML.indexOf("<span style=\"color: green;\">green text</span>"), -1, 1.62 + "Content should be pasted in HTML format"); 1.63 + is(gPasteEvents, 2, "Two paste events must be fired"); 1.64 + 1.65 + SimpleTest.finish(); 1.66 + }, 1.67 + function() { 1.68 + ok(false, "Failed to copy the second item to the clipboard"); 1.69 + SimpleTest.finish(); 1.70 + } 1.71 + ); 1.72 + }, 1.73 + function() { 1.74 + ok(false, "Failed to copy the first item to the clipboard"); 1.75 + SimpleTest.finish(); 1.76 + } 1.77 + ); 1.78 +}); 1.79 + 1.80 +</script> 1.81 +</pre> 1.82 +</body> 1.83 +</html>