diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
commit | 36d22d82aa202bb199967e9512281e9a53db42c9 (patch) | |
tree | 105e8c98ddea1c1e4784a60a5a6410fa416be2de /testing/web-platform/tests/html/editing/dnd/microdata/021.html | |
parent | Initial commit. (diff) | |
download | firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esr
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/html/editing/dnd/microdata/021.html')
-rw-r--r-- | testing/web-platform/tests/html/editing/dnd/microdata/021.html | 104 |
1 files changed, 104 insertions, 0 deletions
diff --git a/testing/web-platform/tests/html/editing/dnd/microdata/021.html b/testing/web-platform/tests/html/editing/dnd/microdata/021.html new file mode 100644 index 0000000000..62e1864bef --- /dev/null +++ b/testing/web-platform/tests/html/editing/dnd/microdata/021.html @@ -0,0 +1,104 @@ +<!DOCTYPE html> +<title>drag & drop - microdata when addElement is used</title> +<style> + body > div { + height: 200px; + width: 200px; + background-color: orange; + position: absolute; + top: 8px; + left: 8px; + } + body > div * { + display: none; + } + body > div + div { + background-color: navy; + left: 250px; + } + body > div + div + div { + background-color: fuchsia; + left: 500px; + } + p:first-of-type { + margin-top: 220px; + } +</style> + +<script> + +function makeEl(eltype,props,contents) { + var elem = document.createElement(eltype); + for( var i in props ) { + if( props.hasOwnProperty(i) ) { + elem.setAttribute(i,props[i]); + } + } + if( contents ) { + elem.innerHTML = contents; + } + return elem; +} + +var orange, fails = [], doneonce = false; +window.onload = function() { + orange = document.getElementsByTagName('div')[0]; + + orange.appendChild( makeEl('div',{itemprop:'foo'},'test') ); + + orange.ondragstart = function(e) { + e.dataTransfer.addElement(document.getElementById('side1')); + e.dataTransfer.addElement(document.getElementById('side2')); + e.dataTransfer.effectAllowed = 'copy'; + e.dataTransfer.setData('Text', 'dummy text'); + var err; + if( err = checkprops(e.dataTransfer.getData('application/microdata+json')) ) { + fails[fails.length] = e.type + ' ' + err; + } + }; + orange.nextSibling.ondragenter = orange.nextSibling.ondragleave = orange.nextSibling.ondragover = + orange.ondrag = orange.ondragend = function(e) { + if( e.type == 'dragover' || e.type == 'dragenter' ) { + e.preventDefault(); + e.dataTransfer.dropEffect = 'copy'; + } + if( e.dataTransfer.getData('application/microdata+json') ) { + fails[fails.length] = e.type + ' unexpectedly had microdata (security restriction)'; + } + }; + orange.nextSibling.ondrop = function(e) { + var err; + if( err = checkprops(e.dataTransfer.getData('application/microdata+json')) ) { + fails[fails.length] = e.type + ' ' + err; + } + if( e.type != 'drop' ) { return; } + if( doneonce ) { return; } + doneonce = true; + setTimeout(function () { + document.getElementsByTagName('p')[0].innerHTML = fails.length ? ( 'FAIL: ' + fails.join('<br>') ) : 'PASS'; + fails = []; + }, 200 ); + }; + +}; +function checkprops(md) { + var i; + if( !md ) { return 'no microdata'; } + md = JSON.parse(md); + if( !md.items ) { return 'no items'; } + if( md.items.length != 1 ) { return 'items.length '+md.items.length+' instead of 1'; } + if( !md.items[0].properties ) { return 'no properties'; } + if( !md.items[0].properties.foo ) { return 'no properties.foo'; } + if( md.items[0].properties.bar ) { return 'unexpected properties.bar'; } + if( md.items[0].properties.foo.length != 1 ) { return 'properties.foo length '+md.items[0].properties.foo.length+' instead of 1'; } + if( md.items[0].properties.foo[0] != orange.properties.namedItem('foo').getValues()[0] ) { return 'properties.foo[0] <i>'+md.items[0].properties.foo[0]+'</i> instead of <i>'+orange.properties.namedItem('foo').getValues()[0]+'</i>'; } + return ''; +} + +</script> + +<div draggable='true' itemscope></div><div></div><div></div> +<h4 itemscope id="side1">xxx</h4><h4 itemprop="bar" id="side2">yyy</h4> + +<p>Use your pointing device to drag the orange box to the pink box, then back to the blue box, and release it.</p> +<noscript><p>Enable JavaScript and reload</p></noscript> |