1<!doctype html>
2<html>
3<head>
4<script src="/resources/testharness.js"></script>
5<script src="/resources/testharnessreport.js"></script>
6</head>
7<body>
8<script>
9    function busyWait(millis) {
10        const start = performance.now();
11        while (performance.now() < start + millis) {}
12    }
13    promise_test(async t => {
14        const delay = 3000;
15        const iframe = document.createElement('iframe');
16        iframe.src = './resources/now_frame.html';
17        document.body.appendChild(iframe);
18        await new Promise(resolve => iframe.addEventListener('load', resolve));
19        iframe.contentWindow.addEventListener('beforeunload', () => {
20            busyWait(delay);
21        });
22        iframe.src = './resources/post.html';
23        await new Promise(resolve => this.addEventListener('message', ({data}) => {
24            if (data === 'done')
25                resolve();
26        }));
27
28        const entry = iframe.contentWindow.performance.getEntriesByType('navigation')[0];
29        assert_less_than(entry.fetchStart, delay);
30    }, 'timeOrigin should be set after beforeunload');
31</script>
32</body>
33</html>
34