Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(18)

Side by Side Diff: LayoutTests/fast/events/drag-dataTransferItemList.html

Issue 22837006: Have DataTransferItemList.add() methods return the added item (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | LayoutTests/fast/events/drag-dataTransferItemList-expected.txt » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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>
OLDNEW
« no previous file with comments | « no previous file | LayoutTests/fast/events/drag-dataTransferItemList-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698