fune/testing/web-platform/tests/navigation-api/navigation-history-entry/current-basic.html
Domenic Denicola 53e7c51dfb Bug 1760181 [wpt PR 33182] - App history API to navigation API rename (2/n), a=testonly
Automatic update from web-platform-tests
App history API to navigation API rename (2/n)

See https://github.com/WICG/navigation-api/issues/83 and https://github.com/WICG/navigation-api/pull/203 for context.

This CL renames all test files, with occasional minor updates to their contents. Notably this includes web platform test files.

While doing so, some of the web platform tests were slightly moved around to give a clearer directory structure. This revealed some confusing duplication (and in some cases mislocated tests) around state updates, which is tracked in https://crbug.com/1304446.

Bug: 1300246
Change-Id: Ieef0329e7a309c242b5391f050878bc182487905
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3510194
Reviewed-by: Nate Chapin <japhet@chromium.org>
Reviewed-by: Mason Freed <masonf@chromium.org>
Commit-Queue: Domenic Denicola <domenic@chromium.org>
Cr-Commit-Position: refs/heads/main@{#980702}

--

wpt-commits: 4e628b145e52797f421c7f832d13014387aac961
wpt-pr: 33182
2022-03-26 21:56:55 +00:00

107 lines
4.6 KiB
HTML

<!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 = navigation.currentEntry;
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(navigation.entries().length, 1);
assert_equals(first_entry, navigation.entries()[0]);
history.replaceState(2, "", "#2");
let second_entry = navigation.currentEntry;
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(navigation.entries().length, 1);
assert_equals(second_entry, navigation.entries()[0]);
history.pushState(3, "", "#3");
let third_entry = navigation.currentEntry;
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(navigation.entries().length, 2);
assert_equals(third_entry, navigation.entries()[1]);
history.pushState(4, "");
let fourth_entry = navigation.currentEntry;
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(navigation.entries().length, 3);
assert_equals(fourth_entry, navigation.entries()[2]);
history.replaceState(5, "");
let fifth_entry = navigation.currentEntry;
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(navigation.entries().length, 3);
assert_equals(fifth_entry, navigation.entries()[2]);
history.pushState(5, "");
let fifth_entry_after_push = navigation.currentEntry;
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(navigation.entries().length, 4);
assert_equals(fifth_entry_after_push, navigation.entries()[3]);
history.replaceState(5, "");
let fifth_entry_after_replace = navigation.currentEntry;
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(navigation.entries().length, 4);
assert_equals(fifth_entry_after_replace, navigation.entries()[3]);
location.hash = "6";
let sixth_entry = navigation.currentEntry;
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(navigation.entries().length, 4);
assert_equals(sixth_entry, navigation.entries()[3]);
navigation.entries().forEach(entry => {
assert_true(isUUID(entry.id));
assert_true(isUUID(entry.key));
});
}, "Basic tests for navigation.currentEntry");
</script>