OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <html> | 2 <html> |
3 <head> | 3 <head> |
4 <script src="../js/resources/js-test-pre.js"></script> | 4 <script src="../js/resources/js-test-pre.js"></script> |
5 <style> | 5 <style> |
6 #drag { | 6 #drag { |
7 border: 1px solid black; | 7 border: 1px solid black; |
8 height: 200px; | 8 height: 200px; |
9 width: 200px; | 9 width: 200px; |
10 } | 10 } |
11 #drop { | 11 #drop { |
12 border: 1px solid black; | 12 border: 1px solid black; |
13 height: 200px; | 13 height: 200px; |
14 width: 200px; | 14 width: 200px; |
15 } | 15 } |
16 </style> | 16 </style> |
17 <script> | 17 <script> |
18 function legacyDragStart(dataTransfer) | 18 function legacyDragStart(dataTransfer) |
19 { | 19 { |
20 dataTransfer.setData('text', 'sample'); | 20 dataTransfer.setData('text', 'sample'); |
21 dataTransfer.setData('url', 'http://www.google.com/'); | 21 dataTransfer.setData('url', 'http://www.google.com/'); |
22 dataTransfer.setData('text/html', '<em>Markup</em>'); | 22 dataTransfer.setData('text/html', '<em>Markup</em>'); |
23 dataTransfer.setData('custom-data', 'hello world'); | 23 dataTransfer.setData('custom-data', 'hello world'); |
24 } | 24 } |
25 | 25 |
26 var testDataTransfer; | 26 var testDataTransfer; |
| 27 var testItem; |
27 function itemListDragStart(dataTransfer) | 28 function itemListDragStart(dataTransfer) |
28 { | 29 { |
29 testDataTransfer = dataTransfer; | 30 testDataTransfer = dataTransfer; |
30 shouldThrow('testDataTransfer.items.add()', '"TypeError: Not enough argument
s"'); | 31 shouldThrow('testDataTransfer.items.add()', '"TypeError: Not enough argument
s"'); |
31 shouldThrow('testDataTransfer.items.add("sample")', '"TypeError: Type error"
'); | 32 shouldThrow('testDataTransfer.items.add("sample")', '"TypeError: Type error"
'); |
32 dataTransfer.items.add('sample', 'text/plain'); | 33 testItem = dataTransfer.items.add('sample', 'text/plain'); |
33 dataTransfer.items.add('http://www.google.com/', 'text/uri-list'); | 34 shouldBeEqualToString('testItem.kind', 'string'); |
34 dataTransfer.items.add('<em>Markup</em>', 'text/html'); | 35 shouldBeEqualToString('testItem.type', 'text/plain'); |
35 dataTransfer.items.add('hello world', 'custom-data'); | 36 testItem = dataTransfer.items.add('http://www.google.com/', 'text/uri-list')
; |
| 37 shouldBeEqualToString('testItem.kind', 'string'); |
| 38 shouldBeEqualToString('testItem.type', 'text/uri-list'); |
| 39 testItem = dataTransfer.items.add('<em>Markup</em>', 'text/html'); |
| 40 shouldBeEqualToString('testItem.kind', 'string'); |
| 41 shouldBeEqualToString('testItem.type', 'text/html'); |
| 42 testItem = dataTransfer.items.add('hello world', 'custom-data'); |
| 43 shouldBeEqualToString('testItem.kind', 'string'); |
| 44 shouldBeEqualToString('testItem.type', 'custom-data'); |
36 } | 45 } |
37 | 46 |
38 function dragstart(event) | 47 function dragstart(event) |
39 { | 48 { |
40 var dragMethod = document.getElementById('dragMethod'); | 49 var dragMethod = document.getElementById('dragMethod'); |
41 if (dragMethod.selectedIndex == 0) | 50 if (dragMethod.selectedIndex == 0) |
42 legacyDragStart(event.dataTransfer); | 51 legacyDragStart(event.dataTransfer); |
43 else if (dragMethod.selectedIndex == 1) | 52 else if (dragMethod.selectedIndex == 1) |
44 itemListDragStart(event.dataTransfer); | 53 itemListDragStart(event.dataTransfer); |
45 } | 54 } |
(...skipping 24 matching lines...) Expand all Loading... |
70 } | 79 } |
71 | 80 |
72 var outstandingRequests; | 81 var outstandingRequests; |
73 var types, expectedTypes; | 82 var types, expectedTypes; |
74 var testData, expectedTestData; | 83 var testData, expectedTestData; |
75 function itemListDrop(dataTransfer) | 84 function itemListDrop(dataTransfer) |
76 { | 85 { |
77 testDataTransfer = dataTransfer; | 86 testDataTransfer = dataTransfer; |
78 outstandingRequests = 0; | 87 outstandingRequests = 0; |
79 shouldBe('testDataTransfer.items.length', '4'); | 88 shouldBe('testDataTransfer.items.length', '4'); |
| 89 shouldBeNull('testDataTransfer.items.add("test", "text/plain")'); // Read-on
ly. |
| 90 shouldBe('testDataTransfer.items.length', '4'); |
80 types = []; | 91 types = []; |
81 for (var i = 0; i < dataTransfer.items.length; ++i) { | 92 for (var i = 0; i < dataTransfer.items.length; ++i) { |
82 types.push({kind: dataTransfer.items[i].kind, type: dataTransfer.items[i
].type}); | 93 types.push({kind: dataTransfer.items[i].kind, type: dataTransfer.items[i
].type}); |
83 } | 94 } |
84 types.sort(function (a, b) { return a.type.localeCompare(b.type); }); | 95 types.sort(function (a, b) { return a.type.localeCompare(b.type); }); |
85 expectedTypes = [ | 96 expectedTypes = [ |
86 { kind: 'string', type: 'custom-data'}, | 97 { kind: 'string', type: 'custom-data'}, |
87 { kind: 'string', type: 'text/html'}, | 98 { kind: 'string', type: 'text/html'}, |
88 { kind: 'string', type: 'text/plain'}, | 99 { kind: 'string', type: 'text/plain'}, |
89 { kind: 'string', type: 'text/uri-list'}, | 100 { kind: 'string', type: 'text/uri-list'}, |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
174 <div id="console"></div> | 185 <div id="console"></div> |
175 <script> | 186 <script> |
176 description("Tests drag'n drop and well as DataTransferItemList"); | 187 description("Tests drag'n drop and well as DataTransferItemList"); |
177 window.jsTestIsAsync = true; | 188 window.jsTestIsAsync = true; |
178 | 189 |
179 runNext(); | 190 runNext(); |
180 </script> | 191 </script> |
181 <script src="../js/resources/js-test-post.js"></script> | 192 <script src="../js/resources/js-test-post.js"></script> |
182 </body> | 193 </body> |
183 </html> | 194 </html> |
OLD | NEW |