author Neil Deakin <>
Thu, 07 Dec 2017 08:39:50 -0500
changeset 449756 8972884c1ac7e699f081c012cde67d45eb323975
parent 300951 bd5c55a25ab2915331df2cf70848a3838e3e091b
child 470782 c10c705a1feae70c507bb644dcf2867cbe63db6f
permissions -rw-r--r--
Bug 1419925, implement a promise-oriented version of waitForClipboard, promiseClipboardChange, change a selection of tests to use this instead. Simplify some other clipboard tests that were unreliable before the fix for 1394757. r=jmaher

<?xml version="1.0"?>
This test is copied from test_copypaste.html, but it's XHTML instead of HTML.
XHTML is encoded differently from HTML when copied; see bugs 888839 and 723163.
This test is different from test_copypaste.html in two ways:

  1. The text/html clipboard flavor isn't tested, since nsCopySupport doesn't
     produce it for XHTML.
  2. The text/unicode flavor isn't tested when the selection is in hidden
     elements, since nsCopySupport doesn't produce text/plain for hidden
     elements, and unlike HTML, neither does it produce text/_moz_htmlcontext
     and text/_moz_htmlinfo, which the clipboard converts to text/unicode.
<html xml:lang="en" xmlns="">
  <title>Test for copy/paste with XHTML</title>
  <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
  <script type="text/javascript" src="copypaste.js"></script>
  <script type="text/javascript" src="/tests/SimpleTest/SpawnTask.js"></script>
  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
<a target="_blank" href="">Mozilla Bug 888839</a>
<p id="display"></p>
<div id="content" style="display: none">
<pre id="test">
<script class="testbody" type="text/javascript">

function modifySelectionDiv12() {
  modifySelection("X<b style='display:none'>Y</b>");

addLoadEvent(() => {
  add_task(async function test_copyhtml() {
    await testCopyPaste(true);


  <div id="draggable" title="title to have a long HTML line">This is a <em>draggable</em> bit of text.</div>
  <textarea id="input" cols="40" rows="10"></textarea>

  <div id="alist">
      <li style="display: none;">baz</li>

  <div id="blist">
      <li style="display: none;">baz</li>

  <div id="clist">
      <li style="display: none;">baz</li>

<div id="div4">
  T<textarea>t t t</textarea>

<div id="div5">
  T<textarea>     </textarea>

<div id="div6" style="display:none"></div>
var x = $("div6")

<div id="div7" style="display:none">div7</div>
<div id="div8" style="visibility:hidden">div8</div>
<div style="visibility:hidden"><div id="div9" style="visibility:visible">div9</div></div>
<div style="visibility:hidden"><div><div><div id="div10"></div></div></div></div>
var x = $("div10")

<div id="div11" oncopy="modifySelection('X')"><span>div</span>11</div>
<div id="div12" oncopy="modifySelectionDiv12()"><span>div</span>12</div>

<div id="div13">_<noscript>FAIL</noscript>_</div>

<table><tr id="tr1"><td>foo</td><td>bar</td></tr></table>