Skip to content
This repository was archived by the owner on Mar 19, 2021. It is now read-only.

Commit cd19dbd

Browse files
LanWei22chromium-wpt-export-bot
authored andcommitted
Use promise in wpt pointer event tests to end the tests
Instead of adding a variable to check if the test should be finished, we can create a promise object and end the test at its last callback. Bug: 606367 Change-Id: I6be3a61db1f54fa88b56e919b8be6dfa318b21c0 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1704865 Reviewed-by: Navid Zolghadr <[email protected]> Commit-Queue: Lan Wei <[email protected]> Cr-Commit-Position: refs/heads/master@{#684399}
1 parent a4ddde6 commit cd19dbd

11 files changed

+73
-82
lines changed

pointerevents/pointerevent_sequence_at_implicit_release_on_drag.html

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,16 @@
2727
var test_pointer_event = setup_pointerevent_test("Event sequence at implicit release on drag", ["touch"]);
2828

2929
var button = document.getElementById("done");
30-
var clickIsReceived = false;
30+
var actions_promise;
3131
on_event(document.getElementById("done"), "click", function() {
3232
test_pointer_event.step(function () {
3333
var expected_events = "pointercancel, lostpointercapture, pointerout, pointerleave";
3434
assert_equals(event_log.join(", "), expected_events);
3535
});
36-
clickIsReceived = true;
36+
// Make sure the test finishes after all the input actions are completed.
37+
actions_promise.then( () => {
38+
test_pointer_event.done();
39+
});
3740
});
3841

3942
var target = document.getElementById("target");
@@ -55,13 +58,8 @@
5558
});
5659

5760
// Inject touch inputs.
58-
pointerDragInTarget("touch", target, 'right').then(function() {
61+
actions_promise = pointerDragInTarget("touch", target, 'right').then(function() {
5962
return clickInTarget("touch", button);
60-
}).then(function() {
61-
test_pointer_event.step(function () {
62-
assert_true(clickIsReceived, "click should be received before the test finishes");
63-
}, "click should be received before the test finishes");
64-
test_pointer_event.done();
6563
});
6664
}
6765
</script>

pointerevents/pointerevent_touch-action-auto-css_touch.html

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ <h4 id="desc">Test Description: Try to scroll text DOWN. Wait for description up
8989
var target0 = document.getElementById("target0");
9090

9191
var test_touchaction = async_test("touch-action attribute test");
92+
var actions_promise;
9293

9394
xScr0 = target0.scrollLeft;
9495
yScr0 = target0.scrollTop;
@@ -117,18 +118,17 @@ <h4 id="desc">Test Description: Try to scroll text DOWN. Wait for description up
117118
}
118119

119120
if(xScrollIsReceived && yScrollIsReceived) {
121+
// Make sure the test finishes after all the input actions are completed.
122+
actions_promise.then( () => {
123+
test_touchaction.done();
124+
});
120125
updateDescriptionComplete();
121126
}
122127
});
123128

124129
// Inject touch inputs and wait for all the actions finish to end the test.
125-
touchScrollInTarget(target0, 'down').then(function() {
130+
actions_promise = touchScrollInTarget(target0, 'down').then(function() {
126131
return touchScrollInTarget(target0, 'right');
127-
}).then(function() {
128-
test_touchaction.step(function () {
129-
assert_true(xScrollIsReceived && yScrollIsReceived, "x-scroll and y-scroll should be received before the test finishes");
130-
}, "x-scroll and y-scroll should be received before the test finishes");
131-
test_touchaction.done();
132132
});
133133
}
134134
</script>

pointerevents/pointerevent_touch-action-inherit_child-none_touch.html

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ <h4 id="desc">Test Description: Try to scroll element DOWN then RIGHT inside blu
8787
function run() {
8888
var target0 = document.getElementById("target0");
8989
var btnComplete = document.getElementById("btnComplete");
90-
var clickIsReceived = false;
90+
var actions_promise;
9191

9292
// Check if touch-action attribute works properly for embedded divs
9393
//
@@ -98,7 +98,11 @@ <h4 id="desc">Test Description: Try to scroll element DOWN then RIGHT inside blu
9898
assert_equals(target0.scrollLeft, 0, "scroll x offset should be 0 in the end of the test");
9999
assert_equals(target0.scrollTop, 0, "scroll y offset should be 0 in the end of the test");
100100
});
101-
clickIsReceived = true;
101+
102+
// Make sure the test finishes after all the input actions are completed.
103+
actions_promise.then( () => {
104+
test_touchaction.done();
105+
});
102106
updateDescriptionComplete();
103107
});
104108

