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

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

Issue 892083003: Revert Implement <select> Popup Menu using PagePopup (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 10 months 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(element, callback) { 22 function openPicker(input, callback) {
23 window.moveTo(); 23 window.moveTo();
24 element.offsetTop; // Force to lay out 24 input.offsetTop; // Force to lay out
25 if (element.tagName === "SELECT") { 25 if (input.type === "color") {
26 sendKey(element, "Down", false, true); 26 input.focus();
27 } else if (element.tagName === "INPUT") { 27 eventSender.keyDown(" ");
28 if (element.type === "color") { 28 } else {
29 element.focus(); 29 sendKey(input, "Down", false, true);
30 eventSender.keyDown(" ");
31 } else {
32 sendKey(element, "Down", false, true);
33 }
34 } 30 }
35 popupWindow = window.internals.pagePopupWindow; 31 popupWindow = window.internals.pagePopupWindow;
36 if (typeof callback === "function") { 32 if (typeof callback === "function") {
37 popupOpenCallback = (function(callback) { 33 popupOpenCallback = (function(callback) {
38 // 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
39 // because the window will move back to (0, 0) when the 35 // because the window will move back to (0, 0) when the
40 // ShellViewMsg_SetTestConfiguration IPC arrives. 36 // ShellViewMsg_SetTestConfiguration IPC arrives.
41 window.moveTo(); 37 window.moveTo();
42 callback(); 38 callback();
43 }).bind(this, callback); 39 }).bind(this, callback);
44 popupWindow.addEventListener("didOpenPicker", popupOpenCallbackWrapper, false); 40 popupWindow.addEventListener("didOpenPicker", popupOpenCallbackWrapper, false);
45 } 41 }
46 } 42 }
OLDNEW
« no previous file with comments | « LayoutTests/TestExpectations ('k') | LayoutTests/fast/forms/select/menulist-popup-open-hide-using-keyboard.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698