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

Side by Side Diff: LayoutTests/http/tests/resources/pointer-lock/pointer-lock-test-harness-prefixed.js

Issue 437443005: Revert of Revert of Remove prefixed Pointer Lock API. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 4 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 | Annotate | Revision Log
OLDNEW
(Empty)
1 // Automatically add doNextStepButton to document for manual tests.
2 if (!window.testRunner) {
3 setTimeout(function () {
4 if (window.doNextStepButtonDisabled)
5 return;
6 doNextStepButton = document.body.insertBefore(document.createElement("bu tton"), document.body.firstChild);
7 doNextStepButton.onclick = doNextStep;
8 doNextStepButton.innerText = "doNextStep button for manual testing. Use keyboard to select button and press (TAB, then SPACE).";
9 }, 0);
10 }
11
12 function runOnKeyPress(fn)
13 {
14 function keypressHandler() {
15 document.removeEventListener('keypress', keypressHandler, false);
16 fn();
17 }
18 document.addEventListener('keypress', keypressHandler, false);
19
20 if (window.testRunner)
21 eventSender.keyDown(" ", []);
22 }
23
24 function doNextStep(args)
25 {
26 args = args || {};
27 if (!window.testRunner && args.withUserGesture)
28 return; // Wait for human to press doNextStep button.
29
30 if (typeof(currentStep) == "undefined")
31 currentStep = 0;
32
33 setTimeout(function () {
34 var thisStep = currentStep++;
35 if (thisStep < todo.length)
36 if (args.withUserGesture)
37 runOnKeyPress(todo[thisStep]);
38 else
39 todo[thisStep]();
40 else if (thisStep == todo.length)
41 setTimeout(function () { finishJSTest(); }, 0); // Deferred so that excessive doNextStep calls will be observed.
42 else
43 testFailed("doNextStep called too many times.");
44 }, 0);
45 }
46
47 function doNextStepWithUserGesture()
48 {
49 doNextStep({withUserGesture: true});
50 }
51
52 function eventExpected(eventHandlerName, message, expectedCalls, targetHanderNod e)
53 {
54 targetHanderNode[eventHandlerName] = function () {
55 switch (expectedCalls--) {
56 case 0:
57 testFailed(eventHandlerName + " received after: " + message);
58 finishJSTest();
59 break;
60 case 1:
61 doNextStep();
62 default:
63 testPassed(eventHandlerName + " received after: " + message);
64 };
65 };
66 };
67
68 function expectOnlyChangeEvent(message, targetDocument) {
69 debug(" " + message);
70 targetDocument = targetDocument !== undefined ? targetDocument : document;
71 eventExpected("onwebkitpointerlockchange", message, 1, targetDocument);
72 eventExpected("onwebkitpointerlockerror", message, 0, targetDocument);
73 };
74
75 function expectOnlyErrorEvent(message, targetDocument) {
76 debug(" " + message);
77 targetDocument = targetDocument !== undefined ? targetDocument : document;
78 eventExpected("onwebkitpointerlockchange", message, 0, targetDocument);
79 eventExpected("onwebkitpointerlockerror", message, 1, targetDocument);
80 };
81
82 function expectNoEvents(message, targetDocument) {
83 debug(" " + message);
84 targetDocument = targetDocument !== undefined ? targetDocument : document;
85 eventExpected("onwebkitpointerlockchange", message, 0, targetDocument);
86 eventExpected("onwebkitpointerlockerror", message, 0, targetDocument);
87 };
88
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698