@@ -107,15 +111,10 @@ <h4 id="desc">Test Description: Try to scroll element DOWN then RIGHT inside blu
107111
});
108112

109113
// Inject touch inputs.
110-
touchScrollInTarget(scrollTarget, 'down').then(function() {
114+
actions_promise = touchScrollInTarget(scrollTarget, 'down').then(function() {
111115
return touchScrollInTarget(scrollTarget, 'right');
112116
}).then(function() {
113117
return clickInTarget("touch", btnComplete);
114-
}).then(function() {
115-
test_touchaction.step(function () {
116-
assert_true(clickIsReceived, "click should be received before the test finishes");
117-
}, "click should be received before the test finishes");
118-
test_touchaction.done();
119118
});
120119
}
121120
</script>

pointerevents/pointerevent_touch-action-inherit_child-pan-x-child-pan-x_touch.html

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ <h4 id="desc">Test Description: Try to scroll element DOWN then RIGHT inside blu
9191
function run() {
9292
var target0 = document.getElementById("target0");
9393
var btnComplete = document.getElementById("btnComplete");
94-
var clickIsReceived = false;
94+
var actions_promise;
9595

9696
// Check if touch-action attribute works properly for embedded divs
9797
//
@@ -102,20 +102,19 @@ <h4 id="desc">Test Description: Try to scroll element DOWN then RIGHT inside blu
102102
assert_not_equals(target0.scrollLeft, 0, "scroll x offset should not be 0 in the end of the test");
103103
assert_equals(target0.scrollTop, 0, "scroll y offset should be 0 in the end of the test");
104104
});
105-
clickIsReceived = true;
105+
106+
// Make sure the test finishes after all the input actions are completed.
107+
actions_promise.then( () => {
108+
test_touchaction.done();
109+
});
106110
updateDescriptionComplete();
107111
});
108112

109113
// Inject touch inputs.
110-
touchScrollInTarget(scrollTarget, 'down').then(function() {
114+
actions_promise = touchScrollInTarget(scrollTarget, 'down').then(function() {
111115
return touchScrollInTarget(scrollTarget, 'right');
112116
}).then(function() {
113117
return clickInTarget("touch", btnComplete);
114-
}).then(function() {
115-
test_touchaction.step(function () {
116-
assert_true(clickIsReceived, "click should be received before the test finishes");
117-
}, "click should be received before the test finishes");
118-
test_touchaction.done();
119118
});
120119
}
121120
</script>

pointerevents/pointerevent_touch-action-inherit_highest-parent-none_touch.html

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ <h4 id="desc">Test Description: Try to scroll text DOWN inside blue rectangle. W
9292
var target0 = document.getElementById("target0");
9393

9494
var test_touchaction = async_test("touch-action attribute test");
95+
var actions_promise;
9596

9697
xScr0 = target0.scrollLeft;
9798
yScr0 = target0.scrollTop;
@@ -117,18 +118,17 @@ <h4 id="desc">Test Description: Try to scroll text DOWN inside blue rectangle. W
117118
}
118119

119120
if(xScrollIsReceived && yScrollIsReceived) {
121+
// Make sure the test finishes after all the input actions are completed.
122+
actions_promise.then( () => {
123+
test_touchaction.done();
124+
});
120125
updateDescriptionComplete();
121126
}
122127
});
123128

