Skip to content

Commit

Permalink
App history API to navigation API rename (3/n)
Browse files Browse the repository at this point in the history
See WICG/navigation-api#83 and WICG/navigation-api#203 for context.

This CL is scoped mostly to the third_party/blink/renderer/core/app_history directory. That directory itself has been renamed from app_history to navigation_api. Its contents also follow the new naming. Notably, this includes changing all the IDL interface names and their backing classes, which has minor web-exposed implications.

Code outside of that directory is mostly updated due to the change from blink::AppHistory to blink::NavigationApi. References to app history still exist in Blink outside of that directory, as well as within Chromium at large; those will be tackled in a future CL.

This also finishes the process of updating the web platform tests, by both updating the actual test code for the interface renames, and updating various test descriptions and comments.

Bug: 1300246
Change-Id: I244e5fbb5d7977e8d61edae1e59d7bbfb6bdc75c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3522964
Reviewed-by: Nate Chapin <japhet@chromium.org>
Commit-Queue: Domenic Denicola <domenic@chromium.org>
Cr-Commit-Position: refs/heads/main@{#981804}
  • Loading branch information
domenic authored and chromium-wpt-export-bot committed Mar 16, 2022
1 parent 7ead7ca commit 3f00a90
Show file tree
Hide file tree
Showing 104 changed files with 120 additions and 131 deletions.
11 changes: 0 additions & 11 deletions navigation-api/README.md

This file was deleted.

2 changes: 1 addition & 1 deletion navigation-api/currententrychange-event/anchor-click.html
Expand Up @@ -14,5 +14,5 @@
});
a.click();
assert_true(oncurrententrychange_called);
}, "AppHistoryCurrentChangeEvent fires for link click");
}, "currententrychange fires for link click");
</script>
8 changes: 4 additions & 4 deletions navigation-api/currententrychange-event/constructor.html
Expand Up @@ -4,20 +4,20 @@
<script>
test(() => {
assert_throws_js(TypeError, () => {
new AppHistoryCurrentChangeEvent("currententrychange");
new NavigationCurrentEntryChangeEvent("currententrychange");
});
}, "can't bypass required members by omitting the dictionary entirely");

test(() => {
assert_throws_js(TypeError, () => {
new AppHistoryCurrentChangeEvent("currententrychange", {
new NavigationCurrentEntryChangeEvent("currententrychange", {
navigationType: "push"
});
});
}, "from is required");

test(() => {
const event = new AppHistoryCurrentChangeEvent("currententrychange", {
const event = new NavigationCurrentEntryChangeEvent("currententrychange", {
navigationType: "replace",
from: navigation.currentEntry
});
Expand All @@ -26,7 +26,7 @@
}, "all properties are reflected back");

test(t => {
const event = new AppHistoryCurrentChangeEvent("currententrychange", { from: navigation.currentEntry });
const event = new NavigationCurrentEntryChangeEvent("currententrychange", { from: navigation.currentEntry });
assert_equals(event.navigationType, null);
}, "defaults are as expected");
</script>
Expand Up @@ -20,5 +20,5 @@
assert_false(oncurrententrychange_called);
await new Promise(resolve => window.onpopstate = resolve);
assert_true(oncurrententrychange_called);
}, "AppHistoryCurrentChangeEvent fires for history.back()");
}, "currententrychange fires for history.back()");
</script>
Expand Up @@ -12,5 +12,5 @@
});
history.pushState(1, "", "#1");
assert_true(oncurrententrychange_called);
}, "AppHistoryCurrentChangeEvent fires for history.pushState()");
}, "currententrychange fires for history.pushState()");
</script>
Expand Up @@ -14,5 +14,5 @@
});
history.replaceState(1, "", "#1");
assert_true(oncurrententrychange_called);
}, "AppHistoryCurrentChangeEvent fires for history.replaceState()");
}, "currententrychange fires for history.replaceState()");
</script>
2 changes: 1 addition & 1 deletion navigation-api/currententrychange-event/location-api.html
Expand Up @@ -14,5 +14,5 @@
});
location.hash = "#foo";
assert_true(oncurrententrychange_called);
}, "AppHistoryCurrentChangeEvent fires for location API navigations");
}, "currententrychange fires for location API navigations");
</script>
Expand Up @@ -11,5 +11,5 @@
assert_equals(w.location.href, "about:blank#2");

