Only report resource timing to parent frame for the first iframe load
[WebKit-https.git] / LayoutTests / http / tests / misc / resource-timing-navigation-in-restored-iframe.html
1 <!DOCTYPE html>
2 <script src="/js-test-resources/js-test.js"></script>
3 <script>
4     description('Tests that subsequent navigation in an iframe restored from history does not report resource timing.');
5     window.jsTestIsAsync = true;
6     function runTest() {
7         if (!sessionStorage.didNav) {
8             sessionStorage.didNav = true;
9             // Navigate a timeout to make sure we generate a history entry that we can go back to.
10             setTimeout(function() {
11                 location.href = 'resources/alert-then-back.html';
12             }, 0);
13         } else {
14             delete sessionStorage.didNav;
15             window.addEventListener('message', (event) => {
16                 resources = performance.getEntriesByType('resource');
17                 shouldBe('resources.length', '1');
18                 shouldBeEqualToString('resources[0].name', 'http://127.0.0.1:8000/js-test-resources/js-test.js');
19                 if (window.testRunner)
20                     finishJSTest();
21             });
22             document.getElementById('target-iframe').contentWindow.postMessage('navigate', '*');
23         }
24     }
25     window.onload = runTest;
26 </script>
27 <iframe id="target-iframe" src="http://localhost:8080/misc/resources/navigate-on-message.html"></iframe>