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/microdata | |
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/microdata')
23 files changed, 2411 insertions, 0 deletions
diff --git a/testing/web-platform/tests/html/editing/dnd/microdata/000.html b/testing/web-platform/tests/html/editing/dnd/microdata/000.html new file mode 100644 index 0000000000..b6e641d08f --- /dev/null +++ b/testing/web-platform/tests/html/editing/dnd/microdata/000.html @@ -0,0 +1,93 @@ +<!DOCTYPE html> +<title>drag & drop - no microdata for no itemscope</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.ondragstart = function(e) { + 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 collection'; } + if( md.items.length != 0 ) { return 'unexpected items found'; } + return ''; +} + +</script> + +<div draggable='true'></div><div></div><div></div> + +<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> diff --git a/testing/web-platform/tests/html/editing/dnd/microdata/001.html b/testing/web-platform/tests/html/editing/dnd/microdata/001.html new file mode 100644 index 0000000000..3f13565868 --- /dev/null +++ b/testing/web-platform/tests/html/editing/dnd/microdata/001.html @@ -0,0 +1,128 @@ +<!DOCTYPE html> +<title>drag & drop - microdata for non looping simple drop</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('meta',{itemprop:'foo',content:'test'}) ); + orange.appendChild( makeEl('audio',{itemprop:'bar',src:'test'},'fail') ); + orange.appendChild( makeEl('embed',{itemprop:'foo',src:'test'}) ); + orange.appendChild( makeEl('iframe',{itemprop:'bar',src:'test'},'fail') ); + orange.appendChild( makeEl('img',{itemprop:'foo',src:'test'}) ); + orange.appendChild( makeEl('source',{itemprop:'bar',src:'test'}) ); + orange.appendChild( makeEl('track',{itemprop:'foo',src:'test'}) ); + orange.appendChild( makeEl('video',{itemprop:'bar',src:'test'},'fail') ); + orange.appendChild( makeEl('a',{itemprop:'foo',href:'test'},'fail') ); + orange.appendChild( makeEl('area',{itemprop:'bar',href:'test'}) ); + orange.appendChild( makeEl('link',{itemprop:'foo',href:'test'}) ); + orange.appendChild( makeEl('object',{itemprop:'bar',data:'test'},'fail') ); + orange.appendChild( makeEl('time',{itemprop:'foo'},'fail') ); + orange.appendChild( makeEl('time',{itemprop:'baz',datetime:'test'},'fail') ); + orange.appendChild( makeEl('div',{itemprop:'baz'},'test') ); + orange.appendChild( makeEl('madeuponthespot',{itemprop:'foo'},'test') ); + orange.appendChild( makeEl('madeuponthespot',{itemprop:'foo',content:'test',src:'test',href:'test',data:'test',datetime:'test',value:'test'},'test') ); + orange.appendChild( makeEl('input',{itemprop:'foo',value:'test'},'test') ); + + orange.ondragstart = function(e) { + 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 || md.items.length != 1 ) { return 'no items'; } + 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 'no properties.bar'; } + if( !md.items[0].properties.baz ) { return 'no properties.baz'; } + if( md.items[0].properties.foo.length != 10 ) { return 'properties.foo length '+md.items[0].properties.foo.length+' instead of 10'; } + if( md.items[0].properties.bar.length != 6 ) { return 'properties.bar length '+md.items[0].properties.bar.length+' instead of 6'; } + if( md.items[0].properties.baz.length != 2 ) { return 'properties.baz length '+md.items[0].properties.baz.length+' instead of 2'; } + for( i = 0; i < 10; i++ ) { + if( md.items[0].properties.foo[i] != orange.properties.namedItem('foo').getValues()[i] ) { return 'properties.foo['+i+'] <i>'+md.items[0].properties.foo[i]+'</i> instead of <i>'+orange.properties.namedItem('foo').getValues()[i]+'</i>'; } + } + for( i = 0; i < 6; i++ ) { + if( md.items[0].properties.bar[i] != orange.properties.namedItem('bar').getValues()[i] ) { return 'properties.bar['+i+'] <i>'+md.items[0].properties.bar[i]+'</i> instead of <i>'+orange.properties.namedItem('bar').getValues()[i]+'</i>'; } + } + for( i = 0; i < 2; i++ ) { + if( md.items[0].properties.baz[i] != orange.properties.namedItem('baz').getValues()[i] ) { return 'properties.baz['+i+'] <i>'+md.items[0].properties.baz[i]+'</i> instead of <i>'+orange.properties.namedItem('baz').getValues()[i]+'</i>'; } + } + return ''; +} + +</script> + +<div draggable='true' itemscope></div><div></div><div></div> + +<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> diff --git a/testing/web-platform/tests/html/editing/dnd/microdata/002.html b/testing/web-platform/tests/html/editing/dnd/microdata/002.html new file mode 100644 index 0000000000..4e9a5e6de1 --- /dev/null +++ b/testing/web-platform/tests/html/editing/dnd/microdata/002.html @@ -0,0 +1,106 @@ +<!DOCTYPE html> +<title>drag & drop - microdata with itemref</title> +<style> + body > div { + height: 200px; + width: 200px; + background-color: orange; + position: absolute; + top: 8px; + left: 8px; + } + body > div *, span { + 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.parentNode.insertBefore( makeEl('span',{itemprop:'foo',id:'id1'},'dummytext1 '), orange ); + orange.parentNode.appendChild( makeEl('span',{itemprop:'bar',id:'id2'},'dummytext2 ') ); + orange.parentNode.appendChild( makeEl('span',{itemprop:'foo',id:'id3'},'dummytext3 ') ); + + orange.ondragstart = function(e) { + 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 || md.items.length != 1 ) { return 'no items'; } + 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 'no properties.bar'; } + if( md.items[0].properties.foo.length != 2 ) { return 'properties.foo length '+md.items[0].properties.foo.length+' instead of 2'; } + if( md.items[0].properties.bar.length != 1 ) { return 'properties.bar length '+md.items[0].properties.bar.length+' instead of 1'; } + for( i = 0; i < 2; i++ ) { + if( md.items[0].properties.foo[i] != orange.properties.namedItem('foo').getValues()[i] ) { return 'properties.foo['+i+'] <i>'+md.items[0].properties.foo[i]+'</i> instead of <i>'+orange.properties.namedItem('foo').getValues()[i]+'</i>'; } + } + if( md.items[0].properties.bar[0] != orange.properties.namedItem('bar').getValues()[0] ) { return 'properties.bar[0] <i>'+md.items[0].properties.bar[i]+'</i> instead of <i>'+orange.properties.namedItem('bar').getValues()[0]+'</i>'; } + return ''; +} + +</script> + +<div draggable='true' itemscope itemref='id3 id2 id1'></div><div></div><div></div> + +<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> diff --git a/testing/web-platform/tests/html/editing/dnd/microdata/003.html b/testing/web-platform/tests/html/editing/dnd/microdata/003.html new file mode 100644 index 0000000000..1bd0ced463 --- /dev/null +++ b/testing/web-platform/tests/html/editing/dnd/microdata/003.html @@ -0,0 +1,132 @@ +<!DOCTYPE html> +<title>drag & drop - microdata changes after dragstart</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('meta',{itemprop:'foo',content:'test'}) ); + orange.appendChild( makeEl('audio',{itemprop:'bar',src:'test'},'fail') ); + orange.appendChild( makeEl('embed',{itemprop:'foo',src:'test'}) ); + orange.appendChild( makeEl('iframe',{itemprop:'bar',src:'test'},'fail') ); + orange.appendChild( makeEl('img',{itemprop:'foo',src:'test'}) ); + orange.appendChild( makeEl('source',{itemprop:'bar',src:'test'}) ); + orange.appendChild( makeEl('track',{itemprop:'foo',src:'test'}) ); + orange.appendChild( makeEl('video',{itemprop:'bar',src:'test'},'fail') ); + orange.appendChild( makeEl('a',{itemprop:'foo',href:'test'},'fail') ); + orange.appendChild( makeEl('area',{itemprop:'bar',href:'test'}) ); + orange.appendChild( makeEl('link',{itemprop:'foo',href:'test'}) ); + orange.appendChild( makeEl('object',{itemprop:'bar',data:'test'},'fail') ); + orange.appendChild( makeEl('time',{itemprop:'foo'},'fail') ); + orange.appendChild( makeEl('time',{itemprop:'baz',datetime:'test'},'fail') ); + orange.appendChild( makeEl('div',{itemprop:'baz'},'test') ); + orange.appendChild( makeEl('madeuponthespot',{itemprop:'foo'},'test') ); + orange.appendChild( makeEl('madeuponthespot',{itemprop:'foo',content:'test',src:'test',href:'test',data:'test',datetime:'test',value:'test'},'test') ); + orange.appendChild( makeEl('input',{itemprop:'foo',value:'test'},'test') ); + + orange.ondragstart = function(e) { + 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; + } + //microdata should be stored and reused after the dragstart event + //removing the item should not cause the microdata tohave disappeared when the drop event fires + this.itemScope = false; + }; + 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, md = e.dataTransfer.getData('application/microdata+json'); + orange.itemScope = true; + if( err = checkprops(md) ) { + 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 || md.items.length != 1 ) { return 'no items'; } + 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 'no properties.bar'; } + if( !md.items[0].properties.baz ) { return 'no properties.baz'; } + if( md.items[0].properties.foo.length != 10 ) { return 'properties.foo length '+md.items[0].properties.foo.length+' instead of 10'; } + if( md.items[0].properties.bar.length != 6 ) { return 'properties.bar length '+md.items[0].properties.bar.length+' instead of 6'; } + if( md.items[0].properties.baz.length != 2 ) { return 'properties.baz length '+md.items[0].properties.baz.length+' instead of 2'; } + for( i = 0; i < 10; i++ ) { + if( md.items[0].properties.foo[i] != orange.properties.namedItem('foo').getValues()[i] ) { return 'properties.foo['+i+'] <i>'+md.items[0].properties.foo[i]+'</i> instead of <i>'+orange.properties.namedItem('foo').getValues()[i]+'</i>'; } + } + for( i = 0; i < 6; i++ ) { + if( md.items[0].properties.bar[i] != orange.properties.namedItem('bar').getValues()[i] ) { return 'properties.bar['+i+'] <i>'+md.items[0].properties.bar[i]+'</i> instead of <i>'+orange.properties.namedItem('bar').getValues()[i]+'</i>'; } + } + for( i = 0; i < 2; i++ ) { + if( md.items[0].properties.baz[i] != orange.properties.namedItem('baz').getValues()[i] ) { return 'properties.baz['+i+'] <i>'+md.items[0].properties.baz[i]+'</i> instead of <i>'+orange.properties.namedItem('baz').getValues()[i]+'</i>'; } + } + return ''; +} + +</script> + +<div draggable='true' itemscope></div><div></div><div></div> + +<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> diff --git a/testing/web-platform/tests/html/editing/dnd/microdata/004.html b/testing/web-platform/tests/html/editing/dnd/microdata/004.html new file mode 100644 index 0000000000..7ed821e54f --- /dev/null +++ b/testing/web-platform/tests/html/editing/dnd/microdata/004.html @@ -0,0 +1,116 @@ +<!DOCTYPE html> +<title>drag & drop - microdata with nested item as property</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',itemscope:'itemscope'},'') ); + orange.appendChild( makeEl('div',{itemprop:'foo',itemscope:'itemscope'},'') ); + orange.lastChild.appendChild( makeEl('div',{itemprop:'bar'},'test') ); + orange.appendChild( makeEl('div',{itemprop:'bar',itemscope:'itemscope'},'') ); + + orange.ondragstart = function(e) { + 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 md.items.length+' items 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 'no properties.bar'; } + if( md.items[0].properties.foo.length != 2 ) { return 'properties.foo length '+md.items[0].properties.foo.length+' instead of 2'; } + if( md.items[0].properties.bar.length != 1 ) { return 'properties.bar length '+md.items[0].properties.bar.length+' instead of 1'; } + + if( !md.items[0].properties.foo[0] ) { return 'properties.foo[0] <i>'+md.items[0].properties.foo[0]+'</i> instead of <i>{properties:{}}</i>'; } + if( !md.items[0].properties.foo[0].properties ) { return 'properties.foo[0].properties <i>'+md.items[0].properties.foo[0].properties+'</i> instead of <i>{}</i>'; } + + if( !md.items[0].properties.foo[1] ) { return 'properties.foo[1] <i>'+md.items[0].properties.foo[1]+'</i> instead of <i>{properties:{bar:[test]}}</i>'; } + if( !md.items[0].properties.foo[1].properties ) { return 'properties.foo[1].properties <i>'+md.items[0].properties.foo[1].properties+'</i> instead of <i>{bar:[test]}</i>'; } + if( !md.items[0].properties.foo[1].properties.bar ) { return 'properties.foo[1].properties.bar <i>'+md.items[0].properties.foo[1].properties.bar+'</i> instead of <i>[test]</i>'; } + if( !md.items[0].properties.foo[1].properties.bar.length ) { return 'properties.foo[1].properties.bar.length <i>'+md.items[0].properties.foo[1].properties.bar.length+'</i> instead of 1'; } + if( md.items[0].properties.foo[1].properties.bar[0] != 'test') { return 'properties.foo[1].properties.bar[0] <i>'+md.items[0].properties.foo[1].properties.bar[0]+'</i> instead of <i>test</i>'; } + + if( !md.items[0].properties.bar[0] ) { return 'properties.bar[0] <i>'+md.items[0].properties.bar[0]+'</i> instead of <i>{properties:{}}</i>'; } + if( !md.items[0].properties.bar[0].properties ) { return 'properties.bar[0].properties <i>'+md.items[0].properties.bar[0].properties+'</i> instead of <i>{}</i>'; } + return ''; +} + +</script> + +<div draggable='true' itemscope></div><div></div><div></div> + +<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> diff --git a/testing/web-platform/tests/html/editing/dnd/microdata/005.html b/testing/web-platform/tests/html/editing/dnd/microdata/005.html new file mode 100644 index 0000000000..ae83f6d5f5 --- /dev/null +++ b/testing/web-platform/tests/html/editing/dnd/microdata/005.html @@ -0,0 +1,115 @@ +<!DOCTYPE html> +<title>drag & drop - microdata with nested item as non-property</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',itemscope:'itemscope'},'') ); + orange.appendChild( makeEl('div',{itemscope:'itemscope'},'') ); + orange.lastChild.appendChild( makeEl('div',{itemprop:'bar'},'test') ); + orange.appendChild( makeEl('div',{itemprop:'bar',itemscope:'itemscope'},'') ); + + orange.ondragstart = function(e) { + 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) { + // http://dev.w3.org/html5/md/#drag-and-drop + //"The user agent must take the list of dragged nodes and extract the microdata from those nodes into a JSON form" + // http://dev.w3.org/html5/spec/dnd.html#drag-and-drop-processing-model + //"the list of dragged nodes contains only the source node, if any." + //nested items should only be in the items list if they are in a dragged *selection* + var i; + if( !md ) { return 'no microdata'; } + md = JSON.parse(md); + if( !md.items ) { return 'no items'; } + if( md.items.length != 1 ) { return md.items.length+' items 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 'no 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.bar.length != 1 ) { return 'properties.bar length '+md.items[0].properties.bar.length+' instead of 1'; } + + if( !md.items[0].properties.foo[0] ) { return 'properties.foo[0] <i>'+md.items[0].properties.foo[0]+'</i> instead of <i>{properties:{}}</i>'; } + if( !md.items[0].properties.foo[0].properties ) { return 'properties.foo[0].properties <i>'+md.items[0].properties.foo[0].properties+'</i> instead of <i>{}</i>'; } + + if( !md.items[0].properties.bar[0] ) { return 'properties.bar[0] <i>'+md.items[0].properties.bar[0]+'</i> instead of <i>{properties:{}}</i>'; } + if( !md.items[0].properties.bar[0].properties ) { return 'properties.bar[0].properties <i>'+md.items[0].properties.bar[0].properties+'</i> instead of <i>{}</i>'; } + return ''; +} + +</script> + +<div draggable='true' itemscope></div><div></div><div></div> + +<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> diff --git a/testing/web-platform/tests/html/editing/dnd/microdata/006.html b/testing/web-platform/tests/html/editing/dnd/microdata/006.html new file mode 100644 index 0000000000..b9e2ba229e --- /dev/null +++ b/testing/web-platform/tests/html/editing/dnd/microdata/006.html @@ -0,0 +1,105 @@ +<!DOCTYPE html> +<title>drag & drop - microdata with type and id</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',itemscope:'itemscope',itemtype:'http://example.com/',id:'id2',itemid:'http://example.com/bar'},'') ); + + orange.ondragstart = function(e) { + 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 md.items.length+' items instead of 1'; } + if( md.items[0].type != orange.getAttribute('itemtype') ) { return 'items[0].type <i>'+md.items[0].type+'</i> instead of <i>'+orange.getAttribute('itemtype')+'</i>'; } + if( md.items[0].id != orange.getAttribute('itemid') ) { return 'items[0].id <i>'+md.items[0].id+'</i> instead of <i>'+orange.getAttribute('itemid')+'</i>'; } + if( !md.items[0].properties ) { return 'no properties'; } + if( !md.items[0].properties.foo ) { return 'no properties.foo'; } + 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] ) { return 'properties.foo[0] <i>'+md.items[0].properties.foo[0]+'</i> instead of <i>{...}</i>'; } + if( md.items[0].properties.foo[0].type != orange.firstChild.getAttribute('itemtype') ) { return 'items[0].properties.foo[0].type <i>'+md.items[0].properties.foo[0].type+'</i> instead of <i>'+orange.firstChild.getAttribute('itemtype')+'</i>'; } + if( md.items[0].properties.foo[0].id != orange.firstChild.getAttribute('itemid') ) { return 'items[0].properties.foo[0].id <i>'+md.items[0].properties.foo[0].id+'</i> instead of <i>'+orange.firstChild.getAttribute('itemid')+'</i>'; } + if( !md.items[0].properties.foo[0].properties ) { return 'properties.foo[0].properties <i>'+md.items[0].properties.foo[0].properties+'</i> instead of <i>{}</i>'; } + return ''; +} + +</script> + +<div draggable='true' itemscope id='id1' itemtype='http://example.org/' itemid='http://example.org/foo'></div><div></div><div></div> + +<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> diff --git a/testing/web-platform/tests/html/editing/dnd/microdata/007.html b/testing/web-platform/tests/html/editing/dnd/microdata/007.html new file mode 100644 index 0000000000..e6eb87d82a --- /dev/null +++ b/testing/web-platform/tests/html/editing/dnd/microdata/007.html @@ -0,0 +1,116 @@ +<!DOCTYPE html> +<title>drag & drop - microdata with multiply named item as property</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 bar',itemscope:'itemscope'},'') ); + orange.lastChild.appendChild( makeEl('div',{itemprop:'baz'},'test') ); + + orange.ondragstart = function(e) { + 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 md.items.length+' items 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 'no properties.bar'; } + if( md.items[0].properties.baz ) { return 'properties.baz should not exist'; } + 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.bar.length != 1 ) { return 'properties.bar length '+md.items[0].properties.bar.length+' instead of 1'; } + + if( !md.items[0].properties.foo[0] ) { return 'properties.foo[1] <i>'+md.items[0].properties.foo[0]+'</i> instead of <i>{properties:{baz:[test]}}</i>'; } + if( !md.items[0].properties.foo[0].properties ) { return 'properties.foo[0].properties <i>'+md.items[0].properties.foo[0].properties+'</i> instead of <i>{baz:[test]}</i>'; } + if( !md.items[0].properties.foo[0].properties.baz ) { return 'properties.foo[0].properties.baz <i>'+md.items[0].properties.foo[0].properties.baz+'</i> instead of <i>[test]</i>'; } + if( !md.items[0].properties.foo[0].properties.baz.length ) { return 'properties.foo[0].properties.baz.length <i>'+md.items[0].properties.foo[0].properties.baz.length+'</i> instead of 1'; } + if( md.items[0].properties.foo[0].properties.baz[0] != 'test') { return 'properties.foo[0].properties.baz[0] <i>'+md.items[0].properties.foo[0].properties.baz[0]+'</i> instead of <i>test</i>'; } + + if( !md.items[0].properties.bar[0] ) { return 'properties.bar[1] <i>'+md.items[0].properties.bar[0]+'</i> instead of <i>{properties:{baz:[test]}}</i>'; } + if( !md.items[0].properties.bar[0].properties ) { return 'properties.bar[0].properties <i>'+md.items[0].properties.bar[0].properties+'</i> instead of <i>{baz:[test]}</i>'; } + if( !md.items[0].properties.bar[0].properties.baz ) { return 'properties.bar[0].properties.baz <i>'+md.items[0].properties.bar[0].properties.baz+'</i> instead of <i>[test]</i>'; } + if( !md.items[0].properties.bar[0].properties.baz.length ) { return 'properties.bar[0].properties.baz.length <i>'+md.items[0].properties.bar[0].properties.baz.length+'</i> instead of 1'; } + if( md.items[0].properties.bar[0].properties.baz[0] != 'test') { return 'properties.bar[0].properties.baz[0] <i>'+md.items[0].properties.bar[0].properties.baz[0]+'</i> instead of <i>test</i>'; } + + return ''; +} + +</script> + +<div draggable='true' itemscope></div><div></div><div></div> + +<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> diff --git a/testing/web-platform/tests/html/editing/dnd/microdata/008.html b/testing/web-platform/tests/html/editing/dnd/microdata/008.html new file mode 100644 index 0000000000..d4cd797817 --- /dev/null +++ b/testing/web-platform/tests/html/editing/dnd/microdata/008.html @@ -0,0 +1,94 @@ +<!DOCTYPE html> +<title>drag & drop - no microdata for selection with no items</title> +<style> + body > div { + height: 100px; + width: 200px; + background-color: fuchsia; + position: absolute; + top: 8px; + left: 8px; + } + span span { + display: none; + } + body > div + div { + background-color: navy; + top: 116px; + } + body > div + div + div { + background-color: orange; + top: 224px; + } + p:first-of-type { + margin-top: 350px; + } +</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')[2]; + orange.ondragstart = function(e) { + 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.previousSibling.ondragenter = orange.previousSibling.ondragleave = orange.previousSibling.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.previousSibling.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 collection'; } + if( md.items.length != 0 ) { return 'unexpected items found'; } + return ''; +} + +</script> + +<div></div><div></div><div>01<span>23</span>45<span>67</span>89</div> + +<p>Use your pointing device to select the text substring "12345678" above, drag the selection upwards to the pink box, +then back to the blue box, and release it.</p> +<noscript><p>Enable JavaScript and reload</p></noscript> diff --git a/testing/web-platform/tests/html/editing/dnd/microdata/009.html b/testing/web-platform/tests/html/editing/dnd/microdata/009.html new file mode 100644 index 0000000000..637cabe017 --- /dev/null +++ b/testing/web-platform/tests/html/editing/dnd/microdata/009.html @@ -0,0 +1,98 @@ +<!DOCTYPE html> +<title>drag & drop - microdata for selection surrounding one item</title> +<style> + body > div { + height: 100px; + width: 200px; + background-color: fuchsia; + position: absolute; + top: 8px; + left: 8px; + } + span * { + display: none; + } + body > div + div { + background-color: navy; + top: 116px; + } + body > div + div + div { + background-color: orange; + top: 224px; + } + p:first-of-type { + margin-top: 350px; + } +</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')[2]; + orange.childNodes[1].appendChild( makeEl('span',{itemprop:'foo'},'test') ); + orange.ondragstart = function(e) { + 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.previousSibling.ondragenter = orange.previousSibling.ondragleave = orange.previousSibling.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.previousSibling.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 || md.items.length != 1 ) { return 'no items'; } + if( !md.items[0].properties ) { return 'no properties'; } + if( !md.items[0].properties.foo ) { return 'no properties.foo'; } + 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.childNodes[1].properties.namedItem('foo').getValues()[0] ) { return 'properties.foo[0] <i>'+md.items[0].properties.foo[0]+'</i> instead of <i>'+orange.childNodes[1].properties.namedItem('foo').getValues()[0]+'</i>'; } + return ''; +} + +</script> + +<div></div><div></div><div>01<span itemscope>23</span>45<span>67</span>89</div> + +<p>Use your pointing device to select the text substring "12345678" above, drag the selection upwards to the pink box, +then back to the blue box, and release it.</p> +<noscript><p>Enable JavaScript and reload</p></noscript> diff --git a/testing/web-platform/tests/html/editing/dnd/microdata/010.html b/testing/web-platform/tests/html/editing/dnd/microdata/010.html new file mode 100644 index 0000000000..53a6321a3e --- /dev/null +++ b/testing/web-platform/tests/html/editing/dnd/microdata/010.html @@ -0,0 +1,104 @@ +<!DOCTYPE html> +<title>drag & drop - microdata for selection surrounding multiple items</title> +<style> + body > div { + height: 100px; + width: 200px; + background-color: fuchsia; + position: absolute; + top: 8px; + left: 8px; + } + span * { + display: none; + } + body > div + div { + background-color: navy; + top: 116px; + } + body > div + div + div { + background-color: orange; + top: 224px; + } + p:first-of-type { + margin-top: 350px; + } +</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')[2]; + orange.childNodes[1].appendChild( makeEl('span',{itemprop:'foo'},'test') ); + orange.childNodes[3].appendChild( makeEl('span',{itemprop:'bar'},'test') ); + orange.ondragstart = function(e) { + 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.previousSibling.ondragenter = orange.previousSibling.ondragleave = orange.previousSibling.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.previousSibling.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 != 2 ) { return md.items.length+' items instead of 2'; } + if( !md.items[0].properties ) { return 'no items[0].properties'; } + if( !md.items[0].properties.foo ) { return 'no items[0].properties.foo'; } + if( md.items[0].properties.foo.length != 1 ) { return 'items[0].properties.foo length '+md.items[0].properties.foo.length+' instead of 1'; } + if( md.items[0].properties.foo[0] != orange.childNodes[1].properties.namedItem('foo').getValues()[0] ) { return 'items[0].properties.foo[0] <i>'+md.items[0].properties.foo[0]+'</i> instead of <i>'+orange.childNodes[1].properties.namedItem('foo').getValues()[0]+'</i>'; } + if( !md.items[1].properties ) { return 'no items[1].properties'; } + if( !md.items[1].properties.bar ) { return 'no items[1].properties.bar'; } + if( md.items[1].properties.bar.length != 1 ) { return 'items[1].properties.bar length '+md.items[1].properties.bar.length+' instead of 1'; } + if( md.items[1].properties.bar[0] != orange.childNodes[1].properties.namedItem('foo').getValues()[0] ) { return 'items[1].properties.bar[0] <i>'+md.items[1].properties.bar[0]+'</i> instead of <i>'+orange.childNodes[1].properties.namedItem('foo').getValues()[0]+'</i>'; } + return ''; +} + +</script> + +<div></div><div></div><div>01<span itemscope>23</span>45<span itemscope>67</span>89</div> + +<p>Use your pointing device to select the text substring "12345678" above, drag the selection upwards to the pink box, +then back to the blue box, and release it.</p> +<noscript><p>Enable JavaScript and reload</p></noscript> diff --git a/testing/web-platform/tests/html/editing/dnd/microdata/011.html b/testing/web-platform/tests/html/editing/dnd/microdata/011.html new file mode 100644 index 0000000000..819e5ceab0 --- /dev/null +++ b/testing/web-platform/tests/html/editing/dnd/microdata/011.html @@ -0,0 +1,107 @@ +<!DOCTYPE html> +<title>drag & drop - microdata for selection partially intersecting multiple items</title> +<style> + body > div { + height: 100px; + width: 200px; + background-color: fuchsia; + position: absolute; + top: 8px; + left: 8px; + } + span * { + display: none; + } + body > div + div { + background-color: navy; + top: 116px; + } + body > div + div + div { + background-color: orange; + top: 224px; + } + p:first-of-type { + margin-top: 350px; + } +</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')[2]; + orange.childNodes[1].appendChild( makeEl('span',{itemprop:'foo'},'test') ); + orange.childNodes[3].appendChild( makeEl('span',{itemprop:'bar'},'test') ); + orange.ondragstart = function(e) { + 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.previousSibling.ondragenter = orange.previousSibling.ondragleave = orange.previousSibling.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.previousSibling.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) { + // http://dev.w3.org/html5/spec/dnd.html#list-of-dragged-nodes + //"If it is a selection that is being dragged, then the list of dragged nodes contains, in tree order, every node that is partially or completely included in the selection (including all their ancestors)." + //given this "ancestors" situation, what is to stop every item in the body from being included? oversight perhaps? tests 18-20 cover this more extensively + var i; + if( !md ) { return 'no microdata'; } + md = JSON.parse(md); + if( !md.items ) { return 'no items'; } + if( md.items.length != 2 ) { return md.items.length+' items instead of 2'; } + if( !md.items[0].properties ) { return 'no items[0].properties'; } + if( !md.items[0].properties.foo ) { return 'no items[0].properties.foo'; } + if( md.items[0].properties.foo.length != 1 ) { return 'items[0].properties.foo length '+md.items[0].properties.foo.length+' instead of 1'; } + if( md.items[0].properties.foo[0] != orange.childNodes[1].properties.namedItem('foo').getValues()[0] ) { return 'items[0].properties.foo[0] <i>'+md.items[0].properties.foo[0]+'</i> instead of <i>'+orange.childNodes[1].properties.namedItem('foo').getValues()[0]+'</i>'; } + if( !md.items[1].properties ) { return 'no items[1].properties'; } + if( !md.items[1].properties.bar ) { return 'no items[1].properties.bar'; } + if( md.items[1].properties.bar.length != 1 ) { return 'items[1].properties.bar length '+md.items[1].properties.bar.length+' instead of 1'; } + if( md.items[1].properties.bar[0] != orange.childNodes[1].properties.namedItem('foo').getValues()[0] ) { return 'items[1].properties.bar[0] <i>'+md.items[1].properties.bar[0]+'</i> instead of <i>'+orange.childNodes[1].properties.namedItem('foo').getValues()[0]+'</i>'; } + return ''; +} + +</script> + +<div></div><div></div><div>01<span itemscope>23</span>45<span itemscope>67</span>89</div> + +<p>Use your pointing device to select the text substring "3456" above, drag the selection upwards to the pink box, +then back to the blue box, and release it.</p> +<noscript><p>Enable JavaScript and reload</p></noscript> diff --git a/testing/web-platform/tests/html/editing/dnd/microdata/012.html b/testing/web-platform/tests/html/editing/dnd/microdata/012.html new file mode 100644 index 0000000000..307d610e90 --- /dev/null +++ b/testing/web-platform/tests/html/editing/dnd/microdata/012.html @@ -0,0 +1,104 @@ +<!DOCTYPE html> +<title>drag & drop - microdata for selection surrounding nested property items</title> +<style> + body > div { + height: 100px; + width: 200px; + background-color: fuchsia; + position: absolute; + top: 8px; + left: 8px; + } + span * { + display: none; + } + body > div + div { + background-color: navy; + top: 116px; + } + body > div + div + div { + background-color: orange; + top: 224px; + } + p:first-of-type { + margin-top: 350px; + } +</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')[2]; + orange.childNodes[1].appendChild( makeEl('span',{itemscope:'itemscope',itemprop:'foo'},'test') ); + orange.childNodes[1].lastChild.appendChild( makeEl('span',{itemprop:'bar'},'test') ); + orange.ondragstart = function(e) { + 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.previousSibling.ondragenter = orange.previousSibling.ondragleave = orange.previousSibling.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.previousSibling.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) { + //items should be represented at the top level only if they do not have the itemprop attribute + var i; + if( !md ) { return 'no microdata'; } + md = JSON.parse(md); + if( !md.items ) { return 'no items'; } + if( md.items.length != 1 ) { return md.items.length+' items instead of 1'; } + if( !md.items[0].properties ) { return 'no items[0].properties'; } + if( !md.items[0].properties.foo ) { return 'no items[0].properties.foo'; } + if( md.items[0].properties.foo.length != 1 ) { return 'items[0].properties.foo length '+md.items[0].properties.foo.length+' instead of 1'; } + if( !md.items[0].properties.foo[0].properties ) { return 'items[1].properties.foo[0].properties <i>'+md.items[0].properties.foo[0].properties+'</i> instead of <i>{bar:[test]}</i>'; } + if( !md.items[0].properties.foo[0].properties.bar ) { return 'items[1].properties.foo[0].properties.bar <i>'+md.items[0].properties.foo[0].properties.bar+'</i> instead of <i>[test]</i>'; } + if( md.items[0].properties.foo[0].properties.bar.length != 1 ) { return 'items[1].properties.foo[0].properties.bar.length <i>'+md.items[0].properties.foo[0].properties.bar.length+'</i> instead of 1'; } + if( md.items[0].properties.foo[0].properties.bar[0] != 'test') { return 'items[1].properties.foo[0].properties.bar[0] <i>'+md.items[0].properties.foo[0].properties.bar[0]+'</i> instead of <i>test</i>'; } + return ''; +} + +</script> + +<div></div><div></div><div>01<span itemscope>23</span>45<span itemscope itemprop="baz">67</span>89</div> + +<p>Use your pointing device to select the text substring "12345678" above, drag the selection upwards to the pink box, +then back to the blue box, and release it.</p> +<noscript><p>Enable JavaScript and reload</p></noscript> diff --git a/testing/web-platform/tests/html/editing/dnd/microdata/013.html b/testing/web-platform/tests/html/editing/dnd/microdata/013.html new file mode 100644 index 0000000000..000a9d7f05 --- /dev/null +++ b/testing/web-platform/tests/html/editing/dnd/microdata/013.html @@ -0,0 +1,104 @@ +<!DOCTYPE html> +<title>drag & drop - microdata for selection surrounding nested non-property items</title> +<style> + body > div { + height: 100px; + width: 200px; + background-color: fuchsia; + position: absolute; + top: 8px; + left: 8px; + } + span * { + display: none; + } + body > div + div { + background-color: navy; + top: 116px; + } + body > div + div + div { + background-color: orange; + top: 224px; + } + p:first-of-type { + margin-top: 350px; + } +</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')[2]; + orange.childNodes[1].appendChild( makeEl('span',{itemscope:'itemscope'},'test') ); + orange.childNodes[1].lastChild.appendChild( makeEl('span',{itemprop:'bar'},'test') ); + orange.ondragstart = function(e) { + 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.previousSibling.ondragenter = orange.previousSibling.ondragleave = orange.previousSibling.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.previousSibling.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) { + //*all* items should be represented at the top level, even if they are nested + var i; + if( !md ) { return 'no microdata'; } + md = JSON.parse(md); + if( !md.items ) { return 'no items'; } + if( md.items.length != 2 ) { return md.items.length+' items instead of 2'; } + if( !md.items[0].properties ) { return 'no items[0].properties'; } + if( md.items[0].properties.bar ) { return 'unexpected items[0].properties.bar'; } + + if( !md.items[1].properties ) { return 'no items[1].properties'; } + if( !md.items[1].properties.bar ) { return 'no items[1].properties.bar'; } + if( md.items[1].properties.bar.length != 1 ) { return 'items[1].properties.bar length '+md.items[1].properties.bar.length+' instead of 1'; } + if( md.items[1].properties.bar[0] != 'test' ) { return 'items[1].properties.bar[0] <i>'+md.items[1].properties.bar[0]+'</i> instead of <i>test</i>'; } + return ''; +} + +</script> + +<div></div><div></div><div>01<span itemscope>23</span>45<span>67</span>89</div> + +<p>Use your pointing device to select the text substring "12345678" above, drag the selection upwards to the pink box, +then back to the blue box, and release it.</p> +<noscript><p>Enable JavaScript and reload</p></noscript> diff --git a/testing/web-platform/tests/html/editing/dnd/microdata/014.html b/testing/web-platform/tests/html/editing/dnd/microdata/014.html new file mode 100644 index 0000000000..785c059a31 --- /dev/null +++ b/testing/web-platform/tests/html/editing/dnd/microdata/014.html @@ -0,0 +1,97 @@ +<!DOCTYPE html> +<title>drag & drop - microdata with sibling itemref loop</title> +<style> + body > div { + height: 200px; + width: 200px; + background-color: orange; + position: absolute; + top: 8px; + left: 8px; + } + body > div *, span { + 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.ondragstart = function(e) { + 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) { + // http://dev.w3.org/html5/md/#extracting-json + //"check if the element is a top-level microdata item, and if it is" + //as it has itemprop, it is not a top-level item, and should be ignored + var i; + if( !md ) { return 'no microdata'; } + md = JSON.parse(md); + if( !md.items ) { return 'no items'; } + if( md.items.length != 0 ) { return md.items.length+' items instead of 0'; } + return ''; +} + +</script> + +<div draggable='true' itemscope itemprop='foo' id='id1' itemref='id2'></div><div id='id2' itemprop='bar' itemscope itemref='id1'></div><div></div> + +<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> diff --git a/testing/web-platform/tests/html/editing/dnd/microdata/015.html b/testing/web-platform/tests/html/editing/dnd/microdata/015.html new file mode 100644 index 0000000000..36f2643293 --- /dev/null +++ b/testing/web-platform/tests/html/editing/dnd/microdata/015.html @@ -0,0 +1,99 @@ +<!DOCTYPE html> +<title>drag & drop - microdata with parent itemref loop</title> +<style> + blockquote > div { + height: 200px; + width: 200px; + background-color: orange; + position: absolute; + top: 8px; + left: 8px; + } + blockquote > div *, span { + display: none; + } + blockquote > div + div { + background-color: navy; + left: 250px; + } + blockquote > 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.ondragstart = function(e) { + 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) { + // http://dev.w3.org/html5/md/#extracting-json + //"check if the element is a top-level microdata item, and if it is" + //as it has itemprop, it is not a top-level item, and should be ignored + var i; + if( !md ) { return 'no microdata'; } + md = JSON.parse(md); + if( !md.items ) { return 'no items'; } + if( md.items.length != 0 ) { return md.items.length+' items instead of 0'; } + return ''; +} + +</script> + +<blockquote id='id1' itemprop='bar' itemscope> +<div draggable='true' itemscope itemprop='foo' itemref='id1'></div><div></div><div></div> +</blockquote> + +<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> diff --git a/testing/web-platform/tests/html/editing/dnd/microdata/016.html b/testing/web-platform/tests/html/editing/dnd/microdata/016.html new file mode 100644 index 0000000000..153098bf89 --- /dev/null +++ b/testing/web-platform/tests/html/editing/dnd/microdata/016.html @@ -0,0 +1,160 @@ +<!DOCTYPE html> +<title>drag & drop - microdata with nested sibling itemref loop</title> +<style> + body > div { + height: 200px; + width: 200px; + background-color: orange; + position: absolute; + top: 8px; + left: 8px; + } + body > div *, span { + 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.ondragstart = function(e) { + 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) { + // http://dev.w3.org/html5/md/#extracting-json + //"If value is an item, then: If value is in memory, then let value be the string "ERROR"." + /* +Loop detection happens only after the loop has been created, at which point it returns a property value +of "ERROR" instead of the value which has already been encountered on the stringifying stack. +Should create the following construct: +{ + items:[ + { + properties:{ + foo:[ + { + properties:{ + bar:[ + { + properties:{ + foo:[ + "ERROR" + ] + } + } + ] + } + } + ], + bar:[ + { + properties:{ + foo:[ + { + properties:{ + bar:[ + "ERROR" + ] + } + } + ] + } + } + ] + } + } + ] +} + */ + + var i; + if( !md ) { return 'no microdata'; } + md = JSON.parse(md); + if( !md.items ) { return 'no items'; } + if( md.items.length != 1 ) { return md.items.length+' items instead of 1'; } + if( !md.items[0].properties ) { return 'no items[0].properties'; } + if( !md.items[0].properties.foo ) { return 'no items[0].properties.foo'; } + if( md.items[0].properties.foo.length != 1 ) { return 'items[0].properties.foo length '+md.items[0].properties.foo.length+' instead of 1'; } + if( !md.items[0].properties.foo[0].properties ) { return 'items[1].properties.foo[0].properties <i>'+md.items[0].properties.foo[0].properties+'</i> instead of object'; } + if( !md.items[0].properties.foo[0].properties.bar ) { return 'items[1].properties.foo[0].properties.bar <i>'+md.items[0].properties.foo[0].properties.bar+'</i> instead of array'; } + if( md.items[0].properties.foo[0].properties.bar.length != 1 ) { return 'items[1].properties.foo[0].properties.bar.length <i>'+md.items[0].properties.foo[0].properties.bar.length+'</i> instead of 1'; } + if( !md.items[0].properties.foo[0].properties.bar[0].properties ) { return 'items[1].properties.foo[0].properties.bar[0].properties <i>'+md.properties.foo[0].properties.bar[0].properties+'</i> instead of object'; } + if( !md.items[0].properties.foo[0].properties.bar[0].properties.foo ) { return 'items[1].properties.foo[0].properties.bar[0].properties.foo <i>'+md.items[0].properties.foo[0].properties.bar[0].properties.foo+'</i> instead of array'; } + if( md.items[0].properties.foo[0].properties.bar[0].properties.foo.length != 1 ) { return 'items[1].properties.foo[0].properties.bar[0].properties.foo.length <i>'+md.items[0].properties.foo[0].properties.bar[0].properties.foo.length+'</i> instead of 1'; } + if( md.items[0].properties.foo[0].properties.bar[0].properties.foo[0] != 'ERROR' ) { return 'items[1].properties.foo[0].properties.bar[0].properties.foo.length <i>'+md.items[0].properties.foo[0].properties.bar[0].properties.foo[0]+'</i> instead of <i>ERROR</a>'; } + + if( !md.items[0].properties.bar ) { return 'no items[0].properties.bar'; } + if( md.items[0].properties.bar.length != 1 ) { return 'items[0].properties.bar length '+md.items[0].properties.bar.length+' instead of 1'; } + if( !md.items[0].properties.bar[0].properties ) { return 'items[1].properties.bar[0].properties <i>'+md.items[0].properties.bar[0].properties+'</i> instead of object'; } + if( !md.items[0].properties.bar[0].properties.foo ) { return 'items[1].properties.bar[0].properties.foo <i>'+md.items[0].properties.bar[0].properties.foo+'</i> instead of array'; } + if( md.items[0].properties.bar[0].properties.foo.length != 1 ) { return 'items[1].properties.bar[0].properties.foo.length <i>'+md.items[0].properties.bar[0].properties.foo.length+'</i> instead of 1'; } + if( !md.items[0].properties.bar[0].properties.foo[0].properties ) { return 'items[1].properties.bar[0].properties.foo[0].properties <i>'+md.properties.bar[0].properties.foo[0].properties+'</i> instead of object'; } + if( !md.items[0].properties.bar[0].properties.foo[0].properties.bar ) { return 'items[1].properties.bar[0].properties.foo[0].properties.bar <i>'+md.items[0].properties.bar[0].properties.foo[0].properties.bar+'</i> instead of array'; } + if( md.items[0].properties.bar[0].properties.foo[0].properties.bar.length != 1 ) { return 'items[1].properties.bar[0].properties.foo[0].properties.bar.length <i>'+md.items[0].properties.bar[0].properties.foo[0].properties.bar.length+'</i> instead of 1'; } + if( md.items[0].properties.bar[0].properties.foo[0].properties.bar[0] != 'ERROR' ) { return 'items[1].properties.bar[0].properties.foo[0].properties.bar.length <i>'+md.items[0].properties.bar[0].properties.foo[0].properties.bar[0]+'</i> instead of <i>ERROR</a>'; } + return ''; +} + +</script> + +<div draggable='true' itemscope><div itemscope itemprop='foo' id='id1' itemref='id2'></div><div itemscope itemprop='bar' id='id2' itemref='id1'></div></div><div></div><div></div> + +<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> diff --git a/testing/web-platform/tests/html/editing/dnd/microdata/017.html b/testing/web-platform/tests/html/editing/dnd/microdata/017.html new file mode 100644 index 0000000000..dab270e643 --- /dev/null +++ b/testing/web-platform/tests/html/editing/dnd/microdata/017.html @@ -0,0 +1,137 @@ +<!DOCTYPE html> +<title>drag & drop - microdata with nested parent itemref loop</title> +<style> + body > div { + height: 200px; + width: 200px; + background-color: orange; + position: absolute; + top: 8px; + left: 8px; + } + body > div *, span { + 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.ondragstart = function(e) { + 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) { + // http://dev.w3.org/html5/md/#extracting-json + //"If value is an item, then: If value is in memory, then let value be the string "ERROR"." + /* +Loop detection happens only after the loop has been created, at which point it returns a property value +of "ERROR" instead of the value which has already been encountered on the stringifying stack. +Should create the following construct: +{ + items:[ + { + properties:{ + foo:[ + { + properties:{ + bar:[ + { + properties:{ + foo:[ + "ERROR" + ] + } + } + ] + } + } + ] + } + } + ] +} + */ + + var i; + if( !md ) { return 'no microdata'; } + md = JSON.parse(md); + if( !md.items ) { return 'no items'; } + if( md.items.length != 1 ) { return md.items.length+' items instead of 1'; } + if( !md.items[0].properties ) { return 'no items[0].properties'; } + if( !md.items[0].properties.foo ) { return 'no items[0].properties.foo'; } + if( md.items[0].properties.foo.length != 1 ) { return 'items[0].properties.foo length '+md.items[0].properties.foo.length+' instead of 1'; } + if( !md.items[0].properties.foo[0].properties ) { return 'items[1].properties.foo[0].properties <i>'+md.items[0].properties.foo[0].properties+'</i> instead of object'; } + if( !md.items[0].properties.foo[0].properties.bar ) { return 'items[1].properties.foo[0].properties.bar <i>'+md.items[0].properties.foo[0].properties.bar+'</i> instead of array'; } + if( md.items[0].properties.foo[0].properties.bar.length != 1 ) { return 'items[1].properties.foo[0].properties.bar.length <i>'+md.items[0].properties.foo[0].properties.bar.length+'</i> instead of 1'; } + if( !md.items[0].properties.foo[0].properties.bar[0].properties ) { return 'items[1].properties.foo[0].properties.bar[0].properties <i>'+md.properties.foo[0].properties.bar[0].properties+'</i> instead of object'; } + if( !md.items[0].properties.foo[0].properties.bar[0].properties.foo ) { return 'items[1].properties.foo[0].properties.bar[0].properties.foo <i>'+md.items[0].properties.foo[0].properties.bar[0].properties.foo+'</i> instead of array'; } + if( md.items[0].properties.foo[0].properties.bar[0].properties.foo.length != 1 ) { return 'items[1].properties.foo[0].properties.bar[0].properties.foo.length <i>'+md.items[0].properties.foo[0].properties.bar[0].properties.foo.length+'</i> instead of 1'; } + if( md.items[0].properties.foo[0].properties.bar[0].properties.foo[0] != 'ERROR' ) { return 'items[1].properties.foo[0].properties.bar[0].properties.foo.length <i>'+md.items[0].properties.foo[0].properties.bar[0].properties.foo[0]+'</i> instead of <i>ERROR</a>'; } + return ''; +} + +</script> + +<div draggable='true' itemscope> + <span id='id1' itemprop='foo' itemscope><span itemscope itemprop='bar' itemref='id1'></span></span> +</div><div></div><div></div> + +<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> diff --git a/testing/web-platform/tests/html/editing/dnd/microdata/018.html b/testing/web-platform/tests/html/editing/dnd/microdata/018.html new file mode 100644 index 0000000000..357ba4f0fe --- /dev/null +++ b/testing/web-platform/tests/html/editing/dnd/microdata/018.html @@ -0,0 +1,95 @@ +<!DOCTYPE html> +<title>drag & drop - microdata for selection partially intersecting a single item</title> +<style> + body > div { + height: 100px; + width: 200px; + background-color: fuchsia; + position: absolute; + top: 8px; + left: 8px; + } + body > div + div { + background-color: navy; + top: 116px; + } + body > div + div + div { + background-color: orange; + top: 224px; + } + p:first-of-type { + margin-top: 350px; + } +</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')[2]; + orange.ondragstart = function(e) { + 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.previousSibling.ondragenter = orange.previousSibling.ondragleave = orange.previousSibling.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.previousSibling.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) { + // http://dev.w3.org/html5/spec/dnd.html#list-of-dragged-nodes + //"If it is a selection that is being dragged, then the list of dragged nodes contains, in tree order, every node that is partially or completely included in the selection (including all their ancestors)." + //this test checks that the parent of the text node is included + var i; + if( !md ) { return 'no microdata'; } + md = JSON.parse(md); + if( !md.items ) { return 'no items'; } + if( md.items.length != 1 ) { return md.items.length+' items instead of 1'; } + if( md.items[0].id != 'http://example.com/item1' ) { return 'items[0].id incorrect'; } + return ''; +} + +</script> + +<div></div><div></div><div itemscope itemid="http://example.com/item1">abc</div> + +<p>Use your pointing device to select the text substring "b" above, drag the selection upwards to the pink box, +then back to the blue box, and release it.</p> +<noscript><p>Enable JavaScript and reload</p></noscript> diff --git a/testing/web-platform/tests/html/editing/dnd/microdata/019.html b/testing/web-platform/tests/html/editing/dnd/microdata/019.html new file mode 100644 index 0000000000..11525214e2 --- /dev/null +++ b/testing/web-platform/tests/html/editing/dnd/microdata/019.html @@ -0,0 +1,96 @@ +<!DOCTYPE html> +<title>drag & drop - microdata for selection partially intersecting nested items</title> +<style> + body > div { + height: 100px; + width: 200px; + background-color: fuchsia; + position: absolute; + top: 8px; + left: 8px; + } + body > div + div { + background-color: navy; + top: 116px; + } + body > div + div + div { + background-color: orange; + top: 224px; + } + p:first-of-type { + margin-top: 350px; + } +</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')[2]; + orange.ondragstart = function(e) { + 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.previousSibling.ondragenter = orange.previousSibling.ondragleave = orange.previousSibling.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.previousSibling.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) { + // http://dev.w3.org/html5/spec/dnd.html#list-of-dragged-nodes + //"If it is a selection that is being dragged, then the list of dragged nodes contains, in tree order, every node that is partially or completely included in the selection (including all their ancestors)." + //this test checks that all ancestors of the text node are included + var i; + if( !md ) { return 'no microdata'; } + md = JSON.parse(md); + if( !md.items ) { return 'no items'; } + if( md.items.length != 2 ) { return md.items.length+' items instead of 2'; } + if( md.items[0].id != 'http://example.com/item1' ) { return 'items[0].id incorrect'; } + if( md.items[1].id != 'http://example.com/item2' ) { return 'items[1].id incorrect'; } + return ''; +} + +</script> + +<div></div><div></div><div itemscope itemid="http://example.com/item1">a<span itemscope itemid="http://example.com/item2">bcd</span>e</div> + +<p>Use your pointing device to select the text substring "d" above, drag the selection upwards to the pink box, +then back to the blue box, and release it.</p> +<noscript><p>Enable JavaScript and reload</p></noscript> diff --git a/testing/web-platform/tests/html/editing/dnd/microdata/020.html b/testing/web-platform/tests/html/editing/dnd/microdata/020.html new file mode 100644 index 0000000000..33667224ca --- /dev/null +++ b/testing/web-platform/tests/html/editing/dnd/microdata/020.html @@ -0,0 +1,99 @@ +<!DOCTYPE html> +<title>drag & drop - microdata for selection partially intersecting multiple items but not siblings</title> +<style> + body > div { + height: 100px; + width: 400px; + background-color: fuchsia; + position: absolute; + top: 8px; + left: 8px; + } + body > div + div { + background-color: navy; + top: 116px; + } + body > div + div + div { + background-color: orange; + top: 224px; + } + p:first-of-type { + margin-top: 350px; + } +</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')[2]; + orange.ondragstart = function(e) { + 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.previousSibling.ondragenter = orange.previousSibling.ondragleave = orange.previousSibling.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.previousSibling.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) { + // http://dev.w3.org/html5/spec/dnd.html#list-of-dragged-nodes + //"If it is a selection that is being dragged, then the list of dragged nodes contains, in tree order, every node that is partially or completely included in the selection (including all their ancestors)." + //this test checks that all ancestors of the selection's end points are included, and all elements enclosed by the selection are included, but no non-selected siblings of ancestors are included + var i; + if( !md ) { return 'no microdata'; } + md = JSON.parse(md); + if( !md.items ) { return 'no items'; } + if( md.items.length != 5 ) { return md.items.length+' items instead of 5'; } + if( md.items[0].id != 'http://example.com/item1' ) { return 'items[0].id incorrect'; } + if( md.items[1].id != 'http://example.com/item4' ) { return 'items[1].id incorrect'; } + if( md.items[2].id != 'http://example.com/item5' ) { return 'items[2].id incorrect'; } + if( md.items[3].id != 'http://example.com/item6' ) { return 'items[3].id incorrect'; } + if( md.items[4].id != 'http://example.com/item7' ) { return 'items[4].id incorrect'; } + return ''; +} + +</script> + +<div></div><div></div><div itemscope itemid="http://example.com/item1"><span itemscope itemid="http://example.com/item2">ab<span itemscope itemid="http://example.com/item3">cd</span>ef</span><span itemscope itemid="http://example.com/item4">gh<span itemscope itemid="http://example.com/item5">ij</span>kl</span><span itemscope itemid="http://example.com/item6">mn<span itemscope itemid="http://example.com/item7">op</span>qr</span><span itemscope itemid="http://example.com/item8">st<span itemscope itemid="http://example.com/item9">uv</span>wx</span></div> + +<p>Use your pointing device to select the text substring "hijklmnopq" above, drag the selection upwards to the pink box, +then back to the blue box, and release it.</p> +<noscript><p>Enable JavaScript and reload</p></noscript> 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> diff --git a/testing/web-platform/tests/html/editing/dnd/microdata/test b/testing/web-platform/tests/html/editing/dnd/microdata/test new file mode 100644 index 0000000000..42d41d980e --- /dev/null +++ b/testing/web-platform/tests/html/editing/dnd/microdata/test @@ -0,0 +1,2 @@ +<!doctype html> +<!-- The tests in this folder point to this file in e.g. <img src> --> |