Update web-platform-tests to revision 0d318188757a9c996e20b82db201fd04de5aa255

This commit is contained in:
James Graham 2015-03-27 09:15:38 +00:00
parent b2a5225831
commit 1a81b18b9f
12321 changed files with 544385 additions and 6 deletions

View file

@ -0,0 +1,120 @@
<!doctype html>
<html>
<head>
<title>Synthetic drag events</title>
<script type="text/javascript" src="/resources/testharness.js"></script>
<script type="text/javascript" src="/resources/testharnessreport.js"></script>
</head>
<body>
<div id="log"></div>
<script type="text/javascript">
test(function() {
assert_own_property(window,'DragEvent');
}, 'window.DragEvent should be exposed' );
test(function() {
assert_throws('NOT_SUPPORTED_ERR', function() {
var evt = document.createEvent('DragEvent');
});
}, 'createEvent should not be able to create a DragEvent' );
test(function() {
var evt = new DragEvent('dragstart');
assert_false( !!evt.initDragEvent, 'initDragEvent' );
assert_true( !!evt.initMouseEvent, 'initMouseEvent' );
assert_true( !!evt.initUIEvent, 'initUIEvent' );
assert_true( !!evt.initEvent, 'initEvent' );
}, 'DragEvent should have all of the inherited init*Event methods' );
//cannot test non-synthetic dataTransfer objects as the param here because that needs a real DragEvent to create a proper one with global storage
//will be tested in another file
test(function() {
var evt = new DragEvent('dragstart');
evt.initMouseEvent('dragstart', true, true, window, 1, 0, 0, 0, 0, false, false, false, false, 1, document.body);
}, 'initMouseEvent should not throw' );
test(function() {
var evt = new DragEvent('dragstart');
evt.initUIEvent('dragstart', true, true, window, 1);
}, 'initUIEvent should not throw' );
test(function() {
var evt = new DragEvent('dragstart');
evt.initEvent('dragstart', true, true);
}, 'initEvent should not throw' );
test(function() {
var evt = new DragEvent('dragstart', {dataTransfer:null}), div = document.createElement('div'), ranlistener = false;
div.ondragstart = function () { ranlistener = true; };
div.dispatchEvent(evt);
assert_true(ranlistener);
}, 'DragEvent constructor with null as the dataTransfer parameter should be able to fire the event' );
test(function() {
var evt = new DragEvent('dragstart', {dataTransfer:undefined}), div = document.createElement('div'), ranlistener = false;
div.ondragstart = function () { ranlistener = true; };
div.dispatchEvent(evt);
assert_true(ranlistener);
}, 'DragEvent constructor with undefined as the dataTransfer parameter should be able to fire the event' );
test(function() {
assert_throws(new TypeError(), function() {
var evt = new DragEvent('dragstart', {dataTransfer:{}});
});
}, 'DragEvent constructor with custom object as the dataTransfer parameter should throw TypeError' );
test(function() {
var evt = new DragEvent('dragstart'), div = document.createElement('div'), ranlistener = false;
div.ondragstart = function () { ranlistener = true; };
evt.initMouseEvent('dragstart', true, true, window, 1, 0, 0, 0, 0, false, false, false, false, 1, document.body);
div.dispatchEvent(evt);
assert_true(ranlistener);
}, 'initMouseEvent should be able to fire the event' );
test(function() {
var evt = new DragEvent('dragstart'), div = document.createElement('div'), ranlistener = false;
div.ondragstart = function () { ranlistener = true; };
evt.initUIEvent('dragstart', true, true, window, 1);
div.dispatchEvent(evt);
assert_true(ranlistener);
}, 'initUIEvent should be able to fire the event' );
test(function() {
var evt = new DragEvent('dragstart'), div = document.createElement('div'), ranlistener = false;
div.ondragstart = function () { ranlistener = true; };
evt.initEvent('dragstart', true, true);
div.dispatchEvent(evt);
assert_true(ranlistener);
}, 'initEvent should be able to fire the event' );
test(function() {
var evt = new DragEvent('dragstart', {dataTransfer:null}), div = document.createElement('div'), dTrans = 'fail';
div.ondragstart = function (e) { dTrans = e.dataTransfer };
div.dispatchEvent(evt);
assert_equals(dTrans,null);
}, 'DragEvent constructor with null as the dataTransfer parameter should give null as the dataTransfer' );
test(function() {
var evt = new DragEvent('dragstart', {dataTransfer:undefined}), div = document.createElement('div'), dTrans = 'fail';
div.ondragstart = function (e) { dTrans = e.dataTransfer };
div.dispatchEvent(evt);
assert_equals(dTrans,null);
}, 'DragEvent constructor with undefined as the dataTransfer parameter should give null as the dataTransfer' );
test(function() {
var evt = new DragEvent('dragstart'), div = document.createElement('div'), dTrans = 'fail';
div.ondragstart = function (e) { dTrans = e.dataTransfer };
evt.initMouseEvent('dragstart', true, true, window, 1, 0, 0, 0, 0, false, false, false, false, 1, document.body);
div.dispatchEvent(evt);
assert_equals(dTrans,null);
}, 'initMouseEvent should give null as the dataTransfer' );
test(function() {
var evt = new DragEvent('dragstart'), div = document.createElement('div'), dTrans = 'fail';
div.ondragstart = function (e) { dTrans = e.dataTransfer };
evt.initUIEvent('dragstart', true, true, window, 1);
div.dispatchEvent(evt);
assert_equals(dTrans,null);
}, 'initUIEvent should give null as the dataTransfer' );
test(function() {
var evt = new DragEvent('dragstart'), div = document.createElement('div'), dTrans = 'fail';
div.ondragstart = function (e) { dTrans = e.dataTransfer };
evt.initEvent('dragstart', true, true);
div.dispatchEvent(evt);
assert_equals(dTrans,null);
}, 'initEvent should give null as the dataTransfer' );
//cannot test that synthetic event does not use the same data store as non-synthetic event because that needs a real DragEvent to create a proper one with global storage
//will be tested in another file
</script>
<noscript><p>Enable JavaScript and reload</p></noscript>
</body>
</html>

