4 <link rel=
"help" href=
"http://www.w3.org/TR/2013/WD-html51-20130528/editing.html#dom-datatransferitemlist-remove">
5 <script src=
"../../resources/js-test.js"></script>
9 description("Checks that DataTransferItemList.remove() is working");
11 var dataTansferItemList
;
14 debug("* copy event");
15 event
.preventDefault();
16 dataTansferItemList
= event
.clipboardData
.items
;
18 dataTansferItemList
.add('a', 'text/plain');
19 dataTansferItemList
.add('http://www.google.com/', 'text/uri-list');
20 dataTansferItemList
.add('<em>Markup</em>', 'text/html');
21 dataTansferItemList
.add('hello world', 'custom-data');
23 shouldBe('dataTansferItemList.length', '4');
24 shouldBeEqualToString('dataTansferItemList[0].type', 'text/plain');
25 shouldBeEqualToString('dataTansferItemList[1].type', 'text/uri-list');
26 shouldBeEqualToString('dataTansferItemList[2].type', 'text/html');
27 shouldBeEqualToString('dataTansferItemList[3].type', 'custom-data');
30 shouldThrow('dataTansferItemList.remove()', '"TypeError: Failed to execute \'remove\' on \'DataTransferItemList\': 1 argument required, but only 0 present."');
31 shouldNotThrow('dataTansferItemList.remove(-1)');
32 shouldBe('dataTansferItemList.length', '4');
33 shouldNotThrow('dataTansferItemList.remove(999)');
34 shouldBe('dataTansferItemList.length', '4');
37 shouldNotThrow('dataTansferItemList.remove(0)');
38 shouldBe('dataTansferItemList.length', '3');
39 shouldBeEqualToString('dataTansferItemList[0].type', 'text/uri-list');
40 shouldBeEqualToString('dataTansferItemList[1].type', 'text/html');
41 shouldNotThrow('dataTansferItemList.remove(-4294967295)'); // Wraps to 1.
42 shouldBe('dataTansferItemList.length', '2');
43 shouldBeEqualToString('dataTansferItemList[1].type', 'custom-data');
48 debug("* paste event");
49 dataTansferItemList
= event
.clipboardData
.items
;
50 shouldBe('dataTansferItemList.length', '2');
51 shouldThrow('dataTansferItemList.remove(0)', '"InvalidStateError: Failed to execute \'remove\' on \'DataTransferItemList\': The list is not writable."'); // List is readonly during paste.
52 shouldBe('dataTansferItemList.length', '2');
55 document
.oncopy
= copy
;
56 document
.onpaste
= paste
;
57 document
.execCommand('copy');
58 document
.execCommand('paste');