| 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(element, callback) { |
| 23 window.moveTo(); | 23 window.moveTo(); |
| 24 input.offsetTop; // Force to lay out | 24 element.offsetTop; // Force to lay out |
| 25 if (input.type === "color") { | 25 if (element.tagName === "SELECT") { |
| 26 input.focus(); | 26 sendKey(element, "Down", false, true); |
| 27 eventSender.keyDown(" "); | 27 } else if (element.tagName === "INPUT") { |
| 28 } else { | 28 if (element.type === "color") { |
| 29 sendKey(input, "Down", false, true); | 29 element.focus(); |
| 30 eventSender.keyDown(" "); |
| 31 } else { |
| 32 sendKey(element, "Down", false, true); |
| 33 } |
| 30 } | 34 } |
| 31 popupWindow = window.internals.pagePopupWindow; | 35 popupWindow = window.internals.pagePopupWindow; |
| 32 if (typeof callback === "function") { | 36 if (typeof callback === "function") { |
| 33 popupOpenCallback = (function(callback) { | 37 popupOpenCallback = (function(callback) { |
| 34 // We need to move the window to the top left of available space | 38 // 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 | 39 // because the window will move back to (0, 0) when the |
| 36 // ShellViewMsg_SetTestConfiguration IPC arrives. | 40 // ShellViewMsg_SetTestConfiguration IPC arrives. |
| 37 window.moveTo(); | 41 window.moveTo(); |
| 38 callback(); | 42 callback(); |
| 39 }).bind(this, callback); | 43 }).bind(this, callback); |
| 40 popupWindow.addEventListener("didOpenPicker", popupOpenCallbackWrapper,
false); | 44 popupWindow.addEventListener("didOpenPicker", popupOpenCallbackWrapper,
false); |
| 41 } | 45 } |
| 42 } | 46 } |
| OLD | NEW |