summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/performance-timeline/tentative/include-frames-from-child-same-origin-grandchild.sub.html
blob: 16142ca953a0b9da887354ee4dfa80276b0bef71 (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
<!DOCTYPE html>
<head>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
</body>
<script>
promise_test(() => {
    return new Promise(resolve => {
        performance.clearResourceTimings()

        // Create child iframe with an embedded frame that is cross-origin with its parent but same-origin with the current frame.
        const crossOriginChildFrame = document.createElement('iframe')
        crossOriginChildFrame.src = "http://{{hosts[][www]}}:{{ports[http][0]}}/performance-timeline/resources/parent-frame-with-cross-origin-child.sub.html"
        document.body.appendChild(crossOriginChildFrame)

        // Listen for postMessage() from child frame.
        window.addEventListener("message", e => {
            // 0 entries for parent, 4 for child, 0 for grandchild.
            assert_equals(e.data, 4)

            const entries = performance.getEntries(true)

            // 3 entries for parent, 0 for child, 2 for grandchild.
            assert_equals(entries.length, 5)

            resolve()
        })
    })
}, "GetEntries of a Cross-Origin child frame with one Same-Origin grandchild frame")
</script>