editor/libeditor/html/tests/test_bug490879.xul

changeset 0
6474c204b198
equal deleted inserted replaced
-1:000000000000 0:75b2bcdde8b5
1 <?xml version="1.0"?>
2 <?xml-stylesheet href="chrome://global/skin"
3 type="text/css"?>
4 <?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css"
5 type="text/css"?>
6 <!--
7 https://bugzilla.mozilla.org/show_bug.cgi?id=490879
8 -->
9 <window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
10 title="Mozilla Bug 490879" onload="runTest();">
11 <script type="application/javascript"
12 src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
13
14 <body xmlns="http://www.w3.org/1999/xhtml">
15 <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=490879"
16 target="_blank">Mozilla Bug 490879</a>
17 <p/>
18 <iframe id="i1" width="200" height="100" src="about:blank" /><br />
19 <img id="i" src="green.png" />
20 <p/>
21 <pre id="test">
22 </pre>
23 </body>
24 <script class="testbody" type="application/javascript">
25 <![CDATA[
26
27 function runTest() {
28 function verifyContent() {
29 const kExpectedImgSpec = "data:image/png;base64,";
30 var e = document.getElementById('i1');
31 var doc = e.contentDocument;
32 is(doc.getElementsByTagName("img")[0].src.substring(0, kExpectedImgSpec.length),
33 kExpectedImgSpec, "The pasted image is a base64-encoded data: URI");
34 }
35
36 function pasteInto() {
37 var e = document.getElementById('i1');
38 var doc = e.contentDocument;
39 doc.designMode = "on";
40 doc.defaultView.focus();
41 var selection = doc.defaultView.getSelection();
42 selection.removeAllRanges();
43 selection.selectAllChildren(doc.body);
44 selection.collapseToEnd();
45 doc.execCommand("paste", false, null);
46 }
47
48 function copyToClipBoard() {
49 var tmpNode = document.popupNode;
50 document.popupNode = document.getElementById("i");
51
52 const kCmd = "cmd_copyImageContents";
53 var controller = top.document.commandDispatcher
54 .getControllerForCommand(kCmd);
55 ok((controller && controller.isCommandEnabled(kCmd)), "have copy command");
56 controller.doCommand(kCmd);
57
58 document.popupNode = tmpNode;
59 }
60
61 copyToClipBoard();
62 pasteInto();
63 verifyContent();
64
65 SimpleTest.finish();
66 }
67
68 SimpleTest.waitForExplicitFinish();
69 ]]>
70 </script>
71 </window>

mercurial