https://github.com/web-platform-tests/wpt
Raw File
Tip revision: dc95d6e03b834edb8aef5b1c9f63187625197117 authored by Dong-hee Na on 10 October 2018, 08:14:18 UTC
Convert blocks.dat to html5lib_blocks.html
Tip revision: dc95d6e
target-in-different-window.html
<!DOCTYPE html>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="./resources/intersection-observer-test-utils.js"></script>

<script>
var entries = [];
var popup, target;

function waitForPopupNotification(f) {
  popup.requestAnimationFrame(function() {
    popup.requestAnimationFrame(function() { popup.setTimeout(f); });
  });
}

async_test((t) => {
  var observer = new IntersectionObserver(function(changes) {
    entries = entries.concat(changes);
  });
  popup = window.open();
  t.add_cleanup(() => popup.close());
  target = popup.document.createElement('div');
  target.style.width = "100px";
  target.style.height = "100px";
  observer.observe(target);
  waitForPopupNotification(t.step_func(() => {
    assert_equals(entries.length, 1, "Initial notification for detached target.");
    assert_equals(entries[0].isIntersecting, false, "not intersecting");
    popup.document.body.appendChild(target);
    waitForPopupNotification(t.step_func_done(() => {
      assert_equals(entries.length, 2, "Notification after insertion into popup.");
      assert_equals(entries[1].isIntersecting, true, "intersecting");
    }));
  }));
}, "IntersectionObserver with target in a different window.");
</script>
back to top