blob: 9c73740d07d1caf7762c86d108f21f287e19481b [file] [log] [blame]
<!DOCTYPE html>
<html>
<head>
<script src="../../resources/js-test.js"></script>
</head>
<body>
<dialog id="test-dialog"></dialog>
<script>
description("Tests that dialog.returnValue is settable and returns the last value set.");
dialog = document.getElementById('test-dialog');
shouldBe("dialog.returnValue", "''");
dialog.returnValue = 'Setting value directly';
shouldBe("dialog.returnValue", "'Setting value directly'");
dialog.returnValue = null;
shouldBe("dialog.returnValue", "'null'");
dialog.returnValue = '';
shouldBe("dialog.returnValue", "''");
dialog.returnValue = 7;
shouldBe("dialog.returnValue", "'7'");
dialog.show();
dialog.close('Return value set from close()');
shouldBe("dialog.returnValue", "'Return value set from close()'");
dialog.show();
dialog.close('');
shouldBe("dialog.returnValue", "''");
dialog.show();
dialog.close(null);
shouldBe("dialog.returnValue", "'null'");
dialog.returnValue = 'Should not change because no argument to close()';
dialog.show();
dialog.close();
shouldBe("dialog.returnValue", "'Should not change because no argument to close()'");
dialog.returnValue = 'Should not change because of undefined argument to close()';
dialog.show();
dialog.close(undefined);
shouldBe("dialog.returnValue", "'Should not change because of undefined argument to close()'");
dialog.returnValue = 'Should not change because of no-op close()';
shouldNotThrow("dialog.close('blah')");
shouldBe("dialog.returnValue", "'Should not change because of no-op close()'");
</script>
</body>
</html>