Title: [129330] trunk
Revision
129330
Author
[email protected]
Date
2012-09-24 00:41:04 -0700 (Mon, 24 Sep 2012)

Log Message

Skeleton implementation of dialog.showModal()
https://bugs.webkit.org/show_bug.cgi?id=97425

Patch by Matt Falkenhagen <[email protected]> on 2012-09-24
Reviewed by Kent Tamura.

Source/WebCore:

This adds a basic implementation of showModal(), so it later can be
used to test the top layer, once it is implemented. The main features
of showModal(), modality and the top layer, are not yet implemented.

Test: fast/dom/HTMLDialogElement/dialog-show-modal.html

* html/HTMLDialogElement.cpp:
(WebCore::HTMLDialogElement::showModal): The same as show(), but throws an error in the cases specified in the spec.
(WebCore):
* html/HTMLDialogElement.h:
(HTMLDialogElement):
* html/HTMLDialogElement.idl:

LayoutTests:

Add a test that showModal() opens the dialog or throws an error in the cases specified in the spec.

* fast/dom/HTMLDialogElement/dialog-show-modal-expected.txt: Added.
* fast/dom/HTMLDialogElement/dialog-show-modal.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (129329 => 129330)


--- trunk/LayoutTests/ChangeLog	2012-09-24 07:24:28 UTC (rev 129329)
+++ trunk/LayoutTests/ChangeLog	2012-09-24 07:41:04 UTC (rev 129330)
@@ -1,3 +1,15 @@
+2012-09-24  Matt Falkenhagen  <[email protected]>
+
+        Skeleton implementation of dialog.showModal()
+        https://bugs.webkit.org/show_bug.cgi?id=97425
+
+        Reviewed by Kent Tamura.
+
+        Add a test that showModal() opens the dialog or throws an error in the cases specified in the spec.
+
+        * fast/dom/HTMLDialogElement/dialog-show-modal-expected.txt: Added.
+        * fast/dom/HTMLDialogElement/dialog-show-modal.html: Added.
+
 2012-09-23  Gavin Barraclough  <[email protected]>
 
         Sorting a non-array creates propreties (spec-violation)

Added: trunk/LayoutTests/fast/dom/HTMLDialogElement/dialog-show-modal-expected.txt (0 => 129330)


--- trunk/LayoutTests/fast/dom/HTMLDialogElement/dialog-show-modal-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/dom/HTMLDialogElement/dialog-show-modal-expected.txt	2012-09-24 07:41:04 UTC (rev 129330)
@@ -0,0 +1,19 @@
+Tests that showModal() performs the steps specified in the HTML spec. bug 97425
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS computedStyle.getPropertyValue('display') is "none"
+PASS computedStyle.getPropertyValue('display') is "block"
+"If dialog already has an open attribute, then throw an InvalidStateError exception."
+PASS dialog.showModal(); threw exception Error: INVALID_STATE_ERR: DOM Exception 11.
+PASS computedStyle.getPropertyValue('display') is "none"
+"If dialog is not in a Document, then throw an InvalidStateError exception."
+PASS dialog.showModal(); threw exception Error: INVALID_STATE_ERR: DOM Exception 11.
+PASS dialog.open is false
+Although the document is not attached to any pages, showModal() should execute as normal.
+PASS dialog.open is true
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/fast/dom/HTMLDialogElement/dialog-show-modal.html (0 => 129330)


--- trunk/LayoutTests/fast/dom/HTMLDialogElement/dialog-show-modal.html	                        (rev 0)
+++ trunk/LayoutTests/fast/dom/HTMLDialogElement/dialog-show-modal.html	2012-09-24 07:41:04 UTC (rev 129330)
@@ -0,0 +1,42 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+<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=""
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (129329 => 129330)


--- trunk/Source/WebCore/ChangeLog	2012-09-24 07:24:28 UTC (rev 129329)
+++ trunk/Source/WebCore/ChangeLog	2012-09-24 07:41:04 UTC (rev 129330)
@@ -1,3 +1,23 @@
+2012-09-24  Matt Falkenhagen  <[email protected]>
+
+        Skeleton implementation of dialog.showModal()
+        https://bugs.webkit.org/show_bug.cgi?id=97425
+
+        Reviewed by Kent Tamura.
+
+        This adds a basic implementation of showModal(), so it later can be
+        used to test the top layer, once it is implemented. The main features
+        of showModal(), modality and the top layer, are not yet implemented.
+
+        Test: fast/dom/HTMLDialogElement/dialog-show-modal.html
+
+        * html/HTMLDialogElement.cpp:
+        (WebCore::HTMLDialogElement::showModal): The same as show(), but throws an error in the cases specified in the spec.
+        (WebCore):
+        * html/HTMLDialogElement.h:
+        (HTMLDialogElement):
+        * html/HTMLDialogElement.idl:
+
 2012-09-24  Ryuan Choi  <[email protected]>
 
         [EFL] Regression after r129328

Modified: trunk/Source/WebCore/html/HTMLDialogElement.cpp (129329 => 129330)


--- trunk/Source/WebCore/html/HTMLDialogElement.cpp	2012-09-24 07:24:28 UTC (rev 129329)
+++ trunk/Source/WebCore/html/HTMLDialogElement.cpp	2012-09-24 07:41:04 UTC (rev 129330)
@@ -62,6 +62,15 @@
     setBooleanAttribute(openAttr, true);
 }
 
+void HTMLDialogElement::showModal(ExceptionCode& ec)
+{
+    if (fastHasAttribute(openAttr) || !inDocument()) {
+        ec = INVALID_STATE_ERR;
+        return;
+    }
+    setBooleanAttribute(openAttr, true);
+}
+
 bool HTMLDialogElement::isPresentationAttribute(const QualifiedName& name) const
 {
     // FIXME: Workaround for <https://bugs.webkit.org/show_bug.cgi?id=91058>: modifying an attribute for which there is an attribute selector

Modified: trunk/Source/WebCore/html/HTMLDialogElement.h (129329 => 129330)


--- trunk/Source/WebCore/html/HTMLDialogElement.h	2012-09-24 07:24:28 UTC (rev 129329)
+++ trunk/Source/WebCore/html/HTMLDialogElement.h	2012-09-24 07:41:04 UTC (rev 129330)
@@ -41,6 +41,7 @@
 
     void close(ExceptionCode&);
     void show();
+    void showModal(ExceptionCode&);
 
 private:
     HTMLDialogElement(const QualifiedName&, Document*);

Modified: trunk/Source/WebCore/html/HTMLDialogElement.idl (129329 => 129330)


--- trunk/Source/WebCore/html/HTMLDialogElement.idl	2012-09-24 07:24:28 UTC (rev 129329)
+++ trunk/Source/WebCore/html/HTMLDialogElement.idl	2012-09-24 07:41:04 UTC (rev 129330)
@@ -31,6 +31,7 @@
         attribute [Reflect] boolean open;
         void close() raises(DOMException);
         void show();
+        void showModal() raises(DOMException);
     };
 
 }
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to