summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/performance-timeline/tentative/performance-entry-source.html
blob: d10d3c5ed512b79cc9ea516de0d1d59d7959cedf (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
<!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 => {
      const navigationEntries = performance.getEntries({ type: 'navigation' })
      const parentEntry = navigationEntries[0]

      // Parent NavigationTiming source is current window.
      assert_equals(parentEntry.source, window)

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

      childFrame.addEventListener('load', () => {
        const markedEntries = performance.getEntries(
          { name: 'mark_child_frame', includeChildFrames: true });

        const childEntry = markedEntries[0]

        // Child PerformanceMark source is the child's Window.
        assert_equals(childEntry.source, childFrame.contentWindow)

        resolve()
      })
    })
  }, "PerformanceEntry source is equal to its respective Window")
</script>