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

Unified 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: Fixed tests for mac 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 side-by-side diff with in-line comments
Download patch
Index: LayoutTests/fast/forms/resources/picker-common.js
diff --git a/LayoutTests/fast/forms/resources/picker-common.js b/LayoutTests/fast/forms/resources/picker-common.js
index 0a20ef231c5d5a32e95adcb13a10f11f955cb73b..f69889604146faf42588d269ed93266eefcf5763 100644
--- a/LayoutTests/fast/forms/resources/picker-common.js
+++ b/LayoutTests/fast/forms/resources/picker-common.js
@@ -19,24 +19,54 @@ function sendKey(input, keyName, ctrlKey, altKey) {
input.dispatchEvent(event);
}
-function openPicker(input, callback) {
- window.moveTo();
- input.offsetTop; // Force to lay out
- if (input.type === "color") {
- input.focus();
- eventSender.keyDown(" ");
- } else {
- sendKey(input, "Down", false, true);
+function rootWindow() {
+ var currentWindow = window;
+ while (currentWindow !== currentWindow.parent) {
+ currentWindow = currentWindow.parent;
}
- popupWindow = window.internals.pagePopupWindow;
- if (typeof callback === "function") {
- popupOpenCallback = (function(callback) {
- // We need to move the window to the top left of available space
- // because the window will move back to (0, 0) when the
- // ShellViewMsg_SetTestConfiguration IPC arrives.
- window.moveTo();
- callback();
- }).bind(this, callback);
- popupWindow.addEventListener("didOpenPicker", popupOpenCallbackWrapper, false);
+ return currentWindow;
+}
+
+function openPicker(element, callback, errorCallback) {
+ rootWindow().moveTo();
+ element.offsetTop; // Force to lay out
+ if (element.tagName === "SELECT") {
+ sendKey(element, "Down", false, true);
+ } else if (element.tagName === "INPUT") {
+ if (element.type === "color") {
+ element.focus();
+ eventSender.keyDown(" ");
+ } else {
+ sendKey(element, "Down", false, true);
+ }
}
+ popupWindow = window.internals.pagePopupWindow;
+ if (typeof callback === "function" && popupWindow)
+ setPopupOpenCallback(callback);
+ else if (typeof errorCallback === "function" && !popupWindow)
+ errorCallback();
+}
+
+function clickToOpenPicker(x, y, callback, errorCallback) {
+ rootWindow().moveTo();
+ eventSender.mouseMoveTo(x, y);
+ eventSender.mouseDown();
+ eventSender.mouseUp();
+ popupWindow = window.internals.pagePopupWindow;
+ if (typeof callback === "function" && popupWindow)
+ setPopupOpenCallback(callback);
+ else if (typeof errorCallback === "function" && !popupWindow)
+ errorCallback();
+}
+
+function setPopupOpenCallback(callback) {
+ console.assert(popupWindow);
+ popupOpenCallback = (function(callback) {
+ // We need to move the window to the top left of available space
+ // because the window will move back to (0, 0) when the
+ // ShellViewMsg_SetTestConfiguration IPC arrives.
+ rootWindow().moveTo();
+ callback();
+ }).bind(this, callback);
+ popupWindow.addEventListener("didOpenPicker", popupOpenCallbackWrapper, false);
}

Powered by Google App Engine
This is Rietveld 408576698