124129
// Inject touch inputs and wait for all the actions finish to end the test.
125-
touchScrollInTarget(target0, 'down').then(function() {
130+
actions_promise = touchScrollInTarget(target0, 'down').then(function() {
126131
return touchScrollInTarget(target0, 'right');
127-
}).then(function() {
128-
test_touchaction.step(function () {
129-
assert_true(xScrollIsReceived && yScrollIsReceived, "x-scroll and y-scroll should be received before the test finishes");
130-
}, "x-scroll and y-scroll should be received before the test finishes");
131-
test_touchaction.done();
132132
});
133133
}
134134

pointerevents/pointerevent_touch-action-inherit_parent-none_touch.html

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ <h4 id="desc">Test Description: Try to scroll element DOWN then RIGHT inside blu
8787
function run() {
8888
var target0 = document.getElementById("target0");
8989
var btnComplete = document.getElementById("btnComplete");
90-
var clickIsReceived = false;
90+
var actions_promise;
9191

9292
// Check if touch-action attribute works properly for embedded divs
9393
//
@@ -98,7 +98,11 @@ <h4 id="desc">Test Description: Try to scroll element DOWN then RIGHT inside blu
9898
assert_equals(target0.scrollLeft, 0, "scroll x offset should be 0 in the end of the test");
9999
assert_equals(target0.scrollTop, 0, "scroll y offset should be 0 in the end of the test");
100100
});
101-
clickIsReceived = true;
101+
102+
// Make sure the test finishes after all the input actions are completed.
103+
actions_promise.then( () => {
104+
test_touchaction.done();
105+
});
102106
updateDescriptionComplete();
103107
});
104108

@@ -107,15 +111,10 @@ <h4 id="desc">Test Description: Try to scroll element DOWN then RIGHT inside blu
107111
});
108112

109113
// Inject touch inputs.
110-
touchScrollInTarget(scrollTarget, 'down').then(function() {
114+
actions_promise = touchScrollInTarget(scrollTarget, 'down').then(function() {
111115
return touchScrollInTarget(scrollTarget, 'right');
112116
}).then(function() {
113117
return clickInTarget("touch", btnComplete);
114-
}).then(function() {
115-
test_touchaction.step(function () {
116-
assert_true(clickIsReceived, "click should be received before the test finishes");
117-
}, "click should be received before the test finishes");
118-
test_touchaction.done();
119118
});
120119
}
121120
</script>

pointerevents/pointerevent_touch-action-none-css_touch.html

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ <h4 id="desc">Test Description: Try to scroll element DOWN then RIGHT. Tap Compl
8787
function run() {
8888
var target0 = document.getElementById("target0");
8989
var btnComplete = document.getElementById("btnComplete");
90-
var clickIsReceived = false;
90+
var actions_promise;
9191

9292
// Check if "touch-action: none" attribute works properly
9393
//TA: 15.2
@@ -97,7 +97,11 @@ <h4 id="desc">Test Description: Try to scroll element DOWN then RIGHT. Tap Compl
9797
assert_equals(target0.scrollLeft, 0, "scroll x offset should be 0 in the end of the test");
9898
assert_equals(target0.scrollTop, 0, "scroll y offset should be 0 in the end of the test");
9999
});
100-
clickIsReceived = true;
100+
101+
// Make sure the test finishes after all the input actions are completed.
102+
actions_promise.then( () => {
103+
test_touchaction.done();
104+
});
101105
updateDescriptionComplete();
102106
});
103107

@@ -106,15 +110,10 @@ <h4 id="desc">Test Description: Try to scroll element DOWN then RIGHT. Tap Compl
106110
});
107111

108112
// Inject touch inputs.
109-
touchScrollInTarget(target0, 'down').then(function() {
113+
actions_promise = touchScrollInTarget(target0, 'down').then(function() {
110114
return touchScrollInTarget(target0, 'right');
111115
}).then(function() {
112116
return clickInTarget("touch", btnComplete);
113-
}).then(function() {
114-
test_touchaction.step(function () {
115-
assert_true(clickIsReceived, "click should be received before the test finishes");
116-
}, "click should be received before the test finishes");
117-
test_touchaction.done();
118117
});
119118
}
120119
</script>

pointerevents/pointerevent_touch-action-pan-x-css_touch.html

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ <h4 id="desc">Test Description: Try to scroll element DOWN then RIGHT. Tap Compl
8686
function run() {
8787
var target0 = document.getElementById("target0");
8888
var btnComplete = document.getElementById("btnComplete");
89-
var clickIsReceived = false;
89+
var actions_promise;
9090

9191
// Check if "touch-action: pan-x" attribute works properly
9292
//TA: 15.3
@@ -96,20 +96,19 @@ <h4 id="desc">Test Description: Try to scroll element DOWN then RIGHT. Tap Compl
9696
assert_not_equals(target0.scrollLeft, 0, "scroll x offset should not be 0 in the end of the test");
9797
assert_equals(target0.scrollTop, 0, "scroll y offset should be 0 in the end of the test");
9898
});
99-
clickIsReceived = true;
99+
100+
// Make sure the test finishes after all the input actions are completed.
101+
actions_promise.then( () => {
102+
test_touchaction.done();
103+
});
100104
updateDescriptionComplete();
101105
});
102106