View file

@ -0,0 +1,339 @@
<!doctype html>
<html>
<head>
<title>Synthetic events with real data store must inherit protection status from real events</title>
<style type="text/css">
blockquote { height: 100px; width: 100px; background: orange; margin: 0; padding: 0; float: left; }
blockquote + blockquote { background: blue; }
blockquote + blockquote + blockquote { background: fuchsia; }
blockquote + div { clear: left; }
</style>
<script type="text/javascript" src="/resources/testharness.js"></script>
<script type="text/javascript">
setup(function () {},{explicit_done:true,explicit_timeout:true});
window.onload = function () {
var orange = document.getElementsByTagName('blockquote')[0],
blue = document.getElementsByTagName('blockquote')[1],
fuchsia = document.getElementsByTagName('blockquote')[2],
evtdone = {};
orange.ondragstart = function (e) {
evtdone[e.type] = true;
e.dataTransfer.effectAllowed = 'copy';
var t = async_test(e.type+' should share its data with the synthetic event');
blue.ondragstart = function (e) {
t.step(function() {
assert_equals( e.dataTransfer.getData('text'), 'dragstart real data', 'step 1' );
e.dataTransfer.setData('text','dragstart-dragstart synthetic data');
assert_equals( e.dataTransfer.getData('text'), 'dragstart-dragstart synthetic data', 'step 2' );
});
};
t.step(function() {
var evt = new DragEvent('dragstart', {dataTransfer:e.dataTransfer});
e.dataTransfer.setData('text','dragstart real data'); //changing in between steps, just to make sure it uses the underlying data store, not a temporary clone
blue.dispatchEvent(evt);
});
t.done();
test(function() {
assert_equals( e.dataTransfer.getData('text'), 'dragstart-dragstart synthetic data' );
}, e.type+' should see the data from the synthetic event' );
var t2 = async_test(e.type+' should share its protection status with the synthetic event');
blue.ondrag = function (e) {
t2.step(function() {
e.dataTransfer.setData('text','dragstart-drag synthetic data');
assert_equals( e.dataTransfer.getData('text'), 'dragstart-drag synthetic data' );
});
};
t2.step(function() {
var evt = new DragEvent('drag', {dataTransfer:e.dataTransfer});
blue.dispatchEvent(evt);
});
t2.done();
var t3 = async_test(e.type+' should share its protection status with the nested synthetic event');
blue.ondrag = function (e) {
blue.ondragend = function (e) {
t3.step(function() {
assert_equals( e.dataTransfer.getData('text'), 'dragstart-drag synthetic data', 'step1' );
e.dataTransfer.setData('text','dragstart-drag-dragend synthetic data');
assert_equals( e.dataTransfer.getData('text'), 'dragstart-drag-dragend synthetic data', 'step2' );
});
};
t3.step(function() {
var evt = new DragEvent('dragend', {dataTransfer:e.dataTransfer});
blue.dispatchEvent(evt);
});
};
t3.step(function() {
var evt = new DragEvent('drag', {dataTransfer:e.dataTransfer});
blue.dispatchEvent(evt);
});
t3.done();
test(function() {
assert_equals( e.dataTransfer.getData('text'), 'dragstart-drag-dragend synthetic data' );
}, e.type+' should see the data from the nested synthetic event' );
};
blue.ondragenter = blue.ondragover = function (e) {
e.preventDefault();
};
orange.ondrag = blue.ondragleave = function (e) {
if( evtdone[e.type] ) { return; }
evtdone[e.type] = true;
var evtype = e.type;
var t = async_test(e.type+' should share its data with the synthetic event');
blue.ondragstart = function (e) {
t.step(function() {
assert_true( e.dataTransfer.items.length > 0, 'items.length' );
});
};
t.step(function() {
var evt = new DragEvent('dragstart', {dataTransfer:e.dataTransfer});
blue.dispatchEvent(evt);
});
t.done();
var t2 = async_test(e.type+' should share its protection status with the synthetic event');
blue.ondragstart = function (e) {
t2.step(function() {
assert_equals( e.dataTransfer.getData('text'), '', 'step 1' );
e.dataTransfer.setData('text',evtype+'-dragstart synthetic data');
assert_equals( e.dataTransfer.getData('text'), '', 'step 2' );
});
};
t2.step(function() {
var evt = new DragEvent('dragstart', {dataTransfer:e.dataTransfer});
blue.dispatchEvent(evt);
});
t2.done();
test(function() {
assert_equals( e.dataTransfer.getData('text'), '' );
}, e.type+' protection status should not be modified by the synthetic event' );
var t3 = async_test(e.type+' should share its protection status with the nested synthetic event');
blue.ondragstart = function (e) {
var div = document.createElement('div');
div.ondragstart = function (e) {
t3.step(function() {
assert_equals( e.dataTransfer.getData('text'), '', 'step1' );
e.dataTransfer.setData('text',evtype+'dragstart-dragstart synthetic data');
assert_equals( e.dataTransfer.getData('text'), '', 'step2' );
});
};
t3.step(function() {
var evt = new DragEvent('dragend', {dataTransfer:e.dataTransfer});
div.dispatchEvent(evt);
});
};
t3.step(function() {
var evt = new DragEvent('drag', {dataTransfer:e.dataTransfer});
blue.dispatchEvent(evt);
});
t3.done();
};
fuchsia.ondragenter = fuchsia.ondragover = function (e) {
e.preventDefault();
if( evtdone[e.type] ) { return; }
evtdone[e.type] = true;
var evtype = e.type;
var t = async_test(e.type+' should share its data with the synthetic event');
blue.ondragstart = function (e) {
t.step(function() {
assert_true( e.dataTransfer.items.length > 0, 'items.length' );
});
};
t.step(function() {
var evt = new DragEvent('dragstart', {dataTransfer:e.dataTransfer});
blue.dispatchEvent(evt);
});
t.done();
var t2 = async_test(e.type+' should share its protection status with the synthetic event');
blue.ondragstart = function (e) {
t2.step(function() {
assert_equals( e.dataTransfer.getData('text'), '', 'step 1' );
e.dataTransfer.setData('text',evtype+'-dragstart synthetic data');
assert_equals( e.dataTransfer.getData('text'), '', 'step 2' );
});
};
t2.step(function() {
var evt = new DragEvent('dragstart', {dataTransfer:e.dataTransfer});
blue.dispatchEvent(evt);
});
t2.done();
test(function() {
assert_equals( e.dataTransfer.getData('text'), '' );
}, e.type+' protection status should not be modified by the synthetic event' );
var t3 = async_test(e.type+' should share its protection status with the nested synthetic event');
blue.ondragstart = function (e) {
var div = document.createElement('div');
div.ondragstart = function (e) {
t3.step(function() {
assert_equals( e.dataTransfer.getData('text'), '', 'step1' );
e.dataTransfer.setData('text',evtype+'dragstart-dragstart synthetic data');
assert_equals( e.dataTransfer.getData('text'), '', 'step2' );
});
};
t3.step(function() {
var evt = new DragEvent('dragend', {dataTransfer:e.dataTransfer});
div.dispatchEvent(evt);
});
};
t3.step(function() {
var evt = new DragEvent('drag', {dataTransfer:e.dataTransfer});
blue.dispatchEvent(evt);
});
t3.done();
};
fuchsia.ondrop = function (e) {
e.preventDefault();
if( evtdone[e.type] ) { return; }
evtdone[e.type] = true;
var evtype = e.type;
var t = async_test(e.type+' should share its data with the synthetic event');
blue.ondragstart = function (e) {
t.step(function() {
assert_equals( e.dataTransfer.getData('text'), 'dragstart-drag-dragend synthetic data' );
});
};
t.step(function() {
var evt = new DragEvent('dragstart', {dataTransfer:e.dataTransfer});
blue.dispatchEvent(evt);
});
t.done();
var t2 = async_test(e.type+' should share its protection status with the synthetic event');
blue.ondragstart = function (e) {
t2.step(function() {
assert_equals( e.dataTransfer.getData('text'), 'dragstart-drag-dragend synthetic data', 'step 1' );
e.dataTransfer.setData('text',evtype+'-dragstart synthetic data');
assert_equals( e.dataTransfer.getData('text'), 'dragstart-drag-dragend synthetic data', 'step 2' );
});
};
t2.step(function() {
var evt = new DragEvent('dragstart', {dataTransfer:e.dataTransfer});
blue.dispatchEvent(evt);
});
t2.done();
test(function() {
e.dataTransfer.setData('text','drop synthetic data');
assert_equals( e.dataTransfer.getData('text'), 'dragstart-drag-dragend synthetic data' );
}, e.type+' protection status should not be modified by the synthetic event' );
var t3 = async_test(e.type+' should share its protection status with the nested synthetic event');
blue.ondragstart = function (e) {
var div = document.createElement('div');
div.ondragstart = function (e) {
t3.step(function() {
assert_equals( e.dataTransfer.getData('text'), 'dragstart-drag-dragend synthetic data', 'step 1' );
e.dataTransfer.setData('text',evtype+'dragstart-dragstart synthetic data');
assert_equals( e.dataTransfer.getData('text'), 'dragstart-drag-dragend synthetic data', 'step 2' );
});
};
t3.step(function() {
var evt = new DragEvent('dragend', {dataTransfer:e.dataTransfer});
div.dispatchEvent(evt);
});
};
t3.step(function() {
var evt = new DragEvent('drag', {dataTransfer:e.dataTransfer});
blue.dispatchEvent(evt);
});
t3.done();
};
orange.ondragend = function (e) {
if( evtdone[e.type] ) { return; }
evtdone[e.type] = true;
var evtype = e.type;
var t = async_test(e.type+' should share its data with the synthetic event');
blue.ondragstart = function (e) {
t.step(function() {
assert_true( e.dataTransfer.items.length > 0, 'items.length' );
});
};
t.step(function() {
var evt = new DragEvent('dragstart', {dataTransfer:e.dataTransfer});
blue.dispatchEvent(evt);
});
t.done();
var t2 = async_test(e.type+' should share its protection status with the synthetic event');
blue.ondragstart = function (e) {
t2.step(function() {
assert_equals( e.dataTransfer.getData('text'), '', 'step 1' );
e.dataTransfer.setData('text',evtype+'-dragstart synthetic data');
assert_equals( e.dataTransfer.getData('text'), '', 'step 2' );
});
};
t2.step(function() {
var evt = new DragEvent('dragstart', {dataTransfer:e.dataTransfer});
blue.dispatchEvent(evt);
});
t2.done();
test(function() {
assert_equals( e.dataTransfer.getData('text'), '' );
}, e.type+' protection status should not be modified by the synthetic event' );
var t3 = async_test(e.type+' should share its protection status with the nested synthetic event');
blue.ondragstart = function (e) {
var div = document.createElement('div');
div.ondragstart = function (e) {
t3.step(function() {
assert_equals( e.dataTransfer.getData('text'), '', 'step1' );
e.dataTransfer.setData('text',evtype+'dragstart-dragstart synthetic data');
assert_equals( e.dataTransfer.getData('text'), '', 'step2' );
});
};
t3.step(function() {
var evt = new DragEvent('dragend', {dataTransfer:e.dataTransfer});
div.dispatchEvent(evt);
});
};
t3.step(function() {
var evt = new DragEvent('drag', {dataTransfer:e.dataTransfer});
blue.dispatchEvent(evt);
});
t3.done();
test(function() {
var failtxt = '- Reload and try again';
assert_true( evtdone.dragstart, 'dragstart event was not tested'+failtxt );
assert_true( evtdone.drag, 'drag event was not tested'+failtxt );
assert_true( evtdone.dragenter, 'dragenter event was not tested'+failtxt );
assert_true( evtdone.dragleave, 'dragleave event was not tested'+failtxt );
assert_true( evtdone.dragover, 'dragover event was not tested'+failtxt );
assert_true( evtdone.drop, 'drop event was not tested'+failtxt );
assert_true( evtdone.dragend, 'dragend event was not tested'+failtxt );
}, 'all event types must now have been tested' );
done();
};
};
</script>
</head>
<body>
<p>Drag the orange square over the blue square then the fuchsia square, then release it.</p>
<blockquote draggable="true"></blockquote>
<blockquote></blockquote>
<blockquote></blockquote>
<div id="log"></div>
<noscript><p>Enable JavaScript and reload</p></noscript>
</body>
</html>

