Commit b941f7f2 authored by Mustaq Ahmed's avatar Mustaq Ahmed Committed by Commit Bot

Fix user-activation/chained-setTimeout flake.

Delay the click to let initial asserts complete synchronously.

Bug: 1069087
Change-Id: I646b558d74cba977306f973c040c1420da9e2b2b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2142139
Commit-Queue: Mustaq Ahmed <mustaq@chromium.org>
Reviewed-by: default avatarNavid Zolghadr <nzolghadr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#757968}
parent d60e79d1
...@@ -10,48 +10,51 @@ ...@@ -10,48 +10,51 @@
<script src="/resources/testdriver.js"></script> <script src="/resources/testdriver.js"></script>
<script src="/resources/testdriver-vendor.js"></script> <script src="/resources/testdriver-vendor.js"></script>
<script> <script>
let chained_timeout_test = async_test("Chained setTimeout test");
const max_call_depth = 3; const max_call_depth = 3;
let initial_async_tests = {}; const delay_ms = 10;
let final_async_tests = {};
function testInitialStates(depth) { function testInitialStates(depth) {
assert_true(1 <= depth && depth <= max_call_depth); assert_true(1 <= depth && depth <= max_call_depth);
initial_async_tests[depth].step_timeout(() => { chained_timeout_test.step_timeout(() => {
assert_false(navigator.userActivation.isActive); let test_name = "Call-depth=" + depth + ": initial activation states are false";
assert_false(navigator.userActivation.hasBeenActive); test(() => {
initial_async_tests[depth].done(); assert_false(navigator.userActivation.isActive);
assert_false(navigator.userActivation.hasBeenActive);
}, test_name);
if (depth < max_call_depth) if (depth < max_call_depth)
testInitialStates(depth+1); testInitialStates(depth+1);
}, 10); else
test_driver.click(document.body);
}, delay_ms);
} }
function testFinalStates(depth) { function testFinalStates(depth) {
assert_true(1 <= depth && depth <= max_call_depth); assert_true(1 <= depth && depth <= max_call_depth);
final_async_tests[depth].step_timeout(() => { chained_timeout_test.step_timeout(() => {
assert_true(navigator.userActivation.isActive); let test_name = "Call-depth=" + depth + ": after-click activation states are true";
assert_true(navigator.userActivation.hasBeenActive); test(() => {
final_async_tests[depth].done(); assert_true(navigator.userActivation.isActive);
assert_true(navigator.userActivation.hasBeenActive);
}, test_name);
if (depth < max_call_depth) if (depth < max_call_depth)
testFinalStates(depth+1); testFinalStates(depth+1);
}, 10) else
chained_timeout_test.done();
}, delay_ms)
} }
function run() { function run() {
for (let i = 1; i <= max_call_depth; i++) {
initial_async_tests[i] = async_test("Call-depth=" + i + " initial state");
final_async_tests[i] = async_test("Call-depth=" + i + " final state");
}
testInitialStates(1);
window.addEventListener("click", event => { window.addEventListener("click", event => {
testFinalStates(1); testFinalStates(1);
}); });
test_driver.click(document.body);
testInitialStates(1);
} }
</script> </script>
</head> </head>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment