Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change async_test to promise_test in clear-window-name.https.html #25572

Merged
merged 2 commits into from Sep 23, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
55 changes: 23 additions & 32 deletions html/browsers/windows/clear-window-name.https.html
Expand Up @@ -18,91 +18,82 @@
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); });
stephenmcgruer marked this conversation as resolved.
Show resolved Hide resolved

const response = await fetch(stashURL);
res = await response.text();
}
if (res !== expected) {
stephenmcgruer marked this conversation as resolved.
Show resolved Hide resolved
assert_unreached('Stash result does not equal expected result.')
}
}

async_test(async t => {
promise_test(async t => {
const id = token();

window.open(`resources/window-name.sub.html?report=${id}|close`, id);
await pollResultAndCheck(t, id, id);;
stephenmcgruer marked this conversation as resolved.
Show resolved Hide resolved
}, "Window.name is not reset when there is an opener around");

async_test(async t => {
promise_test(async t => {
const id = token();

window.open(`resources/window-name.sub.html?cross|same|report=${id}|close`, id);
await pollResultAndCheck(t, id, id);
}, "Window.name is not reset when there is an opener around (cross-origin)");

async_test(async t => {
promise_test(async t => {
const id = token();

window.open(`resources/window-name.sub.html?report=${id}|close`, id, "noopener");
await pollResultAndCheck(t, id, id);
}, "Window.name is not reset at the first navigation away from initial about:blank with noopener");

async_test(async t => {
promise_test(async t => {
const id = token();

window.open(`resources/window-name.sub.html?cross|same|report=${id}|close`, id, "noopener");
await pollResultAndCheck(t, id, "");
}, "Window.name is reset at the first cross-origin navigation with noopener");

async_test(async t => {
promise_test(async t => {
const id = token();

let win = window.open(`resources/window-name.sub.html?report=${id}|close`, id);
win.opener = null;
await pollResultAndCheck(t, id, id);
}, "Window.name is not reset at the first navigation away from initial about:blank with window.opener set to null");

async_test(async t => {
promise_test(async t => {
const id = token();

let win = window.open(`resources/window-name.sub.html?same|report=${id}|close`, id);
win.opener = null;
await pollResultAndCheck(t, id, id);
}, "Window.name is not reset at the same-origin navigation with window.opener set to null");

async_test(async t => {
promise_test(async t => {
const id = token();

let win = window.open(`resources/window-name.sub.html?cross|same|report=${id}|close`, id);
win.opener = null;
await pollResultAndCheck(t, id, "");
}, "Window.name is reset at the first first cross-origin navigation with window.opener set to null");

async_test(async t => {
promise_test(async t => {
const id = token();

anchorClick(`resources/window-name.sub.html?set=${id}|report=${id}|close`);
await pollResultAndCheck(t, id, id);
}, "Window.name is set by the window");

async_test(async t => {
promise_test(async t => {
const id = token();

anchorClick(`resources/window-name.sub.html?set=${id}|cross|same|report=${id}|close`);
Expand Down