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

Attempt to test replace before load #28480

Merged
merged 18 commits into from
Jun 24, 2021
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<!DOCTYPE html>
<meta charset="utf-8">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="resources/helpers.js"></script>

<body>
<script>
"use strict";
promise_test(async t => {
const sentinelIframe = await setupSentinelIframe(t);
const startingHistoryLength = history.length;

const code = `
window.onload = () => {
const a = document.createElement("a");
a.href = "/common/blank.html?thereplacement";
document.body.append(a);
a.click();
};
`;

const startURL = "resources/code-injector.html?pipe=sub(none)&code=" + encodeURIComponent(code);
const afterReplacementURL = "/common/blank.html?thereplacement";
const iframe = insertIframe(t, startURL);

assert_equals(history.length, startingHistoryLength, "Inserting the under-test iframe must not change history.length");

await waitForLoadAllowingIntermediateLoads(t, iframe, afterReplacementURL);
assert_equals(history.length, startingHistoryLength + 1, "history.length must change after waiting for the load");
}, "aElement.click() during the load event must NOT replace");
</script>
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<!DOCTYPE html>
<meta charset="utf-8">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="resources/helpers.js"></script>

<body>
<script>
"use strict";
promise_test(async t => {
const sentinelIframe = await setupSentinelIframe(t);
const startingHistoryLength = history.length;

const code = `
window.onpageshow = () => {
const a = document.createElement("a");
a.href = "/common/blank.html?thereplacement";
document.body.append(a);
a.click();
};
`;

const startURL = "resources/code-injector.html?pipe=sub(none)&code=" + encodeURIComponent(code);
const afterReplacementURL = "/common/blank.html?thereplacement";
const iframe = insertIframe(t, startURL);

assert_equals(history.length, startingHistoryLength, "Inserting the under-test iframe must not change history.length");

await waitForLoadAllowingIntermediateLoads(t, iframe, afterReplacementURL);
assert_equals(history.length, startingHistoryLength + 1, "history.length must change after waiting for the load");
}, "aElement.click() during the pageshow event must NOT replace");
</script>
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<!DOCTYPE html>
<meta charset="utf-8">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="resources/helpers.js"></script>

<body>
<script>
"use strict";
promise_test(async t => {
const sentinelIframe = await setupSentinelIframe(t);
const startingHistoryLength = history.length;

const code = `
const a = document.createElement("a");
a.href = "/common/blank.html?thereplacement";
document.currentScript.before(a);
a.click();
`;

const startURL = "resources/code-injector.html?pipe=sub(none)&code=" + encodeURIComponent(code);
const afterReplacementURL = "/common/blank.html?thereplacement";
const iframe = insertIframe(t, startURL);

assert_equals(history.length, startingHistoryLength, "Inserting the under-test iframe must not change history.length");

await waitForLoad(t, iframe, afterReplacementURL);
assert_equals(history.length, startingHistoryLength + 1, "history.length must change after waiting for the load");
}, "aElement.click() before the load event must NOT replace");
</script>
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<!DOCTYPE html>
<meta charset="utf-8">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="resources/helpers.js"></script>
<script src="/resources/testdriver.js"></script>
<script src="/resources/testdriver-vendor.js"></script>

<body>
<script>
"use strict";
promise_test(async t => {
const sentinelIframe = await setupSentinelIframe(t);
const startingHistoryLength = history.length;

const code = `
window.onload = () => {
const a = document.createElement("a");
a.href = "/common/blank.html?thereplacement";
a.id = "the-anchor";
a.textContent = "needs to have content to be clickable";
document.body.append(a);
parent.test_driver.click(a);
};
`;

const startURL = "resources/slow-code-injector.html?pipe=sub(none)&code=" + encodeURIComponent(code);
const afterReplacementURL = "/common/blank.html?thereplacement";
const iframe = insertIframe(t, startURL);

assert_equals(history.length, startingHistoryLength, "Inserting the under-test iframe must not change history.length");

await waitForLoadAllowingIntermediateLoads(t, iframe, afterReplacementURL);
assert_equals(history.length, startingHistoryLength + 1, "history.length must change after waiting for the load");
}, "User click on <a> during the load event must NOT replace");
</script>
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<!DOCTYPE html>
<meta charset="utf-8">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="resources/helpers.js"></script>
<script src="/resources/testdriver.js"></script>
<script src="/resources/testdriver-vendor.js"></script>

<body>
<script>
"use strict";
promise_test(async t => {
const sentinelIframe = await setupSentinelIframe(t);
const startingHistoryLength = history.length;

const code = `
window.onpageshow = () => {
const a = document.createElement("a");
a.href = "/common/blank.html?thereplacement";
a.id = "the-anchor";
a.textContent = "needs to have content to be clickable";
document.body.append(a);
parent.test_driver.click(a);
};
`;

const startURL = "resources/slow-code-injector.html?pipe=sub(none)&code=" + encodeURIComponent(code);
const afterReplacementURL = "/common/blank.html?thereplacement";
const iframe = insertIframe(t, startURL);

assert_equals(history.length, startingHistoryLength, "Inserting the under-test iframe must not change history.length");

await waitForLoadAllowingIntermediateLoads(t, iframe, afterReplacementURL);
assert_equals(history.length, startingHistoryLength + 1, "history.length must change after waiting for the load");
}, "User click on <a> during the pageshow event must NOT replace");
</script>
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<!DOCTYPE html>
<meta charset="utf-8">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="resources/helpers.js"></script>
<script src="/resources/testdriver.js"></script>
<script src="/resources/testdriver-vendor.js"></script>

