https://github.com/web-platform-tests/wpt
Revision 4d1bb3796f155d206bbf1a1d89db7f8b79402c8d authored by Rune Lillesveen on 27 March 2018, 00:22:42 UTC, committed by Chromium WPT Sync on 27 March 2018, 00:22:42 UTC
Bug: 820299
Change-Id: I596113eeea7d4c13cf689364744bff7c261f93d3
Reviewed-on: https://chromium-review.googlesource.com/978247
Commit-Queue: Darren Shen <shend@chromium.org>
Reviewed-by: Darren Shen <shend@chromium.org>
Cr-Commit-Position: refs/heads/master@{#545896}
1 parent f497de8
Raw File
Tip revision: 4d1bb3796f155d206bbf1a1d89db7f8b79402c8d authored by Rune Lillesveen on 27 March 2018, 00:22:42 UTC
[css-typedom] Add support for the *-gap properties.
Tip revision: 4d1bb37
bounding-box.html
<!DOCTYPE html>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="./resources/intersection-observer-test-utils.js"></script>

<style>
pre, #log {
  position: absolute;
  top: 0;
  left: 200px;
}
#root {
  overflow: visible;
  height: 200px;
  width: 160px;
  border: 7px solid black;
}
#target {
  margin: 10px;
  width: 100px;
  height: 100px;
  padding: 10px;
  background-color: green;
}
</style>

<div id="root">
  <div id="target" style="transform: translateY(300px)"></div>
</div>

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

runTestCycle(function() {
  target = document.getElementById("target");
  assert_true(!!target, "target exists");
  var root = document.getElementById("root");
  assert_true(!!root, "root exists");
  var observer = new IntersectionObserver(function(changes) {
    entries = entries.concat(changes)
  }, {root: root});
  observer.observe(target);
  entries = entries.concat(observer.takeRecords());
  assert_equals(entries.length, 0, "No initial notifications.");
  runTestCycle(step0, "First rAF.");
}, "Test that the target's border bounding box is used to calculate intersection.");

function step0() {
  var targetBounds = clientBounds(target);
  target.style.transform = "translateY(195px)";
  runTestCycle(step1, "target.style.transform = 'translateY(195px)'");
  checkLastEntry(entries, 0, targetBounds.concat(0, 0, 0, 0, 8, 182, 8, 222, false));
}

function step1() {
  var targetBounds = clientBounds(target);
  target.style.transform = "";
  checkLastEntry(entries, 1, targetBounds.concat(25, 145, 220, 222, 8, 182, 8, 222, true));
}
</script>
back to top