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

Unified Diff: third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/events/Event-initEvent.html

Issue 1529523002: Import dom/ from web-platform-tests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: tweak W3CImportExpectations Created 5 years 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/imported/web-platform-tests/dom/events/Event-initEvent.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/events/Event-initEvent.html b/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/events/Event-initEvent.html
new file mode 100644
index 0000000000000000000000000000000000000000..20b2f87080ca8e888779d7fadceeaf746b23b242
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/events/Event-initEvent.html
@@ -0,0 +1,121 @@
+<!DOCTYPE html>
+<title>Event.initEvent</title>
+<link rel="author" title="Ms2ger" href="mailto:Ms2ger@gmail.com">
+<script src="../../../../resources/testharness.js"></script>
+<script src="../../../../resources/testharnessreport.js"></script>
+<div id="log"></div>
+<script>
+var booleans = [true, false];
+booleans.forEach(function(bubbles) {
+ booleans.forEach(function(cancelable) {
+ test(function() {
+ var e = document.createEvent("Event")
+ e.initEvent("type", bubbles, cancelable)
+
+ // Step 3.
+ // Can't test the stop propagation flag and stop immediate propagation flag.
+ assert_equals(e.defaultPrevented, false, "defaultPrevented")
+ // Step 4.
+ assert_equals(e.isTrusted, false, "isTrusted")
+ // Step 5.
+ assert_equals(e.target, null, "target")
+ // Step 6.
+ assert_equals(e.type, "type", "type")
+ // Step 7.
+ assert_equals(e.bubbles, bubbles, "bubbles")
+ // Step 8.
+ assert_equals(e.cancelable, cancelable, "cancelable")
+ }, "Properties of initEvent(type, " + bubbles + ", " + cancelable + ")")
+ })
+})
+
+test(function() {
+ var e = document.createEvent("Event")
+ e.initEvent("type 1", true, false)
+ assert_equals(e.type, "type 1", "type (first init)")
+ assert_equals(e.bubbles, true, "bubbles (first init)")
+ assert_equals(e.cancelable, false, "cancelable (first init)")
+
+ e.initEvent("type 2", false, true)
+ assert_equals(e.type, "type 2", "type (second init)")
+ assert_equals(e.bubbles, false, "bubbles (second init)")
+ assert_equals(e.cancelable, true, "cancelable (second init)")
+}, "Calling initEvent multiple times (getting type).")
+
+test(function() {
+ // https://bugzilla.mozilla.org/show_bug.cgi?id=998809
+ var e = document.createEvent("Event")
+ e.initEvent("type 1", true, false)
+ assert_equals(e.bubbles, true, "bubbles (first init)")
+ assert_equals(e.cancelable, false, "cancelable (first init)")
+
+ e.initEvent("type 2", false, true)
+ assert_equals(e.type, "type 2", "type (second init)")
+ assert_equals(e.bubbles, false, "bubbles (second init)")
+ assert_equals(e.cancelable, true, "cancelable (second init)")
+}, "Calling initEvent multiple times (not getting type).")
+
+// Step 2.
+async_test(function() {
+ // https://www.w3.org/Bugs/Public/show_bug.cgi?id=17715
+
+ var e = document.createEvent("Event")
+ e.initEvent("type", false, false)
+ assert_equals(e.type, "type", "type (first init)")
+ assert_equals(e.bubbles, false, "bubbles (first init)")
+ assert_equals(e.cancelable, false, "cancelable (first init)")
+
+ var target = document.createElement("div")
+ target.addEventListener("type", this.step_func(function() {
+ e.initEvent("fail", true, true)
+ assert_equals(e.type, "type", "type (second init)")
+ assert_equals(e.bubbles, false, "bubbles (second init)")
+ assert_equals(e.cancelable, false, "cancelable (second init)")
+ }), false)
+
+ assert_equals(target.dispatchEvent(e), true, "dispatchEvent must return true")
+
+ this.done()
+}, "Calling initEvent must not have an effect during dispatching.")
+
+async_test(function() {
+ var e = document.createEvent("Event")
+ e.initEvent("type", false, false)
+ e.stopPropagation()
+
+ var target = document.createElement("div")
+ target.addEventListener("type", this.step_func(function() {
+ assert_unreached("")
+ }), false)
+ assert_equals(target.dispatchEvent(e), true, "dispatchEvent must return true")
+ assert_equals(target.dispatchEvent(e), true, "dispatchEvent must return true")
+
+ e.initEvent("type", false, false)
+ var called = false
+ var target = document.createElement("div")
+ target.addEventListener("type", this.step_func(function() {
+ called = true
+ }), false)
+ assert_false(called)
+ assert_equals(target.dispatchEvent(e), true, "dispatchEvent must return true")
+ assert_true(called)
+
+ this.done()
+}, "Calling initEvent must unset the stop propagation flag.")
+
+async_test(function() {
+ var e = document.createEvent("Event")
+ e.initEvent("type", false, false)
+
+ var target = document.createElement("div")
+ target.addEventListener("type", this.step_func(function() {
+ e.initEvent("type2", true, true);
+ assert_equals(e.type, "type", "initEvent type setter should short-circuit");
+ assert_false(e.bubbles, "initEvent bubbles setter should short-circuit");
+ assert_false(e.cancelable, "initEvent cancelable setter should short-circuit");
+ }), false)
+ assert_equals(target.dispatchEvent(e), true, "dispatchEvent must return true")
+
+ this.done()
+}, "Calling initEvent during propagation.")
+</script>

Powered by Google App Engine
This is Rietveld 408576698