| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 /* Reports an event to DragAndDropBrowserTest and DOMDragEventWaiter */ | 5 /* Reports an event to DragAndDropBrowserTest and DOMDragEventWaiter */ |
| 6 window.reportDragAndDropEvent = function(ev) { | 6 window.reportDragAndDropEvent = function(ev) { |
| 7 function safe(f) { | 7 function safe(f) { |
| 8 try { | 8 try { |
| 9 return f(); | 9 return f(); |
| 10 } catch(err) { | 10 } catch(err) { |
| 11 return "exception: " + err.message; | 11 return "Got exception: " + err.message; |
| 12 } | 12 } |
| 13 } | 13 } |
| 14 | 14 |
| 15 console.log("got event: " + ev.type); | 15 var msg = "Got a " + ev.type + " event from the " + window.name + " frame."; |
| 16 console.log(msg); |
| 16 | 17 |
| 17 if (window.domAutomationController) { | 18 if (window.domAutomationController) { |
| 18 window.domAutomationController.setAutomationId(0); | 19 window.domAutomationController.setAutomationId(0); |
| 19 window.domAutomationController.send({ | 20 window.domAutomationController.send({ |
| 20 client_position: safe(function() { | 21 client_position: safe(function() { |
| 21 return "(" + ev.clientX + ", " + ev.clientY + ")"; | 22 return "(" + ev.clientX + ", " + ev.clientY + ")"; |
| 22 }), | 23 }), |
| 23 drop_effect: safe(function() { return ev.dataTransfer.dropEffect; }), | 24 drop_effect: safe(function() { return ev.dataTransfer.dropEffect; }), |
| 24 effect_allowed: safe(function() { | 25 effect_allowed: safe(function() { |
| 25 return ev.dataTransfer.effectAllowed; | 26 return ev.dataTransfer.effectAllowed; |
| 26 }), | 27 }), |
| 27 event_type: ev.type, | 28 event_type: ev.type, |
| 28 file_names: safe(function() { | 29 file_names: safe(function() { |
| 29 return Array | 30 return Array |
| 30 .from(ev.dataTransfer.files) | 31 .from(ev.dataTransfer.files) |
| 31 .map(function(file) { return file.name; }) | 32 .map(function(file) { return file.name; }) |
| 32 .sort().join(); | 33 .sort().join(); |
| 33 }), | 34 }), |
| 34 mime_types: safe(function() { | 35 mime_types: safe(function() { |
| 35 return Array.from(ev.dataTransfer.types).sort().join(); | 36 return Array.from(ev.dataTransfer.types).sort().join(); |
| 36 }), | 37 }), |
| 37 page_position: safe(function() { | 38 page_position: safe(function() { |
| 38 return "(" + ev.pageX + ", " + ev.pageY + ")"; | 39 return "(" + ev.pageX + ", " + ev.pageY + ")"; |
| 39 }), | 40 }), |
| 40 window_name: window.name | 41 window_name: window.name |
| 41 }); | 42 }); |
| 42 } | 43 } |
| 43 } | 44 } |
| OLD | NEW |