test_bug1306532.html (2194B)
1 <!DOCTYPE HTML> 2 <html><head> 3 <title>Test for bug 1306532</title> 4 <style src="/tests/SimpleTest/test.css" type="text/css"></style> 5 <script src="/tests/SimpleTest/SimpleTest.js"></script> 6 <script src="/tests/SimpleTest/EventUtils.js"></script> 7 8 <script class="testbody" type="application/javascript"> 9 10 function runTest() { 11 const headingone = document.getElementById("headingone"); 12 const celltwo = document.getElementById("celltwo"); 13 const pasteframe = document.getElementById("pasteframe"); 14 15 // Copy content from table. 16 var selection = getSelection(); 17 var startRange = document.createRange(); 18 startRange.setStart(headingone, 0); 19 startRange.setEnd(celltwo, 0); 20 selection.removeAllRanges(); 21 selection.addRange(startRange); 22 SpecialPowers.wrap(document).execCommand("copy", false, null); 23 24 // Paste content into "pasteframe" 25 var pasteContainer = pasteframe.contentDocument.body; 26 var pasteRange = pasteframe.contentDocument.createRange(); 27 pasteRange.selectNodeContents(pasteContainer); 28 pasteRange.collapse(false); 29 selection.removeAllRanges(); 30 selection.addRange(pasteRange); 31 SpecialPowers.wrap(pasteframe.contentDocument).execCommand("paste", false, null); 32 33 is(pasteContainer.querySelector("#headingone").textContent, "Month", "First heading should be 'Month'."); 34 is(pasteContainer.querySelector("#headingtwo").textContent, "Savings", "Second heading should be 'Savings'."); 35 is(pasteContainer.querySelector("#cellone").textContent, "January", "First cell should be 'January'."); 36 is(pasteContainer.querySelector("#celltwo").textContent, "$100", "Second cell should be '$100'."); 37 38 SimpleTest.finish(); 39 } 40 41 SimpleTest.waitForExplicitFinish(); 42 43 </script> 44 </head> 45 <body> 46 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1306532">Mozilla Bug 1306532</a> 47 <p id="display"></p> 48 49 <pre id="test"> 50 </pre> 51 52 <div id="container"> 53 <table border="1"> 54 <tr> 55 <th id="headingone">Month</th> 56 <th id="headingtwo">Savings</th> 57 </tr> 58 <tr> 59 <td id="cellone">January</td> 60 <td id="celltwo">$100</td> 61 </tr> 62 </table> 63 </div> 64 65 <iframe onload="runTest();" id="pasteframe" srcdoc="<html><body contenteditable='true'>"></iframe> 66 67 </body> 68 </html>