4 <script src=
"../../../resources/js-test.js"></script>
7 <dialog id=
"mydialog">It's my dialog.
</dialog>
9 description("Tests that showModal() performs the steps specified in the HTML spec. bug 97425");
11 dialog
= document
.getElementById('mydialog');
12 computedStyle
= window
.getComputedStyle(dialog
, null);
13 shouldBeEqualToString("computedStyle.getPropertyValue('display')", "none");
16 shouldBeEqualToString("computedStyle.getPropertyValue('display')", "block");
18 // The quoted texts output below are from <http://www.whatwg.org/specs/web-apps/current-work/multipage/commands.html#dom-dialog-showmodal>.
19 debug('"If dialog already has an open attribute, then throw an InvalidStateError exception."');
20 shouldThrow('dialog.showModal();', '"InvalidStateError: Failed to execute \'showModal\' on \'HTMLDialogElement\': The element already has an \'open\' attribute, and therefore cannot be opened modally."');
23 shouldBeEqualToString("computedStyle.getPropertyValue('display')", "none");
25 dialog
.parentNode
.removeChild(dialog
);
26 debug('"If dialog is not in a Document, then throw an InvalidStateError exception."');
27 shouldThrow('dialog.showModal();', '"InvalidStateError: Failed to execute \'showModal\' on \'HTMLDialogElement\': The element is not in a Document."');
29 doc
= document
.implementation
.createHTMLDocument();
30 doc
.body
.appendChild(dialog
);
31 shouldBeFalse("dialog.open");
33 debug('Although the document is not attached to any pages, showModal() should execute as normal.');
34 shouldBeTrue("dialog.open");