Skip to content

Commit a7f93b0

Browse files
committed
Add more tests for returnValue behaviour
1 parent ea88ad8 commit a7f93b0

File tree

1 file changed

+126
-0
lines changed

1 file changed

+126
-0
lines changed

html/semantics/the-button-element/command-and-commandfor/on-dialog-behavior.html

Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,69 @@
138138
`invoking to close (with command ${setType} as ${command}) open dialog closes and sets returnValue`,
139139
);
140140

141+
promise_test(
142+
async function (t) {
143+
t.add_cleanup(resetState);
144+
invokee.show();
145+
assert_true(invokee.open, "invokee.open");
146+
assert_false(invokee.matches(":modal"), "invokee :modal");
147+
if (setType === "property") {
148+
containedinvoker.command = command;
149+
} else {
150+
containedinvoker.setAttribute("command", command);
151+
}
152+
invokee.returnValue = "test";
153+
containedinvoker.setAttribute("value", "foo");
154+
await clickOn(containedinvoker);
155+
assert_equals(invokee.returnValue, "foo");
156+
assert_false(invokee.open, "invokee.open");
157+
assert_false(invokee.matches(":modal"), "invokee :modal");
158+
},
159+
`invoking to close (with command ${setType} as ${command}) open dialog closes and overrides returnValue`,
160+
);
161+
162+
promise_test(
163+
async function (t) {
164+
t.add_cleanup(resetState);
165+
invokee.show();
166+
assert_true(invokee.open, "invokee.open");
167+
assert_false(invokee.matches(":modal"), "invokee :modal");
168+
if (setType === "property") {
169+
containedinvoker.command = command;
170+
} else {
171+
containedinvoker.setAttribute("command", command);
172+
}
173+
invokee.returnValue = "test";
174+
containedinvoker.setAttribute("value", "");
175+
await clickOn(containedinvoker);
176+
assert_equals(invokee.returnValue, "");
177+
assert_false(invokee.open, "invokee.open");
178+
assert_false(invokee.matches(":modal"), "invokee :modal");
179+
},
180+
`invoking to close (with command ${setType} as ${command}) open dialog closes and overrides returnValue when empty string`,
181+
);
182+
183+
promise_test(
184+
async function (t) {
185+
t.add_cleanup(resetState);
186+
invokee.show();
187+
assert_true(invokee.open, "invokee.open");
188+
assert_false(invokee.matches(":modal"), "invokee :modal");
189+
if (setType === "property") {
190+
containedinvoker.command = command;
191+
} else {
192+
containedinvoker.setAttribute("command", command);
193+
}
194+
invokee.returnValue = "test";
195+
containedinvoker.removeAttribute("value");
196+
await clickOn(containedinvoker);
197+
assert_equals(invokee.returnValue, "test");
198+
assert_false(invokee.open, "invokee.open");
199+
assert_false(invokee.matches(":modal"), "invokee :modal");
200+
},
201+
`invoking to close (with command ${setType} as ${command}) open dialog closes and doesn't override returnValue when missing value attribute`,
202+
);
203+
141204
promise_test(
142205
async function (t) {
143206
t.add_cleanup(resetState);
@@ -277,6 +340,69 @@
277340
`invoking to close (with command ${setType} as ${command}) open dialog closes and sets returnValue`,
278341
);
279342

343+
promise_test(
344+
async function (t) {
345+
t.add_cleanup(resetState);
346+
invokee.show();
347+
assert_true(invokee.open, "invokee.open");
348+
assert_false(invokee.matches(":modal"), "invokee :modal");
349+
if (setType === "property") {
350+
containedinvoker.command = command;
351+
} else {
352+
containedinvoker.setAttribute("command", command);
353+
}
354+
invokee.returnValue = "test";
355+
containedinvoker.setAttribute("value", "foo");
356+
await clickOn(containedinvoker);
357+
assert_equals(invokee.returnValue, "foo");
358+
assert_false(invokee.open, "invokee.open");
359+
assert_false(invokee.matches(":modal"), "invokee :modal");
360+
},
361+
`invoking to close (with command ${setType} as ${command}) open dialog closes and overrides returnValue`,
362+
);
363+
364+
promise_test(
365+
async function (t) {
366+
t.add_cleanup(resetState);
367+
invokee.show();
368+
assert_true(invokee.open, "invokee.open");
369+
assert_false(invokee.matches(":modal"), "invokee :modal");
370+
if (setType === "property") {
371+
containedinvoker.command = command;
372+
} else {
373+
containedinvoker.setAttribute("command", command);
374+
}
375+
invokee.returnValue = "test";
376+
containedinvoker.setAttribute("value", "");
377+
await clickOn(containedinvoker);
378+
assert_equals(invokee.returnValue, "");
379+
assert_false(invokee.open, "invokee.open");
380+
assert_false(invokee.matches(":modal"), "invokee :modal");
381+
},
382+
`invoking to close (with command ${setType} as ${command}) open dialog closes and overrides returnValue when empty string`,
383+
);
384+
385+
promise_test(
386+
async function (t) {
387+
t.add_cleanup(resetState);
388+
invokee.show();
389+
assert_true(invokee.open, "invokee.open");
390+
assert_false(invokee.matches(":modal"), "invokee :modal");
391+
if (setType === "property") {
392+
containedinvoker.command = command;
393+
} else {
394+
containedinvoker.setAttribute("command", command);
395+
}
396+
invokee.returnValue = "test";
397+
containedinvoker.removeAttribute("value");
398+
await clickOn(containedinvoker);
399+
assert_equals(invokee.returnValue, "test");
400+
assert_false(invokee.open, "invokee.open");
401+
assert_false(invokee.matches(":modal"), "invokee :modal");
402+
},
403+
`invoking to close (with command ${setType} as ${command}) open dialog closes and doesn't override returnValue when missing value attribute`,
404+
);
405+
280406
promise_test(
281407
async function (t) {
282408
t.add_cleanup(resetState);

0 commit comments

Comments
 (0)