WebKit Bugzilla
Attachment 347451 Details for
Bug 188670
: [IntersectionObserver] Fire an initial dummy notification
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch for landing
bug-188670-20180818181320.patch (text/plain), 55.50 KB, created by
Ali Juma
on 2018-08-18 15:13:21 PDT
(
hide
)
Description:
Patch for landing
Filename:
MIME Type:
Creator:
Ali Juma
Created:
2018-08-18 15:13:21 PDT
Size:
55.50 KB
patch
obsolete
>Subversion Revision: 234899 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index 27f4473e083b0914a9b8f32d142349f981f3daf1..bcb39d659dde14060620e5e0920753b01f977634 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,51 @@ >+2018-08-18 Ali Juma <ajuma@chromium.org> >+ >+ [IntersectionObserver] Fire an initial dummy notification >+ https://bugs.webkit.org/show_bug.cgi?id=188670 >+ >+ Reviewed by Simon Fraser. >+ >+ Add logic to track ongoing intersection observations. Create an IntersectionObserverRegistration >+ and fire a single dummy notification for each one. >+ >+ Test: intersection-observer/root-element-moved.html >+ Also tested by existing tests in imported/w3c/web-platform-tests/intersection-observer. >+ >+ * dom/Document.cpp: >+ (WebCore::Document::~Document): >+ (WebCore::Document::addIntersectionObserver): >+ (WebCore::Document::removeIntersectionObserver): >+ (WebCore::Document::updateIntersectionObservations): >+ (WebCore::Document::notifyIntersectionObserversTimerFired): >+ * dom/Document.h: >+ (WebCore::Document::numberOfIntersectionObservers const): >+ * dom/Element.cpp: >+ (WebCore::Element::didMoveToNewDocument): >+ (WebCore::Element::disconnectFromIntersectionObservers): >+ * page/IntersectionObserver.cpp: >+ (WebCore::IntersectionObserver::create): >+ (WebCore::IntersectionObserver::IntersectionObserver): >+ (WebCore::IntersectionObserver::~IntersectionObserver): >+ (WebCore::IntersectionObserver::observe): >+ (WebCore::IntersectionObserver::unobserve): >+ (WebCore::IntersectionObserver::disconnect): >+ (WebCore::IntersectionObserver::takeRecords): >+ (WebCore::IntersectionObserver::targetDestroyed): >+ (WebCore::IntersectionObserver::removeTargetRegistration): >+ (WebCore::IntersectionObserver::removeAllTargets): >+ (WebCore::IntersectionObserver::rootDestroyed): >+ (WebCore::IntersectionObserver::appendQueuedEntry): >+ (WebCore::IntersectionObserver::notify): >+ * page/IntersectionObserver.h: >+ (WebCore::IntersectionObserver::trackingDocument): >+ (WebCore::IntersectionObserver:: const): >+ (WebCore::IntersectionObserver::hasObservationTargets const): >+ * page/IntersectionObserver.idl: >+ * testing/Internals.cpp: >+ (WebCore::Internals::numberOfIntersectionObservers const): >+ * testing/Internals.h: >+ * testing/Internals.idl: >+ > 2018-08-15 Aditya Keerthi <akeerthi@apple.com> > > [Datalist] Add button to TextFieldInputs with a datalist >diff --git a/Source/WebCore/dom/Document.cpp b/Source/WebCore/dom/Document.cpp >index df39f4da574add66115d20da7ca54f534aed69ce..ee8b8b4da23db691565e5a8a492437b12e753f76 100644 >--- a/Source/WebCore/dom/Document.cpp >+++ b/Source/WebCore/dom/Document.cpp >@@ -109,6 +109,7 @@ > #include "ImageBitmapRenderingContext.h" > #include "ImageLoader.h" > #include "InspectorInstrumentation.h" >+#include "IntersectionObserver.h" > #include "JSCustomElementInterface.h" > #include "JSDOMPromiseDeferred.h" > #include "JSLazyEventListener.h" >@@ -503,6 +504,9 @@ Document::Document(Frame* frame, const URL& url, unsigned documentClasses, unsig > , m_constantPropertyMap(std::make_unique<ConstantPropertyMap>(*this)) > , m_documentClasses(documentClasses) > , m_eventQueue(*this) >+#if ENABLE(INTERSECTION_OBSERVER) >+ , m_intersectionObserversNotifyTimer(*this, &Document::notifyIntersectionObserversTimerFired) >+#endif > , m_loadEventDelayTimer(*this, &Document::loadEventDelayTimerFired) > #if PLATFORM(IOS) > #if ENABLE(DEVICE_ORIENTATION) >@@ -639,7 +643,7 @@ Document::~Document() > if (auto* platformMediaSessionManager = PlatformMediaSessionManager::sharedManagerIfExists()) > platformMediaSessionManager->stopAllMediaPlaybackForDocument(this); > #endif >- >+ > // We must call clearRareData() here since a Document class inherits TreeScope > // as well as Node. See a comment on TreeScope.h for the reason. > if (hasRareData()) >@@ -7413,6 +7417,76 @@ void Document::removeViewportDependentPicture(HTMLPictureElement& picture) > m_viewportDependentPictures.remove(&picture); > } > >+#if ENABLE(INTERSECTION_OBSERVER) >+void Document::addIntersectionObserver(RefPtr<IntersectionObserver>&& observer) >+{ >+ ASSERT(m_intersectionObservers.find(observer) == notFound); >+ m_intersectionObservers.append(WTFMove(observer)); >+} >+ >+RefPtr<IntersectionObserver> Document::removeIntersectionObserver(IntersectionObserver& observer) >+{ >+ RefPtr<IntersectionObserver> observerRef; >+ auto index = m_intersectionObservers.find(&observer); >+ if (index != notFound) { >+ observerRef = WTFMove(m_intersectionObservers[index]); >+ m_intersectionObservers.remove(index); >+ } >+ return observerRef; >+} >+ >+void Document::updateIntersectionObservations() >+{ >+ for (auto observer : m_intersectionObservers) { >+ bool needNotify = false; >+ for (Element* target : observer->observationTargets()) { >+ auto& targetRegistrations = target->intersectionObserverData()->registrations; >+ auto index = targetRegistrations.findMatching([observer](auto& registration) { >+ return registration.observer.get() == observer; >+ }); >+ ASSERT(index != notFound); >+ auto& registration = targetRegistrations[index]; >+ >+ // FIXME: Compute intersection of target and observer's root. >+ size_t thresholdIndex = 0; >+ double timestamp = 0; >+ std::optional<DOMRectInit> rootBounds; >+ DOMRectInit targetBoundingClientRect; >+ DOMRectInit intersectionRect; >+ double intersectionRatio = 0; >+ bool isIntersecting = false; >+ if (!registration.previousThresholdIndex || thresholdIndex != registration.previousThresholdIndex) { >+ observer->appendQueuedEntry(IntersectionObserverEntry::create({ >+ timestamp, >+ rootBounds, >+ targetBoundingClientRect, >+ intersectionRect, >+ intersectionRatio, >+ target, >+ isIntersecting, >+ })); >+ needNotify = true; >+ registration.previousThresholdIndex = thresholdIndex; >+ } >+ } >+ if (needNotify) >+ m_intersectionObserversWithPendingNotifications.append(makeWeakPtr(observer.get())); >+ } >+ >+ if (m_intersectionObserversWithPendingNotifications.size()) >+ m_intersectionObserversNotifyTimer.startOneShot(0_s); >+} >+ >+void Document::notifyIntersectionObserversTimerFired() >+{ >+ for (auto observer : m_intersectionObserversWithPendingNotifications) { >+ if (observer) >+ observer->notify(); >+ } >+ m_intersectionObserversWithPendingNotifications.clear(); >+} >+#endif >+ > const AtomicString& Document::dir() const > { > auto* documentElement = this->documentElement(); >diff --git a/Source/WebCore/dom/Document.h b/Source/WebCore/dom/Document.h >index 2e3afc20b059a8b6b964b89b9b595f4b071c18c1..9587bb92e3d4cfec4ca38737c69ee1f743fa1a04 100644 >--- a/Source/WebCore/dom/Document.h >+++ b/Source/WebCore/dom/Document.h >@@ -235,6 +235,10 @@ class MediaSession; > class HTMLAttachmentElement; > #endif > >+#if ENABLE(INTERSECTION_OBSERVER) >+class IntersectionObserver; >+#endif >+ > namespace Style { > class Scope; > }; >@@ -1359,6 +1363,13 @@ public: > void addViewportDependentPicture(HTMLPictureElement&); > void removeViewportDependentPicture(HTMLPictureElement&); > >+#if ENABLE(INTERSECTION_OBSERVER) >+ void addIntersectionObserver(RefPtr<IntersectionObserver>&&); >+ RefPtr<IntersectionObserver> removeIntersectionObserver(IntersectionObserver&); >+ unsigned numberOfIntersectionObservers() const { return m_intersectionObservers.size(); } >+ void updateIntersectionObservations(); >+#endif >+ > #if ENABLE(MEDIA_STREAM) > void setHasCaptureMediaStreamTrack() { m_hasHadCaptureMediaStreamTrack = true; } > bool hasHadCaptureMediaStreamTrack() const { return m_hasHadCaptureMediaStreamTrack; } >@@ -1575,6 +1586,10 @@ private: > > void checkViewportDependentPictures(); > >+#if ENABLE(INTERSECTION_OBSERVER) >+ void notifyIntersectionObserversTimerFired(); >+#endif >+ > #if USE(QUICK_LOOK) > bool shouldEnforceQuickLookSandbox() const; > void applyQuickLookSandbox(); >@@ -1757,6 +1772,12 @@ private: > > HashSet<HTMLPictureElement*> m_viewportDependentPictures; > >+#if ENABLE(INTERSECTION_OBSERVER) >+ Vector<RefPtr<IntersectionObserver>> m_intersectionObservers; >+ Vector<WeakPtr<IntersectionObserver>> m_intersectionObserversWithPendingNotifications; >+ Timer m_intersectionObserversNotifyTimer; >+#endif >+ > Timer m_loadEventDelayTimer; > > ViewportArguments m_viewportArguments; >diff --git a/Source/WebCore/dom/Element.cpp b/Source/WebCore/dom/Element.cpp >index b47c8932587bb190f8222bad8bf583f59e90b770..f22ba7ca257a5848b19a0a05a831d47e87566ce0 100644 >--- a/Source/WebCore/dom/Element.cpp >+++ b/Source/WebCore/dom/Element.cpp >@@ -1648,6 +1648,15 @@ void Element::didMoveToNewDocument(Document& oldDocument, Document& newDocument) > > if (UNLIKELY(isDefinedCustomElement())) > CustomElementReactionQueue::enqueueAdoptedCallbackIfNeeded(*this, oldDocument, newDocument); >+ >+#if ENABLE(INTERSECTION_OBSERVER) >+ if (auto* observerData = intersectionObserverData()) { >+ for (auto observer : observerData->observers) { >+ if (observer->hasObservationTargets()) >+ newDocument.addIntersectionObserver(oldDocument.removeIntersectionObserver(*observer)); >+ } >+ } >+#endif > } > > bool Element::hasAttributes() const >@@ -3244,7 +3253,11 @@ void Element::disconnectFromIntersectionObservers() > if (!observerData) > return; > >- for (auto* observer : observerData->observers) >+ for (auto& registration : observerData->registrations) >+ registration.observer->targetDestroyed(*this); >+ observerData->registrations.clear(); >+ >+ for (auto observer : observerData->observers) > observer->rootDestroyed(); > observerData->observers.clear(); > } >diff --git a/Source/WebCore/page/IntersectionObserver.cpp b/Source/WebCore/page/IntersectionObserver.cpp >index 44f346da143560ee4f3510f3dba365d52c4b43de..9082f841944579f7963c7a241d2be025da3ad459 100644 >--- a/Source/WebCore/page/IntersectionObserver.cpp >+++ b/Source/WebCore/page/IntersectionObserver.cpp >@@ -81,7 +81,7 @@ static ExceptionOr<LengthBox> parseRootMargin(String& rootMargin) > return LengthBox(WTFMove(margins[0]), WTFMove(margins[1]), WTFMove(margins[2]), WTFMove(margins[3])); > } > >-ExceptionOr<Ref<IntersectionObserver>> IntersectionObserver::create(Ref<IntersectionObserverCallback>&& callback, IntersectionObserver::Init&& init) >+ExceptionOr<Ref<IntersectionObserver>> IntersectionObserver::create(Document& document, Ref<IntersectionObserverCallback>&& callback, IntersectionObserver::Init&& init) > { > auto rootMarginOrException = parseRootMargin(init.rootMargin); > if (rootMarginOrException.hasException()) >@@ -100,10 +100,10 @@ ExceptionOr<Ref<IntersectionObserver>> IntersectionObserver::create(Ref<Intersec > return Exception { RangeError, "Failed to construct 'IntersectionObserver': all thresholds must lie in the range [0.0, 1.0]." }; > } > >- return adoptRef(*new IntersectionObserver(WTFMove(callback), init.root, rootMarginOrException.releaseReturnValue(), WTFMove(thresholds))); >+ return adoptRef(*new IntersectionObserver(document, WTFMove(callback), init.root, rootMarginOrException.releaseReturnValue(), WTFMove(thresholds))); > } > >-IntersectionObserver::IntersectionObserver(Ref<IntersectionObserverCallback>&& callback, Element* root, LengthBox&& parsedRootMargin, Vector<double>&& thresholds) >+IntersectionObserver::IntersectionObserver(Document& document, Ref<IntersectionObserverCallback>&& callback, Element* root, LengthBox&& parsedRootMargin, Vector<double>&& thresholds) > : m_root(root) > , m_rootMargin(WTFMove(parsedRootMargin)) > , m_thresholds(WTFMove(thresholds)) >@@ -111,14 +111,16 @@ IntersectionObserver::IntersectionObserver(Ref<IntersectionObserverCallback>&& c > { > if (m_root) { > auto& observerData = m_root->ensureIntersectionObserverData(); >- observerData.observers.append(this); >- } >+ observerData.observers.append(makeWeakPtr(this)); >+ } else if (auto* frame = document.frame()) >+ m_implicitRootDocument = makeWeakPtr(frame->mainFrame().document()); > } > > IntersectionObserver::~IntersectionObserver() > { > if (m_root) > m_root->intersectionObserverData()->observers.removeFirst(this); >+ removeAllTargets(); > } > > String IntersectionObserver::rootMargin() const >@@ -138,28 +140,103 @@ String IntersectionObserver::rootMargin() const > return stringBuilder.toString(); > } > >-void IntersectionObserver::observe(Element&) >+void IntersectionObserver::observe(Element& target) > { >+ if (!trackingDocument() || m_observationTargets.contains(&target)) >+ return; >+ >+ target.ensureIntersectionObserverData().registrations.append({ makeWeakPtr(this), std::nullopt }); >+ bool hadObservationTargets = hasObservationTargets(); >+ m_observationTargets.append(&target); >+ auto* document = trackingDocument(); >+ if (!hadObservationTargets) >+ document->addIntersectionObserver(this); >+ document->postTask([document] (ScriptExecutionContext&) mutable { >+ document->updateIntersectionObservations(); >+ }); > } > >-void IntersectionObserver::unobserve(Element&) >+void IntersectionObserver::unobserve(Element& target) > { >+ if (!removeTargetRegistration(target)) >+ return; >+ >+ bool removed = m_observationTargets.removeFirst(&target); >+ ASSERT_UNUSED(removed, removed); >+ >+ if (!hasObservationTargets()) { >+ if (auto* document = trackingDocument()) >+ document->removeIntersectionObserver(*this); >+ } > } > > void IntersectionObserver::disconnect() > { >+ if (!hasObservationTargets()) >+ return; >+ >+ removeAllTargets(); >+ if (auto* document = trackingDocument()) >+ document->removeIntersectionObserver(*this); >+} >+ >+Vector<Ref<IntersectionObserverEntry>> IntersectionObserver::takeRecords() >+{ >+ return WTFMove(m_queuedEntries); > } > >-Vector<RefPtr<IntersectionObserverEntry>> IntersectionObserver::takeRecords() >+void IntersectionObserver::targetDestroyed(Element& target) > { >- return { }; >+ m_observationTargets.removeFirst(&target); >+ if (!hasObservationTargets()) { >+ if (auto* document = trackingDocument()) >+ document->removeIntersectionObserver(*this); >+ } >+} >+ >+bool IntersectionObserver::removeTargetRegistration(Element& target) >+{ >+ auto* observerData = target.intersectionObserverData(); >+ if (!observerData) >+ return false; >+ >+ auto& registrations = observerData->registrations; >+ return registrations.removeFirstMatching([this](auto& registration) { >+ return registration.observer.get() == this; >+ }); >+} >+ >+void IntersectionObserver::removeAllTargets() >+{ >+ for (auto* target : m_observationTargets) { >+ bool removed = removeTargetRegistration(*target); >+ ASSERT_UNUSED(removed, removed); >+ } >+ m_observationTargets.clear(); > } > > void IntersectionObserver::rootDestroyed() > { > ASSERT(m_root); >- disconnect(); >+ auto& document = m_root->document(); > m_root = nullptr; >+ if (hasObservationTargets()) { >+ removeAllTargets(); >+ document.removeIntersectionObserver(*this); >+ } >+} >+ >+void IntersectionObserver::appendQueuedEntry(Ref<IntersectionObserverEntry>&& entry) >+{ >+ m_queuedEntries.append(WTFMove(entry)); >+} >+ >+void IntersectionObserver::notify() >+{ >+ if (m_queuedEntries.isEmpty() || !m_callback->canInvokeCallback()) >+ return; >+ >+ m_callback->handleEvent(takeRecords(), *this); > } > > } // namespace WebCore >diff --git a/Source/WebCore/page/IntersectionObserver.h b/Source/WebCore/page/IntersectionObserver.h >index 7aac21832094d863ef768f92df75bfaf3a5ab3b7..ba2d18ab87e48e3515637b29478c0259c24064d6 100644 >--- a/Source/WebCore/page/IntersectionObserver.h >+++ b/Source/WebCore/page/IntersectionObserver.h >@@ -32,22 +32,30 @@ > #include "LengthBox.h" > #include <wtf/RefCounted.h> > #include <wtf/Variant.h> >+#include <wtf/WeakPtr.h> > #include <wtf/text/WTFString.h> > > namespace WebCore { > >+class Document; > class Element; > >+struct IntersectionObserverRegistration { >+ WeakPtr<IntersectionObserver> observer; >+ std::optional<size_t> previousThresholdIndex; >+}; >+ > struct IntersectionObserverData { > // IntersectionObservers for which the element that owns this IntersectionObserverData is the root. >- // The IntersectionObservers are owned by JavaScript wrappers and by IntersectionObserverRegistrations >- // for each target currently being observed. >- Vector<IntersectionObserver*> observers; >+ // An IntersectionObserver without any targets is only owned by JavaScript wrappers. An >+ // IntersectionObserver with at least one target is also owned by its trackingDocument. >+ Vector<WeakPtr<IntersectionObserver>> observers; > >- // FIXME: Create and track IntersectionObserverRegistrations. >+ // IntersectionObserverRegistrations for which the element that owns this IntersectionObserverData is the target. >+ Vector<IntersectionObserverRegistration> registrations; > }; > >-class IntersectionObserver : public RefCounted<IntersectionObserver> { >+class IntersectionObserver : public RefCounted<IntersectionObserver>, public CanMakeWeakPtr<IntersectionObserver> { > public: > struct Init { > Element* root { nullptr }; >@@ -55,29 +63,43 @@ public: > Variant<double, Vector<double>> threshold; > }; > >- static ExceptionOr<Ref<IntersectionObserver>> create(Ref<IntersectionObserverCallback>&&, Init&&); >+ static ExceptionOr<Ref<IntersectionObserver>> create(Document&, Ref<IntersectionObserverCallback>&&, Init&&); > > ~IntersectionObserver(); > >+ Document* trackingDocument() { return m_root ? &m_root->document() : m_implicitRootDocument.get(); } >+ > Element* root() const { return m_root; } > String rootMargin() const; > const Vector<double>& thresholds() const { return m_thresholds; } >+ const Vector<Element*> observationTargets() const { return m_observationTargets; } > > void observe(Element&); > void unobserve(Element&); > void disconnect(); > >- Vector<RefPtr<IntersectionObserverEntry>> takeRecords(); >+ Vector<Ref<IntersectionObserverEntry>> takeRecords(); > >+ void targetDestroyed(Element&); >+ bool hasObservationTargets() const { return m_observationTargets.size(); } > void rootDestroyed(); > >+ void appendQueuedEntry(Ref<IntersectionObserverEntry>&&); >+ void notify(); >+ > private: >- IntersectionObserver(Ref<IntersectionObserverCallback>&&, Element* root, LengthBox&& parsedRootMargin, Vector<double>&& thresholds); >- >+ IntersectionObserver(Document&, Ref<IntersectionObserverCallback>&&, Element* root, LengthBox&& parsedRootMargin, Vector<double>&& thresholds); >+ >+ bool removeTargetRegistration(Element&); >+ void removeAllTargets(); >+ >+ WeakPtr<Document> m_implicitRootDocument; > Element* m_root; > LengthBox m_rootMargin; > Vector<double> m_thresholds; > Ref<IntersectionObserverCallback> m_callback; >+ Vector<Element*> m_observationTargets; >+ Vector<Ref<IntersectionObserverEntry>> m_queuedEntries; > }; > > >diff --git a/Source/WebCore/page/IntersectionObserver.idl b/Source/WebCore/page/IntersectionObserver.idl >index e6dbabf6c0204e910978507a476e111e8de74b15..f78772af74ec53d9109582365aac1c2f5c2fc852 100644 >--- a/Source/WebCore/page/IntersectionObserver.idl >+++ b/Source/WebCore/page/IntersectionObserver.idl >@@ -27,6 +27,7 @@ > > [ > Conditional=INTERSECTION_OBSERVER, >+ ConstructorCallWith=Document, > ConstructorMayThrowException, > Constructor(IntersectionObserverCallback callback, optional IntersectionObserverInit options), > ImplementationLacksVTable, >diff --git a/Source/WebCore/testing/Internals.cpp b/Source/WebCore/testing/Internals.cpp >index 13b7b707e2738e33f810ce49ccd5a1af0bd72745..09c45afa8a982afbc9a56dd61850e17df367bbd2 100644 >--- a/Source/WebCore/testing/Internals.cpp >+++ b/Source/WebCore/testing/Internals.cpp >@@ -2310,6 +2310,13 @@ unsigned Internals::referencingNodeCount(const Document& document) const > return document.referencingNodeCount(); > } > >+#if ENABLE(INTERSECTION_OBSERVER) >+unsigned Internals::numberOfIntersectionObservers(const Document& document) const >+{ >+ return document.numberOfIntersectionObservers(); >+} >+#endif >+ > uint64_t Internals::documentIdentifier(const Document& document) const > { > return document.identifier().toUInt64(); >diff --git a/Source/WebCore/testing/Internals.h b/Source/WebCore/testing/Internals.h >index d0d2879ce6f6737945d57379147b6376d344646f..9c1cab9c30ca106f80797781df4433087069ffe4 100644 >--- a/Source/WebCore/testing/Internals.h >+++ b/Source/WebCore/testing/Internals.h >@@ -364,6 +364,10 @@ public: > unsigned numberOfLiveDocuments() const; > unsigned referencingNodeCount(const Document&) const; > >+#if ENABLE(INTERSECTION_OBSERVER) >+ unsigned numberOfIntersectionObservers(const Document&) const; >+#endif >+ > uint64_t documentIdentifier(const Document&) const; > bool isDocumentAlive(uint64_t documentIdentifier) const; > >diff --git a/Source/WebCore/testing/Internals.idl b/Source/WebCore/testing/Internals.idl >index 01148b98d9b0f8bfb454a7d7411a6f6f64c8820f..2322663c7f97b4d7d721564697a6c30c34d4c03c 100644 >--- a/Source/WebCore/testing/Internals.idl >+++ b/Source/WebCore/testing/Internals.idl >@@ -359,6 +359,7 @@ enum CompositingPolicy { > unsigned long numberOfLiveNodes(); > unsigned long numberOfLiveDocuments(); > unsigned long referencingNodeCount(Document document); >+ [Conditional=INTERSECTION_OBSERVER] unsigned long numberOfIntersectionObservers(Document document); > WindowProxy? openDummyInspectorFrontend(DOMString url); > void closeDummyInspectorFrontend(); > [MayThrowException] void setInspectorIsUnderTest(boolean isUnderTest); >diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog >index de4b2bd150301ea5769fcc36e34615b4b3a1b5f1..9086314782a5e442cf707d7cbe324bdb070220b7 100644 >--- a/LayoutTests/ChangeLog >+++ b/LayoutTests/ChangeLog >@@ -1,3 +1,14 @@ >+2018-08-18 Ali Juma <ajuma@chromium.org> >+ >+ [IntersectionObserver] Fire an initial dummy notification >+ https://bugs.webkit.org/show_bug.cgi?id=188670 >+ >+ Reviewed by Simon Fraser. >+ >+ * intersection-observer/root-element-deleted.html: Add additional assertions. >+ * intersection-observer/root-element-moved-expected.txt: Added. >+ * intersection-observer/root-element-moved.html: Added. >+ > 2018-08-15 Ali Juma <ajuma@chromium.org> > > Disable IntersectionObserver tests on Windows for now >diff --git a/LayoutTests/imported/w3c/ChangeLog b/LayoutTests/imported/w3c/ChangeLog >index baaad25387312dd8793116139233197a800f8b8f..b235410732202fdc9e9dd372e933f35722146d63 100644 >--- a/LayoutTests/imported/w3c/ChangeLog >+++ b/LayoutTests/imported/w3c/ChangeLog >@@ -1,3 +1,37 @@ >+2018-08-18 Ali Juma <ajuma@chromium.org> >+ >+ [IntersectionObserver] Fire an initial dummy notification >+ https://bugs.webkit.org/show_bug.cgi?id=188670 >+ >+ Reviewed by Simon Fraser. >+ >+ Rebaseline tests now that an initial notification is fired. >+ >+ * web-platform-tests/intersection-observer/bounding-box-expected.txt: >+ * web-platform-tests/intersection-observer/client-rect-expected.txt: >+ * web-platform-tests/intersection-observer/containing-block-expected.txt: >+ * web-platform-tests/intersection-observer/cross-origin-iframe-expected.txt: >+ * web-platform-tests/intersection-observer/disconnect-expected.txt: >+ * web-platform-tests/intersection-observer/display-none-expected.txt: >+ * web-platform-tests/intersection-observer/edge-inclusive-intersection-expected.txt: >+ * web-platform-tests/intersection-observer/iframe-no-root-expected.txt: >+ * web-platform-tests/intersection-observer/inline-client-rect-expected.txt: >+ * web-platform-tests/intersection-observer/isIntersecting-change-events-expected.txt: >+ * web-platform-tests/intersection-observer/multiple-targets-expected.txt: >+ * web-platform-tests/intersection-observer/multiple-thresholds-expected.txt: >+ * web-platform-tests/intersection-observer/observer-without-js-reference-expected.txt: >+ * web-platform-tests/intersection-observer/remove-element-expected.txt: >+ * web-platform-tests/intersection-observer/root-margin-expected.txt: >+ * web-platform-tests/intersection-observer/same-document-no-root-expected.txt: >+ * web-platform-tests/intersection-observer/same-document-root-expected.txt: >+ * web-platform-tests/intersection-observer/same-document-zero-size-target-expected.txt: >+ * web-platform-tests/intersection-observer/shadow-content-expected.txt: >+ * web-platform-tests/intersection-observer/text-target-expected.txt: >+ * web-platform-tests/intersection-observer/timestamp-expected.txt: >+ * web-platform-tests/intersection-observer/unclipped-root-expected.txt: >+ * web-platform-tests/intersection-observer/zero-area-element-hidden-expected.txt: >+ * web-platform-tests/intersection-observer/zero-area-element-visible-expected.txt: >+ > 2018-08-14 Ryosuke Niwa <rniwa@webkit.org> > > connectedCallback is invoked by the HTML parser after child nodes had been inserted >diff --git a/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/bounding-box-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/bounding-box-expected.txt >index 50762b64c80febecffaae98d9c467d7d3f61ef62..2a30215c484e4cb70824d011678ce29347e90430 100644 >--- a/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/bounding-box-expected.txt >+++ b/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/bounding-box-expected.txt >@@ -1,5 +1,5 @@ > > PASS Test that the target's border bounding box is used to calculate intersection. >-FAIL First rAF. assert_equals: entries.length expected 1 but got 0 >-FAIL target.style.transform = 'translateY(195px)' assert_equals: entries.length expected 2 but got 0 >+FAIL First rAF. assert_equals: entries[0].boundingClientRect.left expected 25 but got 0 >+FAIL target.style.transform = 'translateY(195px)' assert_equals: entries.length expected 2 but got 1 > >diff --git a/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/client-rect-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/client-rect-expected.txt >index 08fc2c4b449f4d5d0dcdc3f707a41a956a0d229b..2d27f6723e91910dae87a72c02eed9441ce5ddd7 100644 >--- a/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/client-rect-expected.txt >+++ b/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/client-rect-expected.txt >@@ -1,4 +1,4 @@ > > PASS IntersectionObserverEntry.boundingClientRect should match target.boundingClientRect() >-FAIL First rAF should generate notification. assert_equals: One notification. expected 1 but got 0 >+FAIL First rAF should generate notification. assert_equals: entries[0].boundingClientRect.left expected 8 but got 0 > >diff --git a/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/containing-block-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/containing-block-expected.txt >index 9eeb18e5977332c4fc9d3ca358624fe67fc00d5a..73be024490b156e37b0d2e8d1cae773b10669cf7 100644 >--- a/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/containing-block-expected.txt >+++ b/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/containing-block-expected.txt >@@ -1,7 +1,7 @@ > > PASS IntersectionObserver should only report intersections if root is a containing block ancestor of target. >-FAIL In containing block and intersecting. assert_equals: entries.length expected 1 but got 0 >-FAIL In containing block and not intersecting. assert_equals: entries.length expected 2 but got 0 >-FAIL Not in containing block and intersecting. assert_equals: entries.length expected 2 but got 0 >-FAIL Not in containing block and not intersecting. assert_equals: entries.length expected 2 but got 0 >+FAIL In containing block and intersecting. assert_equals: entries[0].boundingClientRect.left expected 58 but got 0 >+FAIL In containing block and not intersecting. assert_equals: entries.length expected 2 but got 1 >+FAIL Not in containing block and intersecting. assert_equals: entries.length expected 2 but got 1 >+FAIL Not in containing block and not intersecting. assert_equals: entries.length expected 2 but got 1 > >diff --git a/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/cross-origin-iframe-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/cross-origin-iframe-expected.txt >index f26709bc5cf3bdc7301c085bb53ff65063d71a44..95c52cb6102a3de268d6da56be50b98e496bfd1e 100644 >--- a/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/cross-origin-iframe-expected.txt >+++ b/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/cross-origin-iframe-expected.txt >@@ -1,7 +1,7 @@ > > > PASS Intersection observer test with no explicit root and target in a cross-origin iframe. >-FAIL First rAF assert_equals: expected 1 but got 0 >+PASS First rAF > PASS topDocument.scrollingElement.scrollTop = 200 > FAIL iframeDocument.scrollingElement.scrollTop = 250 assert_equals: expected 1 but got 0 > FAIL topDocument.scrollingElement.scrollTop = 100 assert_equals: expected 1 but got 0 >diff --git a/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/disconnect-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/disconnect-expected.txt >index 41df6e7a70bb1a50cc1773f24ae80fe0d9e6eeeb..f88c12c28008e77d08aac8cb06c97a9caa6e6c2f 100644 >--- a/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/disconnect-expected.txt >+++ b/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/disconnect-expected.txt >@@ -1,5 +1,5 @@ > > PASS IntersectionObserver should not deliver pending notifications after disconnect(). >-FAIL First rAF. assert_equals: Initial notification. expected 1 but got 0 >-FAIL observer.disconnect() assert_equals: No new notifications. expected 1 but got 0 >+PASS First rAF. >+PASS observer.disconnect() > >diff --git a/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/display-none-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/display-none-expected.txt >index 372a41fd75e1464241ce6c1babc83cbbcfcd386d..967db203b6440755e4092a55b39b9a15fb87233f 100644 >--- a/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/display-none-expected.txt >+++ b/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/display-none-expected.txt >@@ -1,6 +1,6 @@ > > PASS IntersectionObserver should send a not-intersecting notification for a target that gets display:none. >-FAIL Intersecting notification after first rAF. assert_equals: entries.length expected 1 but got 0 >-FAIL Not-intersecting notification after setting display:none on target. assert_equals: entries.length expected 2 but got 0 >-FAIL Intersecting notification after removing display:none on target. assert_equals: entries.length expected 3 but got 0 >+FAIL Intersecting notification after first rAF. assert_equals: entries[0].boundingClientRect.left expected 8 but got 0 >+FAIL Not-intersecting notification after setting display:none on target. assert_equals: entries.length expected 2 but got 1 >+FAIL Intersecting notification after removing display:none on target. assert_equals: entries.length expected 3 but got 1 > >diff --git a/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/edge-inclusive-intersection-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/edge-inclusive-intersection-expected.txt >index 6fd199f7d53f050299d4f8fe08eb294a50167a5a..c8595b0cba5a722fe506d676f06ee5127306b51f 100644 >--- a/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/edge-inclusive-intersection-expected.txt >+++ b/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/edge-inclusive-intersection-expected.txt >@@ -1,7 +1,7 @@ > > PASS IntersectionObserver should detect and report edge-adjacent and zero-area intersections. >-FAIL First rAF. assert_equals: entries.length expected 1 but got 0 >-FAIL Set transform=translateY(200px) on target. assert_equals: entries.length expected 2 but got 0 >-FAIL Set transform=translateY(201px) on target. assert_equals: entries.length expected 3 but got 0 >-FAIL Set transform=translateY(185px) on target. assert_equals: entries.length expected 4 but got 0 >+FAIL First rAF. assert_equals: entries[0].boundingClientRect.left expected 8 but got 0 >+FAIL Set transform=translateY(200px) on target. assert_equals: entries.length expected 2 but got 1 >+FAIL Set transform=translateY(201px) on target. assert_equals: entries.length expected 3 but got 1 >+FAIL Set transform=translateY(185px) on target. assert_equals: entries.length expected 4 but got 1 > >diff --git a/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/iframe-no-root-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/iframe-no-root-expected.txt >index 9137bee6b5d4e8de631354876333fbe9b04b624c..5daefcc5b8819ed05ca9c597592552462ce7b5ab 100644 >--- a/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/iframe-no-root-expected.txt >+++ b/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/iframe-no-root-expected.txt >@@ -1,8 +1,8 @@ > > > PASS Observer with the implicit root; target in a same-origin iframe. >-FAIL First rAF. assert_equals: entries.length expected 1 but got 0 >-FAIL document.scrollingElement.scrollTop = 200 assert_equals: entries.length == 1 expected 1 but got 0 >-FAIL iframe.contentDocument.scrollingElement.scrollTop = 250 assert_equals: entries.length expected 2 but got 0 >-FAIL document.scrollingElement.scrollTop = 100 assert_equals: entries.length expected 3 but got 0 >+FAIL First rAF. assert_equals: entries[0].boundingClientRect.left expected 8 but got 0 >+PASS document.scrollingElement.scrollTop = 200 >+FAIL iframe.contentDocument.scrollingElement.scrollTop = 250 assert_equals: entries.length expected 2 but got 1 >+FAIL document.scrollingElement.scrollTop = 100 assert_equals: entries.length expected 3 but got 1 > >diff --git a/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/inline-client-rect-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/inline-client-rect-expected.txt >index 1ccadf05989d0299c05cd80d1f04bcccd1b0908c..eda47367bbaef463fe3833ec57bf090f2d4bb416 100644 >--- a/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/inline-client-rect-expected.txt >+++ b/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/inline-client-rect-expected.txt >@@ -1,6 +1,6 @@ > 1 2 3 4 5 > > PASS Inline target >-FAIL First rAF assert_equals: entries.length expected 1 but got 0 >-FAIL scroller.scrollLeft = 90 assert_equals: entries.length expected 2 but got 0 >+FAIL First rAF assert_equals: entries[0].boundingClientRect.left expected 320 but got 0 >+FAIL scroller.scrollLeft = 90 assert_equals: entries.length expected 2 but got 1 > >diff --git a/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/isIntersecting-change-events-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/isIntersecting-change-events-expected.txt >index 07d48f20195ec7acbbb54800c160092a91850b6b..666955928ce3700720d0bf91989d2b8a3306b9ab 100644 >--- a/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/isIntersecting-change-events-expected.txt >+++ b/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/isIntersecting-change-events-expected.txt >@@ -1,4 +1,4 @@ > > PASS isIntersecting changes should trigger notifications. >-FAIL Rects in initial notifications should report initial positions. assert_equals: Has 3 initial notifications. expected 3 but got 0 >+FAIL Rects in initial notifications should report initial positions. assert_equals: Check 1st entry rect.right expected 100 but got 0 > >diff --git a/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/multiple-targets-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/multiple-targets-expected.txt >index 4d1482ccb46a3dc4e686dff5e8a7bfac5f7bf20f..acebac2fcfaa0a7914a240196983002e36aea429 100644 >--- a/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/multiple-targets-expected.txt >+++ b/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/multiple-targets-expected.txt >@@ -1,7 +1,7 @@ > > PASS One observer with multiple targets. >-FAIL First rAF. assert_equals: Three initial notifications. expected 3 but got 0 >-FAIL document.scrollingElement.scrollTop = 150 assert_equals: Four notifications. expected 4 but got 0 >-FAIL document.scrollingElement.scrollTop = 10000 assert_equals: Six notifications. expected 6 but got 0 >-FAIL document.scrollingElement.scrollTop = 0 assert_equals: Nine notifications. expected 9 but got 0 >+PASS First rAF. >+FAIL document.scrollingElement.scrollTop = 150 assert_equals: Four notifications. expected 4 but got 3 >+FAIL document.scrollingElement.scrollTop = 10000 assert_equals: Six notifications. expected 6 but got 3 >+FAIL document.scrollingElement.scrollTop = 0 assert_equals: Nine notifications. expected 9 but got 3 > >diff --git a/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/multiple-thresholds-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/multiple-thresholds-expected.txt >index f4a66f808e5edb8949d7da8dc1778557b66f71e6..305679f80c737e5c7a4a46361bb13c61a92626d2 100644 >--- a/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/multiple-thresholds-expected.txt >+++ b/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/multiple-thresholds-expected.txt >@@ -1,11 +1,11 @@ > > PASS Observer with multiple thresholds. >-FAIL First rAF. assert_equals: entries.length expected 1 but got 0 >-FAIL document.scrollingElement.scrollTop = 120 assert_equals: entries.length expected 2 but got 0 >-FAIL document.scrollingElement.scrollTop = 160 assert_equals: entries.length expected 3 but got 0 >-FAIL document.scrollingElement.scrollTop = 200 assert_equals: entries.length expected 4 but got 0 >-FAIL document.scrollingElement.scrollTop = 240 assert_equals: entries.length expected 5 but got 0 >-FAIL document.scrollingElement.scrollTop = window.innerHeight + 140 assert_equals: entries.length expected 6 but got 0 >-FAIL document.scrollingElement.scrollTop = window.innerHeight + 160 assert_equals: entries.length expected 7 but got 0 >-FAIL document.scrollingElement.scrollTop = window.innerHeight + 200 assert_equals: entries.length expected 8 but got 0 >+FAIL First rAF. assert_equals: entries[0].boundingClientRect.left expected 8 but got 0 >+FAIL document.scrollingElement.scrollTop = 120 assert_equals: entries.length expected 2 but got 1 >+FAIL document.scrollingElement.scrollTop = 160 assert_equals: entries.length expected 3 but got 1 >+FAIL document.scrollingElement.scrollTop = 200 assert_equals: entries.length expected 4 but got 1 >+FAIL document.scrollingElement.scrollTop = 240 assert_equals: entries.length expected 5 but got 1 >+FAIL document.scrollingElement.scrollTop = window.innerHeight + 140 assert_equals: entries.length expected 6 but got 1 >+FAIL document.scrollingElement.scrollTop = window.innerHeight + 160 assert_equals: entries.length expected 7 but got 1 >+FAIL document.scrollingElement.scrollTop = window.innerHeight + 200 assert_equals: entries.length expected 8 but got 1 > >diff --git a/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/observer-without-js-reference-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/observer-without-js-reference-expected.txt >index 4935ea6151cb330dcd9153acbc5d27a61405a6d2..2e7607f314b8750926650b3043bc218a479bbbe4 100644 >--- a/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/observer-without-js-reference-expected.txt >+++ b/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/observer-without-js-reference-expected.txt >@@ -1,5 +1,5 @@ > > PASS IntersectionObserver that is unreachable in js should still generate notifications. >-FAIL First rAF assert_equals: One notification. expected 1 but got 0 >-FAIL document.scrollingElement.scrollTop = 300 assert_equals: Two notifications. expected 2 but got 0 >+PASS First rAF >+FAIL document.scrollingElement.scrollTop = 300 assert_equals: Two notifications. expected 2 but got 1 > >diff --git a/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/remove-element-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/remove-element-expected.txt >index dd4186c082586cc61f2b778d19940b4ad41647ef..fc1b4a2bcbaaf9b113d8ac7a87fd52dddc517435 100644 >--- a/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/remove-element-expected.txt >+++ b/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/remove-element-expected.txt >@@ -1,8 +1,8 @@ > > PASS Verify that not-intersecting notifications are sent when a target is removed from the DOM tree. >-FAIL First rAF assert_equals: entries.length expected 1 but got 0 >-FAIL root.scrollTop = 150 assert_equals: entries.length expected 2 but got 0 >-FAIL root.removeChild(target). assert_equals: entries.length expected 3 but got 0 >-FAIL root.insertBefore(target, trailingSpace). assert_equals: entries.length expected 3 but got 0 >-FAIL root.scrollTop = 150 after reinserting target. assert_equals: entries.length expected 4 but got 0 >+FAIL First rAF assert_equals: entries[0].boundingClientRect.left expected 11 but got 0 >+FAIL root.scrollTop = 150 assert_equals: entries.length expected 2 but got 1 >+FAIL root.removeChild(target). assert_equals: entries.length expected 3 but got 1 >+FAIL root.insertBefore(target, trailingSpace). assert_equals: entries.length expected 3 but got 1 >+FAIL root.scrollTop = 150 after reinserting target. assert_equals: entries.length expected 4 but got 1 > >diff --git a/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/root-margin-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/root-margin-expected.txt >index 5d1e48f94ed374cfc4b44cadfc69138d104e1482..f396e95425428428bef7a7aa0984d220bf303767 100644 >--- a/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/root-margin-expected.txt >+++ b/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/root-margin-expected.txt >@@ -1,8 +1,8 @@ > > > PASS Root margin tests >-FAIL First rAF. assert_equals: entries.length expected 1 but got 0 >-FAIL document.scrollingElement.scrollLeft = 100 assert_equals: entries.length expected 2 but got 0 >-FAIL document.scrollingElement.scrollTop = document.documentElement.clientHeight + 200 assert_equals: entries.length expected 2 but got 0 >-FAIL document.scrollingElement.scrollTop = document.documentElement.clientHeight + 300 assert_equals: entries.length expected 3 but got 0 >+FAIL First rAF. assert_equals: entries[0].boundingClientRect.left expected 972 but got 0 >+FAIL document.scrollingElement.scrollLeft = 100 assert_equals: entries.length expected 2 but got 1 >+FAIL document.scrollingElement.scrollTop = document.documentElement.clientHeight + 200 assert_equals: entries.length expected 2 but got 1 >+FAIL document.scrollingElement.scrollTop = document.documentElement.clientHeight + 300 assert_equals: entries.length expected 3 but got 1 > >diff --git a/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/same-document-no-root-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/same-document-no-root-expected.txt >index 30c7a88cd81649ae47b792a005e53893402d4532..7bdff406a781f6db4064c53288967c137470b0c5 100644 >--- a/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/same-document-no-root-expected.txt >+++ b/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/same-document-no-root-expected.txt >@@ -1,6 +1,6 @@ > > PASS IntersectionObserver in a single document using the implicit root. >-FAIL First rAF. assert_equals: entries.length expected 1 but got 0 >-FAIL document.scrollingElement.scrollTop = 300 assert_equals: entries.length expected 2 but got 0 >-FAIL document.scrollingElement.scrollTop = 100 assert_equals: entries.length expected 3 but got 0 >+FAIL First rAF. assert_equals: entries[0].boundingClientRect.left expected 8 but got 0 >+FAIL document.scrollingElement.scrollTop = 300 assert_equals: entries.length expected 2 but got 1 >+FAIL document.scrollingElement.scrollTop = 100 assert_equals: entries.length expected 3 but got 1 > >diff --git a/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/same-document-root-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/same-document-root-expected.txt >index 6a18d4d560fa6a385eb8b4dc7ba59be252e5202a..1cc69784199d7d690874064eb17348fb138e00cb 100644 >--- a/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/same-document-root-expected.txt >+++ b/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/same-document-root-expected.txt >@@ -1,9 +1,9 @@ > > PASS IntersectionObserver in a single document with explicit root. >-FAIL First rAF assert_equals: entries.length expected 1 but got 0 >-FAIL document.scrollingElement.scrollTop = window.innerHeight. assert_equals: No notifications after scrolling frame. expected 1 but got 0 >-FAIL root.scrollTop = 150 with root scrolled into view. assert_equals: entries.length expected 2 but got 0 >-FAIL document.scrollingElement.scrollTop = 0. assert_equals: entries.length expected 2 but got 0 >-FAIL root.scrollTop = 0 assert_equals: entries.length expected 3 but got 0 >-FAIL root.scrollTop = 150 with root scrolled out of view. assert_equals: entries.length expected 4 but got 0 >+FAIL First rAF assert_equals: entries[0].boundingClientRect.left expected 11 but got 0 >+PASS document.scrollingElement.scrollTop = window.innerHeight. >+FAIL root.scrollTop = 150 with root scrolled into view. assert_equals: entries.length expected 2 but got 1 >+FAIL document.scrollingElement.scrollTop = 0. assert_equals: entries.length expected 2 but got 1 >+FAIL root.scrollTop = 0 assert_equals: entries.length expected 3 but got 1 >+FAIL root.scrollTop = 150 with root scrolled out of view. assert_equals: entries.length expected 4 but got 1 > >diff --git a/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/same-document-zero-size-target-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/same-document-zero-size-target-expected.txt >index 40b11a681301511df142629b7f6f01d72645c99f..a6f547028c95bcc60a830d635befedf577d89632 100644 >--- a/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/same-document-zero-size-target-expected.txt >+++ b/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/same-document-zero-size-target-expected.txt >@@ -1,6 +1,6 @@ > > PASS Observing a zero-area target. >-FAIL First rAF assert_equals: entries.length expected 1 but got 0 >-FAIL document.scrollingElement.scrollTop = 300 assert_equals: entries.length expected 2 but got 0 >-FAIL document.scrollingElement.scrollTop = 100 assert_equals: entries.length expected 3 but got 0 >+FAIL First rAF assert_equals: entries[0].boundingClientRect.left expected 8 but got 0 >+FAIL document.scrollingElement.scrollTop = 300 assert_equals: entries.length expected 2 but got 1 >+FAIL document.scrollingElement.scrollTop = 100 assert_equals: entries.length expected 3 but got 1 > >diff --git a/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/shadow-content-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/shadow-content-expected.txt >index bd0179886430c5287a3f8d1499f22d6640446e4f..c7395777f9af1251f1bd3dd908282d7dff7f8ae9 100644 >--- a/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/shadow-content-expected.txt >+++ b/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/shadow-content-expected.txt >@@ -1,4 +1,4 @@ > > PASS Observing a target inside shadow DOM. >-FAIL First rAF after creating shadow DOM. assert_equals: entries.length expected 1 but got 0 >+FAIL First rAF after creating shadow DOM. assert_equals: entries[0].boundingClientRect.left expected 8 but got 0 > >diff --git a/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/text-target-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/text-target-expected.txt >index a713ec2acf269c98d1140abfe444e87f446b6a86..6d7b211fa2eb2e8dbe247fc85e3cb0f8df5dc961 100644 >--- a/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/text-target-expected.txt >+++ b/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/text-target-expected.txt >@@ -1,7 +1,7 @@ > > > PASS IntersectionObserver observing a br element. >-FAIL First rAF. assert_equals: entries.length expected 1 but got 0 >-FAIL document.scrollingElement.scrollTop = 300 assert_equals: entries.length expected 2 but got 0 >-FAIL document.scrollingElement.scrollTop = 100 assert_equals: entries.length expected 3 but got 0 >+FAIL First rAF. assert_equals: entries[0].boundingClientRect.left expected 8 but got 0 >+FAIL document.scrollingElement.scrollTop = 300 assert_equals: entries.length expected 2 but got 1 >+FAIL document.scrollingElement.scrollTop = 100 assert_equals: entries.length expected 3 but got 1 > >diff --git a/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/timestamp-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/timestamp-expected.txt >index c8e113505b187ab19d006507aec96bfa8b56a692..fd25cbf86806828bdfdc854d67e9f5ba2cc4e1b1 100644 >--- a/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/timestamp-expected.txt >+++ b/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/timestamp-expected.txt >@@ -1,6 +1,6 @@ > > > PASS Check that timestamps correspond to the to execution context that created the observer. >-FAIL First rAF after iframe is loaded. assert_equals: One notification to top window observer. expected 1 but got 0 >+PASS First rAF after iframe is loaded. > FAIL Generate notifications. undefined is not an object (evaluating 'topWindowEntries[1].time') > >diff --git a/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/unclipped-root-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/unclipped-root-expected.txt >index eabc5778c39717e2fe5ef82f3960213759eebb79..af52e04b8bb6a4967cdaae8496def8b0f756320b 100644 >--- a/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/unclipped-root-expected.txt >+++ b/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/unclipped-root-expected.txt >@@ -1,5 +1,5 @@ > > PASS Test that border bounding box is used to calculate intersection with a non-scrolling root. >-FAIL First rAF. assert_equals: entries.length expected 1 but got 0 >-FAIL target.style.transform = 'translateY(195px)' assert_equals: entries.length expected 2 but got 0 >+FAIL First rAF. assert_equals: entries[0].boundingClientRect.left expected 15 but got 0 >+FAIL target.style.transform = 'translateY(195px)' assert_equals: entries.length expected 2 but got 1 > >diff --git a/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/zero-area-element-hidden-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/zero-area-element-hidden-expected.txt >index 2507ee2bf3746e5898b1df36db3f85214b5d4551..28aa4902b1099488e9bca089552c3bcb7976b22e 100644 >--- a/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/zero-area-element-hidden-expected.txt >+++ b/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/zero-area-element-hidden-expected.txt >@@ -1,4 +1,4 @@ > > PASS A zero-area hidden target should not be intersecting. >-FAIL First rAF. assert_equals: entries.length expected 1 but got 0 >+FAIL First rAF. assert_equals: entries[0].boundingClientRect.left expected 8 but got 0 > >diff --git a/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/zero-area-element-visible-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/zero-area-element-visible-expected.txt >index d4ba44456f76740b7e16d11667efebaad8ce358a..c118fdf66d058fe5762aa05ec0bf7250c9180de4 100644 >--- a/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/zero-area-element-visible-expected.txt >+++ b/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/zero-area-element-visible-expected.txt >@@ -1,4 +1,4 @@ > > PASS Ensure that a zero-area target intersecting root generates a notification with intersectionRatio == 1 >-FAIL First rAF should generate a notification. assert_equals: One notification. expected 1 but got 0 >+FAIL First rAF should generate a notification. assert_equals: intersectionRatio == 1 expected 1 but got 0 > >diff --git a/LayoutTests/intersection-observer/root-element-deleted.html b/LayoutTests/intersection-observer/root-element-deleted.html >index 114d9ac502b4f7e9cfc610d18e9e4e29de4b8da6..c35493a6f2f9814b0f0ee095b3a47d33e8f5ebdf 100644 >--- a/LayoutTests/intersection-observer/root-element-deleted.html >+++ b/LayoutTests/intersection-observer/root-element-deleted.html >@@ -15,12 +15,14 @@ > var target = document.getElementById('target'); > assert_equals(observer.root, root, 'Observer starts out with non-null root'); > observer.observe(target); >+ assert_equals(internals.numberOfIntersectionObservers(document), 1); > root.parentNode.removeChild(root); > root = null; > target = null; > requestAnimationFrame(t.step_func_done(function() { > GCController.collect(); > assert_equals(observer.root, null, 'Observer has null root after root element is destroyed'); >+ assert_equals(internals.numberOfIntersectionObservers(document), 0); > })); > }, "IntersectionObserver doesn't keep unreachable root alive"); > </script> >diff --git a/LayoutTests/intersection-observer/root-element-moved-expected.txt b/LayoutTests/intersection-observer/root-element-moved-expected.txt >new file mode 100644 >index 0000000000000000000000000000000000000000..6552be4143b4acb992be76f540315d6652dc40b0 >--- /dev/null >+++ b/LayoutTests/intersection-observer/root-element-moved-expected.txt >@@ -0,0 +1,3 @@ >+ >+PASS Document's active intersection observers get updated >+ >diff --git a/LayoutTests/intersection-observer/root-element-moved.html b/LayoutTests/intersection-observer/root-element-moved.html >new file mode 100644 >index 0000000000000000000000000000000000000000..d51c8158205b804b9ea9f0295157715fc1ba10fc >--- /dev/null >+++ b/LayoutTests/intersection-observer/root-element-moved.html >@@ -0,0 +1,31 @@ >+<!DOCTYPE html><!-- webkit-test-runner [ enableIntersectionObserver=true ] --> >+<head> >+<script src="../resources/testharness.js"></script> >+<script src="../resources/testharnessreport.js"></script> >+<body> >+ >+<div id="root" style="position:absolute"> >+ <div id="target" style="width: 100px; height: 100px; background-color: green"></div> >+</div> >+ >+<script> >+ var observer; >+ var root = document.getElementById('root'); >+ var target = document.getElementById('target'); >+ test(function() { >+ observer = new IntersectionObserver(function() {}, { root: document.getElementById('root') });; >+ assert_equals(observer.root, root); >+ observer.observe(target); >+ assert_equals(internals.numberOfIntersectionObservers(document), 1); >+ document.body.appendChild(target); >+ var newDoc = document.implementation.createHTMLDocument('New document'); >+ newDoc.body.appendChild(root); >+ assert_equals(internals.numberOfIntersectionObservers(document), 0); >+ assert_equals(internals.numberOfIntersectionObservers(newDoc), 1); >+ document.body.appendChild(root); >+ assert_equals(internals.numberOfIntersectionObservers(document), 1); >+ assert_equals(internals.numberOfIntersectionObservers(newDoc), 0); >+ },"Document's active intersection observers get updated"); >+</script> >+</body> >+</html>
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 188670
:
347287
|
347289
|
347389
|
347441
| 347451