-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Test replace vs. push before/during load and pageshow
Follows whatwg/html#6714.
- Loading branch information
Showing
45 changed files
with
1,628 additions
and
6 deletions.
There are no files selected for viewing
32 changes: 32 additions & 0 deletions
32
...browsing-the-web/navigating-across-documents/replace-before-load/a-click-during-load.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
32 changes: 32 additions & 0 deletions
32
...sing-the-web/navigating-across-documents/replace-before-load/a-click-during-pageshow.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
30 changes: 30 additions & 0 deletions
30
html/browsers/browsing-the-web/navigating-across-documents/replace-before-load/a-click.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
36 changes: 36 additions & 0 deletions
36
...ing-the-web/navigating-across-documents/replace-before-load/a-user-click-during-load.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
36 changes: 36 additions & 0 deletions
36
...the-web/navigating-across-documents/replace-before-load/a-user-click-during-pageshow.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
34 changes: 34 additions & 0 deletions
34
...owsers/browsing-the-web/navigating-across-documents/replace-before-load/a-user-click.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
41 changes: 41 additions & 0 deletions
41
...e-web/navigating-across-documents/replace-before-load/form-requestsubmit-during-load.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
41 changes: 41 additions & 0 deletions
41
...b/navigating-across-documents/replace-before-load/form-requestsubmit-during-pageshow.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
39 changes: 39 additions & 0 deletions
39
.../browsing-the-web/navigating-across-documents/replace-before-load/form-requestsubmit.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
45 changes: 45 additions & 0 deletions
45
...navigating-across-documents/replace-before-load/form-submit-button-click-during-load.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
Oops, something went wrong.