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

Unified Diff: third_party/WebKit/LayoutTests/fast/dom/Window/dispatchEvent.html

Issue 2667393002: Stop using script-tests in fast/dom/. (Closed)
Patch Set: . Created 3 years, 11 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/fast/dom/Window/dispatchEvent.html
diff --git a/third_party/WebKit/LayoutTests/fast/dom/Window/dispatchEvent.html b/third_party/WebKit/LayoutTests/fast/dom/Window/dispatchEvent.html
index e4ca6f6552fa111512e3449bff1ee637281bb112..48777599efa0fd6b59d137f7579788e323f5cde9 100644
--- a/third_party/WebKit/LayoutTests/fast/dom/Window/dispatchEvent.html
+++ b/third_party/WebKit/LayoutTests/fast/dom/Window/dispatchEvent.html
@@ -4,6 +4,47 @@
<script src="../../../resources/js-test.js"></script>
</head>
<body>
-<script src="script-tests/dispatchEvent.js"></script>
+<script>
+description("Test window.dispatchEvent().");
+
+// Test that non-events throw
+var event = {};
+shouldThrow("window.dispatchEvent(event)");
+
+// Test that non-initialized events throw
+event = document.createEvent("Event");
+shouldThrow("window.dispatchEvent(event)");
+
+// Test basic dispatch
+var myEventDispatched = false;
+var target;
+var currentTarget;
+window.addEventListener("myEvent", function(evt) {
+ myEventDispatched = true;
+ target = evt.target;
+ currentTarget = evt.currentTarget;
+}, false);
+event = document.createEvent("Event");
+event.initEvent("myEvent", false, false);
+window.dispatchEvent(event);
+shouldBeTrue("myEventDispatched");
+shouldBe("target", "window");
+shouldBe("currentTarget", "window");
+
+// Test that both useCapture and non-useCapture listeners are dispatched to
+var useCaptureDispatched = false;
+window.addEventListener("myEvent", function(evt) {
+ useCaptureDispatched = true;
+}, true);
+var nonUseCaptureDispatched = false;
+window.addEventListener("myEvent", function(evt) {
+ nonUseCaptureDispatched = true;
+}, false);
+event = document.createEvent("Event");
+event.initEvent("myEvent", false, false);
+window.dispatchEvent(event);
+shouldBeTrue("useCaptureDispatched");
+shouldBeTrue("nonUseCaptureDispatched");
+</script>
</body>
</html>

Powered by Google App Engine
This is Rietveld 408576698