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

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

Issue 2354273002: Remove window.moveTo calls from picker-common.js (Closed)
Patch Set: Created 4 years, 2 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 // We need some delay. Without it, testRunner.notifyDone() freezes. 9 // We need some delay. Without it, testRunner.notifyDone() freezes.
10 // See crbug.com/562311. 10 // See crbug.com/562311.
(...skipping 16 matching lines...) Expand all
27 // - menulist SELECT 27 // - menulist SELECT
28 // - INPUT color 28 // - INPUT color
29 // - INPUT date/datetime-local/month/week 29 // - INPUT date/datetime-local/month/week
30 // 30 //
31 // |callback| is called if we successfully open the picker UI. However it is 31 // |callback| is called if we successfully open the picker UI. However it is
32 // called only for the following types: 32 // called only for the following types:
33 // - menulist SELECT on Windows, Linux, and CrOS 33 // - menulist SELECT on Windows, Linux, and CrOS
34 // - INPUT color with DATALIST 34 // - INPUT color with DATALIST
35 // - INPUT date/datetime-local/month/week 35 // - INPUT date/datetime-local/month/week
36 function openPicker(element, callback, errorCallback) { 36 function openPicker(element, callback, errorCallback) {
37 rootWindow().moveTo(window.screenX, window.screenY);
38 element.offsetTop; // Force to lay out 37 element.offsetTop; // Force to lay out
39 element.focus(); 38 element.focus();
40 if (element.tagName === "SELECT") { 39 if (element.tagName === "SELECT") {
41 eventSender.keyDown("ArrowDown", ["altKey"]); 40 eventSender.keyDown("ArrowDown", ["altKey"]);
42 } else if (element.tagName === "INPUT") { 41 } else if (element.tagName === "INPUT") {
43 if (element.type === "color") { 42 if (element.type === "color") {
44 eventSender.keyDown(" "); 43 eventSender.keyDown(" ");
45 } else { 44 } else {
46 eventSender.keyDown("ArrowDown", ["altKey"]); 45 eventSender.keyDown("ArrowDown", ["altKey"]);
47 } 46 }
48 } 47 }
49 popupWindow = window.internals.pagePopupWindow; 48 popupWindow = window.internals.pagePopupWindow;
50 if (typeof callback === "function" && popupWindow) 49 if (typeof callback === "function" && popupWindow)
51 setPopupOpenCallback(callback); 50 setPopupOpenCallback(callback);
52 else if (typeof errorCallback === "function" && !popupWindow) 51 else if (typeof errorCallback === "function" && !popupWindow)
53 errorCallback(); 52 errorCallback();
54 } 53 }
55 54
56 function clickToOpenPicker(x, y, callback, errorCallback) { 55 function clickToOpenPicker(x, y, callback, errorCallback) {
57 rootWindow().moveTo(window.screenX, window.screenY);
58 eventSender.mouseMoveTo(x, y); 56 eventSender.mouseMoveTo(x, y);
59 eventSender.mouseDown(); 57 eventSender.mouseDown();
60 eventSender.mouseUp(); 58 eventSender.mouseUp();
61 popupWindow = window.internals.pagePopupWindow; 59 popupWindow = window.internals.pagePopupWindow;
62 if (typeof callback === "function" && popupWindow) 60 if (typeof callback === "function" && popupWindow)
63 setPopupOpenCallback(callback); 61 setPopupOpenCallback(callback);
64 else if (typeof errorCallback === "function" && !popupWindow) 62 else if (typeof errorCallback === "function" && !popupWindow)
65 errorCallback(); 63 errorCallback();
66 } 64 }
67 65
68 function setPopupOpenCallback(callback) { 66 function setPopupOpenCallback(callback) {
69 console.assert(popupWindow); 67 console.assert(popupWindow);
70 popupOpenCallback = (function(callback) { 68 popupOpenCallback = (function(callback) {
71 // We need to move the window to the top left of available space 69 // We need to move the window to the top left of available space
keishi 2016/09/22 15:08:59 nit: This comment and this function should also be
bokan 2016/09/23 00:53:54 Done.
72 // because the window will move back to (0, 0) when the 70 // because the window will move back to (0, 0) when the
73 // ShellViewMsg_SetTestConfiguration IPC arrives. 71 // ShellViewMsg_SetTestConfiguration IPC arrives.
74 rootWindow().moveTo(window.screenX, window.screenY);
75 callback(); 72 callback();
76 }).bind(this, callback); 73 }).bind(this, callback);
77 try { 74 try {
78 popupWindow.addEventListener("didOpenPicker", popupOpenCallbackWrapper, false); 75 popupWindow.addEventListener("didOpenPicker", popupOpenCallbackWrapper, false);
79 } catch(e) { 76 } catch(e) {
80 debug(e.name); 77 debug(e.name);
81 } 78 }
82 } 79 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698