summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/navigation-api/currententrychange-event/constructor.html
blob: b09e68e1c71e0edc9b2cf5a045cce9bba3a42706 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
<!doctype html>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
test(() => {
  assert_throws_js(TypeError, () => {
    new NavigationCurrentEntryChangeEvent("currententrychange");
  });
}, "can't bypass required members by omitting the dictionary entirely");

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

test(() => {
  const event = new NavigationCurrentEntryChangeEvent("currententrychange", {
    navigationType: "replace",
    from: navigation.currentEntry
  });
  assert_equals(event.navigationType, "replace");
  assert_equals(event.from, navigation.currentEntry);
}, "all properties are reflected back");

test(t => {
  const event = new NavigationCurrentEntryChangeEvent("currententrychange", { from: navigation.currentEntry });
  assert_equals(event.navigationType, null);
}, "defaults are as expected");
</script>