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

Unified Diff: third_party/WebKit/LayoutTests/imported/wpt_automation/pointerevents/pointerevent_common_input.js

Issue 2306103003: Use querySelector instead of getElementById (Closed)
Patch Set: Created 4 years, 3 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: third_party/WebKit/LayoutTests/imported/wpt_automation/pointerevents/pointerevent_common_input.js
diff --git a/third_party/WebKit/LayoutTests/imported/wpt_automation/pointerevents/pointerevent_common_input.js b/third_party/WebKit/LayoutTests/imported/wpt_automation/pointerevents/pointerevent_common_input.js
index 9a1185c88c6fc2caadb059f0e0f4694e23bb9198..3bdabf2767fc691fbe3116f3a796557bfa1ad8af 100644
--- a/third_party/WebKit/LayoutTests/imported/wpt_automation/pointerevents/pointerevent_common_input.js
+++ b/third_party/WebKit/LayoutTests/imported/wpt_automation/pointerevents/pointerevent_common_input.js
@@ -2,7 +2,6 @@
const scrollOffset = 30;
const boundaryOffset = 5;
-const touchSourceType = 1;
// Mouse inputs.
function mouseMoveToDocument() {
@@ -16,10 +15,10 @@ function mouseMoveToDocument() {
});
}
-function mouseMoveIntoTarget(targetId) {
+function mouseMoveIntoTarget(targetSelector) {
return new Promise(function(resolve, reject) {
if (window.eventSender) {
- var target = document.getElementById(targetId);
+ var target = document.querySelector(targetSelector);
var targetRect = target.getBoundingClientRect();
eventSender.mouseMoveTo(targetRect.left+boundaryOffset, targetRect.top+boundaryOffset);
resolve();
@@ -29,8 +28,8 @@ function mouseMoveIntoTarget(targetId) {
});
}
-function mouseClickInTarget(targetId) {
- return mouseMoveIntoTarget(targetId).then(function() {
+function mouseClickInTarget(targetSelector) {
+ return mouseMoveIntoTarget(targetSelector).then(function() {
return new Promise(function(resolve, reject) {
if (window.eventSender) {
eventSender.mouseDown(0);
@@ -43,13 +42,13 @@ function mouseClickInTarget(targetId) {
});
}
-function mouseDragInTargets(targetIdList) {
+function mouseDragInTargets(targetSelectorList) {
return new Promise(function(resolve, reject) {
if (window.eventSender) {
- mouseMoveIntoTarget(targetIdList[0]).then(function() {
+ mouseMoveIntoTarget(targetSelectorList[0]).then(function() {
eventSender.mouseDown(0);
- for (var i=1; i<targetIdList.length; i++)
- mouseMoveIntoTarget(targetIdList[i]);
+ for (var i=1; i<targetSelectorList.length; i++)
+ mouseMoveIntoTarget(targetSelectorList[i]);
eventSender.mouseUp(0);
resolve();
});
@@ -59,8 +58,8 @@ function mouseDragInTargets(targetIdList) {
});
}
-function mouseDragInTarget(targetId) {
- return mouseDragInTargets([targetId, targetId]);
+function mouseDragInTarget(targetSelector) {
+ return mouseDragInTargets([targetSelector, targetSelector]);
}
function mouseWheelScroll(direction) {
@@ -80,10 +79,10 @@ function mouseWheelScroll(direction) {
}
// Touch inputs.
-function touchTapInTarget(targetId) {
+function touchTapInTarget(targetSelector) {
return new Promise(function(resolve, reject) {
if (window.chrome && chrome.gpuBenchmarking) {
- var target = document.getElementById(targetId);
+ var target = document.querySelector(targetSelector);
target.scrollIntoViewIfNeeded();
var targetRect = target.getBoundingClientRect();
chrome.gpuBenchmarking.tap(targetRect.left + boundaryOffset, targetRect.top + boundaryOffset, function() {
@@ -95,10 +94,10 @@ function touchTapInTarget(targetId) {
});
}
-function touchScrollInTarget(targetId, direction) {
+function touchScrollInTarget(targetSelector, direction) {
return new Promise(function(resolve, reject) {
if (window.chrome && chrome.gpuBenchmarking) {
- var target = document.getElementById(targetId);
+ var target = document.querySelector(targetSelector);
target.scrollIntoViewIfNeeded();
var targetRect = target.getBoundingClientRect();
chrome.gpuBenchmarking.smoothScrollBy(scrollOffset, function() {
@@ -110,62 +109,6 @@ function touchScrollInTarget(targetId, direction) {
});
}
-function scrollPageIfNeeded(targetRect, startX, startY) {
- if (startY > window.innerHeight) {
- window.scrollTo(0, targetRect.top);
- }
- if (startX > window.innerWidth) {
- window.scrollTo(targetRect.left, 0);
- }
-}
-
-// TODO(nzolghadr): these two functions can be removed if we know the ID of the elements where we want to touch, see https://crbug.com/633672.
-function touchSmoothScrollUp(target) {
- if (window.chrome && chrome.gpuBenchmarking) {
- var targetRect = target.getBoundingClientRect();
- var startX = targetRect.left+targetRect.width/2;
- var startY = targetRect.top+targetRect.height/2;
- scrollPageIfNeeded(targetRect, startX, startY);
- targetRect = target.getBoundingClientRect();
- startX = targetRect.left+targetRect.width/2;
- startY = targetRect.top+targetRect.height/2;
- chrome.gpuBenchmarking.smoothScrollBy(scrollOffset, function() {}, startX, startY, touchSourceType, "down");
- }
-}
-
-function touchSmoothScrollLeft(target, callback_func) {
- if (window.chrome && chrome.gpuBenchmarking) {
- var targetRect = target.getBoundingClientRect();
- var startX = targetRect.left+targetRect.width/2;
- var startY = targetRect.top+targetRect.height/2;
- scrollPageIfNeeded(targetRect, startX, startY);
- targetRect = target.getBoundingClientRect();
- startX = targetRect.left+targetRect.width/2;
- startY = targetRect.top+targetRect.height/2;
- chrome.gpuBenchmarking.smoothScrollBy(scrollOffset, callback_func, startX, startY, touchSourceType, "right");
- }
-}
-
-function touchScrollUpInTarget(targetId) {
- if (window.chrome && chrome.gpuBenchmarking) {
- var target = document.getElementById(targetId);
- touchSmoothScrollUp(target);
- }
-}
-
-function touchScrollLeftInTarget(targetId, callback_func) {
- if (window.chrome && chrome.gpuBenchmarking) {
- var target = document.getElementById(targetId);
- touchSmoothScrollLeft(target, callback_func);
- }
-}
-
-function touchScrollByPosition(x, y, offset, direction, callback_func) {
- if (window.chrome && chrome.gpuBenchmarking) {
- chrome.gpuBenchmarking.smoothScrollBy(offset, callback_func, x, y, 1, direction);
- }
-}
-
// Pen inputs.
function penMoveToDocument() {
return new Promise(function(resolve, reject) {
@@ -178,10 +121,10 @@ function penMoveToDocument() {
});
}
-function penMoveIntoTarget(targetId) {
+function penMoveIntoTarget(targetSelector) {
return new Promise(function(resolve, reject) {
if (window.eventSender) {
- var target = document.getElementById(targetId);
+ var target = document.querySelector(targetSelector);
var targetRect = target.getBoundingClientRect();
eventSender.mouseMoveTo(targetRect.left+boundaryOffset, targetRect.top+boundaryOffset, [], "pen", 0);
resolve();
@@ -191,8 +134,8 @@ function penMoveIntoTarget(targetId) {
});
}
-function penClickIntoTarget(targetId) {
- return penMoveIntoTarget(targetId).then(function() {
+function penClickIntoTarget(targetSelector) {
+ return penMoveIntoTarget(targetSelector).then(function() {
return new Promise(function(resolve, reject) {
if (window.eventSender) {
eventSender.mouseDown(0, [], "pen", 0);

Powered by Google App Engine
This is Rietveld 408576698