|
16 | 16 | <script>
|
17 | 17 | test(function () {
|
18 | 18 | const event = new InterestEvent("test");
|
19 |
| - assert_equals(event.action, ""); |
20 |
| - assert_readonly(event, "action", "readonly attribute value"); |
21 |
| - }, "action is a readonly defaulting to ''"); |
| 19 | + assert_equals(event.source, null); |
| 20 | + assert_readonly(event, "source", "readonly attribute value"); |
| 21 | + }, "source is readonly defaulting to null"); |
22 | 22 |
|
23 | 23 | test(function () {
|
24 |
| - const event = new InterestEvent("test"); |
25 |
| - assert_equals(event.invoker, null); |
26 |
| - assert_readonly(event, "invoker", "readonly attribute value"); |
27 |
| - }, "invoker is readonly defaulting to null"); |
28 |
| - |
29 |
| - test(function () { |
30 |
| - const event = new InterestEvent("test", { action: "sAmPle" }); |
31 |
| - assert_equals(event.action, "sAmPle"); |
32 |
| - }, "action reflects initialized attribute"); |
33 |
| - |
34 |
| - test(function () { |
35 |
| - const event = new InterestEvent("test", { action: undefined }); |
36 |
| - assert_equals(event.action, ""); |
37 |
| - }, "action set to undefined"); |
38 |
| - |
39 |
| - test(function () { |
40 |
| - const event = new InterestEvent("test", { action: null }); |
41 |
| - assert_equals(event.action, "null"); |
42 |
| - }, "action set to null"); |
43 |
| - |
44 |
| - test(function () { |
45 |
| - const event = new InterestEvent("test", { action: false }); |
46 |
| - assert_equals(event.action, "false"); |
47 |
| - }, "action set to false"); |
48 |
| - |
49 |
| - test(function () { |
50 |
| - const event = new InterestEvent("test", { action: "" }); |
51 |
| - assert_equals(event.action, ""); |
52 |
| - }, "action explicitly set to empty string"); |
53 |
| - |
54 |
| - test(function () { |
55 |
| - const event = new InterestEvent("test", { action: true }); |
56 |
| - assert_equals(event.action, "true"); |
57 |
| - }, "action set to true"); |
58 |
| - |
59 |
| - test(function () { |
60 |
| - const event = new InterestEvent("test", { action: 0.5 }); |
61 |
| - assert_equals(event.action, "0.5"); |
62 |
| - }, "action set to a number"); |
63 |
| - |
64 |
| - test(function () { |
65 |
| - const event = new InterestEvent("test", { action: [] }); |
66 |
| - assert_equals(event.action, ""); |
67 |
| - }, "action set to []"); |
68 |
| - |
69 |
| - test(function () { |
70 |
| - const event = new InterestEvent("test", { action: [1, 2, 3] }); |
71 |
| - assert_equals(event.action, "1,2,3"); |
72 |
| - }, "action set to [1, 2, 3]"); |
73 |
| - |
74 |
| - test(function () { |
75 |
| - const event = new InterestEvent("test", { action: { sample: 0.5 } }); |
76 |
| - assert_equals(event.action, "[object Object]"); |
77 |
| - }, "action set to an object"); |
78 |
| - |
79 |
| - test(function () { |
80 |
| - const event = new InterestEvent("test", { |
81 |
| - action: { |
82 |
| - toString() { |
83 |
| - return "sample"; |
84 |
| - }, |
85 |
| - }, |
86 |
| - }); |
87 |
| - assert_equals(event.action, "sample"); |
88 |
| - }, "action set to an object with a toString function"); |
89 |
| - |
90 |
| - test(function () { |
91 |
| - const eventInit = { action: "sample", invoker: document.body }; |
| 24 | + const eventInit = { source: document.body }; |
92 | 25 | const event = new InterestEvent("test", eventInit);
|
93 |
| - assert_equals(event.action, "sample"); |
94 |
| - assert_equals(event.invoker, document.body); |
95 |
| - }, "InterestEventInit properties set value"); |
| 26 | + assert_equals(event.source, document.body); |
| 27 | + }, "InterestEventInit properties set value (manual event)"); |
96 | 28 |
|
97 | 29 | test(function () {
|
98 | 30 | const eventInit = {
|
99 |
| - action: "open", |
100 |
| - invoker: document.getElementById("div"), |
| 31 | + source: document.getElementById("div"), |
101 | 32 | };
|
102 | 33 | const event = new InterestEvent("beforetoggle", eventInit);
|
103 |
| - assert_equals(event.action, "open"); |
104 |
| - assert_equals(event.invoker, document.getElementById("div")); |
105 |
| - }, "InterestEventInit properties set value 2"); |
| 34 | + assert_equals(event.source, document.getElementById("div")); |
| 35 | + }, "InterestEventInit properties set value (beforetoggle event)"); |
106 | 36 |
|
107 | 37 | test(function () {
|
108 | 38 | const eventInit = {
|
109 |
| - action: "closed", |
110 |
| - invoker: document.getElementById("button"), |
| 39 | + source: document.getElementById("button"), |
111 | 40 | };
|
112 | 41 | const event = new InterestEvent("toggle", eventInit);
|
113 |
| - assert_equals(event.action, "closed"); |
114 |
| - assert_equals(event.invoker, document.getElementById("button")); |
115 |
| - }, "InterestEventInit properties set value 3"); |
| 42 | + assert_equals(event.source, document.getElementById("button")); |
| 43 | + }, "InterestEventInit properties set value (toggle event)"); |
116 | 44 |
|
117 | 45 | test(function () {
|
118 |
| - const event = new InterestEvent("test", { invoker: undefined }); |
119 |
| - assert_equals(event.invoker, null); |
120 |
| - }, "invoker set to undefined"); |
| 46 | + const event = new InterestEvent("test", { source: undefined }); |
| 47 | + assert_equals(event.source, null); |
| 48 | + }, "source set to undefined"); |
121 | 49 |
|
122 | 50 | test(function () {
|
123 |
| - const event = new InterestEvent("test", { invoker: null }); |
124 |
| - assert_equals(event.invoker, null); |
125 |
| - }, "invoker set to null"); |
| 51 | + const event = new InterestEvent("test", { source: null }); |
| 52 | + assert_equals(event.source, null); |
| 53 | + }, "source set to null"); |
126 | 54 |
|
127 | 55 | test(function () {
|
128 | 56 | assert_throws_js(
|
129 | 57 | TypeError,
|
130 | 58 | function () {
|
131 |
| - new InterestEvent("test", { invoker: false }); |
| 59 | + new InterestEvent("test", { source: false }); |
132 | 60 | },
|
133 |
| - "invoker is not an object", |
| 61 | + "source is not an object", |
134 | 62 | );
|
135 |
| - }, "invoker set to false"); |
| 63 | + }, "source set to false"); |
136 | 64 |
|
137 | 65 | test(function () {
|
138 | 66 | assert_throws_js(
|
139 | 67 | TypeError,
|
140 | 68 | function () {
|
141 |
| - const event = new InterestEvent("test", { invoker: true }); |
| 69 | + const event = new InterestEvent("test", { source: true }); |
142 | 70 | },
|
143 |
| - "invoker is not an object", |
| 71 | + "source is not an object", |
144 | 72 | );
|
145 |
| - }, "invoker set to true"); |
| 73 | + }, "source set to true"); |
146 | 74 |
|
147 | 75 | test(function () {
|
148 | 76 | assert_throws_js(
|
149 | 77 | TypeError,
|
150 | 78 | function () {
|
151 |
| - const event = new InterestEvent("test", { invoker: {} }); |
| 79 | + const event = new InterestEvent("test", { source: {} }); |
152 | 80 | },
|
153 |
| - "invoker is not an object", |
| 81 | + "source is not an object", |
154 | 82 | );
|
155 |
| - }, "invoker set to {}"); |
| 83 | + }, "source set to {}"); |
156 | 84 |
|
157 | 85 | test(function () {
|
158 | 86 | assert_throws_js(
|
159 | 87 | TypeError,
|
160 | 88 | function () {
|
161 |
| - const eventInit = { action: "closed", invoker: new XMLHttpRequest() }; |
| 89 | + const eventInit = { source: new XMLHttpRequest() }; |
162 | 90 | const event = new InterestEvent("toggle", eventInit);
|
163 | 91 | },
|
164 |
| - "invoker is not an Element", |
| 92 | + "source is not an Element", |
165 | 93 | );
|
166 |
| - }, "invoker set to non-Element EventTarget"); |
| 94 | + }, "source set to non-Element EventTarget"); |
167 | 95 | </script>
|
0 commit comments