| <!DOCTYPE html> |
| <html> |
| <head> |
| <script src="../../js/resources/js-test-pre.js"></script> |
| <script> |
| if (window.internals) |
| internals.settings.setDialogElementEnabled(true); |
| </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();', "'Error: INVALID_STATE_ERR: DOM Exception 11'"); |
| |
| 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();', "'Error: INVALID_STATE_ERR: DOM Exception 11'"); |
| |
| 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> |
| <script src="../../js/resources/js-test-post.js"></script> |
| </body> |
| </html> |