await new Promise(resolve => t.step_timeout(resolve, 10));
}, "AppHistoryCurrentChangeEvent does not fire when navigating away from the initial about:blank (popup window)");
}, "currententrychange does not fire when navigating away from the initial about:blank (popup window)");
</script>
Expand Up @@ -8,5 +8,5 @@
i.contentWindow.location.href = "about:blank#1";
i.contentWindow.location.href = "about:blank#2";
await new Promise(resolve => t.step_timeout(resolve, 10));
}, "AppHistoryCurrentChangeEvent does not fire when navigating away from the initial about:blank");
}, "currententrychange does not fire when navigating away from the initial about:blank");
</script>
Expand Up @@ -7,5 +7,5 @@
i.contentWindow.navigation.oncurrententrychange = t.unreached_func("currententrychange should not fire");
i.contentWindow.navigation.navigate("/common/blank.html");
await new Promise(resolve => t.step_timeout(resolve, 10));
}, "AppHistoryCurrentChangeEvent does not fire when navigating away from the initial about:blank");
}, "currententrychange does not fire when navigating away from the initial about:blank");
</script>
Expand Up @@ -16,5 +16,5 @@
i.contentWindow.navigation.oncurrententrychange = t.unreached_func("currententrychange should not fire for cross-document navigations");
i.contentWindow.navigation.forward();
await new Promise(resolve => i.onload = resolve);
}, "AppHistoryCurrentChangeEvent does not fire for cross-document navigation.back() and navigation.forward()");
}, "currententrychange does not fire for cross-document navigation.back() and navigation.forward()");
</script>
Expand Up @@ -36,5 +36,5 @@
assert_false(oncurrententrychange_forward_called);
await forward_result.committed.then(() => forward_committed = true);
assert_true(oncurrententrychange_forward_called);
}, "AppHistoryCurrentChangeEvent fires for navigation.back() and navigation.forward()");
}, "currententrychange fires for same-document navigation.back() and navigation.forward()");
</script>
Expand Up @@ -8,5 +8,5 @@
i.contentWindow.navigation.oncurrententrychange = t.unreached_func("currententrychange should not fire for cross-document navigations");
i.contentWindow.navigation.navigate("/common/blank.html?1");
await new Promise(resolve => i.onload = resolve);
}, "AppHistoryCurrentChangeEvent does not fire for cross-document navigation.navigate()");
}, "currententrychange does not fire for cross-document navigation.navigate()");
</script>
Expand Up @@ -6,5 +6,5 @@
navigation.oncurrententrychange = t.unreached_func("currententrychange should not fire");
navigation.onnavigate = e => e.preventDefault();
await promise_rejects_dom(t, "AbortError", navigation.navigate("#foo").committed);
}, "AppHistoryCurrentChangeEvent does not fire when onnavigate preventDefault() is called");
}, "currententrychange does not fire when onnavigate preventDefault() is called");
</script>
Expand Up @@ -8,5 +8,5 @@
i.contentWindow.navigation.oncurrententrychange = t.unreached_func("currententrychange should not fire for cross-document navigations");
i.contentWindow.navigation.navigate("/common/blank.html?1", { replace: true });
await new Promise(resolve => i.onload = resolve);
}, "AppHistoryCurrentChangeEvent does not fire for cross-document navigation.navigate() with replace");
}, "currententrychange does not fire for cross-document navigation.navigate() with replace");
</script>
Expand Up @@ -19,5 +19,5 @@
let result = navigation.navigate("#foo", { replace: true });
assert_true(oncurrententrychange_called);
await result.committed;
}, "AppHistoryCurrentChangeEvent fires for navigation.navigate() with replace");
}, "currententrychange fires for navigation.navigate() with replace");
</script>
Expand Up @@ -19,5 +19,5 @@
let result = i.contentWindow.navigation.navigate("/common/blank.html?1", { replace: true });
assert_true(oncurrententrychange_called);
await result.committed;
}, "AppHistoryCurrentChangeEvent fires for navigation.navigate() with replace intercepted by transitionWhile");
}, "currententrychange fires for navigation.navigate() with replace intercepted by transitionWhile()");
</script>
Expand Up @@ -17,5 +17,5 @@
let result = navigation.navigate("#foo");
assert_true(oncurrententrychange_called);
await result.committed;
}, "AppHistoryCurrentChangeEvent fires for navigation.navigate()");
}, "currententrychange fires for navigation.navigate()");
</script>
Expand Up @@ -17,5 +17,5 @@
let result = i.contentWindow.navigation.navigate("/common/blank.html?1");
assert_true(oncurrententrychange_called);
await result.committed;
}, "AppHistoryCurrentChangeEvent fires for navigation.navigate() intercepted by transitionWhile");
}, "currententrychange fires for navigation.navigate() intercepted by transitionWhile()");
</script>
Expand Up @@ -8,5 +8,5 @@
i.contentWindow.navigation.oncurrententrychange = t.unreached_func("currententrychange should not fire for cross-document navigations");
i.contentWindow.navigation.reload();
await new Promise(resolve => i.onload = resolve);
}, "AppHistoryCurrentChangeEvent does not fire for cross-document navigation.reload()");
}, "currententrychange does not fire for cross-document navigation.reload()");
</script>
Expand Up @@ -17,5 +17,5 @@
let result = i.contentWindow.navigation.reload();
assert_true(oncurrententrychange_called);
await result.committed;
}, "AppHistoryCurrentChangeEvent fires for navigation.reload() intercepted by transitionWhile");
}, "currententrychange fires for navigation.reload() intercepted by transitionWhile()");
</script>
Expand Up @@ -16,5 +16,5 @@
// "Updating" the state to the current state should still fire currententrychange.
navigation.updateCurrentEntry({ state: navigation.currentEntry.getState() });
assert_equals(oncurrententrychange_count, 2);
}, "AppHistoryCurrentChangeEvent fires for navigation.updateCurrentEntry()");
}, "currententrychange fires for navigation.updateCurrentEntry()");
</script>
4 changes: 2 additions & 2 deletions navigation-api/currententrychange-event/properties.html
Expand Up @@ -4,11 +4,11 @@
<script>
async_test(t => {
navigation.oncurrententrychange = t.step_func_done(e => {
assert_equals(e.constructor, AppHistoryCurrentChangeEvent);
assert_equals(e.constructor, NavigationCurrentEntryChangeEvent);
assert_false(e.bubbles);
assert_false(e.cancelable);
assert_true(e.isTrusted);
});
location.href = "#1";
}, "AppHistoryCurrentChangeEvent's properties");
}, "NavigationCurrentEntryChangeEvent's properties");
</script>
16 changes: 8 additions & 8 deletions navigation-api/navigate-event/event-constructor.html
Expand Up @@ -4,13 +4,13 @@
<script>
test(() => {
assert_throws_js(TypeError, () => {
new AppHistoryNavigateEvent("navigate");
new NavigateEvent("navigate");
});
}, "can't bypass required members by omitting the dictionary entirely");

