editor/libeditor/html/tests/test_bug490879.xul

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     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"/>
    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[
    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   }
    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   }
    48   function copyToClipBoard() {
    49     var tmpNode = document.popupNode;
    50     document.popupNode = document.getElementById("i");
    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);
    58     document.popupNode = tmpNode;
    59   }
    61   copyToClipBoard();
    62   pasteInto();
    63   verifyContent();
    65   SimpleTest.finish();
    66 }
    68 SimpleTest.waitForExplicitFinish();
    69 ]]>
    70 </script>
    71 </window>

mercurial