11cb0ef41Sopenharmony_ci<!doctype html>
21cb0ef41Sopenharmony_ci<html>
31cb0ef41Sopenharmony_ci<head>
41cb0ef41Sopenharmony_ci<script src="/resources/testharness.js"></script>
51cb0ef41Sopenharmony_ci<script src="/resources/testharnessreport.js"></script>
61cb0ef41Sopenharmony_ci</head>
71cb0ef41Sopenharmony_ci<body>
81cb0ef41Sopenharmony_ci<script>
91cb0ef41Sopenharmony_ci    function busyWait(millis) {
101cb0ef41Sopenharmony_ci        const start = performance.now();
111cb0ef41Sopenharmony_ci        while (performance.now() < start + millis) {}
121cb0ef41Sopenharmony_ci    }
131cb0ef41Sopenharmony_ci    promise_test(async t => {
141cb0ef41Sopenharmony_ci        const delay = 3000;
151cb0ef41Sopenharmony_ci        const iframe = document.createElement('iframe');
161cb0ef41Sopenharmony_ci        iframe.src = './resources/now_frame.html';
171cb0ef41Sopenharmony_ci        document.body.appendChild(iframe);
181cb0ef41Sopenharmony_ci        await new Promise(resolve => iframe.addEventListener('load', resolve));
191cb0ef41Sopenharmony_ci        iframe.contentWindow.addEventListener('beforeunload', () => {
201cb0ef41Sopenharmony_ci            busyWait(delay);
211cb0ef41Sopenharmony_ci        });
221cb0ef41Sopenharmony_ci        iframe.src = './resources/post.html';
231cb0ef41Sopenharmony_ci        await new Promise(resolve => this.addEventListener('message', ({data}) => {
241cb0ef41Sopenharmony_ci            if (data === 'done')
251cb0ef41Sopenharmony_ci                resolve();
261cb0ef41Sopenharmony_ci        }));
271cb0ef41Sopenharmony_ci
281cb0ef41Sopenharmony_ci        const entry = iframe.contentWindow.performance.getEntriesByType('navigation')[0];
291cb0ef41Sopenharmony_ci        assert_less_than(entry.fetchStart, delay);
301cb0ef41Sopenharmony_ci    }, 'timeOrigin should be set after beforeunload');
311cb0ef41Sopenharmony_ci</script>
321cb0ef41Sopenharmony_ci</body>
331cb0ef41Sopenharmony_ci</html>
34