-
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.
Bug 1733160 [wpt PR 30951] - Implement AppHistoryCurrentChangeEvent, …
…a=testonly Automatic update from web-platform-tests Implement AppHistoryCurrentChangeEvent Spec/explainer: WICG/navigation-api#171 Bug: 1252532 Change-Id: Ibd8a856fc36b37d5f4095627808a9a0be15de283 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3182849 Reviewed-by: Domenic Denicola <domenic@chromium.org> Commit-Queue: Nate Chapin <japhet@chromium.org> Cr-Commit-Position: refs/heads/main@{#924964} -- wpt-commits: 161a88adff2a582eb6a00fb556a8dbb33801df8b wpt-pr: 30951
- Loading branch information
1 parent
caa1777
commit 4d20d48
Showing
22 changed files
with
423 additions
and
0 deletions.
There are no files selected for viewing
18 changes: 18 additions & 0 deletions
18
testing/web-platform/tests/app-history/currentchange-event/currentchange-anchor-href.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,18 @@ | ||
<!doctype html> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<a id="a" href="#foo"></a> | ||
<script> | ||
test(t => { | ||
let oncurrentchange_called = false; | ||
appHistory.oncurrentchange = t.step_func(e => { | ||
oncurrentchange_called = true; | ||
assert_equals(e.from, appHistory.entries()[0]); | ||
assert_equals(e.from.index, 0); | ||
assert_equals(e.navigationType, "push"); | ||
assert_equals(appHistory.current.index, 1); | ||
}); | ||
a.click(); | ||
assert_true(oncurrentchange_called); | ||
}, "AppHistoryCurrentChangeEvent fires for link click"); | ||
</script> |
20 changes: 20 additions & 0 deletions
20
...sts/app-history/currentchange-event/currentchange-app-history-back-forward-cross-doc.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,20 @@ | ||
<!doctype html> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<iframe id="i" src="/common/blank.html"></iframe> | ||
<script> | ||
promise_test(async t => { | ||
await new Promise(resolve => window.onload = resolve); | ||
i.contentWindow.appHistory.navigate("/common/blank.html?1"); | ||
await new Promise(resolve => i.onload = resolve); | ||
assert_equals(i.contentWindow.appHistory.entries().length, 2); | ||
|
||
i.contentWindow.appHistory.oncurrentchange = t.unreached_func("currentchange should not fire for cross-document navigations"); | ||
i.contentWindow.appHistory.back(); | ||
await new Promise(resolve => i.onload = resolve); | ||
|
||
i.contentWindow.appHistory.oncurrentchange = t.unreached_func("currentchange should not fire for cross-document navigations"); | ||
i.contentWindow.appHistory.forward(); | ||
await new Promise(resolve => i.onload = resolve); | ||
}, "AppHistoryCurrentChangeEvent does not fire for cross-document appHistory.back() and appHistory.forward()"); | ||
</script> |
40 changes: 40 additions & 0 deletions
40
...ests/app-history/currentchange-event/currentchange-app-history-back-forward-same-doc.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,40 @@ | ||
<!doctype html> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<script> | ||
promise_test(async t => { | ||
// Wait for after the load event so that the navigation doesn't get converted | ||
// into a replace navigation. | ||
await new Promise(resolve => window.onload = t.step_timeout(resolve, 0)); | ||
await appHistory.navigate("#foo"); | ||
assert_equals(appHistory.entries().length, 2); | ||
|
||
let oncurrentchange_back_called = false; | ||
let back_committed = false; | ||
appHistory.oncurrentchange = t.step_func(e => { | ||
oncurrentchange_back_called = true; | ||
assert_equals(e.from, appHistory.entries()[1]); | ||
assert_equals(e.navigationType, "traverse"); | ||
assert_equals(appHistory.current.index, 0); | ||
assert_false(back_committed); | ||
}); | ||
let back_result = appHistory.back(); | ||
assert_false(oncurrentchange_back_called); | ||
await back_result.committed.then(() => back_committed = true); | ||
assert_true(oncurrentchange_back_called); | ||
|
||
let oncurrentchange_forward_called = false; | ||
let forward_committed = false; | ||
appHistory.oncurrentchange = t.step_func(e => { | ||
oncurrentchange_forward_called = true; | ||
assert_equals(e.from, appHistory.entries()[0]); | ||
assert_equals(e.navigationType, "traverse"); | ||
assert_equals(appHistory.current.index, 1); | ||
assert_false(forward_committed); | ||
}); | ||
let forward_result = appHistory.forward(); | ||
assert_false(oncurrentchange_forward_called); | ||
await forward_result.committed.then(() => forward_committed = true); | ||
assert_true(oncurrentchange_forward_called); | ||
}, "AppHistoryCurrentChangeEvent fires for appHistory.back() and appHistory.forward()"); | ||
</script> |
12 changes: 12 additions & 0 deletions
12
...m/tests/app-history/currentchange-event/currentchange-app-history-navigate-cross-doc.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,12 @@ | ||
<!doctype html> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<iframe id="i" src="/common/blank.html"></iframe> | ||
<script> | ||
promise_test(async t => { | ||
await new Promise(resolve => window.onload = resolve); | ||
i.contentWindow.appHistory.oncurrentchange = t.unreached_func("currentchange should not fire for cross-document navigations"); | ||
i.contentWindow.appHistory.navigate("/common/blank.html?1"); | ||
await new Promise(resolve => i.onload = resolve); | ||
}, "AppHistoryCurrentChangeEvent does not fire for cross-document appHistory.navigate()"); | ||
</script> |
10 changes: 10 additions & 0 deletions
10
...ts/app-history/currentchange-event/currentchange-app-history-navigate-preventDefault.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,10 @@ | ||
<!doctype html> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<script> | ||
promise_test(async t => { | ||
appHistory.oncurrentchange = t.unreached_func("currentchange should not fire"); | ||
appHistory.onnavigate = e => e.preventDefault(); | ||
await promise_rejects_dom(t, "AbortError", appHistory.navigate("#foo").committed); | ||
}, "AppHistoryCurrentChangeEvent does not fire when onnavigate preventDefault() is called"); | ||
</script> |
12 changes: 12 additions & 0 deletions
12
...app-history/currentchange-event/currentchange-app-history-navigate-replace-cross-doc.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,12 @@ | ||
<!doctype html> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<iframe id="i" src="/common/blank.html"></iframe> | ||
<script> | ||
promise_test(async t => { | ||
await new Promise(resolve => window.onload = resolve); | ||
i.contentWindow.appHistory.oncurrentchange = t.unreached_func("currentchange should not fire for cross-document navigations"); | ||
i.contentWindow.appHistory.navigate("/common/blank.html?1", { replace: true }); | ||
await new Promise(resolve => i.onload = resolve); | ||
}, "AppHistoryCurrentChangeEvent does not fire for cross-document appHistory.navigate() with replace"); | ||
</script> |
23 changes: 23 additions & 0 deletions
23
.../app-history/currentchange-event/currentchange-app-history-navigate-replace-same-doc.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> | ||
<script> | ||
promise_test(async t => { | ||
// Wait for after the load event so that the navigation doesn't get converted | ||
// into a replace navigation. | ||
await new Promise(resolve => window.onload = t.step_timeout(resolve, 0)); | ||
|
||
let oncurrentchange_called = false; | ||
let original_entry = appHistory.current; | ||
appHistory.oncurrentchange = t.step_func(e => { | ||
oncurrentchange_called = true; | ||
assert_equals(e.from, original_entry); | ||
assert_equals(e.from.index, -1); | ||
assert_equals(e.navigationType, "replace"); | ||
assert_equals(appHistory.current.index, 0); | ||
}); | ||
let result = appHistory.navigate("#foo", { replace: true }); | ||
assert_true(oncurrentchange_called); | ||
await result.committed; | ||
}, "AppHistoryCurrentChangeEvent fires for appHistory.navigate() with replace"); | ||
</script> |
23 changes: 23 additions & 0 deletions
23
...story/currentchange-event/currentchange-app-history-navigate-replace-transitionWhile.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> | ||
promise_test(async t => { | ||
await new Promise(resolve => window.onload = resolve); | ||
|
||
let oncurrentchange_called = false; | ||
let original_entry = i.contentWindow.appHistory.current; | ||
i.contentWindow.appHistory.oncurrentchange = t.step_func(e => { | ||
oncurrentchange_called = true; | ||
assert_equals(e.from, original_entry); | ||
assert_equals(e.from.index, -1); | ||
assert_equals(e.navigationType, "replace"); | ||
assert_equals(i.contentWindow.appHistory.current.index, 0); | ||
}); | ||
i.contentWindow.appHistory.onnavigate = e => e.transitionWhile(Promise.resolve()); | ||
let result = i.contentWindow.appHistory.navigate("/common/blank.html?1", { replace: true }); | ||
assert_true(oncurrentchange_called); | ||
await result.committed; | ||
}, "AppHistoryCurrentChangeEvent fires for appHistory.navigate() with replace intercepted by transitionWhile"); | ||
</script> |
21 changes: 21 additions & 0 deletions
21
...rm/tests/app-history/currentchange-event/currentchange-app-history-navigate-same-doc.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,21 @@ | ||
<!doctype html> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<script> | ||
promise_test(async t => { | ||
// Wait for after the load event so that the navigation doesn't get converted | ||
// into a replace navigation. | ||
await new Promise(resolve => window.onload = t.step_timeout(resolve, 0)); | ||
|
||
let oncurrentchange_called = false; | ||
appHistory.oncurrentchange = t.step_func(e => { | ||
oncurrentchange_called = true; | ||
assert_equals(e.from, appHistory.entries()[0]); | ||
assert_equals(e.navigationType, "push"); | ||
assert_equals(appHistory.current.index, 1); | ||
}); | ||
let result = appHistory.navigate("#foo"); | ||
assert_true(oncurrentchange_called); | ||
await result.committed; | ||
}, "AppHistoryCurrentChangeEvent fires for appHistory.navigate()"); | ||
</script> |
21 changes: 21 additions & 0 deletions
21
...s/app-history/currentchange-event/currentchange-app-history-navigate-transitionWhile.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,21 @@ | ||
<!doctype html> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<iframe id="i" src="/common/blank.html"></iframe> | ||
<script> | ||
promise_test(async t => { | ||
await new Promise(resolve => window.onload = resolve); | ||
|
||
let oncurrentchange_called = false; | ||
i.contentWindow.appHistory.oncurrentchange = t.step_func(e => { | ||
oncurrentchange_called = true; | ||
assert_equals(e.from, i.contentWindow.appHistory.entries()[0]); | ||
assert_equals(e.navigationType, "push"); | ||
assert_equals(i.contentWindow.appHistory.current.index, 1); | ||
}); | ||
i.contentWindow.appHistory.onnavigate = e => e.transitionWhile(Promise.resolve()); | ||
let result = i.contentWindow.appHistory.navigate("/common/blank.html?1"); | ||
assert_true(oncurrentchange_called); | ||
await result.committed; | ||
}, "AppHistoryCurrentChangeEvent fires for appHistory.navigate() intercepted by transitionWhile"); | ||
</script> |
12 changes: 12 additions & 0 deletions
12
...orm/tests/app-history/currentchange-event/currentchange-app-history-reload-cross-doc.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,12 @@ | ||
<!doctype html> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<iframe id="i" src="/common/blank.html"></iframe> | ||
<script> | ||
promise_test(async t => { | ||
await new Promise(resolve => window.onload = resolve); | ||
i.contentWindow.appHistory.oncurrentchange = t.unreached_func("currentchange should not fire for cross-document navigations"); | ||
i.contentWindow.appHistory.reload(); | ||
await new Promise(resolve => i.onload = resolve); | ||
}, "AppHistoryCurrentChangeEvent does not fire for cross-document appHistory.reload()"); | ||
</script> |
21 changes: 21 additions & 0 deletions
21
...sts/app-history/currentchange-event/currentchange-app-history-reload-transitionWhile.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,21 @@ | ||
<!doctype html> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<iframe id="i" src="/common/blank.html"></iframe> | ||
<script> | ||
promise_test(async t => { | ||
await new Promise(resolve => window.onload = resolve); | ||
|
||
let oncurrentchange_called = false; | ||
i.contentWindow.appHistory.oncurrentchange = t.step_func(e => { | ||
oncurrentchange_called = true; | ||
assert_equals(e.from, i.contentWindow.appHistory.current); | ||
assert_equals(e.navigationType, "reload"); | ||
assert_equals(i.contentWindow.appHistory.current.index, 0); | ||
}); | ||
i.contentWindow.appHistory.onnavigate = e => e.transitionWhile(Promise.resolve()); | ||
let result = i.contentWindow.appHistory.reload(); | ||
assert_true(oncurrentchange_called); | ||
await result.committed; | ||
}, "AppHistoryCurrentChangeEvent fires for appHistory.reload() intercepted by transitionWhile"); | ||
</script> |
20 changes: 20 additions & 0 deletions
20
...atform/tests/app-history/currentchange-event/currentchange-app-history-updateCurrent.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,20 @@ | ||
<!doctype html> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<script> | ||
test(t => { | ||
let oncurrentchange_count = 0; | ||
appHistory.oncurrentchange = t.step_func(e => { | ||
oncurrentchange_count++; | ||
assert_equals(e.from, appHistory.current); | ||
assert_equals(e.navigationType, null); | ||
assert_equals(appHistory.current.getState(), "newState"); | ||
}); | ||
appHistory.updateCurrent({ state: "newState" }); | ||
assert_equals(oncurrentchange_count, 1); | ||
|
||
// "Updating" the state to the current state should still fire currentchange. | ||
appHistory.updateCurrent({ state: appHistory.current.getState() }); | ||
assert_equals(oncurrentchange_count, 2); | ||
}, "AppHistoryCurrentChangeEvent fires for appHistory.updateCurrent()"); | ||
</script> |
26 changes: 26 additions & 0 deletions
26
...ng/web-platform/tests/app-history/currentchange-event/currentchange-dispose-ordering.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,26 @@ | ||
<!doctype html> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<script> | ||
test(t => { | ||
let oncurrentchange_called = false; | ||
let ondispose_called = false; | ||
|
||
let original_entry = appHistory.current; | ||
original_entry.ondispose = t.step_func(() => { | ||
assert_true(oncurrentchange_called); | ||
ondispose_called = true; | ||
}); | ||
|
||
appHistory.oncurrentchange = t.step_func(e => { | ||
oncurrentchange_called = true; | ||
assert_equals(e.from, original_entry); | ||
assert_equals(e.from.index, -1); | ||
assert_equals(e.navigationType, "replace"); | ||
assert_equals(appHistory.current.index, 0); | ||
}); | ||
appHistory.navigate("#foo", { replace: true }); | ||
assert_true(oncurrentchange_called); | ||
assert_true(ondispose_called); | ||
}, "Ordering between AppHistoryCurrentChangeEvent and AppHistoryEntry dispose events"); | ||
</script> |
24 changes: 24 additions & 0 deletions
24
...b-platform/tests/app-history/currentchange-event/currentchange-history-back-same-doc.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,24 @@ | ||
<!doctype html> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<script> | ||
promise_test(async t => { | ||
// Wait for after the load event so that the navigation doesn't get converted | ||
// into a replace navigation. | ||
await new Promise(resolve => window.onload = t.step_timeout(resolve, 0)); | ||
await appHistory.navigate("#foo"); | ||
assert_equals(appHistory.entries().length, 2); | ||
|
||
let oncurrentchange_called = false; | ||
appHistory.oncurrentchange = t.step_func(e => { | ||
oncurrentchange_called = true; | ||
assert_equals(e.from, appHistory.entries()[1]); | ||
assert_equals(e.navigationType, "traverse"); | ||
assert_equals(appHistory.current.index, 0); | ||
}); | ||
history.back(); | ||
assert_false(oncurrentchange_called); | ||
await new Promise(resolve => window.onpopstate = resolve); | ||
assert_true(oncurrentchange_called); | ||
}, "AppHistoryCurrentChangeEvent fires for history.back()"); | ||
</script> |
16 changes: 16 additions & 0 deletions
16
...g/web-platform/tests/app-history/currentchange-event/currentchange-history-pushState.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,16 @@ | ||
<!doctype html> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<script> | ||
test(t => { | ||
let oncurrentchange_called = false; | ||
appHistory.oncurrentchange = t.step_func(e => { | ||
oncurrentchange_called = true; | ||
assert_equals(e.from, appHistory.entries()[0]); | ||
assert_equals(e.navigationType, "push"); | ||
assert_equals(appHistory.current.index, 1); | ||
}); | ||
history.pushState(1, "", "#1"); | ||
assert_true(oncurrentchange_called); | ||
}, "AppHistoryCurrentChangeEvent fires for history.pushState()"); | ||
</script> |
18 changes: 18 additions & 0 deletions
18
...eb-platform/tests/app-history/currentchange-event/currentchange-history-replaceState.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,18 @@ | ||
<!doctype html> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<script> | ||
test(t => { | ||
let oncurrentchange_called = false; | ||
let original_current = appHistory.current; | ||
appHistory.oncurrentchange = t.step_func(e => { | ||
oncurrentchange_called = true; | ||
assert_equals(e.from, original_current); | ||
assert_equals(e.from.index, -1); | ||
assert_equals(e.navigationType, "replace"); | ||
assert_equals(appHistory.current.index, 0); | ||
}); | ||
history.replaceState(1, "", "#1"); | ||
assert_true(oncurrentchange_called); | ||
}, "AppHistoryCurrentChangeEvent fires for history.replaceState()"); | ||
</script> |
18 changes: 18 additions & 0 deletions
18
testing/web-platform/tests/app-history/currentchange-event/currentchange-location-api.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,18 @@ | ||
<!doctype html> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<script> | ||
test(t => { | ||
let oncurrentchange_called = false; | ||
let original_entry = appHistory.current; | ||
appHistory.oncurrentchange = t.step_func(e => { | ||
oncurrentchange_called = true; | ||
assert_equals(e.from, original_entry); | ||
assert_equals(e.from.index, -1); | ||
assert_equals(e.navigationType, "replace"); | ||
assert_equals(appHistory.current.index, 0); | ||
}); | ||
location.hash = "#foo"; | ||
assert_true(oncurrentchange_called); | ||
}, "AppHistoryCurrentChangeEvent fires for location API navigations"); | ||
</script> |
11 changes: 11 additions & 0 deletions
11
...history/currentchange-event/currentchange-navigate-from-initial-about-blank-same-doc.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,11 @@ | ||
<!doctype html> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<iframe id="i" src="/common/blank.html"></iframe> | ||
<script> | ||
promise_test(async t => { | ||
i.contentWindow.appHistory.oncurrentchange = t.unreached_func("currentchange should not fire"); | ||
history.pushState(1, "", "#1"); | ||
await new Promise(resolve => i.onload = resolve); | ||
}, "AppHistoryCurrentChangeEvent does not fire when navigating away from the initial about:blank"); | ||
</script> |
11 changes: 11 additions & 0 deletions
11
...ests/app-history/currentchange-event/currentchange-navigate-from-initial-about-blank.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,11 @@ | ||
<!doctype html> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<iframe id="i" src="/common/blank.html"></iframe> | ||
<script> | ||
promise_test(async t => { | ||
i.contentWindow.appHistory.oncurrentchange = t.unreached_func("currentchange should not fire"); | ||
i.contentWindow.appHistory.navigate("/common/blank.html#1"); | ||
await new Promise(resolve => i.onload = resolve); | ||
}, "AppHistoryCurrentChangeEvent does not fire when navigating away from the initial about:blank"); | ||
</script> |
Oops, something went wrong.