blob: 0da8c81f6868d1f97a74c3a30a29269403a81b77 [file] [log] [blame]
<!DOCTYPE html>
<html>
<head>
<script src="../../resources/js-test.js"></script>
</head>
<body>
<dialog id="mydialog">It's my dialog.</dialog>
<script>
description("Tests that showModal() performs the steps specified in the HTML spec. bug 97425");
dialog = document.getElementById('mydialog');
computedStyle = window.getComputedStyle(dialog, null);
shouldBeEqualToString("computedStyle.getPropertyValue('display')", "none");
dialog.showModal();
shouldBeEqualToString("computedStyle.getPropertyValue('display')", "block");
// The quoted texts output below are from <http://www.whatwg.org/specs/web-apps/current-work/multipage/commands.html#dom-dialog-showmodal>.
debug('"If dialog already has an open attribute, then throw an InvalidStateError exception."');
shouldThrow('dialog.showModal();', '"InvalidStateError: Failed to execute \'showModal\' on \'HTMLDialogElement\': The element already has an \'open\' attribute, and therefore cannot be opened modally."');
dialog.close();
shouldBeEqualToString("computedStyle.getPropertyValue('display')", "none");
dialog.parentNode.removeChild(dialog);
debug('"If dialog is not in a Document, then throw an InvalidStateError exception."');
shouldThrow('dialog.showModal();', '"InvalidStateError: Failed to execute \'showModal\' on \'HTMLDialogElement\': The element is not in a Document."');
doc = document.implementation.createHTMLDocument();
doc.body.appendChild(dialog);
shouldBeFalse("dialog.open");
dialog.showModal();
debug('Although the document is not attached to any pages, showModal() should execute as normal.');
shouldBeTrue("dialog.open");
</script>
</body>
</html>