diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
commit | 26a029d407be480d791972afb5975cf62c9360a6 (patch) | |
tree | f435a8308119effd964b339f76abb83a57c29483 /testing/web-platform/tests/html/editing/dnd/datastore/058.html | |
parent | Initial commit. (diff) | |
download | firefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz firefox-26a029d407be480d791972afb5975cf62c9360a6.zip |
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/html/editing/dnd/datastore/058.html')
-rw-r--r-- | testing/web-platform/tests/html/editing/dnd/datastore/058.html | 79 |
1 files changed, 79 insertions, 0 deletions
diff --git a/testing/web-platform/tests/html/editing/dnd/datastore/058.html b/testing/web-platform/tests/html/editing/dnd/datastore/058.html new file mode 100644 index 0000000000..c1e7ad95b6 --- /dev/null +++ b/testing/web-platform/tests/html/editing/dnd/datastore/058.html @@ -0,0 +1,79 @@ +<!doctype html> +<html> + <head> + <title>Dropping file into dropzone</title> + <style type="text/css"> +span { display: inline-block; height: 100px; width: 100px; background: orange; } +span + span { background: blue; } + </style> + <script type="text/javascript"> +window.onload = function () { + var drag = document.getElementsByTagName('span')[0]; + drag.ondragstart = function (e) { + e.dataTransfer.setData('text','PASS'); + e.dataTransfer.effectAllowed = 'copy'; + var filein = document.getElementsByTagName('input')[0]; + if( !filein.files ) { + document.getElementsByTagName('p')[0].innerHTML = 'FAIL - file API is not supported.'; + return; + } + if( !filein.files[0] ) { + document.getElementsByTagName('p')[0].innerHTML = 'FAIL - no file was found in the file input.'; + return; + } + var thefile = filein.files[0]; + try { + e.dataTransfer.items.add(thefile); + } catch(err) { + document.getElementsByTagName('p')[0].innerHTML = 'FAIL - error when adding file'; + e.preventDefault(); + return; + } + if( e.dataTransfer.files.length != 1 ) { + document.getElementsByTagName('p')[0].innerHTML = 'FAIL - file was not attached to data store'; + e.preventDefault(); + return; + } + }; + document.getElementsByTagName('span')[1].ondrop = function (e) { + e.preventDefault(); + if( document.getElementsByTagName('p')[0].innerHTML ) { return; } + if( e.dataTransfer.files.length != 1 ) { + document.getElementsByTagName('p')[0].innerHTML = 'FAIL - file was not attached to data store during drop'; + e.preventDefault(); + return; + } + if( !window.FileReader ) { + document.getElementsByTagName('p')[0].innerHTML = 'No FileReader constructor'; + e.preventDefault(); + return; + } + var reader = new FileReader(); + reader.onload = function () { + if( !reader.result ) { + document.getElementsByTagName('p')[0].innerHTML = 'No file data after load'; + } else if( !document.getElementsByTagName('p')[0].innerHTML ) { + document.getElementsByTagName('p')[0].innerHTML = 'PASS'; + } + }; + reader.readAsBinaryString(e.dataTransfer.files[0]); + setTimeout(function () { + if( !reader.result ) { + document.getElementsByTagName('p')[0].innerHTML = 'No file data after timeout'; + } + },1000); + }; +}; + </script> + </head> + <body> + <ol> + <li>Select a non-empty plain text file on your computer using the following input: <input type="file"></li> + <li>Drag the orange square onto the blue square and release it:<br><span draggable="true"></span> <span dropzone="copy file:text/plain"></span><br> + If a prompt appears, accept it.</li> + <li>Fail if new text does not appear below.</li> + </ol> + <p></p> + <noscript><p>Enable JavaScript and reload</p></noscript> + </body> +</html> |