test(() => {
assert_throws_js(TypeError, () => {
new AppHistoryNavigateEvent("navigate", {
new NavigateEvent("navigate", {
navigationType: "push",
canTransition: false,
userInitiated: false,
Expand All @@ -23,10 +23,10 @@
}, "destination is required");

async_test(t => {
// We need to grab an AppHistoryDestination.
// We need to grab an NavigationDestination.
navigation.onnavigate = t.step_func_done(e => {
assert_throws_js(TypeError, () => {
new AppHistoryNavigateEvent("navigate", {
new NavigateEvent("navigate", {
navigationType: "push",
destination: e.destination,
canTransition: false,
Expand All @@ -41,13 +41,13 @@
}, "signal is required");

async_test(t => {
// We need to grab an AppHistoryDestination.
// We need to grab an NavigationDestination.
navigation.onnavigate = t.step_func_done(e => {
const info = { some: "object with identity" };
const formData = new FormData();
const signal = (new AbortController()).signal;

const event = new AppHistoryNavigateEvent("navigate", {
const event = new NavigateEvent("navigate", {
navigationType: "replace",
destination: e.destination,
canTransition: true,
Expand All @@ -71,9 +71,9 @@
}, "all properties are reflected back");

async_test(t => {
// We need to grab an AppHistoryDestination.
// We need to grab an NavigationDestination.
navigation.onnavigate = t.step_func_done(e => {
const event = new AppHistoryNavigateEvent("navigate", {
const event = new NavigateEvent("navigate", {
destination: e.destination,
signal: (new AbortController()).signal
});
Expand Down
Expand Up @@ -17,5 +17,5 @@
await promise_rejects_dom(t, 'AbortError', iframe_constructor, i.contentWindow.navigation.navigate("#1").committed);
assert_true(abort_signal.aborted);
assert_true(onabort_called);
}, "window detach inside AppHistoryNavigateEvent signals AppHistoryNavigateEvent.signal");
}, "window detach inside a navigate event signals event.signal");
</script>
Expand Up @@ -15,5 +15,5 @@
await promise_rejects_dom(t, 'AbortError', navigation.navigate("?1").committed);
assert_true(abort_signal.aborted);
assert_array_equals(events, ["onabort", "onnavigateerror"]);
}, "AppHistoryNavigateEvent.preventDefault signals AppHistoryNavigateEvent.signal");
}, "event.preventDefault() signals event.signal");
</script>
Expand Up @@ -14,5 +14,5 @@
await navigation.navigate("?1").finished;
assert_false(abort_signal.aborted);
assert_false(onabort_called);
}, "AppHistoryNavigateEvent's transitionWhile() does not signal AppHistoryNavigateEvent's signal");
}, "event.transitionWhile() does not signal event.signal");
</script>
Expand Up @@ -36,5 +36,5 @@
t.step_timeout(t.step_func_done(() => {}), 5);
});
});
}, "window.stop() cancels AppHistoryNavigateEvent's transitionWhile() and signals AppHistoryNavigateEvent's signal");
}, "window.stop() cancels the navigate event's transitionWhile() and signals event.signal");
</script>
Expand Up @@ -20,5 +20,5 @@
assert_true(onabort_called);
assert_true(canceled_in_second_handler);
});
}, "window.stop() signals AppHistoryNavigateEvent.signal inside a navigate event handler");
}, "window.stop() signals event.signal inside a navigate event handler");
</script>
Expand Up @@ -19,5 +19,5 @@
// didn't fire on a microtask.
t.step_timeout(t.step_func_done(() => {}), 0);
});
}, "window.stop() signals AppHistoryNavigateEvent.signal");
}, "window.stop() signals event.signal");
</script>
Expand Up @@ -12,5 +12,5 @@
});

