Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(209)

Unified Diff: third_party/WebKit/LayoutTests/intersection-observer/observer-exceptions.html

Issue 1740923004: IntersectionObserver: make exceptions match spec (Closed) Base URL: https://chromium.googlesource.com/chromium/src@master
Patch Set: ASSERT observer constructor succeeded if no exception was thrown Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/LayoutTests/intersection-observer/observer-exceptions.html
diff --git a/third_party/WebKit/LayoutTests/intersection-observer/observer-exceptions.html b/third_party/WebKit/LayoutTests/intersection-observer/observer-exceptions.html
new file mode 100644
index 0000000000000000000000000000000000000000..1da557dd409739693a25bf3a4dd0e801d8d2203f
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/intersection-observer/observer-exceptions.html
@@ -0,0 +1,53 @@
+<!DOCTYPE html>
+<div id="root"></div>
+<script src="../resources/js-test.js"></script>
+<script src="../resources/gc.js"></script>
+<script>
+ description("Test for observer exceptions.");
+ let rootDiv = document.getElementById("root");
+ var exc;
+
+ try {
+ new IntersectionObserver(e => {}, {threshold: [1.1]});
+ testFailed("IntersectionObserver constructor did not throw due to invalid threshold.");
+ } catch(e) {
+ exc = e;
+ shouldBeType("exc", "RangeError");
+ }
+
+ try {
+ new IntersectionObserver(e => {}, {rootMargin: "1"});
+ testFailed("IntersectionObserver constructor did not throw due to invalid rootMargin.");
+ } catch(e) {
+ exc = e;
+ shouldBeType("exc", "DOMException");
+ shouldBe("exc.code", "DOMException.SYNTAX_ERR");
+ }
+
+ try {
+ new IntersectionObserver(e => {}, {rootMargin: "2em"});
+ testFailed("IntersectionObserver constructor did not throw due to invalid rootMargin.");
+ } catch(e) {
+ exc = e;
+ shouldBeType("exc", "DOMException");
+ shouldBe("exc.code", "DOMException.SYNTAX_ERR");
+ }
+
+ try {
+ new IntersectionObserver(e => {}, {rootMargin: "auto"});
+ testFailed("IntersectionObserver constructor did not throw due to invalid rootMargin.");
+ } catch(e) {
+ exc = e;
+ shouldBeType("exc", "DOMException");
+ shouldBe("exc.code", "DOMException.SYNTAX_ERR");
+ }
+
+ let observer = new IntersectionObserver(c => {}, {});
+ try {
+ observer.observe("foo");
+ testFailed("IntersectionObserver.observe with a bad target argument did not throw.");
+ } catch(e) {
+ exc = e;
+ shouldBeType("exc", "TypeError");
+ }
+</script>

Powered by Google App Engine
This is Rietveld 408576698