Changeset 234818 in webkit
- Timestamp:
- Aug 13, 2018 3:02:45 PM (6 years ago)
- Location:
- trunk
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r234804 r234818 1 2018-08-13 Ali Juma <ajuma@chromium.org> 2 3 [IntersectionObserver] Validate threshold values 4 https://bugs.webkit.org/show_bug.cgi?id=188475 5 6 Reviewed by Simon Fraser. 7 8 Add test coverage for interesting floating point threshold values. 9 10 * intersection-observer/intersection-observer-interface-expected.txt: 11 * intersection-observer/intersection-observer-interface.html: 12 1 13 2018-08-13 Ryan Haddad <ryanhaddad@apple.com> 2 14 -
trunk/LayoutTests/imported/w3c/ChangeLog
r234799 r234818 1 2018-08-13 Ali Juma <ajuma@chromium.org> 2 3 [IntersectionObserver] Validate threshold values 4 https://bugs.webkit.org/show_bug.cgi?id=188475 5 6 Reviewed by Simon Fraser. 7 8 Update expectation for newly passing test case. 9 10 * web-platform-tests/intersection-observer/observer-exceptions-expected.txt: 11 * web-platform-tests/intersection-observer/observer-exceptions.html: Fix typo already fixed upstream. 12 1 13 2018-08-13 Yusuke Suzuki <yusukesuzuki@slowstart.org> 2 14 -
trunk/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/observer-exceptions-expected.txt
r234761 r234818 1 1 2 FAIL IntersectionObserver constructor with { threshold: [1.1] } assert_throws: function "function () { 3 new IntersectionObserver(e => {}, {threshold: [1.1]}) 4 }" did not throw 2 PASS IntersectionObserver constructor with { threshold: [1.1] } 5 3 PASS IntersectionObserver constructor with { threshold: ["foo"] } 6 PASS IntersectionObserver constructor wit th { rootMargin: "1" }4 PASS IntersectionObserver constructor with { rootMargin: "1" } 7 5 PASS IntersectionObserver constructor with { rootMargin: "2em" } 8 6 PASS IntersectionObserver constructor with { rootMargin: "auto" } -
trunk/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/observer-exceptions.html
r234723 r234818 20 20 new IntersectionObserver(e => {}, {rootMargin: "1"}) 21 21 }) 22 }, 'IntersectionObserver constructor wit th { rootMargin: "1" }');22 }, 'IntersectionObserver constructor with { rootMargin: "1" }'); 23 23 24 24 test(function () { -
trunk/LayoutTests/intersection-observer/intersection-observer-interface-expected.txt
r234761 r234818 11 11 PASS ExplicitThreshold 12 12 PASS ExplicitThresholds 13 PASS SmallPositiveThreshold 14 PASS SmallNegativeThreshold 15 PASS LargePositiveThreshold 16 PASS LargeNegativeThreshold 17 PASS PositiveInfinityThreshold 18 PASS NegativeInfinityThreshold 19 PASS NaNThreshold 13 20 -
trunk/LayoutTests/intersection-observer/intersection-observer-interface.html
r234761 r234818 54 54 assert_array_equals(observer.thresholds, [0, 0.33333678, 0.5, 0.76645]); 55 55 },'ExplicitThresholds'); 56 test(function() { 57 var observer = new IntersectionObserver(function() {}, { threshold: Number.MIN_VALUE }); 58 assert_array_equals(observer.thresholds, [Number.MIN_VALUE]); 59 },'SmallPositiveThreshold'); 60 test(function() { 61 assert_throws(RangeError(), function() { 62 new IntersectionObserver(function() {}, { threshold: -Number.MIN_VALUE }); 63 }) 64 },'SmallNegativeThreshold'); 65 test(function() { 66 assert_throws(RangeError(), function() { 67 new IntersectionObserver(function() {}, { threshold: Number.MAX_VALUE }); 68 }) 69 },'LargePositiveThreshold'); 70 test(function() { 71 assert_throws(RangeError(), function() { 72 new IntersectionObserver(function() {}, { threshold: -Number.MAX_VALUE }); 73 }) 74 },'LargeNegativeThreshold'); 75 test(function() { 76 assert_throws(TypeError(), function() { 77 new IntersectionObserver(function() {}, { threshold: Number.POSITIVE_INFINITY }); 78 }) 79 },'PositiveInfinityThreshold'); 80 test(function() { 81 assert_throws(TypeError(), function() { 82 new IntersectionObserver(function() {}, { threshold: Number.NEGATIVE_INFINITY }); 83 }) 84 },'NegativeInfinityThreshold'); 85 test(function() { 86 assert_throws(TypeError(), function() { 87 new IntersectionObserver(function() {}, { threshold: Number.NaN }); 88 }) 89 },'NaNThreshold'); 56 90 </script> 57 91 </body> -
trunk/Source/WebCore/ChangeLog
r234817 r234818 1 2018-08-13 Ali Juma <ajuma@chromium.org> 2 3 [IntersectionObserver] Validate threshold values 4 https://bugs.webkit.org/show_bug.cgi?id=188475 5 6 Reviewed by Simon Fraser. 7 8 Throw an exception if any of an IntersectionObserver's thresholds are outside 9 the range [0, 1]. 10 11 Tested by: imported/w3c/web-platform-tests/intersection-observer/observer-exceptions.html 12 intersection-observer/intersection-observer-interface.html 13 14 * page/IntersectionObserver.cpp: 15 (WebCore::IntersectionObserver::create): 16 (WebCore::IntersectionObserver::IntersectionObserver): 17 * page/IntersectionObserver.h: 18 1 19 2018-08-13 Alex Christensen <achristensen@webkit.org> 2 20 -
trunk/Source/WebCore/page/IntersectionObserver.cpp
r234761 r234818 88 88 return rootMarginOrException.releaseException(); 89 89 90 return adoptRef(*new IntersectionObserver(WTFMove(callback), WTFMove(init), rootMarginOrException.releaseReturnValue())); 90 Vector<double> thresholds; 91 WTF::switchOn(init.threshold, [&thresholds] (double initThreshold) { 92 thresholds.reserveInitialCapacity(1); 93 thresholds.uncheckedAppend(initThreshold); 94 }, [&thresholds] (Vector<double>& initThresholds) { 95 thresholds = WTFMove(initThresholds); 96 }); 97 98 for (auto threshold : thresholds) { 99 if (!(threshold >= 0 && threshold <= 1)) 100 return Exception { RangeError, "Failed to construct 'IntersectionObserver': all thresholds must lie in the range [0.0, 1.0]." }; 101 } 102 103 return adoptRef(*new IntersectionObserver(WTFMove(callback), WTFMove(init.root), rootMarginOrException.releaseReturnValue(), WTFMove(thresholds))); 91 104 } 92 105 93 IntersectionObserver::IntersectionObserver(Ref<IntersectionObserverCallback>&& callback, Init&& init, LengthBox&& parsedRootMargin)94 : m_root( init.root)106 IntersectionObserver::IntersectionObserver(Ref<IntersectionObserverCallback>&& callback, RefPtr<Element>&& root, LengthBox&& parsedRootMargin, Vector<double>&& thresholds) 107 : m_root(WTFMove(root)) 95 108 , m_rootMargin(WTFMove(parsedRootMargin)) 109 , m_thresholds(WTFMove(thresholds)) 96 110 , m_callback(WTFMove(callback)) 97 111 { 98 if (WTF::holds_alternative<double>(init.threshold))99 m_thresholds.append(WTF::get<double>(init.threshold));100 else101 m_thresholds = WTF::get<Vector<double>>(WTFMove(init.threshold));102 112 } 103 113 -
trunk/Source/WebCore/page/IntersectionObserver.h
r234761 r234818 60 60 61 61 private: 62 IntersectionObserver(Ref<IntersectionObserverCallback>&&, Init&&, LengthBox&& parsedRootMargin);62 IntersectionObserver(Ref<IntersectionObserverCallback>&&, RefPtr<Element>&& root, LengthBox&& parsedRootMargin, Vector<double>&& thresholds); 63 63 64 64 RefPtr<Element> m_root;
Note: See TracChangeset
for help on using the changeset viewer.