OLD | NEW |
1 window.jsTestIsAsync = true; | 1 window.jsTestIsAsync = true; |
2 if (window.internals) | 2 if (window.internals) |
3 internals.settings.setEnableMockPagePopup(true); | 3 internals.settings.setEnableMockPagePopup(true); |
4 | 4 |
5 var popupWindow = null; | 5 var popupWindow = null; |
6 | 6 |
7 var popupOpenCallback = null; | 7 var popupOpenCallback = null; |
8 function openPicker(input, callback) { | 8 function openPicker(input, callback) { |
9 input.offsetTop; // Force to lay out | 9 input.offsetTop; // Force to lay out |
10 if (input.type === "color") { | 10 if (input.type === "color") { |
11 input.focus(); | 11 input.focus(); |
12 eventSender.keyDown(" "); | 12 eventSender.keyDown(" "); |
13 } else { | 13 } else { |
14 sendKey(input, "Down", false, true); | 14 sendKey(input, "Down", false, true); |
15 } | 15 } |
16 popupWindow = document.getElementById('mock-page-popup').contentWindow; | 16 popupWindow = document.getElementById('mock-page-popup').contentWindow; |
17 if (typeof callback === "function") { | 17 if (typeof callback === "function") { |
18 popupOpenCallback = callback; | 18 popupOpenCallback = callback; |
19 popupWindow.addEventListener("resize", popupOpenCallbackWrapper, false); | 19 popupWindow.addEventListener("didOpenPicker", popupOpenCallbackWrapper,
false); |
20 } | 20 } |
21 } | 21 } |
22 | 22 |
23 function popupOpenCallbackWrapper() { | 23 function popupOpenCallbackWrapper() { |
24 popupWindow.removeEventListener("didOpenPicker", popupOpenCallbackWrapper); | 24 popupWindow.removeEventListener("didOpenPicker", popupOpenCallbackWrapper); |
25 popupOpenCallback(); | 25 popupOpenCallback(); |
26 } | 26 } |
27 | 27 |
28 function sendKey(input, keyName, ctrlKey, altKey) { | 28 function sendKey(input, keyName, ctrlKey, altKey) { |
29 var event = document.createEvent('KeyboardEvent'); | 29 var event = document.createEvent('KeyboardEvent'); |
30 event.initKeyboardEvent('keydown', true, true, document.defaultView, keyName
, 0, ctrlKey, altKey); | 30 event.initKeyboardEvent('keydown', true, true, document.defaultView, keyName
, 0, ctrlKey, altKey); |
31 input.dispatchEvent(event); | 31 input.dispatchEvent(event); |
32 } | 32 } |
33 | 33 |
34 | 34 |
OLD | NEW |