summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/performance-timeline/tentative/include-frames-two-local-children.html
blob: 01d484452212a5181589dc0191c9cd24640bdeca (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 childFrameOneLoaded = false
        let childFrameTwoLoaded = false

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

        childFrameOne.addEventListener("load", () => {
            childFrameOneLoaded = true
            if (childFrameTwoLoaded)
                verifyPerformanceEntries()
        })

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

        childFrameTwo.addEventListener("load", () => {
            childFrameTwoLoaded = true
            if (childFrameOneLoaded)
                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 each child
            assert_equals(entries.length, 8)

            // 1 entry for parent, 1 for each child.
            assert_equals(navigationEntries.length, 3)

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

            resolve()
        }
    })
}, "GetEntries of a parent Frame with two Same-Origin children")
</script>