WebKit Bugzilla
Attachment 346912 Details for
Bug 188475
: [IntersectionObserver] Validate threshold values
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-188475-20180810140554.patch (text/plain), 5.31 KB, created by
Ali Juma
on 2018-08-10 11:05:55 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Ali Juma
Created:
2018-08-10 11:05:55 PDT
Size:
5.31 KB
patch
obsolete
>Subversion Revision: 234761 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index 03f2c3eb684786b0fadaafaf2abf677b7f344639..1b701ec4d6106b2b751d3d34ef144d82620ff609 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,20 @@ >+2018-08-10 Ali Juma <ajuma@chromium.org> >+ >+ [IntersectionObserver] Validate threshold values >+ https://bugs.webkit.org/show_bug.cgi?id=188475 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Throw an exception if any of an IntersectionObserver's thresholds are outside >+ the range [0, 1]. >+ >+ Tested by imported/w3c/web-platform-tests/intersection-observer/observer-exceptions.html >+ >+ * page/IntersectionObserver.cpp: >+ (WebCore::IntersectionObserver::create): >+ (WebCore::IntersectionObserver::IntersectionObserver): >+ * page/IntersectionObserver.h: >+ > 2018-08-10 Ali Juma <ajuma@chromium.org> > > [IntersectionObserver] Implement rootMargin parsing >diff --git a/Source/WebCore/page/IntersectionObserver.cpp b/Source/WebCore/page/IntersectionObserver.cpp >index fa7a2cb422d213bcda46afea0396da933850d11a..3845813ed202ff57f05bb6968b4e3ca6681c05bd 100644 >--- a/Source/WebCore/page/IntersectionObserver.cpp >+++ b/Source/WebCore/page/IntersectionObserver.cpp >@@ -87,18 +87,26 @@ ExceptionOr<Ref<IntersectionObserver>> IntersectionObserver::create(Ref<Intersec > if (rootMarginOrException.hasException()) > return rootMarginOrException.releaseException(); > >- return adoptRef(*new IntersectionObserver(WTFMove(callback), WTFMove(init), rootMarginOrException.releaseReturnValue())); >+ Vector<double> thresholds; >+ if (WTF::holds_alternative<double>(init.threshold)) >+ thresholds.append(WTF::get<double>(init.threshold)); >+ else >+ thresholds = WTF::get<Vector<double>>(WTFMove(init.threshold)); >+ >+ for (auto threshold : thresholds) { >+ if (threshold < 0 || threshold > 1) >+ return Exception { RangeError, "Failed to construct 'IntersectionObserver': all thresholds must lie in the range [0.0, 1.0]." }; >+ } >+ >+ return adoptRef(*new IntersectionObserver(WTFMove(callback), WTFMove(init.root), rootMarginOrException.releaseReturnValue(), WTFMove(thresholds))); > } > >-IntersectionObserver::IntersectionObserver(Ref<IntersectionObserverCallback>&& callback, Init&& init, LengthBox&& parsedRootMargin) >- : m_root(init.root) >+IntersectionObserver::IntersectionObserver(Ref<IntersectionObserverCallback>&& callback, RefPtr<Element>&& root, LengthBox&& parsedRootMargin, Vector<double>&& thresholds) >+ : m_root(WTFMove(root)) > , m_rootMargin(WTFMove(parsedRootMargin)) >+ , m_thresholds(WTFMove(thresholds)) > , m_callback(WTFMove(callback)) > { >- if (WTF::holds_alternative<double>(init.threshold)) >- m_thresholds.append(WTF::get<double>(init.threshold)); >- else >- m_thresholds = WTF::get<Vector<double>>(WTFMove(init.threshold)); > } > > String IntersectionObserver::rootMargin() const >diff --git a/Source/WebCore/page/IntersectionObserver.h b/Source/WebCore/page/IntersectionObserver.h >index 1d3f01201aad081e7c52d81786db36b82f65ccaa..b04cfb21162855b21b670450130895349a2e14e2 100644 >--- a/Source/WebCore/page/IntersectionObserver.h >+++ b/Source/WebCore/page/IntersectionObserver.h >@@ -59,7 +59,7 @@ public: > Vector<RefPtr<IntersectionObserverEntry>> takeRecords(); > > private: >- IntersectionObserver(Ref<IntersectionObserverCallback>&&, Init&&, LengthBox&& parsedRootMargin); >+ IntersectionObserver(Ref<IntersectionObserverCallback>&&, RefPtr<Element>&& root, LengthBox&& parsedRootMargin, Vector<double>&& thresholds); > > RefPtr<Element> m_root; > LengthBox m_rootMargin; >diff --git a/LayoutTests/imported/w3c/ChangeLog b/LayoutTests/imported/w3c/ChangeLog >index cb3cafc97e2609826c46fd97b1263f5687eb7ae7..6be1baba618c60582169dfbbddf78e6d9351323d 100644 >--- a/LayoutTests/imported/w3c/ChangeLog >+++ b/LayoutTests/imported/w3c/ChangeLog >@@ -1,3 +1,14 @@ >+2018-08-10 Ali Juma <ajuma@chromium.org> >+ >+ [IntersectionObserver] Validate threshold values >+ https://bugs.webkit.org/show_bug.cgi?id=188475 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Update expectation for newly passing test case. >+ >+ * web-platform-tests/intersection-observer/observer-exceptions-expected.txt: >+ > 2018-08-10 Ali Juma <ajuma@chromium.org> > > [IntersectionObserver] Implement rootMargin parsing >diff --git a/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/observer-exceptions-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/observer-exceptions-expected.txt >index 69880cc7471a6be0299eee54e3dda1b2ef2d784b..f500b02d3f3af07df2545c9af3c9400673fa2722 100644 >--- a/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/observer-exceptions-expected.txt >+++ b/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/observer-exceptions-expected.txt >@@ -1,7 +1,5 @@ > >-FAIL IntersectionObserver constructor with { threshold: [1.1] } assert_throws: function "function () { >- new IntersectionObserver(e => {}, {threshold: [1.1]}) >- }" did not throw >+PASS IntersectionObserver constructor with { threshold: [1.1] } > PASS IntersectionObserver constructor with { threshold: ["foo"] } > PASS IntersectionObserver constructor witth { rootMargin: "1" } > PASS IntersectionObserver constructor with { rootMargin: "2em" }
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 188475
:
346912
|
347034