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

Unified Diff: third_party/WebKit/LayoutTests/external/wpt_automation/pointerlock/pointerlock_common_input.js

Issue 2846993002: [PointerLock] Add null check before dispatching click event (Closed)
Patch Set: rbyers's comments: Use wpt/pointerlock/; Rename test Created 3 years, 8 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/external/wpt_automation/pointerlock/pointerlock_common_input.js
diff --git a/third_party/WebKit/LayoutTests/external/wpt_automation/pointerlock/pointerlock_common_input.js b/third_party/WebKit/LayoutTests/external/wpt_automation/pointerlock/pointerlock_common_input.js
new file mode 100644
index 0000000000000000000000000000000000000000..499385b189a202ade64758ce8c5361f7a1025605
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/external/wpt_automation/pointerlock/pointerlock_common_input.js
@@ -0,0 +1,54 @@
+// This file contains the commonly used functions in pointerlock tests.
+
+const boundaryOffset = 2;
+
+function scrollPageIfNeeded(targetSelector, targetDocument) {
+ const target = targetDocument.querySelector(targetSelector);
+ const targetRect = target.getBoundingClientRect();
+ if (targetRect.top < 0 || targetRect.left < 0 || targetRect.bottom > window.innerHeight || targetRect.right > window.innerWidth)
+ window.scrollTo(targetRect.left, targetRect.top);
+}
+
+function mouseClickInTarget(targetSelector, targetFrame, button) {
+ let targetDocument = document;
+ let frameLeft = 0;
+ let frameTop = 0;
+ if (button === undefined) {
+ button = 'left';
+ }
+ if (targetFrame !== undefined) {
+ targetDocument = targetFrame.contentDocument;
+ const frameRect = targetFrame.getBoundingClientRect();
+ frameLeft = frameRect.left;
+ frameTop = frameRect.top;
+ }
+ return new Promise(function(resolve, reject) {
+ if (window.chrome && chrome.gpuBenchmarking) {
+ scrollPageIfNeeded(targetSelector, targetDocument);
+ const target = targetDocument.querySelector(targetSelector);
+ const targetRect = target.getBoundingClientRect();
+ const xPosition = frameLeft + targetRect.left + boundaryOffset;
+ const yPosition = frameTop + targetRect.top + boundaryOffset;
+ chrome.gpuBenchmarking.pointerActionSequence(
+ [{
+ source: 'mouse',
+ actions: [
+ {name: 'pointerMove', x: xPosition, y: yPosition},
+ {name: 'pointerDown', x: xPosition, y: yPosition, button: button},
+ {name: 'pointerUp', button: button}
+ ]
+ }],
+ resolve);
+ } else {
+ reject();
+ }
+ });
+}
+
+{
+ const pointerlock_automation = async_test("PointerLock Automation");
+ // Defined in every test and should return a promise that gets resolved when input is finished.
+ inject_input().then(function() {
+ pointerlock_automation.done();
+ });
+}

Powered by Google App Engine
This is Rietveld 408576698