summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/element-timing/cross-origin-iframe-element.sub.html
blob: 2f49933ab964b7a35bb3226be48f09f5901d6584 (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
<!DOCTYPE HTML>
<meta charset=utf-8>
<title>Element Timing: do NOT observe elements from cross-origin iframes</title>
<body>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="resources/element-timing-helpers.js"></script>
<script>
  async_test((t) => {
    assert_implements(window.PerformanceElementTiming, "PerformanceElementTiming is not implemented");
    const observer = new PerformanceObserver(
      t.step_func_done((entryList) => {
        assert_unreached("We should not observe a cross origin element.");
      })
    );
    observer.observe({entryTypes: ['element']});
    // We add the iframe during onload to be sure that the observer is registered
    // in time for it to observe the element timing.
    // TODO(npm): change observer to use buffered flag.
    window.onload = t.step_func(() => {
      // Add a cross origin iframe with an image.
      const iframe = document.createElement('iframe');
      iframe.src = 'http://{{domains[www]}}:{{ports[http][1]}}'
          + '/element-timing/resources/iframe-with-square.html';
      document.body.appendChild(iframe);
      iframe.onload = t.step_func(() => {
        t.step_timeout( () => {
          // After some wait, assume observer did not receive the entry, so the test passes.
          t.done();
        }, 100);
      });
    });
  }, 'Element from cross origin iframe is NOT observable.');
</script>

</body>