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

Side by Side 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 unified diff | Download patch
OLDNEW
(Empty)
1 <!DOCTYPE html>
2 <title>Event.initEvent</title>
3 <link rel="author" title="Ms2ger" href="mailto:Ms2ger@gmail.com">
4 <script src="../../../../resources/testharness.js"></script>
5 <script src="../../../../resources/testharnessreport.js"></script>
6 <div id="log"></div>
7 <script>
8 var booleans = [true, false];
9 booleans.forEach(function(bubbles) {
10 booleans.forEach(function(cancelable) {
11 test(function() {
12 var e = document.createEvent("Event")
13 e.initEvent("type", bubbles, cancelable)
14
15 // Step 3.
16 // Can't test the stop propagation flag and stop immediate propagation fla g.
17 assert_equals(e.defaultPrevented, false, "defaultPrevented")
18 // Step 4.
19 assert_equals(e.isTrusted, false, "isTrusted")
20 // Step 5.
21 assert_equals(e.target, null, "target")
22 // Step 6.
23 assert_equals(e.type, "type", "type")
24 // Step 7.
25 assert_equals(e.bubbles, bubbles, "bubbles")
26 // Step 8.
27 assert_equals(e.cancelable, cancelable, "cancelable")
28 }, "Properties of initEvent(type, " + bubbles + ", " + cancelable + ")")
29 })
30 })
31
32 test(function() {
33 var e = document.createEvent("Event")
34 e.initEvent("type 1", true, false)
35 assert_equals(e.type, "type 1", "type (first init)")
36 assert_equals(e.bubbles, true, "bubbles (first init)")
37 assert_equals(e.cancelable, false, "cancelable (first init)")
38
39 e.initEvent("type 2", false, true)
40 assert_equals(e.type, "type 2", "type (second init)")
41 assert_equals(e.bubbles, false, "bubbles (second init)")
42 assert_equals(e.cancelable, true, "cancelable (second init)")
43 }, "Calling initEvent multiple times (getting type).")
44
45 test(function() {
46 // https://bugzilla.mozilla.org/show_bug.cgi?id=998809
47 var e = document.createEvent("Event")
48 e.initEvent("type 1", true, false)
49 assert_equals(e.bubbles, true, "bubbles (first init)")
50 assert_equals(e.cancelable, false, "cancelable (first init)")
51
52 e.initEvent("type 2", false, true)
53 assert_equals(e.type, "type 2", "type (second init)")
54 assert_equals(e.bubbles, false, "bubbles (second init)")
55 assert_equals(e.cancelable, true, "cancelable (second init)")
56 }, "Calling initEvent multiple times (not getting type).")
57
58 // Step 2.
59 async_test(function() {
60 // https://www.w3.org/Bugs/Public/show_bug.cgi?id=17715
61
62 var e = document.createEvent("Event")
63 e.initEvent("type", false, false)
64 assert_equals(e.type, "type", "type (first init)")
65 assert_equals(e.bubbles, false, "bubbles (first init)")
66 assert_equals(e.cancelable, false, "cancelable (first init)")
67
68 var target = document.createElement("div")
69 target.addEventListener("type", this.step_func(function() {
70 e.initEvent("fail", true, true)
71 assert_equals(e.type, "type", "type (second init)")
72 assert_equals(e.bubbles, false, "bubbles (second init)")
73 assert_equals(e.cancelable, false, "cancelable (second init)")
74 }), false)
75
76 assert_equals(target.dispatchEvent(e), true, "dispatchEvent must return true")
77
78 this.done()
79 }, "Calling initEvent must not have an effect during dispatching.")
80
81 async_test(function() {
82 var e = document.createEvent("Event")
83 e.initEvent("type", false, false)
84 e.stopPropagation()
85
86 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
95 var target = document.createElement("div")
96 target.addEventListener("type", this.step_func(function() {
97 called = true
98 }), false)
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
106 async_test(function() {
107 var e = document.createEvent("Event")
108 e.initEvent("type", false, false)
109
110 var target = document.createElement("div")
111 target.addEventListener("type", this.step_func(function() {
112 e.initEvent("type2", true, true);
113 assert_equals(e.type, "type", "initEvent type setter should short-circuit");
114 assert_false(e.bubbles, "initEvent bubbles setter should short-circuit");
115 assert_false(e.cancelable, "initEvent cancelable setter should short-circuit ");
116 }), false)
117 assert_equals(target.dispatchEvent(e), true, "dispatchEvent must return true")
118
119 this.done()
120 }, "Calling initEvent during propagation.")
121 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698