Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / dom / HTMLDialogElement / dialog-show-modal.html
blob9f4c83f3381bbb2063723224ce945cfff5038ba7
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <script src="../../../resources/js-test.js"></script>
5 </head>
6 <body>
7 <dialog id="mydialog">It's my dialog.</dialog>
8 <script>
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");
15 dialog.showModal();
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."');
22 dialog.close();
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");
32 dialog.showModal();
33 debug('Although the document is not attached to any pages, showModal() should execute as normal.');
34 shouldBeTrue("dialog.open");
35 </script>
36 </body>
37 </html>