summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/performance-timeline/tentative/include-frames-one-same-origin-child-one-cross-origin-child.sub.html
blob: b20bde93eed06c052098d42b8c747e23cc3ba3ff (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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<!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()

        let sameOriginFrameLoaded = false
        let crossOriginFrameLoaded = false

        // Create first child iframe.
        const sameOriginChildFrame = document.createElement('iframe')
        sameOriginChildFrame.src = "../resources/child-frame.html"
        document.body.appendChild(sameOriginChildFrame)

        sameOriginChildFrame.addEventListener("load", () => {
            sameOriginFrameLoaded = true
            if (crossOriginFrameLoaded)
                verifyPerformanceEntries()
        })

        // Create second child iframe.
        const crossOriginChildFrame = document.createElement('iframe')
        crossOriginChildFrame.src = "http://{{hosts[][www]}}:{{ports[http][0]}}/resources/child-frame.html"
        document.body.appendChild(crossOriginChildFrame)

        crossOriginChildFrame.addEventListener("load", () => {
            crossOriginFrameLoaded = true
            if (sameOriginFrameLoaded)
                verifyPerformanceEntries()
        })

        function verifyPerformanceEntries() {
            const entries = performance.getEntries(true)
            const navigationEntries = performance.getEntriesByType("navigation", true)
            const markedEntries = performance.getEntriesByName("entry-name", undefined, true)

            // 4 entries for parent, 2 for local child, 0 for remote child.
            assert_equals(entries.length, 6)

            // 1 entry for parent, 1 for local child.
            assert_equals(navigationEntries.length, 2)

            // 1 entry for local child.
            assert_equals(markedEntries.length, 1)

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