forked from web-platform-tests/wpt
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move app history tests to public WPT (web-platform-tests#29538)
Bug: 1183545 Change-Id: Ie06b392f1982227946a118d16982dff8dd9a4051 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2991902 Auto-Submit: Domenic Denicola <[email protected]> Reviewed-by: Nate Chapin <[email protected]> Commit-Queue: Domenic Denicola <[email protected]> Cr-Commit-Position: refs/heads/master@{#897133} Co-authored-by: Domenic Denicola <[email protected]>
- Loading branch information
1 parent
a2c1301
commit 86c1936
Showing
114 changed files
with
2,510 additions
and
0 deletions.
There are no files selected for viewing
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,4 @@ | ||
spec: https://wicg.github.io/app-history/ | ||
suggested_reviewers: | ||
- domenic | ||
- natechapin |
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,20 @@ | ||
<!doctype html> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<iframe id="i" src="/common/blank.html"></iframe> | ||
<script> | ||
async_test(t => { | ||
window.onload = t.step_func_done(() => { | ||
let i_entry = i.contentWindow.appHistory.current; | ||
assert_true(i_entry.sameDocument); | ||
assert_not_equals(i_entry.url, ""); | ||
assert_not_equals(i_entry.key, ""); | ||
assert_not_equals(i_entry.id, ""); | ||
i.remove(); | ||
assert_false(i_entry.sameDocument); | ||
assert_equals(i_entry.url, ""); | ||
assert_equals(i_entry.key, ""); | ||
assert_equals(i_entry.id, ""); | ||
}); | ||
}, "AppHistoryEntry attributes after detach"); | ||
</script> |
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,17 @@ | ||
<!doctype html> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<iframe id="i" src="/common/blank.html"></iframe> | ||
<script> | ||
async_test(t => { | ||
window.onload = t.step_func_done(() => { | ||
let i_appHistory = i.contentWindow.appHistory; | ||
assert_not_equals(i_appHistory, null); | ||
assert_not_equals(i_appHistory.current, null); | ||
assert_equals(i_appHistory.entries().length, 1); | ||
i.remove(); | ||
assert_equals(i_appHistory.current, null); | ||
assert_equals(i_appHistory.entries().length, 0); | ||
}); | ||
}, "appHistory.current should be null after iframe removal"); | ||
</script> |
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,107 @@ | ||
<!doctype html> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<script src="resources/is_uuid.js"></script> | ||
<script> | ||
test(() => { | ||
let first_entry = appHistory.current; | ||
assert_not_equals(first_entry, null); | ||
assert_not_equals(first_entry.key, null); | ||
assert_true(isUUID(first_entry.key)); | ||
assert_not_equals(first_entry.id, null); | ||
assert_true(isUUID(first_entry.id)); | ||
assert_equals(first_entry.url, location.href); | ||
assert_true(first_entry.sameDocument); | ||
assert_equals(appHistory.entries().length, 1); | ||
assert_equals(first_entry, appHistory.entries()[0]); | ||
|
||
history.replaceState(2, "", "#2"); | ||
let second_entry = appHistory.current; | ||
assert_not_equals(second_entry, first_entry); | ||
assert_equals(second_entry.key, first_entry.key); | ||
assert_true(isUUID(second_entry.key)); | ||
assert_not_equals(second_entry.id, first_entry.id); | ||
assert_true(isUUID(second_entry.id)); | ||
assert_equals(second_entry.url, location.href); | ||
assert_true(second_entry.sameDocument); | ||
assert_equals(appHistory.entries().length, 1); | ||
assert_equals(second_entry, appHistory.entries()[0]); | ||
|
||
history.pushState(3, "", "#3"); | ||
let third_entry = appHistory.current; | ||
assert_not_equals(third_entry, second_entry); | ||
assert_not_equals(third_entry.key, second_entry.key); | ||
assert_true(isUUID(third_entry.key)); | ||
assert_not_equals(third_entry.id, second_entry.id); | ||
assert_true(isUUID(third_entry.id)); | ||
assert_equals(third_entry.url, location.href); | ||
assert_true(third_entry.sameDocument); | ||
assert_equals(appHistory.entries().length, 2); | ||
assert_equals(third_entry, appHistory.entries()[1]); | ||
|
||
history.pushState(4, ""); | ||
let fourth_entry = appHistory.current; | ||
assert_not_equals(fourth_entry, third_entry); | ||
assert_not_equals(fourth_entry.key, third_entry.key); | ||
assert_true(isUUID(fourth_entry.key)); | ||
assert_not_equals(fourth_entry.id, third_entry.id); | ||
assert_true(isUUID(fourth_entry.id)); | ||
assert_equals(fourth_entry.url, third_entry.url); | ||
assert_true(fourth_entry.sameDocument); | ||
assert_equals(appHistory.entries().length, 3); | ||
assert_equals(fourth_entry, appHistory.entries()[2]); | ||
|
||
history.replaceState(5, ""); | ||
let fifth_entry = appHistory.current; | ||
assert_not_equals(fifth_entry, fourth_entry); | ||
assert_equals(fifth_entry.key, fourth_entry.key); | ||
assert_true(isUUID(fifth_entry.key)); | ||
assert_not_equals(fifth_entry.id, fourth_entry.id); | ||
assert_true(isUUID(fifth_entry.id)); | ||
assert_equals(fifth_entry.url, fourth_entry.url); | ||
assert_true(fifth_entry.sameDocument); | ||
assert_equals(appHistory.entries().length, 3); | ||
assert_equals(fifth_entry, appHistory.entries()[2]); | ||
|
||
history.pushState(5, ""); | ||
let fifth_entry_after_push = appHistory.current; | ||
assert_not_equals(fifth_entry_after_push, fifth_entry); | ||
assert_not_equals(fifth_entry_after_push.key, fifth_entry.key); | ||
assert_true(isUUID(fifth_entry_after_push.key)); | ||
assert_not_equals(fifth_entry_after_push.id, fifth_entry.id); | ||
assert_true(isUUID(fifth_entry_after_push.id)); | ||
assert_equals(fifth_entry_after_push.url, fifth_entry.url); | ||
assert_true(fifth_entry_after_push.sameDocument); | ||
assert_equals(appHistory.entries().length, 4); | ||
assert_equals(fifth_entry_after_push, appHistory.entries()[3]); | ||
|
||
history.replaceState(5, ""); | ||
let fifth_entry_after_replace = appHistory.current; | ||
assert_not_equals(fifth_entry_after_replace, fifth_entry_after_push); | ||
assert_equals(fifth_entry_after_replace.key, fifth_entry_after_push.key); | ||
assert_true(isUUID(fifth_entry_after_replace.key)); | ||
assert_not_equals(fifth_entry_after_replace.id, fifth_entry_after_push.id); | ||
assert_true(isUUID(fifth_entry_after_replace.id)); | ||
assert_equals(fifth_entry_after_replace.url, fifth_entry_after_push.url); | ||
assert_true(fifth_entry_after_replace.sameDocument); | ||
assert_equals(appHistory.entries().length, 4); | ||
assert_equals(fifth_entry_after_replace, appHistory.entries()[3]); | ||
|
||
location.hash = "6"; | ||
let sixth_entry = appHistory.current; | ||
assert_not_equals(sixth_entry, fifth_entry_after_replace); | ||
assert_equals(sixth_entry.key, fifth_entry_after_replace.key); | ||
assert_true(isUUID(sixth_entry.key)); | ||
assert_not_equals(sixth_entry.id, fifth_entry_after_replace.id); | ||
assert_true(isUUID(sixth_entry.id)); | ||
assert_not_equals(sixth_entry.url, fifth_entry_after_replace.url); | ||
assert_true(sixth_entry.sameDocument); | ||
assert_equals(appHistory.entries().length, 4); | ||
assert_equals(sixth_entry, appHistory.entries()[3]); | ||
|
||
appHistory.entries().forEach(entry => { | ||
assert_true(isUUID(entry.id)); | ||
assert_true(isUUID(entry.key)); | ||
}); | ||
}, "Basic tests for appHistory.current"); | ||
</script> |
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,33 @@ | ||
<!doctype html> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<script src="/common/get-host-info.sub.js"></script> | ||
<script src="resources/is_uuid.js"></script> | ||
<iframe id="i" src="/common/blank.html"></iframe> | ||
<script> | ||
async_test(t => { | ||
window.onload = t.step_func(() => { | ||
let start_key = i.contentWindow.appHistory.current.key; | ||
let start_id = i.contentWindow.appHistory.current.id; | ||
|
||
let cross_origin_url = new URL("resources/post-entries-length-to-top.html", location.href); | ||
cross_origin_url.hostname = get_host_info().REMOTE_HOST; | ||
i.contentWindow.location.assign(cross_origin_url.href); | ||
|
||
window.onmessage = t.step_func(e => { | ||
assert_equals(e.data, 1); | ||
|
||
i.src = "/common/blank.html?2"; | ||
i.onload = t.step_func_done(() => { | ||
let entries = i.contentWindow.appHistory.entries(); | ||
assert_equals(entries.length, 1); | ||
assert_equals(new URL(entries[0].url).search, "?2"); | ||
assert_not_equals(entries[0].key, start_key); | ||
assert_not_equals(entries[0].id, start_id); | ||
assert_true(isUUID(entries[0].key)); | ||
assert_true(isUUID(entries[0].id)); | ||
}); | ||
}); | ||
}); | ||
}, "appHistory.entries() should only contain entries that are both same-origin and contiguous"); | ||
</script> |
25 changes: 25 additions & 0 deletions
25
app-history/app-history-entry/entries-after-blank-navigation.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,25 @@ | ||
<!doctype html> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<script src="resources/is_uuid.js"></script> | ||
<iframe id="i" src="/common/blank.html"></iframe> | ||
<script> | ||
async_test(t => { | ||
window.onload = t.step_func(() => { | ||
i.onload = t.step_func_done(() => { | ||
let entries = i.contentWindow.appHistory.entries(); | ||
assert_equals(entries.length, 2); | ||
assert_not_equals(entries[1].key, entries[0].key); | ||
assert_not_equals(entries[1].url, entries[0].url); | ||
assert_equals(entries[1].url, "about:blank"); | ||
assert_not_equals(entries[1].id, entries[0].id); | ||
|
||
assert_true(isUUID(entries[0].key)); | ||
assert_true(isUUID(entries[0].id)); | ||
assert_true(isUUID(entries[1].key)); | ||
assert_true(isUUID(entries[1].id)); | ||
}); | ||
i.src = "about:blank"; | ||
}); | ||
}, "AppHistory behavior after navigation to about:blank"); | ||
</script> |
25 changes: 25 additions & 0 deletions
25
app-history/app-history-entry/entries-after-blob-navigation.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,25 @@ | ||
<!doctype html> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<script src="resources/is_uuid.js"></script> | ||
<iframe id="i" src="/common/blank.html"></iframe> | ||
<script> | ||
async_test(t => { | ||
window.onload = t.step_func(() => { | ||
i.onload = t.step_func_done(() => { | ||
let entries = i.contentWindow.appHistory.entries(); | ||
assert_equals(entries.length, 2); | ||
assert_not_equals(entries[1].key, entries[0].key); | ||
assert_not_equals(entries[1].url, entries[0].url); | ||
assert_equals(new URL(entries[1].url).protocol, "blob:"); | ||
assert_not_equals(entries[1].id, entries[0].id); | ||
|
||
assert_true(isUUID(entries[0].key)); | ||
assert_true(isUUID(entries[0].id)); | ||
assert_true(isUUID(entries[1].key)); | ||
assert_true(isUUID(entries[1].id)); | ||
}); | ||
i.src = URL.createObjectURL(new Blob(["<body></body>"])); | ||
}); | ||
}, "AppHistory behavior after navigation to a blob: url"); | ||
</script> |
23 changes: 23 additions & 0 deletions
23
app-history/app-history-entry/entries-after-data-url-navigation.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,23 @@ | ||
<!doctype html> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<iframe id="i" src="/common/blank.html"></iframe> | ||
<script> | ||
async_test(t => { | ||
window.onload = t.step_func(() => { | ||
let start_key = i.contentWindow.appHistory.current.key; | ||
let start_url = i.contentWindow.appHistory.current.url; | ||
let start_id = i.contentWindow.appHistory.current.id; | ||
window.onmessage = t.step_func_done(e => { | ||
assert_equals(e.data.length, 1); | ||
assert_not_equals(e.data.key, start_key); | ||
assert_equals(e.data.protocol, "data:"); | ||
assert_not_equals(e.data.id, start_id); | ||
}); | ||
i.src = "data:text/html,<script>top.postMessage({ length: appHistory.entries().length, " + | ||
"key: appHistory.current.key, protocol: new URL(appHistory.current.url).protocol," + | ||
"id: appHistory.current.id}, '*')</sc" + | ||
"ript>"; | ||
}); | ||
}, "AppHistory behavior after navigation to a data: url"); | ||
</script> |
38 changes: 38 additions & 0 deletions
38
app-history/app-history-entry/entries-after-javascript-url-navigation.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,38 @@ | ||
<!doctype html> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<iframe id="i" src="/common/blank.html"></iframe> | ||
<script> | ||
async_test(t => { | ||
window.onload = t.step_func(() => { | ||
let start_key = i.contentWindow.appHistory.current.key; | ||
let start_url = i.contentWindow.appHistory.current.url; | ||
let start_id = i.contentWindow.appHistory.current.id; | ||
let did_js_url_nav = false; | ||
i.onload = t.step_func(() => { | ||
if (!did_js_url_nav) { | ||
assert_equals(i.contentWindow.appHistory.entries().length, 2); | ||
before_js_nav_key = i.contentWindow.appHistory.current.key; | ||
before_js_nav_url = i.contentWindow.appHistory.current.url; | ||
before_js_nav_id = i.contentWindow.appHistory.current.id; | ||
i.src = "javascript:'new content'"; | ||
did_js_url_nav = true; | ||
} else { | ||
assert_equals(i.contentWindow.appHistory.entries().length, 2); | ||
let first_entry = i.contentWindow.appHistory.entries()[0]; | ||
let js_url_entry = i.contentWindow.appHistory.entries()[1]; | ||
assert_equals(first_entry.key, start_key); | ||
assert_equals(first_entry.url, start_url); | ||
assert_equals(first_entry.id, start_id); | ||
|
||
assert_equals(js_url_entry, i.contentWindow.appHistory.current); | ||
assert_equals(js_url_entry.key, before_js_nav_key); | ||
assert_equals(js_url_entry.url, before_js_nav_url); | ||
assert_not_equals(js_url_entry.id, before_js_nav_id); | ||
t.done(); | ||
} | ||
}); | ||
i.contentWindow.appHistory.navigate("?1"); | ||
}); | ||
}, "AppHistory behavior after navigation to a javascript: url"); | ||
</script> |
34 changes: 34 additions & 0 deletions
34
app-history/app-history-entry/entries-after-navigations-in-multiple-windows.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> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<script src="resources/is_uuid.js"></script> | ||
<iframe id="i" src="/common/blank.html"></iframe> | ||
<script> | ||
async_test(t => { | ||
// The navigations in each window should have only added an appHistory to | ||
// their own window. | ||
function assertExpectedEntries(entries, expected_url) { | ||
assert_equals(entries.length, 2); | ||
assert_not_equals(entries[1].key, entries[0].key); | ||
assert_not_equals(entries[1].url, entries[0].url); | ||
assert_not_equals(entries[1].id, entries[0].id); | ||
assert_true(isUUID(entries[0].key)); | ||
assert_true(isUUID(entries[0].id)); | ||
assert_true(isUUID(entries[1].key)); | ||
assert_true(isUUID(entries[1].id)); | ||
|
||
assert_equals(entries[1].url, expected_url); | ||
} | ||
|
||
// Wait for after the load event so that the navigation doesn't get converted | ||
// into a replace navigation. | ||
window.onload = () => t.step_timeout(t.step_func(() => { | ||
location.hash = "#1"; | ||
i.onload = t.step_func_done(() => { | ||
assertExpectedEntries(appHistory.entries(), location.href); | ||
assertExpectedEntries(i.contentWindow.appHistory.entries(), i.contentWindow.location.href); | ||
}); | ||
i.contentWindow.location = "/common/blank.html?2"; | ||
}), 0); | ||
}, "appHistory.entries() behavior when multiple windows navigate."); | ||
</script> |
25 changes: 25 additions & 0 deletions
25
app-history/app-history-entry/entries-after-srcdoc-navigation.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,25 @@ | ||
<!doctype html> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<script src="resources/is_uuid.js"></script> | ||
<iframe id="i" src="/common/blank.html"></iframe> | ||
<script> | ||
async_test(t => { | ||
window.onload = t.step_func(() => { | ||
i.onload = t.step_func_done(() => { | ||
let entries = i.contentWindow.appHistory.entries(); | ||
assert_equals(entries.length, 2); | ||
assert_not_equals(entries[1].key, entries[0].key); | ||
assert_not_equals(entries[1].url, entries[0].url); | ||
assert_equals(entries[1].url, "about:srcdoc"); | ||
assert_not_equals(entries[1].id, entries[0].id); | ||
|
||
assert_true(isUUID(entries[0].key)); | ||
assert_true(isUUID(entries[0].id)); | ||
assert_true(isUUID(entries[1].key)); | ||
assert_true(isUUID(entries[1].id)); | ||
}); | ||
i.srcdoc = "new"; | ||
}); | ||
}, "AppHistory behavior after setting a srcdoc attribute"); | ||
</script> |
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,8 @@ | ||
<!doctype html> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<script> | ||
test(() => { | ||
assert_not_equals(appHistory.entries(), appHistory.entries()); | ||
}, "appHistory.entries() should not return an identical object on repeated invocations"); | ||
</script> |
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,16 @@ | ||
<!doctype html> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<script> | ||
async_test(t => { | ||
const first_entry = appHistory.entries()[0]; | ||
history.pushState(1, "", "#1"); | ||
assert_equals(appHistory.entries()[0], first_entry); | ||
history.back(); | ||
window.onpopstate = t.step_func_done(() => { | ||
const second_entry = appHistory.entries()[1]; | ||
history.replaceState(0, "", "#0"); | ||
assert_equals(appHistory.entries()[1], second_entry); | ||
}); | ||
}, "A non-active entry in appHistory.entries() should not be modified when a different entry is modified"); | ||
</script> |
Oops, something went wrong.