1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/editor/libeditor/html/tests/test_bug490879.xul Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,71 @@ 1.4 +<?xml version="1.0"?> 1.5 +<?xml-stylesheet href="chrome://global/skin" 1.6 + type="text/css"?> 1.7 +<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" 1.8 + type="text/css"?> 1.9 +<!-- 1.10 +https://bugzilla.mozilla.org/show_bug.cgi?id=490879 1.11 +--> 1.12 +<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" 1.13 + title="Mozilla Bug 490879" onload="runTest();"> 1.14 + <script type="application/javascript" 1.15 + src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/> 1.16 + 1.17 + <body xmlns="http://www.w3.org/1999/xhtml"> 1.18 + <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=490879" 1.19 + target="_blank">Mozilla Bug 490879</a> 1.20 + <p/> 1.21 + <iframe id="i1" width="200" height="100" src="about:blank" /><br /> 1.22 + <img id="i" src="green.png" /> 1.23 + <p/> 1.24 + <pre id="test"> 1.25 + </pre> 1.26 + </body> 1.27 + <script class="testbody" type="application/javascript"> 1.28 + <![CDATA[ 1.29 + 1.30 +function runTest() { 1.31 + function verifyContent() { 1.32 + const kExpectedImgSpec = "data:image/png;base64,"; 1.33 + var e = document.getElementById('i1'); 1.34 + var doc = e.contentDocument; 1.35 + is(doc.getElementsByTagName("img")[0].src.substring(0, kExpectedImgSpec.length), 1.36 + kExpectedImgSpec, "The pasted image is a base64-encoded data: URI"); 1.37 + } 1.38 + 1.39 + function pasteInto() { 1.40 + var e = document.getElementById('i1'); 1.41 + var doc = e.contentDocument; 1.42 + doc.designMode = "on"; 1.43 + doc.defaultView.focus(); 1.44 + var selection = doc.defaultView.getSelection(); 1.45 + selection.removeAllRanges(); 1.46 + selection.selectAllChildren(doc.body); 1.47 + selection.collapseToEnd(); 1.48 + doc.execCommand("paste", false, null); 1.49 + } 1.50 + 1.51 + function copyToClipBoard() { 1.52 + var tmpNode = document.popupNode; 1.53 + document.popupNode = document.getElementById("i"); 1.54 + 1.55 + const kCmd = "cmd_copyImageContents"; 1.56 + var controller = top.document.commandDispatcher 1.57 + .getControllerForCommand(kCmd); 1.58 + ok((controller && controller.isCommandEnabled(kCmd)), "have copy command"); 1.59 + controller.doCommand(kCmd); 1.60 + 1.61 + document.popupNode = tmpNode; 1.62 + } 1.63 + 1.64 + copyToClipBoard(); 1.65 + pasteInto(); 1.66 + verifyContent(); 1.67 + 1.68 + SimpleTest.finish(); 1.69 +} 1.70 + 1.71 +SimpleTest.waitForExplicitFinish(); 1.72 +]]> 1.73 +</script> 1.74 +</window>