summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/navigation-api/commit-behavior/after-transition-window-stop-before-commit.html
blob: 0f5e57d5b665e5d83fcaf7fc5b21e03b32fdc108 (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
33
<!doctype html>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="../navigation-methods/return-value/resources/helpers.js"></script>
<body>
<script>
promise_test(async t => {
  // Wait for after the load event because window.stop() hangs the test harness
  // if called before the load event.
  await new Promise(resolve => window.onload = () => t.step_timeout(resolve, 0));

  navigation.onnavigate = e => {
    e.intercept({ commit: "after-transition" });
  };

  navigation.onnavigatesuccess = t.unreached_func("navigatesuccess must not fire");
  let navigateerror_called = false;
  navigation.onnavigateerror = t.step_func(() => {
    navigateerror_called = true;
    assert_equals(location.hash, "");
  });

  let promises = navigation.navigate("#ShouldNotCommit");
  assert_equals(location.hash, "");

  window.stop();
  await assertBothRejectDOM(t, promises, "AbortError");

  assert_equals(location.hash, "");
  assert_true(navigateerror_called);
}, " { commit: 'after-transition' } with window.stop() before commit");
</script>
</body>