Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | <!DOCTYPE HTML> |
michael@0 | 2 | <html> |
michael@0 | 3 | <!-- |
michael@0 | 4 | https://bugzilla.mozilla.org/show_bug.cgi?id=410986 |
michael@0 | 5 | --> |
michael@0 | 6 | <head> |
michael@0 | 7 | <title>Test for Bug 410986</title> |
michael@0 | 8 | <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> |
michael@0 | 9 | <script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script> |
michael@0 | 10 | <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> |
michael@0 | 11 | </head> |
michael@0 | 12 | <body> |
michael@0 | 13 | <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=410986">Mozilla Bug 410986</a> |
michael@0 | 14 | <p id="display"></p> |
michael@0 | 15 | <div id="content"> |
michael@0 | 16 | <div id="contents"><span style="color: green;">green text</span></div> |
michael@0 | 17 | <div id="editor" contenteditable="true"></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 410986 **/ |
michael@0 | 23 | |
michael@0 | 24 | var gPasteEvents = 0; |
michael@0 | 25 | document.getElementById("editor").addEventListener("paste", function() { |
michael@0 | 26 | ++gPasteEvents; |
michael@0 | 27 | }, false); |
michael@0 | 28 | |
michael@0 | 29 | SimpleTest.waitForExplicitFinish(); |
michael@0 | 30 | SimpleTest.waitForFocus(function() { |
michael@0 | 31 | getSelection().selectAllChildren(document.getElementById("contents")); |
michael@0 | 32 | SimpleTest.waitForClipboard("green text", |
michael@0 | 33 | function() { |
michael@0 | 34 | synthesizeKey("C", {accelKey: true}); |
michael@0 | 35 | }, |
michael@0 | 36 | function() { |
michael@0 | 37 | var ed = document.getElementById("editor"); |
michael@0 | 38 | ed.focus(); |
michael@0 | 39 | if (navigator.platform.indexOf("Mac") >= 0) { |
michael@0 | 40 | synthesizeKey("V", {accelKey: true, shiftKey: true, altKey: true}); |
michael@0 | 41 | } else { |
michael@0 | 42 | synthesizeKey("V", {accelKey: true, shiftKey: true}); |
michael@0 | 43 | } |
michael@0 | 44 | is(ed.innerHTML, "green text", "Content should be pasted in plaintext format"); |
michael@0 | 45 | is(gPasteEvents, 1, "One paste event must be fired"); |
michael@0 | 46 | |
michael@0 | 47 | ed.innerHTML = ""; |
michael@0 | 48 | ed.blur(); |
michael@0 | 49 | getSelection().selectAllChildren(document.getElementById("contents")); |
michael@0 | 50 | SimpleTest.waitForClipboard("green text", |
michael@0 | 51 | function() { |
michael@0 | 52 | synthesizeKey("C", {accelKey: true}); |
michael@0 | 53 | }, |
michael@0 | 54 | function() { |
michael@0 | 55 | var ed = document.getElementById("editor"); |
michael@0 | 56 | ed.focus(); |
michael@0 | 57 | synthesizeKey("V", {accelKey: true}); |
michael@0 | 58 | isnot(ed.innerHTML.indexOf("<span style=\"color: green;\">green text</span>"), -1, |
michael@0 | 59 | "Content should be pasted in HTML format"); |
michael@0 | 60 | is(gPasteEvents, 2, "Two paste events must be fired"); |
michael@0 | 61 | |
michael@0 | 62 | SimpleTest.finish(); |
michael@0 | 63 | }, |
michael@0 | 64 | function() { |
michael@0 | 65 | ok(false, "Failed to copy the second item to the clipboard"); |
michael@0 | 66 | SimpleTest.finish(); |
michael@0 | 67 | } |
michael@0 | 68 | ); |
michael@0 | 69 | }, |
michael@0 | 70 | function() { |
michael@0 | 71 | ok(false, "Failed to copy the first item to the clipboard"); |
michael@0 | 72 | SimpleTest.finish(); |
michael@0 | 73 | } |
michael@0 | 74 | ); |
michael@0 | 75 | }); |
michael@0 | 76 | |
michael@0 | 77 | </script> |
michael@0 | 78 | </pre> |
michael@0 | 79 | </body> |
michael@0 | 80 | </html> |