<body>
<script>
"use strict";
promise_test(async t => {
const sentinelIframe = await setupSentinelIframe(t);
const startingHistoryLength = history.length;

const code = `
const a = document.createElement("a");
a.href = "/common/blank.html?thereplacement";
a.id = "the-anchor";
a.textContent = "needs to have content to be clickable";
document.currentScript.before(a);
parent.test_driver.click(a);
`;

const startURL = "resources/slow-code-injector.html?pipe=sub(none)&code=" + encodeURIComponent(code);
const afterReplacementURL = "/common/blank.html?thereplacement";
const iframe = insertIframe(t, startURL);

assert_equals(history.length, startingHistoryLength, "Inserting the under-test iframe must not change history.length");

await waitForLoad(t, iframe, afterReplacementURL);
assert_equals(history.length, startingHistoryLength + 1, "history.length must change after waiting for the load");
}, "User click on <a> before the load event must NOT replace");
</script>
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<!DOCTYPE html>
<meta charset="utf-8">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="resources/helpers.js"></script>

<body>
<script>
"use strict";
promise_test(async t => {
const sentinelIframe = await setupSentinelIframe(t);
const startingHistoryLength = history.length;

const code = `
window.onload = () => {
const form = document.createElement("form");
form.action = "/common/blank.html";

const input = document.createElement("input");
input.type = "hidden";
input.name = "thereplacement";
form.append(input);

document.body.append(form);
form.requestSubmit();
};
`;

const startURL = "resources/code-injector.html?pipe=sub(none)&code=" + encodeURIComponent(code);
const afterReplacementURL = "/common/blank.html?thereplacement=";
const iframe = insertIframe(t, startURL);

assert_equals(history.length, startingHistoryLength, "Inserting the under-test iframe must not change history.length");

await waitForLoadAllowingIntermediateLoads(t, iframe, afterReplacementURL);
assert_equals(history.length, startingHistoryLength, "history.length must not change after waiting for the replacement");

await checkSentinelIframe(t, sentinelIframe);
assert_equals(history.length, startingHistoryLength, "history.length must not change after checking the sentinel iframe");
}, "Replace during the load event, triggered by formElement.submit()");
</script>
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<!DOCTYPE html>
<meta charset="utf-8">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="resources/helpers.js"></script>

<body>
<script>
"use strict";
promise_test(async t => {
const sentinelIframe = await setupSentinelIframe(t);
const startingHistoryLength = history.length;

const code = `
window.onpageshow = () => {
const form = document.createElement("form");
form.action = "/common/blank.html";

const input = document.createElement("input");
input.type = "hidden";
input.name = "thereplacement";
form.append(input);

document.body.append(form);
form.requestSubmit();
};
`;

const startURL = "resources/code-injector.html?pipe=sub(none)&code=" + encodeURIComponent(code);
const afterReplacementURL = "/common/blank.html?thereplacement=";
const iframe = insertIframe(t, startURL);

assert_equals(history.length, startingHistoryLength, "Inserting the under-test iframe must not change history.length");

await waitForLoadAllowingIntermediateLoads(t, iframe, afterReplacementURL);
assert_equals(history.length, startingHistoryLength, "history.length must not change after waiting for the replacement");

await checkSentinelIframe(t, sentinelIframe);
assert_equals(history.length, startingHistoryLength, "history.length must not change after checking the sentinel iframe");
}, "Replace during the pageshow event, triggered by formElement.submit()");
</script>
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<!DOCTYPE html>
<meta charset="utf-8">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="resources/helpers.js"></script>

<body>
<script>
"use strict";
promise_test(async t => {
const sentinelIframe = await setupSentinelIframe(t);
const startingHistoryLength = history.length;

const code = `
const form = document.createElement("form");
form.action = "/common/blank.html";

const input = document.createElement("input");
input.type = "hidden";
input.name = "thereplacement";
form.append(input);

document.currentScript.before(form);
form.requestSubmit();
`;

const startURL = "resources/code-injector.html?pipe=sub(none)&code=" + encodeURIComponent(code);
const afterReplacementURL = "/common/blank.html?thereplacement=";
const iframe = insertIframe(t, startURL);

assert_equals(history.length, startingHistoryLength, "Inserting the under-test iframe must not change history.length");

await waitForLoad(t, iframe, afterReplacementURL);
assert_equals(history.length, startingHistoryLength, "history.length must not change after waiting for the replacement");

await checkSentinelIframe(t, sentinelIframe);
assert_equals(history.length, startingHistoryLength, "history.length must not change after checking the sentinel iframe");
}, "Replace before load, triggered by formElement.requestSubmit()");
</script>
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<!DOCTYPE html>
<meta charset="utf-8">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="resources/helpers.js"></script>

<body>
<script>
"use strict";
promise_test(async t => {
const sentinelIframe = await setupSentinelIframe(t);
const startingHistoryLength = history.length;

const code = `
window.onload = () => {
const form = document.createElement("form");
form.action = "/common/blank.html";
const input = document.createElement("input");
input.type = "hidden";
input.name = "thereplacement";
form.append(input);
const button = document.createElement("button");
button.type = "submit";
form.append(button);
document.body.append(form);
button.click();
};
`;

const startURL = "resources/code-injector.html?pipe=sub(none)&code=" + encodeURIComponent(code);
const afterReplacementURL = "/common/blank.html?thereplacement=";
const iframe = insertIframe(t, startURL);

assert_equals(history.length, startingHistoryLength, "Inserting the under-test iframe must not change history.length");

await waitForLoadAllowingIntermediateLoads(t, iframe, afterReplacementURL);
assert_equals(history.length, startingHistoryLength, "history.length must not change after waiting for the replacement");

await checkSentinelIframe(t, sentinelIframe);
assert_equals(history.length, startingHistoryLength, "history.length must not change after checking the sentinel iframe");
}, "Replace during load, triggered by submitButton.click()");
</script>
Loading