location.href = "#1";
}, "AppHistoryNavigateEvent's transitionWhile() throws if used after the dispatch phase");
}, "event.transitionWhile() throws if used after the dispatch phase");
</script>
Expand Up @@ -13,5 +13,5 @@

location.href = "#1";
assert_true(assertionHappened);
}, "AppHistoryNavigateEvent's transitionWhile() throws if used on a canceled event");
}, "event.transitionWhile() throws if used on a canceled event");
</script>
Expand Up @@ -15,5 +15,5 @@
});

window.onload = t.step_func(() => location.href = target_url);
}, "AppHistoryNavigateEvent's transitionWhile() intercepts a same-origin cross-document navigation");
}, "event.transitionWhile() intercepts a same-origin cross-document navigation");
</script>
Expand Up @@ -14,5 +14,5 @@
});

window.onload = t.step_func(() => location.href = get_host_info().HTTPS_REMOTE_ORIGIN);
}, "AppHistoryNavigateEvent's transitionWhile() should throw if called for a cross origin navigation");
}, "event.transitionWhile() should throw if called for a cross origin navigation");
</script>
2 changes: 1 addition & 1 deletion navigation-api/navigate-event/transitionWhile-detach.html
Expand Up @@ -13,5 +13,5 @@

i.contentWindow.location.href = "#1";
});
}, "AppHistoryNavigateEvent's transitionWhile() throws if used on an event from a detached iframe");
}, "event.transitionWhile() throws if used on an event from a detached iframe");
</script>
Expand Up @@ -19,5 +19,5 @@
assert_equals(location.hash, "#1");
assert_equals(history.state, "update");
assert_equals(history.length, start_length + 1);
}, "AppHistoryNavigateEvent's transitionWhile() should proceed if the given promise resolves");
}, "event.transitionWhile() should proceed if the given promise resolves");
</script>
Expand Up @@ -19,5 +19,5 @@
assert_equals(location.hash, "#1");
assert_equals(history.state, "update");
assert_equals(history.length, start_length);
}, "AppHistoryNavigateEvent's transitionWhile() should proceed if the given promise resolves");
}, "event.transitionWhile() should proceed if the given promise resolves");
</script>
Expand Up @@ -31,5 +31,5 @@
}));
assert_true(onnavigateerror_called);
assert_true(caught_rejection);
}, "AppHistoryNavigateEvent's transitionWhile() is called multiple times and one of the promises rejects");
}, "event.transitionWhile() is called multiple times and one of the promises rejects");
</script>
Expand Up @@ -37,5 +37,5 @@
assert_true(p1_resolved);
assert_true(p2_resolved);
assert_true(p3_resolved);
}, "navigation.navigate() returns a finished promise that awaits all promises if AppHistoryNavigateEvent's transitionWhile() is called multiple times");
}, "navigation.navigate() returns a finished promise that awaits all promises if event.transitionWhile() is called multiple times");
</script>
Expand Up @@ -15,5 +15,5 @@
}));
});
}, 0);
}, "AppHistoryNavigateEvent's transitionWhile() can intercept navigation.back()");
}, "event.transitionWhile() can intercept navigation.back()");
</script>
Expand Up @@ -3,15 +3,15 @@
<script src="/resources/testharnessreport.js"></script>
<script>
async_test(t => {
// We need to grab an AppHistoryDestination to construct the event.
// We need to grab an NavigationDestination to construct the event.
navigation.onnavigate = t.step_func_done(e => {
const event = new AppHistoryNavigateEvent("navigate", {
const event = new NavigateEvent("navigate", {
destination: e.destination,
signal: (new AbortController()).signal
});

assert_throws_dom("SecurityError", () => event.transitionWhile(Promise.resolve()));
});
history.pushState(1, null, "#1");
}, "AppHistoryNavigateEvent's transitionWhile() throws if invoked on a synthetic event");
}, "event.transitionWhile() throws if invoked on a synthetic event");
</script>
2 changes: 1 addition & 1 deletion navigation-api/navigate-event/transitionWhile-reject.html
Expand Up @@ -22,5 +22,5 @@

location.href = "#1";
assert_equals(location.hash, "#1");
}, "AppHistoryNavigateEvent's transitionWhile() should abort if the given promise rejects");
}, "event.transitionWhile() should abort if the given promise rejects");
</script>

0 comments on commit 3f00a90

Please sign in to comment.