summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/performance-timeline/tentative/include-frames-originA-AA.html
blob: cccbf4100dd2aecccbee743c618fa619ba8d46e6 (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
<!DOCTYPE html>

<head>
  <script src="/resources/testharness.js"></script>
  <script src="/resources/testharnessreport.js"></script>
  <script src="../resources/include-frames-helper.js"></script>
</head>

<body>
  <script>
    const verifyMainFrameEntries = (entries) => {
      let filterOptions = [
        createFilterOption('include-frames-originA-AA', 'navigation', 1, 'Main Frame'),
        createFilterOption('child-frame.html', 'navigation', 2, 'Child Frames'),
        createFilterOption('child-frame.html', 'resource', 2, 'Main Frame'),
        createFilterOption('mark_child_frame', 'mark', 2, 'Child frames')
      ];

      verifyEntries(entries, filterOptions);
    }

    const verifyPerformanceEntries = () => {
      const entries = performance.getEntries({ includeChildFrames: true });

      const navigationEntries = performance.getEntries({ entryType: "navigation", includeChildFrames: true });

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

      verifyMainFrameEntries(entries);

      // 1 entry for main frame, 1 for each child frame.
      assert_equals(navigationEntries.length, 3, 'Navigation entries should be 3.');

      // 1 entry for each child frame.
      assert_equals(markedEntries.length, 2, 'Mark entries should be 2.');
    }

    promise_test(async () => {
      performance.clearResourceTimings();

      // Load first child iframe.
      const promise1 = loadChildFrame('../resources/child-frame.html');

      // Load second child iframe.
      const promise2 = loadChildFrame('../resources/child-frame.html');

      return Promise.all([promise1, promise2]).then(verifyPerformanceEntries);
    }, 'GetEntries of a document of origin A and its two child frames both of origin A.');
  </script>
</body>