tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

test_bug490879.html (1601B)


      1 <!doctype html>
      2 <title>Mozilla Bug 490879</title>
      3 <link rel=stylesheet href="/tests/SimpleTest/test.css">
      4 <script src="/tests/SimpleTest/SimpleTest.js"></script>
      5 <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=490879"
      6   target="_blank">Mozilla Bug 490879</a>
      7 <iframe id="i1" width="200" height="100" src="about:blank"></iframe>
      8 <img id="i" src="green.png">
      9 <script>
     10 async function runTest() {
     11  function verifyContent() {
     12    const kExpectedImgSpec = "data:image/png;base64,";
     13    var e = document.getElementById("i1");
     14    var doc = e.contentDocument;
     15    is(doc.getElementsByTagName("img")[0].src.substring(0, kExpectedImgSpec.length),
     16       kExpectedImgSpec, "The pasted image is a base64-encoded data: URI");
     17  }
     18 
     19  async function pasteInto() {
     20    var e = document.getElementById("i1");
     21    var doc = e.contentDocument;
     22    doc.designMode = "on";
     23    doc.defaultView.focus();
     24    var selection = doc.defaultView.getSelection();
     25    selection.removeAllRanges();
     26    selection.selectAllChildren(doc.body);
     27    selection.collapseToEnd();
     28 
     29    let input = new Promise(resolve => {
     30      doc.body.addEventListener("input", resolve, {once: true})
     31    });
     32 
     33    SpecialPowers.doCommand(window, "cmd_paste");
     34 
     35    info("Waiting for input event");
     36    await input;
     37  }
     38 
     39  function copyToClipBoard() {
     40    SpecialPowers.setCommandNode(window, document.getElementById("i"));
     41    SpecialPowers.doCommand(window, "cmd_copyImageContents");
     42  }
     43 
     44  copyToClipBoard();
     45 
     46  await pasteInto();
     47 
     48  verifyContent();
     49  SimpleTest.finish();
     50 }
     51 
     52 SimpleTest.waitForExplicitFinish();
     53 addLoadEvent(runTest);
     54 </script>