blob: 501857feba4471575531965c865bcaf163d17985 [file] [log] [blame]
<!doctype html>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
test(() => {
assert_throws_js(TypeError, () => {
new AppHistoryNavigateEvent("navigate");
});
}, "can't bypass required members by omitting the dictionary entirely");
test(() => {
assert_throws_js(TypeError, () => {
new AppHistoryNavigateEvent("navigate", {
navigationType: "push",
canTransition: false,
userInitiated: false,
hashChange: false,
signal: (new AbortController()).signal,
formData: null,
info: null
});
});
}, "destination is required");
async_test(t => {
// We need to grab an AppHistoryDestination.
navigation.onnavigate = t.step_func_done(e => {
assert_throws_js(TypeError, () => {
new AppHistoryNavigateEvent("navigate", {
navigationType: "push",
destination: e.destination,
canTransition: false,
userInitiated: false,
hashChange: false,
formData: null,
info: null
});
});
});
history.pushState(1, null, "#1");
}, "signal is required");
async_test(t => {
// We need to grab an AppHistoryDestination.
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", {
navigationType: "replace",
destination: e.destination,
canTransition: true,
userInitiated: true,
hashChange: true,
signal,
formData,
info
});
assert_equals(event.navigationType, "replace");
assert_equals(event.destination, e.destination);
assert_equals(event.canTransition, true);
assert_equals(event.userInitiated, true);
assert_equals(event.hashChange, true);
assert_equals(event.signal, signal);
assert_equals(event.formData, formData);
assert_equals(event.info, info);
});
history.pushState(2, null, "#2");
}, "all properties are reflected back");
async_test(t => {
// We need to grab an AppHistoryDestination.
navigation.onnavigate = t.step_func_done(e => {
const event = new AppHistoryNavigateEvent("navigate", {
destination: e.destination,
signal: (new AbortController()).signal
});
assert_equals(event.navigationType, "push");
assert_equals(event.canTransition, false);
assert_equals(event.userInitiated, false);
assert_equals(event.hashChange, false);
assert_equals(event.formData, null);
assert_equals(event.info, undefined);
});
history.pushState(3, null, "#3");
}, "defaults are as expected");
</script>