103107
// Inject touch inputs.
104-
touchScrollInTarget(target0, 'down').then(function() {
108+
actions_promise = touchScrollInTarget(target0, 'down').then(function() {
105109
return touchScrollInTarget(target0, 'right');
106110
}).then(function() {
107111
return clickInTarget("touch", btnComplete);
108-
}).then(function() {
109-
test_touchaction.step(function () {
110-
assert_true(clickIsReceived, "click should be received before the test finishes");
111-
}, "click should be received before the test finishes");
112-
test_touchaction.done();
113112
});
114113
}
115114
</script>

pointerevents/pointerevent_touch-action-pan-x-pan-y-pan-y_touch.html

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ <h4 id="desc">Test Description: Try to scroll element DOWN then RIGHT inside blu
9090
function run() {
9191
var target0 = document.getElementById("target0");
9292
var btnComplete = document.getElementById("btnComplete");
93-
var clickIsReceived = false;
93+
var actions_promise;
9494

9595
// Check if touch-action attribute works properly for embedded divs
9696
//
@@ -101,20 +101,19 @@ <h4 id="desc">Test Description: Try to scroll element DOWN then RIGHT inside blu
101101
assert_equals(target0.scrollLeft, 0, "scroll x offset should be 0 in the end of the test");
102102
assert_not_equals(target0.scrollTop, 0, "scroll y offset should not be 0 in the end of the test");
103103
});
104-
clickIsReceived = true;
104+
105+
// Make sure the test finishes after all the input actions are completed.
106+
actions_promise.then( () => {
107+
test_touchaction.done();
108+
});
105109
updateDescriptionComplete();
106110
});
107111

108112
// Inject touch inputs.
109-
touchScrollInTarget(target0, 'down').then(function() {
113+
actions_promise = touchScrollInTarget(target0, 'down').then(function() {
110114
return touchScrollInTarget(target0, 'right');
111115
}).then(function() {
112116
return clickInTarget("touch", btnComplete);
113-
}).then(function() {
114-
test_touchaction.step(function () {
115-
assert_true(clickIsReceived, "click should be received before the test finishes");
116-
}, "click should be received before the test finishes");
117-
test_touchaction.done();
118117
});
119118
}
120119
</script>

pointerevents/pointerevent_touch-action-pan-x-pan-y_touch.html

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ <h4 id="desc">Test Description: Try to scroll text DOWN. Wait for description up
8989
var target0 = document.getElementById("target0");
9090

9191
var test_touchaction = async_test("touch-action attribute test");
92+
var actions_promise;
9293

9394
xScr0 = target0.scrollLeft;
9495
yScr0 = target0.scrollTop;
@@ -114,18 +115,17 @@ <h4 id="desc">Test Description: Try to scroll text DOWN. Wait for description up
114115
}
115116

116117
if(xScrollIsReceived && yScrollIsReceived) {
118+
// Make sure the test finishes after all the input actions are completed.
119+
actions_promise.then( () => {
120+
test_touchaction.done();
121+
});
117122
updateDescriptionComplete();
118123
}
119124
});
120125

121126
// Inject touch inputs and wait for all the actions finish to end the test.
122-
touchScrollInTarget(target0, 'down').then(function() {
127+
actions_promise = touchScrollInTarget(target0, 'down').then(function() {
123128
return touchScrollInTarget(target0, 'right');
124-
}).then(function() {
125-
test_touchaction.step(function () {
126-
assert_true(xScrollIsReceived && yScrollIsReceived, "x-scroll and y-scroll should be received before the test finishes");
127-
}, "x-scroll and y-scroll should be received before the test finishes");
128-
test_touchaction.done();
129129
});
130130
}
131131
</script>

0 commit comments

Comments
 (0)