diff options
Diffstat (limited to 'testing/web-platform/tests/html/editing/dnd/file')
21 files changed, 1062 insertions, 0 deletions
diff --git a/testing/web-platform/tests/html/editing/dnd/file/001.html b/testing/web-platform/tests/html/editing/dnd/file/001.html new file mode 100644 index 0000000000..b911920041 --- /dev/null +++ b/testing/web-platform/tests/html/editing/dnd/file/001.html @@ -0,0 +1,103 @@ +<!DOCTYPE html> +<title>drag & drop - simple file drop</title> +<style> + body > div { + height: 200px; + width: 200px; + background-color: orange; + } +</style> + +<script> +var filename = 'fail.png', filesize = '759', filetype = 'image/png'; +var fails = [], finished = false; +window.onload = function() { + var orange = document.getElementsByTagName('div')[0]; + orange.ondragover = orange.ondragenter = function(e) { + e.preventDefault(); + e.dataTransfer.dropEffect = 'copy'; + if( !e.dataTransfer.files ) { + fails[fails.length] = 'No dataTransfer.files for '+e.type; + } + if( !window.FileList ) { + fails[fails.length] = 'No FileList interface object'; + return; + } + if( !( e.dataTransfer.files instanceof FileList ) ) { + fails[fails.length] = 'dataTransfer.files is not a FileList'; + } + if( e.dataTransfer.files.length ) { + fails[fails.length] = 'dataTransfer.files.length is '+e.dataTransfer.files.length+' instead of 0 for '+e.type; + } + }; + orange.ondrop = function(e) { + e.preventDefault(); + if( !e.dataTransfer.files ) { + fails[fails.length] = 'No dataTransfer.files for '+e.type; + } + if( !window.FileList ) { + fails[fails.length] = 'No FileList interface object'; + finish(); + return; + } + if( !( e.dataTransfer.files instanceof FileList ) ) { + fails[fails.length] = 'dataTransfer.files is not a FileList'; + } + if( e.dataTransfer.files.length != 1 ) { + fails[fails.length] = 'dataTransfer.files.length is '+e.dataTransfer.files.length+' instead of 1 for '+e.type; + } + if( !e.dataTransfer.files[0] ) { + fails[fails.length] = 'no dataTransfer.files[0] for drop'; + finish(); + return; + } + if( e.dataTransfer.files[0].size != filesize ) { + fails[fails.length] = 'dataTransfer.files[0].size '+e.dataTransfer.files[0].size+' instead of '+filesize; + } + /* + if( !e.dataTransfer.files[0].lastModified ) { + fails[fails.length] = 'no dataTransfer.files[0].lastModified'; + } + */ + if( e.dataTransfer.files[0].name != filename ) { + fails[fails.length] = 'dataTransfer.files[0].name '+e.dataTransfer.files[0].name+' instead of '+filename; + } + if( e.dataTransfer.files[0].type != filetype ) { + fails[fails.length] = 'dataTransfer.files[0].type '+e.dataTransfer.files[0].type+' instead of '+filetype; + } + if( !window.FileReader ) { + fails[fails.length] = 'No FileReader constructor'; + finish(); + return; + } + var reader = new FileReader(); + reader.onload = function () { + if( !reader.result ) { + fails[fails.length] = 'No file data after load'; + } + if( reader.result.length != filesize ) { + fails[fails.length] = 'File data length '+reader.result.length+' instead of '+filesize; + } + finish(); + }; + reader.readAsBinaryString(e.dataTransfer.files[0]); + setTimeout(function () { + if( !reader.result ) { + fails[fails.length] = 'No file data after timeout'; + } + finish(); + },1000); + }; + +}; +function finish() { + if( finished ) { return; } + finished = true; + document.getElementsByTagName('p')[0].innerHTML = fails.length ? ( 'FAIL: ' + fails.join('<br>') ) : 'PASS'; +} +</script> + +<div></div> + +<p>Save <a href="../resources/fail.png">this image</a> to your desktop. Use your pointing device to drag the saved file from your desktop onto the orange box, and release it. If a confirmation dialog appears, accept it. Fail if nothing happens, or if the browser simply displays the image.</p> +<noscript><p>Enable JavaScript and reload</p></noscript> diff --git a/testing/web-platform/tests/html/editing/dnd/file/002.html b/testing/web-platform/tests/html/editing/dnd/file/002.html new file mode 100644 index 0000000000..c8d633d6d2 --- /dev/null +++ b/testing/web-platform/tests/html/editing/dnd/file/002.html @@ -0,0 +1,146 @@ +<!DOCTYPE html> +<title>drag & drop - multiple file drop</title> +<style> + body > div { + height: 200px; + width: 200px; + background-color: orange; + } +</style> + +<script> +var filename1 = 'fail.png', filesize1 = '759', filetype1 = 'image/png', filename2 = 'fail.txt', filesize2 = '4', filetype2 = 'text/plain'; +var fails = [], finished = false, donecount = 0; +window.onload = function() { + var orange = document.getElementsByTagName('div')[0]; + orange.ondragover = orange.ondragenter = function(e) { + e.preventDefault(); + e.dataTransfer.dropEffect = 'copy'; + if( !e.dataTransfer.files ) { + fails[fails.length] = 'No dataTransfer.files for '+e.type; + } + if( !window.FileList ) { + fails[fails.length] = 'No FileList interface object'; + return; + } + if( !( e.dataTransfer.files instanceof FileList ) ) { + fails[fails.length] = 'dataTransfer.files is not a FileList'; + } + if( e.dataTransfer.files.length ) { + fails[fails.length] = 'dataTransfer.files.length is '+e.dataTransfer.files.length+' instead of 0 for '+e.type; + } + }; + orange.ondrop = function(e) { + e.preventDefault(); + if( !e.dataTransfer.files ) { + fails[fails.length] = 'No dataTransfer.files for '+e.type; + } + if( !window.FileList ) { + fails[fails.length] = 'No FileList interface object'; + finish(); + return; + } + if( !( e.dataTransfer.files instanceof FileList ) ) { + fails[fails.length] = 'dataTransfer.files is not a FileList'; + } + if( e.dataTransfer.files.length != 2 ) { + fails[fails.length] = 'dataTransfer.files.length is '+e.dataTransfer.files.length+' instead of 2 for '+e.type; + } + if( !e.dataTransfer.files[0] ) { + fails[fails.length] = 'no dataTransfer.files[0] for drop'; + finish(); + return; + } + if( !e.dataTransfer.files[1] ) { + fails[fails.length] = 'no dataTransfer.files[1] for drop'; + finish(); + return; + } + //allow files to be dropped in any order, since this will be determined by the OS + var i0 = 0, i1 = 1; + if( e.dataTransfer.files[0].name == filename2 ) { + i0 = 1; + i1 = 0; + } + if( e.dataTransfer.files[i0].size != filesize1 ) { + fails[fails.length] = 'dataTransfer.files['+i0+'].size '+e.dataTransfer.files[i0].size+' instead of '+filesize1; + } + /* + if( !e.dataTransfer.files[i0].lastModified ) { + fails[fails.length] = 'no dataTransfer.files['+i0+'].lastModified'; + } + */ + if( e.dataTransfer.files[i0].name != filename1 ) { + fails[fails.length] = 'dataTransfer.files['+i0+'].name '+e.dataTransfer.files[i0].name+' instead of '+filename1; + } + if( e.dataTransfer.files[i0].type != filetype1 ) { + fails[fails.length] = 'dataTransfer.files['+i0+'].type '+e.dataTransfer.files[i0].type+' instead of '+filetype1; + } + if( e.dataTransfer.files[i1].size != filesize2 ) { + fails[fails.length] = 'dataTransfer.files['+i1+'].size '+e.dataTransfer.files[i1].size+' instead of '+filesize2; + } + /* + if( !e.dataTransfer.files[i1].lastModified ) { + fails[fails.length] = 'no dataTransfer.files['+i1+'].lastModified'; + } + */ + if( e.dataTransfer.files[i1].name != filename2 ) { + fails[fails.length] = 'dataTransfer.files['+i1+'].name '+e.dataTransfer.files[i1].name+' instead of '+filename2; + } + if( e.dataTransfer.files[i1].type != filetype2 ) { + fails[fails.length] = 'dataTransfer.files['+i1+'].type '+e.dataTransfer.files[i1].type+' instead of '+filetype2; + } + if( !window.FileReader ) { + fails[fails.length] = 'No FileReader constructor'; + finish(); + return; + } + var reader1 = new FileReader(); + reader1.readAsBinaryString(e.dataTransfer.files[i0]); + reader1.onload = function () { + if( !reader1.result ) { + fails[fails.length] = 'No files['+i0+'] data after load'; + } + if( reader1.result.length != filesize1 ) { + fails[fails.length] = 'files['+i0+'] file data length '+reader1.result.length+' instead of '+filesize1; + } + if( donecount++ ) { + finish(); + } + }; + var reader2 = new FileReader(); + reader2.onload = function () { + if( !reader2.result ) { + fails[fails.length] = 'No files['+i1+'] data after load'; + } + if( reader2.result.length != filesize2 ) { + fails[fails.length] = 'files['+i1+'] file data length '+reader2.result.length+' instead of '+filesize2; + } + if( donecount++ ) { + finish(); + } + }; + reader2.readAsBinaryString(e.dataTransfer.files[i1]); + setTimeout(function () { + if( !reader1.result ) { + fails[fails.length] = 'No files['+i0+'] data after timeout'; + } + if( !reader2.result ) { + fails[fails.length] = 'No files['+i1+'] data after timeout'; + } + finish(); + },1000); + }; + +}; +function finish() { + if( finished ) { return; } + finished = true; + document.getElementsByTagName('p')[0].innerHTML = fails.length ? ( 'FAIL: ' + fails.join('<br>') ) : 'PASS'; +} +</script> + +<div></div> + +<p>Save <a href="../resources/fail.png">this image</a> and <a href="fail.txt">this text file</a> to your desktop. Use your pointing device to drag both saved files (at the same time) from your desktop onto the orange box, and release them. If a confirmation dialog appears, accept it. Fail if nothing happens, or if the browser simply displays one/both of the files.</p> +<noscript><p>Enable JavaScript and reload</p></noscript> diff --git a/testing/web-platform/tests/html/editing/dnd/file/003.html b/testing/web-platform/tests/html/editing/dnd/file/003.html new file mode 100644 index 0000000000..51e5a5a79c --- /dev/null +++ b/testing/web-platform/tests/html/editing/dnd/file/003.html @@ -0,0 +1,90 @@ +<!DOCTYPE html> +<title>drag & drop - prompting before exposing files</title> +<style> + body > div { + height: 200px; + width: 200px; + background-color: orange; + } +</style> + +<script> +var filename = 'fail.png', filesize = '759', filetype = 'image/png'; +var fails = [], finished = false; +window.onload = function() { + var orange = document.getElementsByTagName('div')[0]; + orange.ondragover = orange.ondragenter = function(e) { + e.preventDefault(); + e.dataTransfer.dropEffect = 'copy'; + }; + orange.ondrop = function(e) { + e.preventDefault(); + if( !e.dataTransfer.files ) { + fails[fails.length] = 'No dataTransfer.files for '+e.type; + } + if( !window.FileList ) { + fails[fails.length] = 'No FileList interface object'; + finish(); + return; + } + if( !( e.dataTransfer.files instanceof FileList ) ) { + fails[fails.length] = 'dataTransfer.files is not a FileList'; + } + if( e.dataTransfer.files.length != 1 ) { + fails[fails.length] = 'dataTransfer.files.length is '+e.dataTransfer.files.length+' instead of 1 for '+e.type; + } + if( !e.dataTransfer.files[0] ) { + fails[fails.length] = 'no dataTransfer.files[0] for drop'; + finish(); + return; + } + if( e.dataTransfer.files[0].size != filesize ) { + fails[fails.length] = 'dataTransfer.files[0].size '+e.dataTransfer.files[0].size+' instead of '+filesize; + } + /* + if( !e.dataTransfer.files[0].lastModified ) { + fails[fails.length] = 'no dataTransfer.files[0].lastModified'; + } + */ + if( e.dataTransfer.files[0].name != filename ) { + fails[fails.length] = 'dataTransfer.files[0].name '+e.dataTransfer.files[0].name+' instead of '+filename; + } + if( e.dataTransfer.files[0].type != filetype ) { + fails[fails.length] = 'dataTransfer.files[0].type '+e.dataTransfer.files[0].type+' instead of '+filetype; + } + if( !window.FileReader ) { + fails[fails.length] = 'No FileReader constructor'; + finish(); + return; + } + var reader = new FileReader(); + reader.onload = function () { + if( !reader.result ) { + fails[fails.length] = 'No file data after load'; + } + if( reader.result.length != filesize ) { + fails[fails.length] = 'File data length '+reader.result.length+' instead of '+filesize; + } + finish(); + }; + reader.readAsBinaryString(e.dataTransfer.files[0]); + setTimeout(function () { + if( !reader.result ) { + fails[fails.length] = 'No file data after timeout'; + } + finish(); + },1000); + }; + +}; +function finish() { + if( finished ) { return; } + finished = true; + document.getElementsByTagName('p')[0].innerHTML = fails.length ? ( 'FAIL: ' + fails.join('<br>') ) : 'PASS'; +} +</script> + +<div></div> + +<p>Save <a href="../resources/fail.png">this image</a> to your desktop. Use your pointing device to drag the saved file from your desktop onto the orange box, and release it. <strong>A confirmation dialog must appear, allowing you to choose to cancel the upload</strong>. Accept it. Fail if nothing happens, or if the browser simply displays the image, or if "PASS" appears as the page text <strong>before</strong> you have accepted the upload.</p> +<noscript><p>Enable JavaScript and reload</p></noscript> diff --git a/testing/web-platform/tests/html/editing/dnd/file/004.html b/testing/web-platform/tests/html/editing/dnd/file/004.html new file mode 100644 index 0000000000..ee0d63455f --- /dev/null +++ b/testing/web-platform/tests/html/editing/dnd/file/004.html @@ -0,0 +1,51 @@ +<!DOCTYPE html> +<title>drag & drop - cancelling the dropped file upload</title> +<style> + body > div { + height: 200px; + width: 200px; + background-color: orange; + } +</style> + +<script> +var fails = []; +window.onload = function() { + var orange = document.getElementsByTagName('div')[0]; + orange.ondragover = orange.ondragenter = function(e) { + e.preventDefault(); + e.dataTransfer.dropEffect = 'copy'; + }; + orange.ondrop = function(e) { + //if the browser simulates a drop, it must do so with an empty FileList + e.preventDefault(); + if( !e.dataTransfer.files ) { + fails[fails.length] = 'No dataTransfer.files for '+e.type; + } + if( !window.FileList ) { + fails[fails.length] = 'No FileList interface object'; + finish(); + return; + } + if( !( e.dataTransfer.files instanceof FileList ) ) { + fails[fails.length] = 'dataTransfer.files is not a FileList'; + } + if( e.dataTransfer.files.length ) { + fails[fails.length] = 'dataTransfer.files.length is '+e.dataTransfer.files.length+' instead of 0 for '+e.type; + } + if( e.dataTransfer.files[0] ) { + fails[fails.length] = 'dataTransfer.files[0] exists for drop'; + finish(); + } + }; + +}; +function finish() { + document.getElementsByTagName('p')[0].innerHTML = fails.length ? ( 'FAIL: ' + fails.join('<br>') ) : 'PASS'; +} +</script> + +<div></div> + +<p>Save <a href="../resources/pass.png">this image</a> to your desktop. Use your pointing device to drag the saved file from your desktop onto the orange box, and release it. <strong>A confirmation dialog must appear, allowing you to choose to cancel the upload</strong>. Refuse it. Pass if nothing happens, or if the browser simply displays the image.</p> +<noscript><p>Enable JavaScript and reload</p></noscript> diff --git a/testing/web-platform/tests/html/editing/dnd/file/005.html b/testing/web-platform/tests/html/editing/dnd/file/005.html new file mode 100644 index 0000000000..afb40e2199 --- /dev/null +++ b/testing/web-platform/tests/html/editing/dnd/file/005.html @@ -0,0 +1,13 @@ +<!DOCTYPE html> +<title>drag & drop - dragging text onto a file input</title> + +<ol> + <li>Save <a href="../resources/filler.html">this file</a> to your computer.</li> + <li>Write the full /path/and/name to that file, into the first input below, then select all of the text you just entered.</li> + <li>Drag selected text to the file input. If no prompt appears, and the text is not added to the file input, pass and ignore further steps.</li> + <li>If a prompt appears, accept it. Fail if the file input's value is set without any prompts.</li> + <li>If a prompt appears; fail if the file input's value is not set after accepting the prompt.</li> +</ol> +<p><input value="/tmp/filler.html"></p> +<p><input type="file"></p> +<noscript><p>Enable JavaScript and reload</p></noscript> diff --git a/testing/web-platform/tests/html/editing/dnd/file/006.html b/testing/web-platform/tests/html/editing/dnd/file/006.html new file mode 100644 index 0000000000..d25c5491e4 --- /dev/null +++ b/testing/web-platform/tests/html/editing/dnd/file/006.html @@ -0,0 +1,13 @@ +<!DOCTYPE html> +<title>drag & drop - cancelling dragging text onto a file input</title> + +<ol> + <li>Save <a href="../resources/filler.html">this file</a> to your computer.</li> + <li>Write the full /path/and/name to that file, into the first input below, then select all of the text you just entered.</li> + <li>Drag selected text to the file input. If no prompt appears, and the text is not added to the file input, pass and ignore further steps.</li> + <li>If a prompt appears, refuse it. Fail if the file input's value is set without any prompts.</li> + <li>If a prompt appears; fail if the file input's value is set after refusing the prompt.</li> +</ol> +<p><input value="/tmp/filler.html"></p> +<p><input type="file"></p> +<noscript><p>Enable JavaScript and reload</p></noscript> diff --git a/testing/web-platform/tests/html/editing/dnd/file/007.html b/testing/web-platform/tests/html/editing/dnd/file/007.html new file mode 100644 index 0000000000..046220bdb6 --- /dev/null +++ b/testing/web-platform/tests/html/editing/dnd/file/007.html @@ -0,0 +1,99 @@ +<!DOCTYPE html> +<title>drag & drop - file drop for large file</title> +<style> + body > div { + height: 200px; + width: 200px; + background-color: orange; + } +</style> + +<script> +//JavaScript can support file sizes up to 9007199254740992 bytes ... in theory +//This test uses a more sane value, just for the sake of UI testing - 32 MB +var filesize1 = 33554432, filesize2 = 134217728; +var fails = [], finished = false; +window.onload = function() { + var orange = document.getElementsByTagName('div')[0]; + orange.ondragover = orange.ondragenter = function(e) { + e.preventDefault(); + e.dataTransfer.dropEffect = 'copy'; + if( !e.dataTransfer.files ) { + fails[fails.length] = 'No dataTransfer.files for '+e.type; + } + if( !window.FileList ) { + fails[fails.length] = 'No FileList interface object'; + return; + } + if( !( e.dataTransfer.files instanceof FileList ) ) { + fails[fails.length] = 'dataTransfer.files is not a FileList'; + } + if( e.dataTransfer.files.length ) { + fails[fails.length] = 'dataTransfer.files.length is '+e.dataTransfer.files.length+' instead of 0 for '+e.type; + } + }; + orange.ondrop = function(e) { + e.preventDefault(); + if( !e.dataTransfer.files ) { + fails[fails.length] = 'No dataTransfer.files for '+e.type; + } + if( !window.FileList ) { + fails[fails.length] = 'No FileList interface object'; + finish(); + return; + } + if( !( e.dataTransfer.files instanceof FileList ) ) { + fails[fails.length] = 'dataTransfer.files is not a FileList'; + } + if( e.dataTransfer.files.length != 1 ) { + fails[fails.length] = 'dataTransfer.files.length is '+e.dataTransfer.files.length+' instead of 1 for '+e.type; + } + if( !e.dataTransfer.files[0] ) { + fails[fails.length] = 'no dataTransfer.files[0] for drop'; + finish(); + return; + } + if( e.dataTransfer.files[0].size != filesize1 && e.dataTransfer.files[0].size != filesize2 ) { + fails[fails.length] = 'dataTransfer.files[0].size '+e.dataTransfer.files[0].size+' instead of '+filesize1+' or '+filesize2; + } + /* + if( !e.dataTransfer.files[0].lastModified ) { + fails[fails.length] = 'no dataTransfer.files[0].lastModified'; + } + */ + if( !window.FileReader ) { + fails[fails.length] = 'No FileReader constructor'; + finish(); + return; + } + var reader = new FileReader(); + reader.readAsBinaryString(e.dataTransfer.files[0]); + reader.onload = function () { + if( !reader.result ) { + fails[fails.length] = 'No file data after load'; + } + if( reader.result.length != filesize1 && reader.result.length != filesize2 ) { + fails[fails.length] = 'File data length '+reader.result.length+' instead of '+filesize1+' or '+filesize2; + } + finish(); + }; + setTimeout(function () { + if( !reader.result ) { + fails[fails.length] = 'No file data after timeout'; + } + finish(); + },1000); + }; + +}; +function finish() { + if( finished ) { return; } + finished = true; + document.getElementsByTagName('p')[0].innerHTML = fails.length ? ( 'FAIL: ' + fails.join('<br>') ) : 'PASS if the UI did not lock up'; +} +</script> + +<div></div> + +<p>Save <a href="../resources/32mb.py">32MB.txt</a> to your desktop. Use your pointing device to drag the saved file from your desktop onto the orange box, and release it. If a confirmation dialog appears, accept it. Fail if this text is not replaced with a pass message. Fail if the UI locks up immediately after dropping the file.</p> +<noscript><p>Enable JavaScript and reload</p></noscript> diff --git a/testing/web-platform/tests/html/editing/dnd/file/008.html b/testing/web-platform/tests/html/editing/dnd/file/008.html new file mode 100644 index 0000000000..4975158209 --- /dev/null +++ b/testing/web-platform/tests/html/editing/dnd/file/008.html @@ -0,0 +1,113 @@ +<!DOCTYPE html> +<title>drag & drop - dropping folders</title> +<style> + body > div { + height: 200px; + width: 200px; + background-color: orange; + } +</style> + +<script> +var fails = [], finished = false; +window.onload = function() { + var orange = document.getElementsByTagName('div')[0]; + orange.ondragover = orange.ondragenter = function(e) { + e.preventDefault(); + e.dataTransfer.dropEffect = 'copy'; + if( !e.dataTransfer.files ) { + fails[fails.length] = 'No dataTransfer.files for '+e.type; + } + if( !window.FileList ) { + fails[fails.length] = 'No FileList interface object'; + return; + } + if( !( e.dataTransfer.files instanceof FileList ) ) { + fails[fails.length] = 'dataTransfer.files is not a FileList'; + } else if( e.dataTransfer.files.length ) { + fails[fails.length] = 'dataTransfer.files.length is '+e.dataTransfer.files.length+' instead of 0 for '+e.type; + } + }; + orange.ondrop = function(e) { + e.preventDefault(); + if( !e.dataTransfer.files ) { + fails[fails.length] = 'No dataTransfer.files for '+e.type; + } + if( !window.FileList ) { + fails[fails.length] = 'No FileList interface object'; + finish(); + return; + } + if( !( e.dataTransfer.files instanceof FileList ) ) { + fails[fails.length] = 'dataTransfer.files is not a FileList'; + } + //browsers represent it as a single file (name matching the folder) + //also allow no files, since that is a valid solution + if( e.dataTransfer.files.length > 1 ) { + //dropping the contents of the folder would be crazy, since there could literally be millions of files, or the entire disk contents + fails[fails.length] = 'dataTransfer.files.length is '+e.dataTransfer.files.length+' instead of 1 for '+e.type; + } + if( !e.dataTransfer.files[0] ) { + finish(); + return; + } + /* + Windows 7 sometimes randomly assigns size to folders, and that is presented to the browser. + Strangely, packing and unpacking that folder can remove its size. + Since this is an OS quirk that we have no control over, the test will not check the size. + if( e.dataTransfer.files[0].size ) { + fails[fails.length] = 'dataTransfer.files[0].size '+e.dataTransfer.files[0].size+' instead of 0'; + } + */ + /* + if( !e.dataTransfer.files[0].lastModified ) { + fails[fails.length] = 'no dataTransfer.files[0].lastModified'; + } + */ + if( !window.FileReader ) { + fails[fails.length] = 'No FileReader constructor'; + finish(); + return; + } + var reader = new FileReader(); + reader.onload = function () { + fails[fails.length] = 'File managed to load even though it was a folder '+e.type; + finish(); + }; + reader.onerror = function () { + finish(); + }; + try { + reader.readAsBinaryString(e.dataTransfer.files[0]); + } catch(err) { + fails[fails.length] = 'Threw an error when trying to read the file '+e.type; + finish(); + return; + } + setTimeout(function () { + fails[fails.length] = 'Onerror failed to fire '+reader.error.code; + finish(); + },1000); + }; + +}; +function finish() { + if( finished ) { return; } + finished = true; + document.getElementsByTagName('p')[0].innerHTML = fails.length ? ( 'FAIL: ' + fails.join('<br>') ) : 'PASS'; +} +</script> + +<div></div> + +<p>Drag a folder containing at least 2 files, from your computer's file manager, onto the orange box above. If a no-drop cursor was shown and no text changes when the folder is dropped, pass and ignore further conditions. If a prompt appears, accept it. Fail if the mouse cursor makes it look like it will work but nothing happens.</p> +<p>This test needs to be repeated with:</p> +<ul> + <li>A regular folder containing at least 2 items</li> + <li>A disk drive (if your OS exposes them) containing at least 2 items</li> + <li>The system trash/recycle bin folder (if your OS exposes one) containing at least 2 items</li> + <li>The "My Computer" folder (if your OS provides it)</li> + <li>Your "My Documents" folder (if your OS provides it)</li> + <li>A folder that you do not have permissions to access</li> +</ul> +<noscript><p>Enable JavaScript and reload</p></noscript> diff --git a/testing/web-platform/tests/html/editing/dnd/file/009.html b/testing/web-platform/tests/html/editing/dnd/file/009.html new file mode 100644 index 0000000000..72381863f2 --- /dev/null +++ b/testing/web-platform/tests/html/editing/dnd/file/009.html @@ -0,0 +1,16 @@ +<!DOCTYPE html> +<title>drag & drop - no dnd event listeners</title> +<style> + body > div { + height: 200px; + width: 200px; + background-color: orange; + } +</style> + +<!-- This test assumes that the browser's default behaviour is to open dropped files. Test 010 continues with this assumption. --> + +<div></div> + +<p>Save <a href="../resources/pass.png">this image</a> to your desktop. Use your pointing device to drag the saved file from your desktop onto the orange box, and release it. Fail if nothing happens.</p> +<noscript><p>Enable JavaScript and reload</p></noscript> diff --git a/testing/web-platform/tests/html/editing/dnd/file/010.html b/testing/web-platform/tests/html/editing/dnd/file/010.html new file mode 100644 index 0000000000..331cafc5ef --- /dev/null +++ b/testing/web-platform/tests/html/editing/dnd/file/010.html @@ -0,0 +1,29 @@ +<!DOCTYPE html> +<title>drag & drop - blocked drop</title> +<style> + body > div { + height: 200px; + width: 200px; + background-color: orange; + } +</style> + +<script> +//This test assumes that if the page does not want to use the drop, that the browser will revert to default behaviour of opening the file +window.onload = function() { + var orange = document.getElementsByTagName('div')[0]; + orange.ondragover = orange.ondragenter = function(e) { + e.preventDefault(); + e.dataTransfer.dropEffect = 'none'; + }; + orange.ondrop = function(e) { + e.preventDefault(); + }; + +}; +</script> + +<div></div> + +<p>Save <a href="../resources/pass.png">this image</a> to your desktop. Use your pointing device to drag the saved file from your desktop onto the orange box, and release it. Fail if nothing happens.</p> +<noscript><p>Enable JavaScript and reload</p></noscript> diff --git a/testing/web-platform/tests/html/editing/dnd/file/011.html b/testing/web-platform/tests/html/editing/dnd/file/011.html new file mode 100644 index 0000000000..a265e7b4dd --- /dev/null +++ b/testing/web-platform/tests/html/editing/dnd/file/011.html @@ -0,0 +1,93 @@ +<!DOCTYPE html> +<title>drag & drop - simple file drop with dropzone attribute</title> +<style> + body > div { + height: 200px; + width: 200px; + background-color: orange; + } +</style> + +<script> +var filename = 'fail.png', filesize = '759', filetype = 'image/png'; +var fails = [], finished = false; +window.onload = function() { + var orange = document.getElementsByTagName('div')[0]; + orange.ondragenter = function(e) { + e.dataTransfer.dropEffect = 'copy'; + }; +/* orange.ondragover = function(e) { + e.preventDefault(); + }; +*/ + orange.ondrop = function(e) { + e.preventDefault(); + if( !e.dataTransfer.files ) { + fails[fails.length] = 'No dataTransfer.files for '+e.type; + } + if( !window.FileList ) { + fails[fails.length] = 'No FileList interface object'; + finish(); + return; + } + if( !( e.dataTransfer.files instanceof FileList ) ) { + fails[fails.length] = 'dataTransfer.files is not a FileList'; + } + if( e.dataTransfer.files.length != 1 ) { + fails[fails.length] = 'dataTransfer.files.length is '+e.dataTransfer.files.length+' instead of 1 for '+e.type; + } + if( !e.dataTransfer.files[0] ) { + fails[fails.length] = 'no dataTransfer.files[0] for drop'; + finish(); + return; + } + if( e.dataTransfer.files[0].size != filesize ) { + fails[fails.length] = 'dataTransfer.files[0].size '+e.dataTransfer.files[0].size+' instead of '+filesize; + } + /* + if( !e.dataTransfer.files[0].lastModified ) { + fails[fails.length] = 'no dataTransfer.files[0].lastModified'; + } + */ + if( e.dataTransfer.files[0].name != filename ) { + fails[fails.length] = 'dataTransfer.files[0].name '+e.dataTransfer.files[0].name+' instead of '+filename; + } + if( e.dataTransfer.files[0].type != filetype ) { + fails[fails.length] = 'dataTransfer.files[0].type '+e.dataTransfer.files[0].type+' instead of '+filetype; + } + if( !window.FileReader ) { + fails[fails.length] = 'No FileReader constructor'; + finish(); + return; + } + var reader = new FileReader(); + reader.onload = function () { + if( !reader.result ) { + fails[fails.length] = 'No file data after load'; + } + if( reader.result.length != filesize ) { + fails[fails.length] = 'File data length '+reader.result.length+' instead of '+filesize; + } + finish(); + }; + reader.readAsBinaryString(e.dataTransfer.files[0]); + setTimeout(function () { + if( !reader.result ) { + fails[fails.length] = 'No file data after timeout'; + } + finish(); + },1000); + }; + +}; +function finish() { + if( finished ) { return; } + finished = true; + document.getElementsByTagName('p')[0].innerHTML = fails.length ? ( 'FAIL: ' + fails.join('<br>') ) : 'PASS'; +} +</script> + +<div dropzone="copy file:image/png"></div> + +<p>Save <a href="../resources/fail.png">this image</a> to your desktop. Use your pointing device to drag the saved file from your desktop onto the orange box, and release it. If a confirmation dialog appears, accept it. Fail if nothing happens, or if the browser simply displays the image.</p> +<noscript><p>Enable JavaScript and reload</p></noscript> diff --git a/testing/web-platform/tests/html/editing/dnd/file/fail.txt b/testing/web-platform/tests/html/editing/dnd/file/fail.txt new file mode 100644 index 0000000000..fc26162516 --- /dev/null +++ b/testing/web-platform/tests/html/editing/dnd/file/fail.txt @@ -0,0 +1 @@ +FAIL
\ No newline at end of file diff --git a/testing/web-platform/tests/html/editing/dnd/file/prompt/001.html b/testing/web-platform/tests/html/editing/dnd/file/prompt/001.html new file mode 100644 index 0000000000..52f6e8d01f --- /dev/null +++ b/testing/web-platform/tests/html/editing/dnd/file/prompt/001.html @@ -0,0 +1,28 @@ +<!DOCTYPE html> +<title>drag & drop - file drop prompt for basic server name</title> +<style> + body > div { + height: 200px; + width: 200px; + background-color: orange; + } +</style> + +<script> +window.onload = function() { + if( location.protocol != 'http:' && location.protocol != 'https:' ) { + document.getElementsByTagName('p')[0].innerHTML = 'This test should be loaded over http or https.'; + return; + } + var orange = document.getElementsByTagName('div')[0]; + orange.ondragover = orange.ondragenter = orange.ondrop = function(e) { + e.preventDefault(); + }; + document.getElementsByTagName('span')[0].innerHTML = location.hostname; +}; +</script> + +<div></div> + +<p>Drag a file from your desktop onto the orange square. A prompt should appear, correctly identifying the server name as <span></span></p> +<noscript><p>Enable JavaScript and reload</p></noscript> diff --git a/testing/web-platform/tests/html/editing/dnd/file/prompt/002.html b/testing/web-platform/tests/html/editing/dnd/file/prompt/002.html new file mode 100644 index 0000000000..f913aedfac --- /dev/null +++ b/testing/web-platform/tests/html/editing/dnd/file/prompt/002.html @@ -0,0 +1,39 @@ +<!DOCTYPE html> +<title>drag & drop - file drop prompt for server name and document.domain</title> +<style> + body > div { + height: 200px; + width: 200px; + background-color: orange; + } +</style> + +<script> +window.onload = function() { + if( location.protocol != 'http:' && location.protocol != 'https:' ) { + document.getElementsByTagName('p')[0].innerHTML = 'This test should be loaded over http or https.'; + return; + } + if( !location.hostname.match(/[^\.]\.[^\.]+\.[^\.]/) ) { + document.getElementsByTagName('p')[0].innerHTML = 'This test should be loaded from a subdomain that allows document.domain to be set to a parent domain (try using a server name that contains at least two or three dots, for example www.example.org).'; + return; + } + var realhost = location.hostname, newdomain = location.hostname.replace(/^[^.]+\./,''); + try { + document.domain = location.hostname.replace(/^[^.]+\./,''); + } catch(e) { + document.getElementsByTagName('p')[0].innerHTML = 'This test should be loaded from a subdomain that allows document.domain to be set to a parent domain.'; + return; + } + var orange = document.getElementsByTagName('div')[0]; + orange.ondragover = orange.ondragenter = orange.ondrop = function(e) { + e.preventDefault(); + }; + document.getElementsByTagName('span')[0].innerHTML = realhost; +}; +</script> + +<div></div> + +<p>Drag a file from your desktop onto the orange square. A prompt should appear, identifying the server name as <span></span></p> +<noscript><p>Enable JavaScript and reload</p></noscript> diff --git a/testing/web-platform/tests/html/editing/dnd/file/prompt/003.html b/testing/web-platform/tests/html/editing/dnd/file/prompt/003.html new file mode 100644 index 0000000000..ada495bd19 --- /dev/null +++ b/testing/web-platform/tests/html/editing/dnd/file/prompt/003.html @@ -0,0 +1,28 @@ +<!DOCTYPE html> +<title>drag & drop - file drop prompt for ftp server name</title> +<style> + body > div { + height: 200px; + width: 200px; + background-color: orange; + } +</style> + +<script> +window.onload = function() { + if( location.protocol != 'ftp:' ) { + document.getElementsByTagName('p')[0].innerHTML = 'This test should be loaded over ftp.'; + return; + } + var orange = document.getElementsByTagName('div')[0]; + orange.ondragover = orange.ondragenter = orange.ondrop = function(e) { + e.preventDefault(); + }; + document.getElementsByTagName('span')[0].innerHTML = location.hostname; +}; +</script> + +<div></div> + +<p>Drag a file from your desktop onto the orange square. A prompt should appear, correctly identifying the server name as <span></span></p> +<noscript><p>Enable JavaScript and reload</p></noscript> diff --git a/testing/web-platform/tests/html/editing/dnd/file/prompt/004.html b/testing/web-platform/tests/html/editing/dnd/file/prompt/004.html new file mode 100644 index 0000000000..0232638ef8 --- /dev/null +++ b/testing/web-platform/tests/html/editing/dnd/file/prompt/004.html @@ -0,0 +1,27 @@ +<!DOCTYPE html> +<title>drag & drop - file drop prompt for file:</title> +<style> + body > div { + height: 200px; + width: 200px; + background-color: orange; + } +</style> + +<script> +window.onload = function() { + if( location.protocol != 'file:' ) { + document.getElementsByTagName('p')[0].innerHTML = 'Save this page to your local filesystem, and load it from there.'; + return; + } + var orange = document.getElementsByTagName('div')[0]; + orange.ondragover = orange.ondragenter = orange.ondrop = function(e) { + e.preventDefault(); + }; +}; +</script> + +<div></div> + +<p>Drag a file from your desktop onto the orange square. A prompt should appear, either showing the server name as localhost, or otherwise identifying this file as the target of the upload.</p> +<noscript><p>Enable JavaScript and reload</p></noscript> diff --git a/testing/web-platform/tests/html/editing/dnd/file/prompt/005.html b/testing/web-platform/tests/html/editing/dnd/file/prompt/005.html new file mode 100644 index 0000000000..3a6c356c2e --- /dev/null +++ b/testing/web-platform/tests/html/editing/dnd/file/prompt/005.html @@ -0,0 +1,27 @@ +<!DOCTYPE html> +<title>drag & drop - file drop prompt for special cases</title> +<style> + body > div { + height: 200px; + width: 200px; + background-color: orange; + } +</style> + +<script> +window.onload = function() { + if( location.protocol == 'file:' || location.protocol == 'http:' || location.protocol == 'https:' ) { + document.getElementsByTagName('p')[0].innerHTML = 'Use the source of this file as the source of special-case URLs within your browser, such as scriptable chrome: or opera: or attachment: URLs (eg. opera:config and send yourself the file as an email attachments and open the attachment in the browser).'; + return; + } + var orange = document.getElementsByTagName('div')[0]; + orange.ondragover = orange.ondragenter = orange.ondrop = function(e) { + e.preventDefault(); + }; +}; +</script> + +<div></div> + +<p>Drag a file from your desktop onto the orange square. A prompt should appear, either showing the server name as unknown, or otherwise identifying this URL as the target of the upload.</p> +<noscript><p>Enable JavaScript and reload</p></noscript> diff --git a/testing/web-platform/tests/html/editing/dnd/file/prompt/006.html b/testing/web-platform/tests/html/editing/dnd/file/prompt/006.html new file mode 100644 index 0000000000..a0f919595b --- /dev/null +++ b/testing/web-platform/tests/html/editing/dnd/file/prompt/006.html @@ -0,0 +1,41 @@ +<!DOCTYPE html> +<title>drag & drop - file drop prompt for data URI with inherited origin</title> +<style> +iframe { border: none; height: 250px; width: 250px; } +</style> + +<script> +window.onload = function() { + if( location.protocol != 'http:' && location.protocol != 'https:' ) { + document.getElementsByTagName('p')[0].innerHTML = 'This test should be loaded over http or https.'; + return; + } + var url = "data:text/html,"+escape( +'<!DOCTYPE html>\ +<title>drag & drop - file drop prompt for data URI with inherited origin<\/title>\ +<style>\ + body > div {\ + height: 200px;\ + width: 200px;\ + background-color: orange;\ + }\ +<\/style>\ +<script>\ +window.onload = function() {\ + var orange = document.getElementsByTagName("div")[0];\ + orange.ondragover = orange.ondragenter = orange.ondrop = function(e) {\ + e.preventDefault();\ + };\ +};\ +<\/script>\ +<div><\/div>' + ); + var frame = document.createElement('iframe'); + frame.setAttribute('src',url); + document.body.appendChild(frame); + document.getElementsByTagName('span')[0].innerHTML = location.hostname; +}; +</script> + +<p>Drag a file from your desktop onto the orange square. A prompt should appear, correctly identifying the server name <span></span>.</p> +<noscript><p>Enable JavaScript and reload</p></noscript> diff --git a/testing/web-platform/tests/html/editing/dnd/file/prompt/007.html b/testing/web-platform/tests/html/editing/dnd/file/prompt/007.html new file mode 100644 index 0000000000..be839f99c9 --- /dev/null +++ b/testing/web-platform/tests/html/editing/dnd/file/prompt/007.html @@ -0,0 +1,32 @@ +<!DOCTYPE html> +<title>drag & drop - file drop prompt for data URI without inherited origin</title> +<script> +window.onload = function() { + var url = "data:text/html,"+escape( +'<!DOCTYPE html>\ +<title>drag & drop - file drop prompt for data URI with inherited origin<\/title>\ +<style>\ + body > div {\ + height: 200px;\ + width: 200px;\ + background-color: orange;\ + }\ +<\/style>\ +<script>\ +window.onload = function() {\ + var orange = document.getElementsByTagName("div")[0];\ + orange.ondragover = orange.ondragenter = orange.ondrop = function(e) {\ + e.preventDefault();\ + };\ +};\ +<\/script>\ +<div><\/div>\ +<p>Drag a file from your desktop onto the orange square. A prompt should appear, either showing the server name as unknown, or otherwise identifying this URL as the target of the upload.<\/p>' + ); + document.getElementsByTagName('p')[1].textContent = url; +}; +</script> + +<p>Load the following URL in a new tab (copy & paste it into the address bar):</p> +<p></p> +<noscript><p>Enable JavaScript and reload</p></noscript> diff --git a/testing/web-platform/tests/html/editing/dnd/file/prompt/008.html b/testing/web-platform/tests/html/editing/dnd/file/prompt/008.html new file mode 100644 index 0000000000..903808ea0d --- /dev/null +++ b/testing/web-platform/tests/html/editing/dnd/file/prompt/008.html @@ -0,0 +1,41 @@ +<!DOCTYPE html> +<title>drag & drop - file drop prompt for javascript URL with inherited origin</title> +<style> +iframe { border: none; height: 250px; width: 250px; } +</style> + +<script> +window.onload = function() { + if( location.protocol != 'http:' && location.protocol != 'https:' ) { + document.getElementsByTagName('p')[0].innerHTML = 'This test should be loaded over http or https.'; + return; + } + var url = "javascript:'"+escape( +'<!DOCTYPE html>\ +<title>drag & drop - file drop prompt for data URI with inherited origin<\/title>\ +<style>\ + body > div {\ + height: 200px;\ + width: 200px;\ + background-color: orange;\ + }\ +<\/style>\ +<script>\ +window.onload = function() {\ + var orange = document.getElementsByTagName("div")[0];\ + orange.ondragover = orange.ondragenter = orange.ondrop = function(e) {\ + e.preventDefault();\ + };\ +};\ +<\/script>\ +<div><\/div>' + +"'"); + var frame = document.createElement('iframe'); + frame.setAttribute('src',url); + document.body.appendChild(frame); + document.getElementsByTagName('span')[0].innerHTML = location.hostname; +}; +</script> + +<p>Drag a file from your desktop onto the orange square. A prompt should appear, correctly identifying the server name <span></span></p> +<noscript><p>Enable JavaScript and reload</p></noscript> diff --git a/testing/web-platform/tests/html/editing/dnd/file/prompt/009.html b/testing/web-platform/tests/html/editing/dnd/file/prompt/009.html new file mode 100644 index 0000000000..b620ad6f15 --- /dev/null +++ b/testing/web-platform/tests/html/editing/dnd/file/prompt/009.html @@ -0,0 +1,32 @@ +<!DOCTYPE html> +<title>drag & drop - file drop prompt for javascript URL without inherited origin</title> +<script> +window.onload = function() { + var url = "javascript:'"+escape( +'<!DOCTYPE html>\ +<title>drag & drop - file drop prompt for data URI with inherited origin<\/title>\ +<style>\ + body > div {\ + height: 200px;\ + width: 200px;\ + background-color: orange;\ + }\ +<\/style>\ +<script>\ +window.onload = function() {\ + var orange = document.getElementsByTagName("div")[0];\ + orange.ondragover = orange.ondragenter = orange.ondrop = function(e) {\ + e.preventDefault();\ + };\ +};\ +<\/script>\ +<div><\/div>\ +<p>Drag a file from your desktop onto the orange square. A prompt should appear, either showing the server name as unknown, or otherwise identifying this URL as the target of the upload (it may alternatively identify the security context about:blank).<\/p>' + +"'"); + document.getElementsByTagName('p')[1].textContent = url; +}; +</script> + +<p>Load the following URL in a new tab (copy & paste it into the address bar):</p> +<p></p> +<noscript><p>Enable JavaScript and reload</p></noscript> |