Skip to content

Commit

Permalink
Fix pollResultAndCheck
Browse files Browse the repository at this point in the history
  • Loading branch information
stephenmcgruer committed Sep 21, 2020
1 parent e43f322 commit 8bb0fbb
Showing 1 changed file with 14 additions and 23 deletions.
37 changes: 14 additions & 23 deletions html/browsers/windows/clear-window-name.https.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,29 +18,20 @@
hyperlink.click();
}

function pollResultAndCheck(t, id, expected) {
return new Promise(resolve => {
const stashURL = new URL("resources/window-name-stash.py", location);
stashURL.searchParams.set('id', id);

let checkResult = t.step_func(async () => {
let response = await fetch(stashURL);
let res = await response.text();


if (res !== "NONE") {
if (res !== expected) {
t.step(() => assert_unreached('Stash result does not equal expected result.'));
}
t.done();
resolve();
} else {
t.step_timeout(checkResult, 100);
}
});

t.step_timeout(checkResult, 100);
});
async function pollResultAndCheck(t, id, expected) {
const stashURL = new URL("resources/window-name-stash.py", location);
stashURL.searchParams.set('id', id);

let res = "NONE";
while (res == "NONE") {
await new Promise(resolve => { t.step_timeout(resolve, 100); });

const response = await fetch(stashURL);
res = await response.text();
}
if (res !== expected) {
assert_unreached('Stash result does not equal expected result.')
}
}

promise_test(async t => {
Expand Down

0 comments on commit 8bb0fbb

Please sign in to comment.