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

Side by Side Diff: LayoutTests/fast/forms/resources/picker-common.js

Issue 736883002: Implement <select> Popup Menu using PagePopup (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years 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
OLDNEW
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 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698