tor-browser

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

008.html (2635B)


      1 <!DOCTYPE html>
      2 <title>drag &amp; drop - no microdata for selection with no items</title>
      3 <style>
      4  body > div {
      5    height: 100px;
      6    width: 200px;
      7    background-color: fuchsia;
      8    position: absolute;
      9    top: 8px;
     10    left: 8px;
     11  }
     12  span span {
     13    display: none;
     14  }
     15  body > div + div {
     16    background-color: navy;
     17    top: 116px;
     18  }
     19  body > div + div + div {
     20    background-color: orange;
     21    top: 224px;
     22  }
     23  p:first-of-type {
     24    margin-top: 350px;
     25  }
     26 </style>
     27 
     28 <script>
     29 
     30 function makeEl(eltype,props,contents) {
     31  var elem = document.createElement(eltype);
     32  for( var i in props ) {
     33    if( props.hasOwnProperty(i) ) {
     34      elem.setAttribute(i,props[i]);
     35    }
     36  }
     37  if( contents ) {
     38    elem.innerHTML = contents;
     39  }
     40  return elem;
     41 }
     42 
     43 var orange, fails = [], doneonce = false;
     44 window.onload = function() {
     45  orange = document.getElementsByTagName('div')[2];
     46  orange.ondragstart = function(e) {
     47    e.dataTransfer.effectAllowed = 'copy';
     48    e.dataTransfer.setData('Text', 'dummy text');
     49    var err;
     50    if( err = checkprops(e.dataTransfer.getData('application/microdata+json')) ) {
     51      fails[fails.length] = e.type + ' ' + err;
     52    }
     53  };
     54  orange.previousSibling.ondragenter = orange.previousSibling.ondragleave = orange.previousSibling.ondragover =
     55  orange.ondrag = orange.ondragend = function(e) {
     56    if( e.type == 'dragover' || e.type == 'dragenter' ) {
     57      e.preventDefault();
     58      e.dataTransfer.dropEffect = 'copy';
     59    }
     60    if( e.dataTransfer.getData('application/microdata+json') ) {
     61      fails[fails.length] = e.type + ' unexpectedly had microdata (security restriction)';
     62    }
     63  };
     64  orange.previousSibling.ondrop = function(e) {
     65    var err;
     66    if( err = checkprops(e.dataTransfer.getData('application/microdata+json')) ) {
     67      fails[fails.length] = e.type + ' ' + err;
     68    }
     69    if( e.type != 'drop' ) { return; }
     70    if( doneonce ) { return; }
     71    doneonce = true;
     72    setTimeout(function () {
     73      document.getElementsByTagName('p')[0].innerHTML = fails.length ? ( 'FAIL: ' + fails.join('<br>') ) : 'PASS';
     74      fails = [];
     75    }, 200 );
     76  };
     77 
     78 };
     79 function checkprops(md) {
     80  var i;
     81  if( !md ) { return 'no microdata'; }
     82  md = JSON.parse(md);
     83  if( !md.items ) { return 'no items collection'; }
     84  if( md.items.length != 0 ) { return 'unexpected items found'; }
     85  return '';
     86 }
     87 
     88 </script>
     89 
     90 <div></div><div></div><div>01<span>23</span>45<span>67</span>89</div>
     91 
     92 <p>Use your pointing device to select the text substring "12345678" above, drag the selection upwards to the pink box,
     93 then back to the blue box, and release it.</p>
     94 <noscript><p>Enable JavaScript and reload</p></noscript>