tor-browser

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

037-proposed.xhtml (3257B)


      1 <html xmlns="http://www.w3.org/1999/xhtml">
      2  <head>
      3    <title>Drag and drop without cancelling dragenter and without body</title>
      4    <style type="text/css">
      5 html {
      6  padding:20px;
      7 }
      8 head + div {
      9  height: 100px;
     10  width: 100px;
     11  background: orange;
     12  display: inline-block;
     13 }
     14 head + div + div {
     15  height: 100px;
     16  width: 100px;
     17  margin-left: 100px;
     18  background: blue;
     19  display: inline-block;
     20 }
     21    </style>
     22    <script type="text/javascript"><![CDATA[
     23 //Drag passes from orange to root element. Dragenter fires at root element.
     24 //Dragenter is not cancelled. Body does not exist. Dragenter fires at root element again.
     25 //Drag passes from root element to blue. Dragenter fires at blue.
     26 //Dragenter is not cancelled. Body does not exist. Current target element is root element.
     27 //Drag passes from blue to root element. Current target element is already root element.
     28 //Drag passes from root element to orange. Dragenter fires at orange, and is cancelled.
     29 window.onload = function () {
     30  var orange = document.getElementsByTagName('div')[0], sequence = [];
     31  orange.ondragstart = function (e) {
     32    e.dataTransfer.setData('text','hello');
     33    e.dataTransfer.effectAllowed = 'copy';
     34  };
     35  orange.ondragenter = orange.ondrop = function (e) {
     36    sequence[sequence.length] = 'orange.'+e.type;
     37    e.preventDefault();
     38  };
     39  orange.ondragleave = function (e) {
     40    sequence[sequence.length] = 'orange.dragleave';
     41  };
     42  orange.ondragover = function (e) {
     43    if( sequence[sequence.length-1] != 'orange.dragover' ) {
     44      sequence[sequence.length] = 'orange.dragover';
     45    }
     46    e.preventDefault();
     47  };
     48  var blue = document.getElementsByTagName('div')[1];
     49  blue.ondragenter = blue.ondragover = blue.ondragleave = function (e) {
     50    sequence[sequence.length] = 'blue.'+e.type;
     51  };
     52  document.documentElement.ondragenter = document.documentElement.ondragleave = function (e) {
     53    if( e.target != this ) { return; }
     54    sequence[sequence.length] = 'html.'+e.type;
     55  };
     56  document.documentElement.ondragover = function (e) {
     57    if( e.target != this ) { return; }
     58    if( sequence[sequence.length-1] != 'html.dragover' ) {
     59      sequence[sequence.length] = 'html.dragover';
     60    }
     61  };
     62  document.ondragenter = document.ondragleave = document.ondragover = document.ondragleave = function (e) {
     63    if( e.target != this ) { return; }
     64    sequence[sequence.length] = 'document.'+e.type;
     65  };
     66  orange.ondragend = function (e) {
     67    sequence = sequence.join('=>')
     68    var desiredsequence = (['orange.dragenter','orange.dragover','html.dragenter','html.dragenter','orange.dragleave','html.dragover','blue.dragenter','html.dragover','orange.dragenter','html.dragleave','orange.dragover','orange.drop']).join('=>')
     69    if( sequence == desiredsequence ) {
     70      document.getElementsByTagName('div')[2].textContent = 'PASS';
     71    } else {
     72      document.getElementsByTagName('div')[2].textContent = 'FAIL, got: '+sequence+' instead of: '+desiredsequence;
     73    }
     74  };
     75 };
     76    ]]></script>
     77  </head>
     78  <!--body-->
     79 
     80    <div draggable="true"></div><div></div>
     81    <div>&#160;</div>
     82    <p>Drag the orange square onto the blue square, then back to the orange square, and release it.</p>
     83    <noscript><p>Enable JavaScript and reload</p></noscript>
     84 
     85  <!--/body-->
     86 </html>