2 <script src=
"/resources/testharness.js"></script>
3 <script src=
"/resources/testharnessreport.js"></script>
4 <script src=
"return-value/resources/helpers.js"></script>
6 <iframe id=
"i" src=
"/common/blank.html"></iframe>
10 window
.onload
= t
.step_func(() => {
11 const iWindow
= i
.contentWindow
;
12 const iDOMException
= iWindow
.DOMException
;
13 const iAppHistoryEntry
= iWindow
.AppHistoryEntry
;
15 i
.contentWindow
.navigation
.navigate("#1").finished
.then(t
.step_func(() => {
16 assert_equals(i
.contentWindow
.navigation
.entries().length
, 2);
17 let key
= i
.contentWindow
.navigation
.entries()[0].key
;
19 let onnavigateerror_called
= false;
22 i
.contentWindow
.navigation
.onnavigate
= t
.step_func(e
=> {
23 e
.transitionWhile(new Promise(resolve
=> () => t
.step_timeout(resolve
, 2)));
24 t
.step_timeout(() => i
.remove(), 1);
27 i
.contentWindow
.navigation
.onnavigatesuccess
= t
.unreached_func("navigatesuccess must not fire");
29 i
.contentWindow
.navigation
.onnavigateerror
= t
.step_func(e
=> {
30 assert_false(onnavigateerror_called
);
31 onnavigateerror_called
= true;
32 assert_equals(e
.filename
, location
.href
);
33 assert_greater_than(e
.lineno
, 0);
34 assert_greater_than(e
.colno
, 0);
36 assertCommittedFulfillsFinishedRejectsExactly(t
, result
, iWindow
.navigation
.currentEntry
, e
.error
, iWindow
, iDOMException
, iAppHistoryEntry
).then(
38 t
.step_func(err
=> { throw err
; })
42 result
= i
.contentWindow
.navigation
.traverseTo(key
);
45 }, "Detach a window between when a traverseTo() fires navigate and navigatesuccess");