tor-browser

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

test_bug795418.html (1807B)


      1 <!DOCTYPE HTML>
      2 <html>
      3 <!--
      4 https://bugzilla.mozilla.org/show_bug.cgi?id=795418
      5 -->
      6 <head>
      7  <meta charset="utf-8">
      8  <title>Test for Bug 795418</title>
      9  <script src="/tests/SimpleTest/SimpleTest.js"></script>
     10  <script src="/tests/SimpleTest/EventUtils.js"></script>
     11  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
     12 </head>
     13 <body>
     14 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=795418">Mozilla Bug 795418</a>
     15 <p id="display"></p>
     16 <div id="content" style="display: none">
     17 </div>
     18 
     19 <div id="copySource">Copy this</div>
     20 <div id="editable" contenteditable><span>AB</span></div>
     21 
     22 <pre id="test">
     23 
     24 <script type="application/javascript">
     25 
     26 /** Test for Bug 795418 */
     27 SimpleTest.waitForExplicitFinish();
     28 SimpleTest.waitForFocus(function() {
     29  var div = document.getElementById("copySource");
     30  var sel = window.getSelection();
     31  sel.removeAllRanges();
     32 
     33  // Select the text from the text node in div.
     34  var r = document.createRange();
     35  r.setStart(div.firstChild, 0);
     36  r.setEnd(div.firstChild, 9);
     37  sel.addRange(r);
     38 
     39  SimpleTest.waitForClipboard(
     40    aData => {
     41      // XXX Oddly, specifying `r.toString()` causes timeout in headless mode.
     42      info(`copied text: "${aData}"`);
     43      return true;
     44    },
     45    function setup() {
     46      synthesizeKey("C", {accelKey: true});
     47    },
     48    function onSuccess() {
     49      var theEdit = document.getElementById("editable");
     50      sel.collapse(theEdit.firstChild, 1);
     51 
     52      SpecialPowers.doCommand(window, "cmd_pasteQuote");
     53      is(theEdit.innerHTML,
     54        "<span>AB<blockquote type=\"cite\">Copy this</blockquote></span>",
     55        "unexpected HTML for test");
     56 
     57      SimpleTest.finish();
     58    },
     59    function onFailure() {
     60      SimpleTest.finish();
     61    },
     62    "text/html"
     63  );
     64 });
     65 
     66 </script>
     67 
     68 </pre>
     69 </body>
     70 </html>