Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 window.jsTestIsAsync = true; | 1 window.jsTestIsAsync = true; |
| 2 | 2 |
| 3 var popupWindow = null; | 3 var popupWindow = null; |
| 4 | 4 |
| 5 var popupOpenCallback = null; | 5 var popupOpenCallback = null; |
| 6 | 6 |
| 7 function popupOpenCallbackWrapper() { | 7 function popupOpenCallbackWrapper() { |
| 8 popupWindow.removeEventListener("didOpenPicker", popupOpenCallbackWrapper); | 8 popupWindow.removeEventListener("didOpenPicker", popupOpenCallbackWrapper); |
| 9 setTimeout(popupOpenCallback, 0); | 9 setTimeout(popupOpenCallback, 0); |
| 10 } | 10 } |
| 11 | 11 |
| 12 function waitUntilClosing(callback) { | 12 function waitUntilClosing(callback) { |
| 13 setTimeout(callback, 1); | 13 setTimeout(callback, 1); |
| 14 } | 14 } |
| 15 | 15 |
| 16 function sendKey(input, keyName, ctrlKey, altKey) { | 16 function sendKey(input, keyName, ctrlKey, altKey) { |
| 17 var event = document.createEvent('KeyboardEvent'); | 17 var event = document.createEvent('KeyboardEvent'); |
| 18 event.initKeyboardEvent('keydown', true, true, document.defaultView, keyName , 0, ctrlKey, altKey); | 18 event.initKeyboardEvent('keydown', true, true, document.defaultView, keyName , 0, ctrlKey, altKey); |
| 19 input.dispatchEvent(event); | 19 input.dispatchEvent(event); |
| 20 } | 20 } |
| 21 | 21 |
| 22 function openPicker(input, callback) { | 22 function openPicker(input, callback) { |
| 23 window.moveTo(); | 23 window.moveTo(window.screenX, window.screenY); |
|
Jens Widell
2015/01/29 13:53:44
This one is funny. This call is required to make t
| |
| 24 input.offsetTop; // Force to lay out | 24 input.offsetTop; // Force to lay out |
| 25 if (input.type === "color") { | 25 if (input.type === "color") { |
| 26 input.focus(); | 26 input.focus(); |
| 27 eventSender.keyDown(" "); | 27 eventSender.keyDown(" "); |
| 28 } else { | 28 } else { |
| 29 sendKey(input, "Down", false, true); | 29 sendKey(input, "Down", false, true); |
| 30 } | 30 } |
| 31 popupWindow = window.internals.pagePopupWindow; | 31 popupWindow = window.internals.pagePopupWindow; |
| 32 if (typeof callback === "function") { | 32 if (typeof callback === "function") { |
| 33 popupOpenCallback = (function(callback) { | 33 popupOpenCallback = (function(callback) { |
| 34 // We need to move the window to the top left of available space | 34 // We need to move the window to the top left of available space |
| 35 // because the window will move back to (0, 0) when the | 35 // because the window will move back to (0, 0) when the |
| 36 // ShellViewMsg_SetTestConfiguration IPC arrives. | 36 // ShellViewMsg_SetTestConfiguration IPC arrives. |
| 37 window.moveTo(); | 37 window.moveTo(window.screenX, window.screenY); |
| 38 callback(); | 38 callback(); |
| 39 }).bind(this, callback); | 39 }).bind(this, callback); |
| 40 popupWindow.addEventListener("didOpenPicker", popupOpenCallbackWrapper, false); | 40 popupWindow.addEventListener("didOpenPicker", popupOpenCallbackWrapper, false); |
| 41 } | 41 } |
| 42 } | 42 } |
| OLD | NEW |