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

Side by Side 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, 7 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
OLDNEW
(Empty)
1 // This file contains the commonly used functions in pointerlock tests.
2
3 const boundaryOffset = 2;
4
5 function scrollPageIfNeeded(targetSelector, targetDocument) {
6 const target = targetDocument.querySelector(targetSelector);
7 const targetRect = target.getBoundingClientRect();
8 if (targetRect.top < 0 || targetRect.left < 0 || targetRect.bottom > window.in nerHeight || targetRect.right > window.innerWidth)
9 window.scrollTo(targetRect.left, targetRect.top);
10 }
11
12 function mouseClickInTarget(targetSelector, targetFrame, button) {
13 let targetDocument = document;
14 let frameLeft = 0;
15 let frameTop = 0;
16 if (button === undefined) {
17 button = 'left';
18 }
19 if (targetFrame !== undefined) {
20 targetDocument = targetFrame.contentDocument;
21 const frameRect = targetFrame.getBoundingClientRect();
22 frameLeft = frameRect.left;
23 frameTop = frameRect.top;
24 }
25 return new Promise(function(resolve, reject) {
26 if (window.chrome && chrome.gpuBenchmarking) {
27 scrollPageIfNeeded(targetSelector, targetDocument);
28 const target = targetDocument.querySelector(targetSelector);
29 const targetRect = target.getBoundingClientRect();
30 const xPosition = frameLeft + targetRect.left + boundaryOffset;
31 const yPosition = frameTop + targetRect.top + boundaryOffset;
32 chrome.gpuBenchmarking.pointerActionSequence(
33 [{
34 source: 'mouse',
35 actions: [
36 {name: 'pointerMove', x: xPosition, y: yPosition},
37 {name: 'pointerDown', x: xPosition, y: yPosition, button: button},
38 {name: 'pointerUp', button: button}
39 ]
40 }],
41 resolve);
42 } else {
43 reject();
44 }
45 });
46 }
47
48 {
49 const pointerlock_automation = async_test("PointerLock Automation");
50 // Defined in every test and should return a promise that gets resolved when i nput is finished.
51 inject_input().then(function() {
52 pointerlock_automation.done();
53 });
54 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698