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

Side by Side Diff: third_party/WebKit/LayoutTests/imported/wpt/dom/events/Event-initEvent.html

Issue 2273143002: Update web-platform-tests. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update baseline Created 4 years, 3 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 unified diff | Download patch
OLDNEW
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <title>Event.initEvent</title> 2 <title>Event.initEvent</title>
3 <link rel="author" title="Ms2ger" href="mailto:Ms2ger@gmail.com"> 3 <link rel="author" title="Ms2ger" href="mailto:Ms2ger@gmail.com">
4 <script src="/resources/testharness.js"></script> 4 <script src="/resources/testharness.js"></script>
5 <script src="/resources/testharnessreport.js"></script> 5 <script src="/resources/testharnessreport.js"></script>
6 <div id="log"></div> 6 <div id="log"></div>
7 <script> 7 <script>
8 var booleans = [true, false]; 8 var booleans = [true, false];
9 booleans.forEach(function(bubbles) { 9 booleans.forEach(function(bubbles) {
10 booleans.forEach(function(cancelable) { 10 booleans.forEach(function(cancelable) {
11 test(function() { 11 test(function() {
12 var e = document.createEvent("Event") 12 var e = document.createEvent("Event")
13 e.initEvent("type", bubbles, cancelable) 13 e.initEvent("type", bubbles, cancelable)
14 14
15 // Step 3. 15 // Step 3.
16 // Can't test the stop propagation flag and stop immediate propagation fla g. 16 // Stop (immediate) propagation flag is tested later
17 assert_equals(e.defaultPrevented, false, "defaultPrevented") 17 assert_equals(e.defaultPrevented, false, "defaultPrevented")
18 // Step 4. 18 // Step 4.
19 assert_equals(e.isTrusted, false, "isTrusted") 19 assert_equals(e.isTrusted, false, "isTrusted")
20 // Step 5. 20 // Step 5.
21 assert_equals(e.target, null, "target") 21 assert_equals(e.target, null, "target")
22 // Step 6. 22 // Step 6.
23 assert_equals(e.type, "type", "type") 23 assert_equals(e.type, "type", "type")
24 // Step 7. 24 // Step 7.
25 assert_equals(e.bubbles, bubbles, "bubbles") 25 assert_equals(e.bubbles, bubbles, "bubbles")
26 // Step 8. 26 // Step 8.
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 assert_equals(e.type, "type", "type (second init)") 71 assert_equals(e.type, "type", "type (second init)")
72 assert_equals(e.bubbles, false, "bubbles (second init)") 72 assert_equals(e.bubbles, false, "bubbles (second init)")
73 assert_equals(e.cancelable, false, "cancelable (second init)") 73 assert_equals(e.cancelable, false, "cancelable (second init)")
74 }), false) 74 }), false)
75 75
76 assert_equals(target.dispatchEvent(e), true, "dispatchEvent must return true") 76 assert_equals(target.dispatchEvent(e), true, "dispatchEvent must return true")
77 77
78 this.done() 78 this.done()
79 }, "Calling initEvent must not have an effect during dispatching.") 79 }, "Calling initEvent must not have an effect during dispatching.")
80 80
81 async_test(function() { 81 test(function() {
82 var e = document.createEvent("Event") 82 var e = document.createEvent("Event")
83 e.stopPropagation()
83 e.initEvent("type", false, false) 84 e.initEvent("type", false, false)
84 e.stopPropagation() 85 var target = document.createElement("div")
86 var called = false
87 target.addEventListener("type", function() { called = true }, false)
88 assert_true(target.dispatchEvent(e), "dispatchEvent must return true")
89 assert_true(called, "Listener must be called")
90 }, "Calling initEvent must unset the stop propagation flag.")
85 91
92 test(function() {
93 var e = document.createEvent("Event")
94 e.stopImmediatePropagation()
95 e.initEvent("type", false, false)
86 var target = document.createElement("div") 96 var target = document.createElement("div")
87 target.addEventListener("type", this.step_func(function() {
88 assert_unreached("")
89 }), false)
90 assert_equals(target.dispatchEvent(e), true, "dispatchEvent must return true")
91 assert_equals(target.dispatchEvent(e), true, "dispatchEvent must return true")
92
93 e.initEvent("type", false, false)
94 var called = false 97 var called = false
95 var target = document.createElement("div") 98 target.addEventListener("type", function() { called = true }, false)
96 target.addEventListener("type", this.step_func(function() { 99 assert_true(target.dispatchEvent(e), "dispatchEvent must return true")
97 called = true 100 assert_true(called, "Listener must be called")
98 }), false) 101 }, "Calling initEvent must unset the stop immediate propagation flag.")
99 assert_false(called)
100 assert_equals(target.dispatchEvent(e), true, "dispatchEvent must return true")
101 assert_true(called)
102
103 this.done()
104 }, "Calling initEvent must unset the stop propagation flag.")
105 102
106 async_test(function() { 103 async_test(function() {
107 var e = document.createEvent("Event") 104 var e = document.createEvent("Event")
108 e.initEvent("type", false, false) 105 e.initEvent("type", false, false)
109 106
110 var target = document.createElement("div") 107 var target = document.createElement("div")
111 target.addEventListener("type", this.step_func(function() { 108 target.addEventListener("type", this.step_func(function() {
112 e.initEvent("type2", true, true); 109 e.initEvent("type2", true, true);
113 assert_equals(e.type, "type", "initEvent type setter should short-circuit"); 110 assert_equals(e.type, "type", "initEvent type setter should short-circuit");
114 assert_false(e.bubbles, "initEvent bubbles setter should short-circuit"); 111 assert_false(e.bubbles, "initEvent bubbles setter should short-circuit");
115 assert_false(e.cancelable, "initEvent cancelable setter should short-circuit "); 112 assert_false(e.cancelable, "initEvent cancelable setter should short-circuit ");
116 }), false) 113 }), false)
117 assert_equals(target.dispatchEvent(e), true, "dispatchEvent must return true") 114 assert_equals(target.dispatchEvent(e), true, "dispatchEvent must return true")
118 115
119 this.done() 116 this.done()
120 }, "Calling initEvent during propagation.") 117 }, "Calling initEvent during propagation.")
121 </script> 118 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698