tor-browser

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

test_bug1264380.html (2013B)


      1 <html>
      2 <head>
      3  <title>Test the dragstart event on the anchor in side shadow DOM</title>
      4  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css">
      5  <script src="/tests/SimpleTest/SimpleTest.js"></script>
      6  <script src="/tests/SimpleTest/EventUtils.js"></script>
      7 <script>
      8 
      9 async function runTests()
     10 {
     11  let dragService = SpecialPowers.Cc["@mozilla.org/widget/dragservice;1"].
     12    getService(SpecialPowers.Ci.nsIDragService);
     13 
     14  let iframe = document.querySelector("iframe");
     15  let iframeDoc = iframe.contentDocument;
     16  let iframeWin = iframe.contentWindow;
     17 
     18  let shadow = iframeDoc.querySelector('#outer').attachShadow({mode: 'open'});
     19 
     20  let target = iframeDoc.createElement('a');
     21  target.textContent = "Drag me if you can!";
     22  const URL = "http://www.mozilla.org/";
     23  target.href = URL;
     24  shadow.appendChild(target);
     25 
     26  // Some of the drag data we don't actually care about for this test,
     27  // so we'll use this comparator function to ignore them.
     28  function ignoreFunc(actualData, expectedData) {
     29    return true;
     30  }
     31 
     32  const EXPECTED_DRAG_DATA = [[{
     33    type: "text/x-moz-url",
     34    data: "",
     35    eqTest: ignoreFunc,
     36  }, {
     37    type: "text/x-moz-url-data",
     38    data: "",
     39    eqTest: ignoreFunc,
     40  }, {
     41    type: "text/x-moz-url-desc",
     42    data: "",
     43    eqTest: ignoreFunc,
     44  }, {
     45    type: "text/uri-list",
     46    data: URL,
     47  }, {
     48    type: "text/_moz_htmlinfo",
     49    data: "",
     50    eqTest: ignoreFunc,
     51  }, {
     52    type: "text/html",
     53    data: "",
     54    eqTest: ignoreFunc,
     55  }, {
     56    type: "text/plain",
     57    data: URL,
     58  }]];
     59 
     60  let result = await synthesizePlainDragAndCancel(
     61    {
     62      srcElement: target,
     63      srcWindow: iframeWin,
     64      finalY: -10,  // Avoid clicking the link
     65    },
     66    EXPECTED_DRAG_DATA);
     67  ok(result === true, "Should have gotten the expected drag data.");
     68  SimpleTest.finish();
     69 }
     70 
     71 
     72 SimpleTest.waitForExplicitFinish();
     73 window.onload = () => {
     74  SimpleTest.waitForFocus(runTests);
     75 };
     76 
     77 </script>
     78 
     79 <body>
     80  <iframe srcdoc='<div id="outer"/>'></iframe>
     81 </body>
     82 </html>