Skip to content

Commit

Permalink
Deflake editing/selection/mouse/drags_within_user-select_combos.html
Browse files Browse the repository at this point in the history
The test is flaky because it depends on the loading status of
elements in the page. This CL fixes that by waiting for the load event.

Bug: None
Change-Id: Ifc3441400782cd598b8ce443e9675c273d79f220
Reviewed-on: https://chromium-review.googlesource.com/910331
Commit-Queue: Yutaka Hirano <yhirano@chromium.org>
Commit-Queue: Yoshifumi Inoue <yosin@chromium.org>
Reviewed-by: Yoshifumi Inoue <yosin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#536266}
  • Loading branch information
yutakahirano authored and Commit Bot committed Feb 13, 2018
1 parent 1302723 commit b24898a
Showing 1 changed file with 28 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,50 +48,64 @@
eventSender.mouseUp();
}

function runDragTests(styling) {
document.body.style.userSelect = styling;
let onload = new Promise(resolve => {
window.addEventListener('load', resolve);
});

test(function () {
function runDragTests(styling) {
promise_test(async () => {
await onload;
document.body.style.userSelect = styling;
let draggableResults = [];
registerEventListenersWithResults(draggableResults);
dragFromTopOfElement(document.getElementById('link'));
compareResults('link', ['mousedown', 'dragstart'], draggableResults);
});
}, `link (style: ${styling})`);

test(function () {
promise_test(async () => {
await onload;
document.body.style.userSelect = styling;
let draggableResults = [];
registerEventListenersWithResults(draggableResults);
dragFromTopOfElement(document.getElementById('button'));
compareResults('button', ['mousedown'], draggableResults);
});
}, `button (style: ${styling})`);

test(function () {
promise_test(async () => {
await onload;
document.body.style.userSelect = styling;
let draggableResults = [];
registerEventListenersWithResults(draggableResults);
dragFromTopOfElement(document.getElementById('image'));
compareResults('image', ['mousedown', 'dragstart'], draggableResults);
});
}, `image (style: ${styling})`);

test(function () {
promise_test(async () => {
await onload;
document.body.style.userSelect = styling;
let draggableResults = [];
registerEventListenersWithResults(draggableResults);
dragFromTopOfElement(document.getElementById('draggable_span'));
compareResults('draggable_span', ['mousedown', 'dragstart'], draggableResults);
});
}, `draggable_span (style: ${styling})`);

test(function () {
promise_test(async () => {
await onload;
document.body.style.userSelect = styling;
let draggableResults = [];
registerEventListenersWithResults(draggableResults);
dragFromTopOfElement(document.getElementById('editable_link'));
compareResults('editable_link', ['mousedown'], draggableResults);
});
}, `editable_link (style: ${styling})`);

test(function () {
promise_test(async () => {
await onload;
document.body.style.userSelect = styling;
let draggableResults = [];
registerEventListenersWithResults(draggableResults);
dragFromTopOfElement(document.getElementById('editable_link2'));
compareResults('editable_link2', ['mousedown'], draggableResults);
});
}, `editable_link2 (style: ${styling})`);
}

runDragTests("auto");
Expand Down

0 comments on commit b24898a

Please sign in to comment.