View file

@ -0,0 +1,78 @@
<!doctype html>
<html>
<head>
<title>Synthetic events using real dataTransfer in new thread</title>
<style type="text/css">
blockquote { height: 100px; width: 100px; background: orange; margin: 0; padding: 0; float: left; }
blockquote + blockquote { background: blue; }
blockquote + blockquote + blockquote { background: fuchsia; }
blockquote + div { clear: left; }
</style>
<script type="text/javascript" src="/resources/testharness.js"></script>
<script type="text/javascript">
setup(function () {},{explicit_done:true,explicit_timeout:true});
window.onload = function () {
var orange = document.getElementsByTagName('blockquote')[0],
blue = document.getElementsByTagName('blockquote')[1],
fuchsia = document.getElementsByTagName('blockquote')[2],
evtdone = {};
orange.ondragstart = function (e) {
e.dataTransfer.effectAllowed = 'copy';
e.dataTransfer.setData('text','dragstart real data');
var dataTransfer = e.dataTransfer;
setTimeout(function () {
var t = async_test('new thread should see data store in protected mode after dragstart');
blue.ondragstart = function (e) {
t.step(function() {
assert_equals( e.dataTransfer.getData('text'), '', 'step 1' );
e.dataTransfer.setData('text','new thread after dragstart');
assert_equals( e.dataTransfer.getData('text'), '', 'step 2' );
});
};
t.step(function() {
var evt = new DragEvent('dragstart', {dataTransfer:dataTransfer});
blue.dispatchEvent(evt);
});
t.done();
},0);
};
fuchsia.ondragenter = fuchsia.ondragover = function (e) {
e.preventDefault();
};
fuchsia.ondrop = function (e) {
e.preventDefault();
var dataTransfer = e.dataTransfer;
setTimeout(function () {
var t = async_test('new thread should see data store in protected mode after drop');
blue.ondragstart = function (e) {
t.step(function() {
assert_equals( e.dataTransfer.getData('text'), '', 'step 1' );
e.dataTransfer.setData('text','new thread after dragstart');
assert_equals( e.dataTransfer.getData('text'), '', 'step 2' );
});
};
t.step(function() {
var evt = new DragEvent('dragstart', {dataTransfer:dataTransfer});
blue.dispatchEvent(evt);
});
t.done();
done();
},0);
};
};
</script>
</head>
<body>
<p>Drag the orange square over the blue square then the fuchsia square, then release it.</p>
<blockquote draggable="true"></blockquote>
<blockquote></blockquote>
<blockquote></blockquote>
<div id="log"></div>
<noscript><p>Enable JavaScript and reload</p></noscript>
</body>
</html>