4 <script src="../../js/resources/js-test-pre.js"></script>
7 <dialog id="test-dialog"></dialog>
9 description("Tests that dialog.returnValue is settable and returns the last value set.");
11 dialog = document.getElementById('test-dialog');
12 shouldBe("dialog.returnValue", "''");
14 dialog.returnValue = 'Setting value directly';
15 shouldBe("dialog.returnValue", "'Setting value directly'");
17 dialog.returnValue = null;
18 shouldBe("dialog.returnValue", "'null'");
20 dialog.returnValue = '';
21 shouldBe("dialog.returnValue", "''");
23 dialog.returnValue = 7;
24 shouldBe("dialog.returnValue", "'7'");
27 dialog.close('Return value set from close()');
28 shouldBe("dialog.returnValue", "'Return value set from close()'");
32 shouldBe("dialog.returnValue", "''");
36 shouldBe("dialog.returnValue", "'null'");
38 dialog.returnValue = 'Should not change because no argument to close()';
41 shouldBe("dialog.returnValue", "'Should not change because no argument to close()'");
43 dialog.returnValue = 'Should not change because close() is invalid';
44 shouldThrow("dialog.close('blah')", "'InvalidStateError: An attempt was made to use an object that is not, or is no longer, usable.'");
45 shouldBe("dialog.returnValue", "'Should not change because close() is invalid'");