testing/web-platform/tests/longtask-timing/longtask-in-sibling-iframe.html
author Nicolás Peña Moreno <npm@chromium.org>
Wed, 06 Mar 2019 12:34:08 +0000
changeset 464647 cd9ac71c85c6abbea6f856c576a3c261c34e6fba
parent 464361 66b1aba3fb4372ec47986e728b1da9b32dd3d368
permissions -rw-r--r--
Bug 1529818 [wpt PR 15492] - LongTasks: fix sibling layout test, a=testonly Automatic update from web-platform-tests LongTasks: fix sibling layout test This CL allows the main frame to produce a long task that is observed by the child frame. Such a long task can be detected because the attribution will be same-origin-ancestor. Bug: 927866 Change-Id: I38849b5f44172cbffd25f3ab429b0c1a96b0f1e3 Reviewed-on: https://chromium-review.googlesource.com/c/1480114 Reviewed-by: Timothy Dresser <tdresser@chromium.org> Commit-Queue: Nicolás Peña Moreno <npm@chromium.org> Cr-Commit-Position: refs/heads/master@{#634243} -- wpt-commits: 493fdc7e7908360273baa0ee13421fff692cf8ed wpt-pr: 15492

<!DOCTYPE HTML>
<meta charset=utf-8>
<title>LongTask Timing: long task in sibling iframe</title>
<body>

<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>

<script>
  async_test(t => {
    if (typeof PerformanceLongTaskTiming === 'undefined') {
        assert_unreached("Longtasks are not supported.");
        t.done();
    }
    window.addEventListener('message', t.step_func(e => {
      assert_equals(e.data['entryType'], 'longtask');
      // Ignore any long task that may be produced by the top-level frame.
      if (e.data['frame-attribution'] === 'same-origin-ancestor')
        return;

      assert_equals(e.data['frame-attribution'], 'same-origin');
      assert_equals(e.data['task-attribution'], 'unknown');
      assert_equals(e.data['containerId'], 'longtask-iframe-id');
      assert_equals(e.data['containerName'], 'longtask-iframe-name');
      assert_equals(e.data['containerSrc'], 'resources/subframe-with-longtask.html');
      t.done();
    }));
    const observingFrame = document.createElement('iframe');
    observingFrame.id = 'observing-iframe-id';
    observingFrame.name = 'observing-iframe-name';
    document.body.appendChild(observingFrame);
    observingFrame.src = 'resources/subframe-observing-longtask.html'

    observingFrame.onload = () => {
      const longtaskFrame = document.createElement('iframe');
      longtaskFrame.id = 'longtask-iframe-id';
      longtaskFrame.name = 'longtask-iframe-name';
      document.body.appendChild(longtaskFrame);
      longtaskFrame.src = 'resources/subframe-with-longtask.html'
    };
}, 'Performance longtask entries are observable in sibling iframe.');
</script>
</body>