<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[235923] trunk/LayoutTests/imported/w3c</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/235923">235923</a></dd>
<dt>Author</dt> <dd>ajuma@chromium.org</dd>
<dt>Date</dt> <dd>2018-09-11 17:17:24 -0700 (Tue, 11 Sep 2018)</dd>
</dl>

<h3>Log Message</h3>
<pre>[IntersectionObserver] Update WPTs to the latest upstream version
https://bugs.webkit.org/show_bug.cgi?id=189515

Reviewed by Youenn Fablet.

* web-platform-tests/intersection-observer/initial-observation-with-threshold-expected.txt: Added.
* web-platform-tests/intersection-observer/initial-observation-with-threshold.html: Added.
* web-platform-tests/intersection-observer/resources/intersection-observer-test-utils.js:
(waitForNotification):
* web-platform-tests/intersection-observer/w3c-import.log:</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsimportedw3cChangeLog">trunk/LayoutTests/imported/w3c/ChangeLog</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestsintersectionobserverresourcesintersectionobservertestutilsjs">trunk/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/resources/intersection-observer-test-utils.js</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestsintersectionobserverw3cimportlog">trunk/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/w3c-import.log</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestsintersectionobserverinitialobservationwiththresholdexpectedtxt">trunk/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/initial-observation-with-threshold-expected.txt</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestsintersectionobserverinitialobservationwiththresholdhtml">trunk/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/initial-observation-with-threshold.html</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsimportedw3cChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/imported/w3c/ChangeLog (235922 => 235923)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/ChangeLog 2018-09-11 23:41:49 UTC (rev 235922)
+++ trunk/LayoutTests/imported/w3c/ChangeLog    2018-09-12 00:17:24 UTC (rev 235923)
</span><span class="lines">@@ -1,3 +1,16 @@
</span><ins>+2018-09-11  Ali Juma  <ajuma@chromium.org>
+
+        [IntersectionObserver] Update WPTs to the latest upstream version
+        https://bugs.webkit.org/show_bug.cgi?id=189515
+
+        Reviewed by Youenn Fablet.
+
+        * web-platform-tests/intersection-observer/initial-observation-with-threshold-expected.txt: Added.
+        * web-platform-tests/intersection-observer/initial-observation-with-threshold.html: Added.
+        * web-platform-tests/intersection-observer/resources/intersection-observer-test-utils.js:
+        (waitForNotification):
+        * web-platform-tests/intersection-observer/w3c-import.log:
+
</ins><span class="cx"> 2018-09-11  Youenn Fablet  <youenn@apple.com>
</span><span class="cx"> 
</span><span class="cx">         Remove MediaDevices NoInterfaceObject
</span></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestsintersectionobserverinitialobservationwiththresholdexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/initial-observation-with-threshold-expected.txt (0 => 235923)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/initial-observation-with-threshold-expected.txt                          (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/initial-observation-with-threshold-expected.txt     2018-09-12 00:17:24 UTC (rev 235923)
</span><span class="lines">@@ -0,0 +1,5 @@
</span><ins>+
+PASS First observation with a threshold. 
+FAIL First rAF assert_equals: entries[0].isIntersecting expected false but got true
+PASS root.scrollTop = 20 
+
</ins></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestsintersectionobserverinitialobservationwiththresholdhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/initial-observation-with-threshold.html (0 => 235923)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/initial-observation-with-threshold.html                          (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/initial-observation-with-threshold.html     2018-09-12 00:17:24 UTC (rev 235923)
</span><span class="lines">@@ -0,0 +1,60 @@
</span><ins>+<!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;
+}
+.spacer {
+  height: calc(100vh + 100px);
+}
+#root {
+  display: inline-block;
+  overflow-y: scroll;
+  height: 240px;
+  border: 3px solid black;
+}
+#target {
+  width: 100px;
+  height: 100px;
+  margin: 200px 0 0 0;
+  background-color: green;
+}
+</style>
+
+<div id="root">
+  <div id="target"></div>
+</div>
+
+<script>
+var entries = [];
+var root, target;
+
+runTestCycle(function() {
+  target = document.getElementById("target");
+  assert_true(!!target, "target exists");
+  root = document.getElementById("root");
+  assert_true(!!root, "root exists");
+  var observer = new IntersectionObserver(function(changes) {
+    entries = entries.concat(changes)
+  }, { root: root, threshold: [0.5] });
+  observer.observe(target);
+  entries = entries.concat(observer.takeRecords());
+  assert_equals(entries.length, 0, "No initial notifications.");
+  runTestCycle(step0, "First rAF");
+}, "First observation with a threshold.");
+
+function step0() {
+  root.scrollTop = 20;
+  runTestCycle(step1, "root.scrollTop = 20");
+  checkLastEntry(entries, 0, [ 11, 111, 211, 311, 11, 111, 211, 251, 11, 111, 11, 251, false]);
+}
+
+function step1() {
+  checkLastEntry(entries, 1, [ 11, 111, 191, 291, 11, 111, 191, 251, 11, 111, 11, 251, true]);
+}
+</script>
</ins></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestsintersectionobserverresourcesintersectionobservertestutilsjs"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/resources/intersection-observer-test-utils.js (235922 => 235923)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/resources/intersection-observer-test-utils.js    2018-09-11 23:41:49 UTC (rev 235922)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/resources/intersection-observer-test-utils.js       2018-09-12 00:17:24 UTC (rev 235923)
</span><span class="lines">@@ -6,23 +6,73 @@
</span><span class="cx"> //   - Modify DOM in a way that should trigger an IntersectionObserver callback.
</span><span class="cx"> // - BeginFrame
</span><span class="cx"> //   - requestAnimationFrame handler runs
</span><del>-//     - First step_timeout()
</del><ins>+//     - Second requestAnimationFrame()
</ins><span class="cx"> //   - Style, layout, paint
</span><span class="cx"> //   - IntersectionObserver generates new notifications
</span><span class="cx"> //     - Posts a task to deliver notifications
</span><del>-// - First step_timeout handler runs
-//   - Second step_timeout()
</del><span class="cx"> // - Task to deliver IntersectionObserver notifications runs
</span><span class="cx"> //   - IntersectionObserver callbacks run
</span><del>-// - Second step_timeout handler runs
</del><ins>+// - Second requestAnimationFrameHandler runs
+//     - step_timeout()
+// - step_timeout handler runs
</ins><span class="cx"> //   - myTestFunction1()
</span><span class="cx"> //     - [optional] waitForNotification(myTestFunction2)
</span><span class="cx"> //       - requestAnimationFrame()
</span><span class="cx"> //     - Verify newly-arrived IntersectionObserver notifications
</span><span class="cx"> //     - [optional] Modify DOM to trigger new notifications
</span><ins>+//
+// Ideally, it should be sufficient to use requestAnimationFrame followed
+// by two step_timeouts, with the first step_timeout firing in between the
+// requestAnimationFrame handler and the task to deliver notifications.
+// However, the precise timing of requestAnimationFrame, the generation of
+// a new display frame (when IntersectionObserver notifications are
+// generated), and the delivery of these events varies between engines, making
+// this tricky to test in a non-flaky way.
+//
+// In particular, in WebKit, requestAnimationFrame and the generation of
+// a display frame are two separate tasks, so a step_timeout called within
+// requestAnimationFrame can fire before a display frame is generated.
+//
+// In Gecko, on the other hand, requestAnimationFrame and the generation of
+// a display frame are a single task, and IntersectionObserver notifications
+// are generated during this task. However, the task posted to deliver these
+// notifications can fire after the following requestAnimationFrame.
+//
+// This means that in general, by the time the second requestAnimationFrame
+// handler runs, we know that IntersectionObservations have been generated,
+// and that a task to deliver these notifications has been posted (though
+// possibly not yet delivered). Then, by the time the step_timeout() handler
+// runs, these notifications have been delivered.
+//
+// Since waitForNotification uses a double-rAF, it is now possible that
+// IntersectionObservers may have generated more notifications than what is
+// under test, but have not yet scheduled the new batch of notifications for
+// delivery. As a result, observer.takeRecords should NOT be used in tests:
+//
+// - myTestFunction0()
+//   - waitForNotification(myTestFunction1)
+//     - requestAnimationFrame()
+//   - Modify DOM in a way that should trigger an IntersectionObserver callback.
+// - BeginFrame
+//   - requestAnimationFrame handler runs
+//     - Second requestAnimationFrame()
+//   - Style, layout, paint
+//   - IntersectionObserver generates a batch of notifications
+//     - Posts a task to deliver notifications
+// - Task to deliver IntersectionObserver notifications runs
+//   - IntersectionObserver callbacks run
+// - BeginFrame
+//   - Second requestAnimationFrameHandler runs
+//     - step_timeout()
+//   - IntersectionObserver generates another batch of notifications
+//     - Post task to deliver notifications
+// - step_timeout handler runs
+//   - myTestFunction1()
+//     - At this point, observer.takeRecords will get the second batch of
+//       notifications.
</ins><span class="cx"> function waitForNotification(t, f) {
</span><span class="cx">   requestAnimationFrame(function() {
</span><del>-    t.step_timeout(function() { t.step_timeout(f); });
</del><ins>+    requestAnimationFrame(function() { t.step_timeout(f); });
</ins><span class="cx">   });
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestsintersectionobserverw3cimportlog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/w3c-import.log (235922 => 235923)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/w3c-import.log   2018-09-11 23:41:49 UTC (rev 235922)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/w3c-import.log      2018-09-12 00:17:24 UTC (rev 235923)
</span><span class="lines">@@ -24,6 +24,7 @@
</span><span class="cx"> /LayoutTests/imported/w3c/web-platform-tests/intersection-observer/edge-inclusive-intersection.html
</span><span class="cx"> /LayoutTests/imported/w3c/web-platform-tests/intersection-observer/idlharness.window.js
</span><span class="cx"> /LayoutTests/imported/w3c/web-platform-tests/intersection-observer/iframe-no-root.html
</span><ins>+/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/initial-observation-with-threshold.html
</ins><span class="cx"> /LayoutTests/imported/w3c/web-platform-tests/intersection-observer/inline-client-rect.html
</span><span class="cx"> /LayoutTests/imported/w3c/web-platform-tests/intersection-observer/isIntersecting-change-events.html
</span><span class="cx"> /LayoutTests/imported/w3c/web-platform-tests/intersection-observer/multiple-targets.html
</span></span></pre>
</div>
</div>

</body>
</html>