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

<head>
  <script src="/resources/testharness.js"></script>
  <script src="/resources/testharnessreport.js"></script>
  <script src=/common/get-host-info.sub.js></script>
  <script src="../resources/include-frames-helper.js"></script>
</head>

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

      verifyEntries(entries, filterOptions);
    }

    const verifyChildFrameEntries = (entries) => {
      let filterOptions = [
        createFilterOption('child-frame.html', 'navigation', 0, 'Child Frame'),
        createFilterOption('mark_child_frame', 'mark', 0, 'Child Frame'),
      ];

      verifyEntries(entries, filterOptions);
    }

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

      await loadChildFrame(
        get_host_info().HTTP_REMOTE_ORIGIN + '/performance_timeline/resources/child-frame.html');

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

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

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

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

      // 0 entry since child frame is cross origin.
      assert_equals(markedEntries.length, 0, 'Mark entries should 0.');
    }, 'GetEntries of a parent Frame of origin A and its child frame of origin B');
  </script>
</body>