changeset 10413:0e36fa13a95a

8049617: move awt automated tests from AWT_Modality to OpenJDK repository - part 3 Reviewed-by: pchelko
author avstepan
date Mon, 21 Jul 2014 13:17:43 +0400
parents db1d1894985c
children 69cfcd8883c5
files test/java/awt/Modal/ModalBlockingTests/BlockingDDAppModalTest.java test/java/awt/Modal/ModalBlockingTests/BlockingDDDocModalTest.java test/java/awt/Modal/ModalBlockingTests/BlockingDDModelessTest.java test/java/awt/Modal/ModalBlockingTests/BlockingDDNonModalTest.java test/java/awt/Modal/ModalBlockingTests/BlockingDDSetModalTest.java test/java/awt/Modal/ModalBlockingTests/BlockingDDTest.java test/java/awt/Modal/ModalBlockingTests/BlockingDDToolkitModalTest.java test/java/awt/Modal/ModalBlockingTests/BlockingDFAppModalTest.java test/java/awt/Modal/ModalBlockingTests/BlockingDFSetModalTest.java test/java/awt/Modal/ModalBlockingTests/BlockingDFTest.java test/java/awt/Modal/ModalBlockingTests/BlockingDFToolkitModalTest.java test/java/awt/Modal/ModalBlockingTests/BlockingDFWModeless1Test.java test/java/awt/Modal/ModalBlockingTests/BlockingDFWModeless2Test.java test/java/awt/Modal/ModalBlockingTests/BlockingDFWNonModal1Test.java test/java/awt/Modal/ModalBlockingTests/BlockingDFWNonModal2Test.java test/java/awt/Modal/ModalBlockingTests/BlockingDFWTest.java test/java/awt/Modal/ModalBlockingTests/BlockingDocModalTest.java test/java/awt/Modal/ModalBlockingTests/BlockingFDAppModalTest.java test/java/awt/Modal/ModalBlockingTests/BlockingFDDocModalTest.java test/java/awt/Modal/ModalBlockingTests/BlockingFDModelessTest.java test/java/awt/Modal/ModalBlockingTests/BlockingFDNonModalTest.java test/java/awt/Modal/ModalBlockingTests/BlockingFDSetModalTest.java test/java/awt/Modal/ModalBlockingTests/BlockingFDTest.java test/java/awt/Modal/ModalBlockingTests/BlockingFDToolkitModalTest.java test/java/awt/Modal/ModalBlockingTests/BlockingFDWDocModal1Test.java test/java/awt/Modal/ModalBlockingTests/BlockingFDWDocModal2Test.java test/java/awt/Modal/ModalBlockingTests/BlockingFDWDocModal3Test.java test/java/awt/Modal/ModalBlockingTests/BlockingFDWDocModal4Test.java test/java/awt/Modal/ModalBlockingTests/BlockingFDWModeless1Test.java test/java/awt/Modal/ModalBlockingTests/BlockingFDWModeless2Test.java test/java/awt/Modal/ModalBlockingTests/BlockingFDWModeless3Test.java test/java/awt/Modal/ModalBlockingTests/BlockingFDWModeless4Test.java test/java/awt/Modal/ModalBlockingTests/BlockingFDWNonModal1Test.java test/java/awt/Modal/ModalBlockingTests/BlockingFDWNonModal2Test.java test/java/awt/Modal/ModalBlockingTests/BlockingFDWNonModal3Test.java test/java/awt/Modal/ModalBlockingTests/BlockingFDWNonModal4Test.java test/java/awt/Modal/ModalBlockingTests/BlockingFDWTest.java test/java/awt/Modal/ModalBlockingTests/BlockingWindowsAppModal1Test.java test/java/awt/Modal/ModalBlockingTests/BlockingWindowsAppModal2Test.java test/java/awt/Modal/ModalBlockingTests/BlockingWindowsAppModal3Test.java test/java/awt/Modal/ModalBlockingTests/BlockingWindowsAppModal4Test.java test/java/awt/Modal/ModalBlockingTests/BlockingWindowsAppModal5Test.java test/java/awt/Modal/ModalBlockingTests/BlockingWindowsAppModal6Test.java test/java/awt/Modal/ModalBlockingTests/BlockingWindowsDocModal1Test.java test/java/awt/Modal/ModalBlockingTests/BlockingWindowsDocModal2Test.java test/java/awt/Modal/ModalBlockingTests/BlockingWindowsDocModalTest.java test/java/awt/Modal/ModalBlockingTests/BlockingWindowsSetModal1Test.java test/java/awt/Modal/ModalBlockingTests/BlockingWindowsSetModal2Test.java test/java/awt/Modal/ModalBlockingTests/BlockingWindowsSetModal3Test.java test/java/awt/Modal/ModalBlockingTests/BlockingWindowsSetModal4Test.java test/java/awt/Modal/ModalBlockingTests/BlockingWindowsSetModal5Test.java test/java/awt/Modal/ModalBlockingTests/BlockingWindowsSetModal6Test.java test/java/awt/Modal/ModalBlockingTests/BlockingWindowsTest.java test/java/awt/Modal/ModalBlockingTests/BlockingWindowsToolkitModal1Test.java test/java/awt/Modal/ModalBlockingTests/BlockingWindowsToolkitModal2Test.java test/java/awt/Modal/ModalBlockingTests/BlockingWindowsToolkitModal3Test.java test/java/awt/Modal/ModalBlockingTests/BlockingWindowsToolkitModal4Test.java test/java/awt/Modal/ModalBlockingTests/BlockingWindowsToolkitModal5Test.java test/java/awt/Modal/ModalBlockingTests/BlockingWindowsToolkitModal6Test.java test/java/awt/Modal/ModalBlockingTests/UnblockedDialogAppModalTest.java test/java/awt/Modal/ModalBlockingTests/UnblockedDialogDocModalTest.java test/java/awt/Modal/ModalBlockingTests/UnblockedDialogModelessTest.java test/java/awt/Modal/ModalBlockingTests/UnblockedDialogNonModalTest.java test/java/awt/Modal/ModalBlockingTests/UnblockedDialogSetModalTest.java test/java/awt/Modal/ModalBlockingTests/UnblockedDialogTest.java test/java/awt/Modal/ModalBlockingTests/UnblockedDialogToolkitModalTest.java test/java/awt/Modal/helpers/TestFrame.java
diffstat 67 files changed, 4164 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/awt/Modal/ModalBlockingTests/BlockingDDAppModalTest.java	Mon Jul 21 13:17:43 2014 +0400
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.awt.Dialog;
+
+/*
+ * @test
+ * @bug 8049617
+ * @summary Check whether an application modal Dialog created with a Dialog
+ *          constructor receives focus, whether its components receive focus
+ *          and respond to key events. Check also the correctness
+ *          of blocking behavior for the parent Dialog.
+ *
+ * @library ../helpers ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @build Flag
+ * @build TestDialog
+ * @run main BlockingDDAppModalTest
+ */
+
+public class BlockingDDAppModalTest {
+
+    public static void main(String[] args) throws Exception {
+        (new BlockingDDTest(Dialog.ModalityType.APPLICATION_MODAL)).doTest();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/awt/Modal/ModalBlockingTests/BlockingDDDocModalTest.java	Mon Jul 21 13:17:43 2014 +0400
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.awt.Dialog;
+
+/*
+ * @test
+ * @bug 8049617
+ * @summary Check whether a document modal Dialog created with a Dialog
+ *          constructor receives focus, whether its components receive focus
+ *          and respond to key events. Check also the correctness
+ *          of blocking behavior for the parent Dialog.
+ *
+ * @library ../helpers ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @build Flag
+ * @build TestDialog
+ * @run main BlockingDDDocModalTest
+ */
+
+public class BlockingDDDocModalTest {
+
+    public static void main(String[] args) throws Exception {
+        (new BlockingDDTest(Dialog.ModalityType.DOCUMENT_MODAL)).doTest();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/awt/Modal/ModalBlockingTests/BlockingDDModelessTest.java	Mon Jul 21 13:17:43 2014 +0400
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.awt.Dialog;
+
+/*
+ * @test
+ * @bug 8049617
+ * @summary Check whether a modeless Dialog created with a Dialog
+ *          constructor receives focus, whether its components receive focus
+ *          and respond to key events. Check also the correctness
+ *          of blocking behavior for the parent Dialog.
+ *
+ * @library ../helpers ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @build Flag
+ * @build TestDialog
+ * @run main BlockingDDModelessTest
+ */
+
+public class BlockingDDModelessTest {
+
+    public static void main(String[] args) throws Exception {
+        (new BlockingDDTest(Dialog.ModalityType.MODELESS)).doTest();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/awt/Modal/ModalBlockingTests/BlockingDDNonModalTest.java	Mon Jul 21 13:17:43 2014 +0400
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8049617
+ * @summary Check whether a non-modal Dialog created with a Dialog
+ *          constructor receives focus, whether its components receive focus
+ *          and respond to key events. Check also the correctness
+ *          of blocking behavior for the parent Dialog.
+ *
+ * @library ../helpers ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @build Flag
+ * @build TestDialog
+ * @run main BlockingDDNonModalTest
+ */
+
+public class BlockingDDNonModalTest {
+
+    public static void main(String[] args) throws Exception {
+        (new BlockingDDTest(null)).doTest();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/awt/Modal/ModalBlockingTests/BlockingDDSetModalTest.java	Mon Jul 21 13:17:43 2014 +0400
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+
+/*
+ * @test
+ * @bug 8049617
+ * @summary Check whether a modal Dialog created with a Dialog
+ *          constructor receives focus, whether its components receive focus
+ *          and respond to key events. Check also the correctness
+ *          of blocking behavior for the parent Dialog.
+ *
+ * @library ../helpers ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @build Flag
+ * @build TestDialog
+ * @run main BlockingDDSetModalTest
+ */
+
+public class BlockingDDSetModalTest {
+
+    public static void main(String[] args) throws Exception {
+        (new BlockingDDTest()).doTest();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/awt/Modal/ModalBlockingTests/BlockingDDTest.java	Mon Jul 21 13:17:43 2014 +0400
@@ -0,0 +1,124 @@
+/*
+ * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.awt.*;
+import static jdk.testlibrary.Asserts.*;
+
+// DD: Dialog -> Dialog
+
+public class BlockingDDTest {
+
+    private TestDialog parent, dialog;
+
+    private static final int delay = 1000;
+    private final ExtendedRobot robot;
+
+    private final Dialog.ModalityType modalityType;
+    private final boolean setModal;
+
+    private BlockingDDTest(Dialog.ModalityType modType, boolean modal) throws Exception {
+
+        modalityType = modType;
+        setModal = modal;
+        robot = new ExtendedRobot();
+        createGUI();
+    }
+
+    public BlockingDDTest(Dialog.ModalityType modType) throws Exception {
+        this(modType, false);
+    }
+
+    public BlockingDDTest() throws Exception {
+        this(null, true);
+    }
+
+
+    private void showParent() {
+
+        parent = new TestDialog((Frame) null);
+        parent.setTitle("Parent");
+        parent.setLocation(50, 50);
+        parent.setVisible(true);
+    }
+
+    private void showChild() {
+
+        dialog = new TestDialog(parent);
+        if (setModal) {
+            dialog.setModal(true);
+        } else if (modalityType != null) {
+            dialog.setModalityType(modalityType);
+        }
+
+        dialog.setLocation(250, 50);
+        dialog.setVisible(true);
+    }
+
+
+    private void createGUI() throws Exception {
+
+        EventQueue.invokeAndWait(this::showParent);
+        robot.waitForIdle(delay);
+        EventQueue.invokeLater(this::showChild);
+        robot.waitForIdle(delay);
+    }
+
+    public void doTest() throws Exception {
+
+        try {
+            dialog.activated.waitForFlagTriggered();
+            assertTrue(dialog.activated.flag(), "Dialog did not trigger " +
+                "Window Activated event when it became visible");
+
+            dialog.closeGained.waitForFlagTriggered();
+            assertTrue(dialog.closeGained.flag(), "the 1st Dialog button " +
+                "did not gain focus when it became visible");
+
+            assertTrue(dialog.closeButton.hasFocus(), "the 1st Dialog button " +
+                "gained the focus but lost it afterwards");
+
+            dialog.checkUnblockedDialog(robot, "Modal Dialog shouldn't be blocked.");
+
+            if ((modalityType == Dialog.ModalityType.APPLICATION_MODAL) ||
+                (modalityType == Dialog.ModalityType.DOCUMENT_MODAL) ||
+                (modalityType == Dialog.ModalityType.TOOLKIT_MODAL) ||
+                dialog.isModal())
+            {
+                parent.checkBlockedDialog(robot,
+                    "Dialog is the parent of a visible " + modalityType + " Dialog.");
+            } else {
+                parent.checkUnblockedDialog(robot,
+                    "Dialog is the parent of a visible " + modalityType + " Dialog.");
+            }
+
+            robot.waitForIdle(delay);
+        } finally {
+            EventQueue.invokeAndWait(this::closeAll);
+        }
+    }
+
+    private void closeAll() {
+        if (parent != null) { parent.dispose(); }
+        if (dialog != null) { dialog.dispose(); }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/awt/Modal/ModalBlockingTests/BlockingDDToolkitModalTest.java	Mon Jul 21 13:17:43 2014 +0400
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.awt.Dialog;
+
+/*
+ * @test
+ * @bug 8049617
+ * @summary Check whether a toolkit modal Dialog created with a Dialog
+ *          constructor receives focus, whether its components receive focus
+ *          and respond to key events. Check also the correctness
+ *          of blocking behavior for the parent Dialog.
+ *
+ * @library ../helpers ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @build Flag
+ * @build TestDialog
+ * @run main BlockingDDToolkitModalTest
+ */
+
+public class BlockingDDToolkitModalTest {
+
+    public static void main(String[] args) throws Exception {
+        (new BlockingDDTest(Dialog.ModalityType.TOOLKIT_MODAL)).doTest();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/awt/Modal/ModalBlockingTests/BlockingDFAppModalTest.java	Mon Jul 21 13:17:43 2014 +0400
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.awt.Dialog;
+
+/*
+ * @test
+ * @bug 8049617
+ * @summary Check whether an application modal Dialog created with a Frame
+ *          constructor receives focus, whether its components receive focus
+ *          and respond to key events. Check also the correctness
+ *          of blocking behavior for the parent Frame.
+ *
+ * @library ../helpers ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @build Flag
+ * @build TestDialog
+ * @run main BlockingDFAppModalTest
+ */
+
+public class BlockingDFAppModalTest {
+
+    public static void main(String[] args) throws Exception {
+        (new BlockingDFTest(Dialog.ModalityType.APPLICATION_MODAL)).doTest();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/awt/Modal/ModalBlockingTests/BlockingDFSetModalTest.java	Mon Jul 21 13:17:43 2014 +0400
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.awt.Dialog;
+
+/*
+ * @test
+ * @bug 8049617
+ * @summary Check whether a modal Dialog created with a Frame
+ *          constructor receives focus, whether its components receive focus
+ *          and respond to key events. Check also the correctness
+ *          of blocking behavior for the parent Frame.
+ *
+ * @library ../helpers ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @build Flag
+ * @build TestDialog
+ * @run main BlockingDFSetModalTest
+ */
+
+public class BlockingDFSetModalTest {
+
+    public static void main(String[] args) throws Exception {
+        (new BlockingDFTest()).doTest();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/awt/Modal/ModalBlockingTests/BlockingDFTest.java	Mon Jul 21 13:17:43 2014 +0400
@@ -0,0 +1,97 @@
+/*
+ * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+
+import java.awt.*;
+import static jdk.testlibrary.Asserts.*;
+
+
+// DF: Dialog -> Frame
+
+public class BlockingDFTest {
+
+    private TestDialog dialog;
+    private TestFrame  frame;
+
+    private static final int delay = 500;
+    private final ExtendedRobot robot;
+
+    private BlockingDFTest(Dialog.ModalityType modalityType,
+                           boolean             setModal) throws Exception {
+
+        robot = new ExtendedRobot();
+        EventQueue.invokeLater(() -> { createGUI(modalityType, setModal); });
+    }
+
+    public BlockingDFTest(Dialog.ModalityType modalityType) throws Exception {
+        this(modalityType, false);
+    }
+
+    public BlockingDFTest() throws Exception { this(null, true); }
+
+
+    private void createGUI(Dialog.ModalityType modalityType,
+                           boolean             setModal) {
+
+        frame = new TestFrame();
+        frame.setLocation(50, 50);
+        frame.setVisible(true);
+
+        dialog = new TestDialog((Dialog) null);
+        dialog.setLocation(250, 50);
+        if (setModal) {
+            dialog.setModal(true);
+        } else if (modalityType != null) {
+            dialog.setModalityType(modalityType);
+        }
+
+        dialog.setVisible(true);
+    }
+
+    public void doTest() throws Exception {
+
+        try {
+
+            robot.waitForIdle(delay);
+            dialog.activated.waitForFlagTriggered();
+            assertTrue(dialog.activated.flag(), "Dialog did not trigger " +
+                "Window Activated event when it became visible");
+
+            dialog.closeGained.waitForFlagTriggered();
+            assertTrue(dialog.closeGained.flag(), "The 1st button did not " +
+                "gain focus when the dialog became visible");
+
+            dialog.checkUnblockedDialog(robot, "");
+            frame.checkBlockedFrame(robot, "");
+            robot.waitForIdle(delay);
+
+        } finally {
+            EventQueue.invokeAndWait(this::closeAll);
+        }
+    }
+
+    private void closeAll() {
+        if (frame  != null) {  frame.dispose(); }
+        if (dialog != null) { dialog.dispose(); }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/awt/Modal/ModalBlockingTests/BlockingDFToolkitModalTest.java	Mon Jul 21 13:17:43 2014 +0400
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.awt.Dialog;
+
+/*
+ * @test
+ * @bug 8049617
+ * @summary Check whether a toolkit modal Dialog created with a Frame
+ *          constructor receives focus, whether its components receives focus
+ *          and respond to key events. Check also the correctness
+ *          of blocking behavior for the parent Frame.
+ *
+ * @library ../helpers ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @build Flag
+ * @build TestDialog
+ * @run main BlockingDFToolkitModalTest
+ */
+
+public class BlockingDFToolkitModalTest {
+
+    public static void main(String[] args) throws Exception {
+        (new BlockingDFTest(Dialog.ModalityType.TOOLKIT_MODAL)).doTest();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/awt/Modal/ModalBlockingTests/BlockingDFWModeless1Test.java	Mon Jul 21 13:17:43 2014 +0400
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.awt.Dialog;
+
+/*
+ * @test
+ * @bug 8049617
+ * @summary Check whether a modeless Dialog created with a Frame
+ *          constructor receives focus, whether its components receive focus
+ *          and respond to key events. Check also if the other windows
+ *          receive mouse and key events.
+ *
+ * @library ../helpers ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @build Flag
+ * @build TestDialog
+ * @build TestFrame
+ * @build TestWindow
+ * @run main BlockingDFWModeless1Test
+ */
+
+public class BlockingDFWModeless1Test {
+
+    public static void main(String[] args) throws Exception {
+        (new BlockingDFWTest(
+            BlockingDFWTest.Parent.FRAME,
+            Dialog.ModalityType.MODELESS)).doTest();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/awt/Modal/ModalBlockingTests/BlockingDFWModeless2Test.java	Mon Jul 21 13:17:43 2014 +0400
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.awt.Dialog;
+
+/*
+ * @test
+ * @bug 8049617
+ * @summary Check whether a modeless Dialog created with a Dialog
+ *          constructor receives focus, whether its components receive focus
+ *          and respond to key events. Check also if the other windows
+ *          receive mouse and key events.
+ *
+ * @library ../helpers ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @build Flag
+ * @build TestDialog
+ * @build TestFrame
+ * @build TestWindow
+ * @run main BlockingDFWModeless2Test
+ */
+
+public class BlockingDFWModeless2Test {
+
+    public static void main(String[] args) throws Exception {
+        (new BlockingDFWTest(
+            BlockingDFWTest.Parent.DIALOG,
+            Dialog.ModalityType.MODELESS)).doTest();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/awt/Modal/ModalBlockingTests/BlockingDFWNonModal1Test.java	Mon Jul 21 13:17:43 2014 +0400
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+
+/*
+ * @test
+ * @bug 8049617
+ * @summary Check whether a non-modal Dialog created with a Frame
+ *          constructor receives focus, whether its components receive focus
+ *          and respond to key events. Check also if the other windows
+ *          receive mouse and key events.
+ *
+ * @library ../helpers ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @build Flag
+ * @build TestDialog
+ * @build TestFrame
+ * @build TestWindow
+ * @run main BlockingDFWNonModal1Test
+ */
+
+public class BlockingDFWNonModal1Test {
+
+    public static void main(String[] args) throws Exception {
+        (new BlockingDFWTest(
+            BlockingDFWTest.Parent.FRAME, null)).doTest();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/awt/Modal/ModalBlockingTests/BlockingDFWNonModal2Test.java	Mon Jul 21 13:17:43 2014 +0400
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+
+/*
+ * @test
+ * @bug 8049617
+ * @summary Check whether a non-modal Dialog created with a Dialog
+ *          constructor receives focus, whether its components receive focus
+ *          and respond to key events. Check also if the other windows
+ *          receive mouse and key events.
+ *
+ * @library ../helpers ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @build Flag
+ * @build TestDialog
+ * @build TestFrame
+ * @build TestWindow
+ * @run main BlockingDFWNonModal2Test
+ */
+
+public class BlockingDFWNonModal2Test {
+
+    public static void main(String[] args) throws Exception {
+        (new BlockingDFWTest(
+            BlockingDFWTest.Parent.DIALOG, null)).doTest();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/awt/Modal/ModalBlockingTests/BlockingDFWTest.java	Mon Jul 21 13:17:43 2014 +0400
@@ -0,0 +1,162 @@
+/*
+ * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.awt.*;
+import java.awt.event.KeyEvent;
+import static jdk.testlibrary.Asserts.*;
+
+// DFW: Dialog -> Frame -> Window
+
+public class BlockingDFWTest {
+
+    private static final int delay = 500;
+    private final ExtendedRobot robot;
+
+    public enum Parent {DIALOG, FRAME};
+
+    private ParentDialog parentDialog;
+    private ParentFrame  parentFrame;
+    private TestDialog dialog;
+    private TestFrame frame;
+    private TestWindow window;
+
+
+    public BlockingDFWTest(Parent parentWin, Dialog.ModalityType modalityType) throws Exception {
+
+        robot = new ExtendedRobot();
+        EventQueue.invokeLater(() -> { createGUI(parentWin, modalityType); });
+    }
+
+    private void createGUI(Parent parentWin, Dialog.ModalityType modalityType) {
+
+        Window p = null;
+        switch (parentWin) {
+            case DIALOG:
+                parentDialog = new ParentDialog((Dialog) null);
+                dialog = new CustomDialog(parentDialog);
+                p = parentDialog;
+                break;
+            case FRAME:
+                parentFrame = new ParentFrame();
+                dialog = new CustomDialog(parentFrame);
+                p = parentFrame;
+                break;
+        }
+
+        assertFalse(p == null, "invalid parent");
+        p.setLocation(50, 50);
+        dialog.setLocation(250, 50);
+        if (modalityType != null) { dialog.setModalityType(modalityType); }
+
+        frame = new TestFrame();
+        frame.setLocation(50, 250);
+        window = new TestWindow(frame);
+        window.setLocation(250, 250);
+
+        p.setVisible(true);
+    }
+
+    public void doTest() throws Exception {
+
+        try {
+
+            robot.waitForIdle(delay);
+
+            if (parentDialog != null) { parentDialog.clickOpenButton(robot); }
+            else if (parentFrame != null) { parentFrame.clickOpenButton(robot); }
+            robot.waitForIdle(delay);
+
+            dialog.activated.waitForFlagTriggered();
+            assertTrue(dialog.activated.flag(), "Dialog did not trigger " +
+                "Window Activated event when it became visible");
+
+            dialog.closeGained.waitForFlagTriggered();
+            assertTrue(dialog.closeGained.flag(), "the 1st button did not gain " +
+                "focus when the dialog became visible");
+
+            assertTrue(dialog.closeButton.hasFocus(), "the 1st dialog button " +
+                "gained focus, but lost it afterwards");
+
+            dialog.openGained.reset();
+            robot.type(KeyEvent.VK_TAB);
+
+            dialog.openGained.waitForFlagTriggered();
+            assertTrue(dialog.openGained.flag(), "Tab navigation did not happen " +
+                "properly; open button did not gain focus on tab press " +
+                "when parent frame is visible");
+
+            dialog.clickOpenButton(robot);
+            robot.waitForIdle(delay);
+
+            frame.activated.waitForFlagTriggered();
+            assertTrue(frame.activated.flag(), "Frame did not trigger " +
+                "Window Activated event when made visible.");
+
+            frame.checkUnblockedFrame(robot, "Frame should not be blocked.");
+            window.checkUnblockedWindow(robot, "Window should not be blocked.");
+            robot.waitForIdle(delay);
+
+        } finally {
+            EventQueue.invokeAndWait(this::closeAll);
+        }
+    }
+
+    private void closeAll() {
+        if (dialog != null) { dialog.dispose(); }
+        if ( frame != null) {  frame.dispose(); }
+        if (window != null) { window.dispose(); }
+        if (parentDialog != null) { parentDialog.dispose(); }
+        if (parentFrame  != null) {  parentFrame.dispose(); }
+    }
+
+
+    class ParentDialog extends TestDialog {
+
+        public ParentDialog(Dialog d) { super(d); }
+
+        @Override
+        public void doOpenAction() {
+            if (dialog != null) { dialog.setVisible(true); }
+        }
+    }
+
+    class ParentFrame extends TestFrame {
+
+        @Override
+        public void doOpenAction() {
+            if (dialog != null) { dialog.setVisible(true); }
+        }
+    }
+
+    class CustomDialog extends TestDialog {
+
+        public CustomDialog(Dialog d) { super(d); }
+        public CustomDialog(Frame  f) { super(f); }
+
+        @Override
+        public void doOpenAction() {
+            if (frame  != null) {  frame.setVisible(true); }
+            if (window != null) { window.setVisible(true); }
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/awt/Modal/ModalBlockingTests/BlockingDocModalTest.java	Mon Jul 21 13:17:43 2014 +0400
@@ -0,0 +1,153 @@
+/*
+ * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+
+import java.awt.*;
+import static jdk.testlibrary.Asserts.*;
+
+
+/*
+ * @test
+ * @bug 8049617
+ * @summary Test if a document modality works as expected:
+ *          whether all the windows lying down the document root
+ *          (Frame) get blocked.
+ *
+ * @library ../helpers ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @build Flag
+ * @build TestDialog
+ * @build TestFrame
+ * @build TestWindow
+ * @run main BlockingDocModalTest
+ */
+
+
+public class BlockingDocModalTest {
+
+    private static final int delay = 500;
+    private final ExtendedRobot robot;
+
+    private TestDialog dialog, childDialog;
+    private TestFrame  frame;
+    private TestWindow window;
+
+
+    public BlockingDocModalTest() throws Exception {
+
+        robot = new ExtendedRobot();
+        EventQueue.invokeLater(this::createGUI);
+    }
+
+    private void createGUI() {
+
+        frame = new CustomFrame();
+        frame.setLocation(50, 50);
+        frame.setVisible(true);
+
+        dialog = new TestDialog(frame);
+        dialog.setLocation(250, 250);
+        dialog.setVisible(true);
+
+        childDialog = new CustomDialog(dialog);
+        childDialog.setLocation(250, 50);
+        childDialog.setModalityType(Dialog.ModalityType.DOCUMENT_MODAL);
+
+        window = new TestWindow(frame);
+        window.setLocation(50, 250);
+    }
+
+    public void doTest() throws Exception {
+
+        try {
+
+            robot.waitForIdle(delay);
+
+            frame.clickOpenButton(robot);
+            robot.waitForIdle(delay);
+
+            childDialog.activated.waitForFlagTriggered();
+            assertTrue(childDialog.activated.flag(), "Dialog did not trigger " +
+                "Window Activated event when it became visible");
+
+            childDialog.closeGained.waitForFlagTriggered();
+            assertTrue(childDialog.closeGained.flag(), "the 1st button did not " +
+                "gain focus when the Dialog became visible");
+
+            assertTrue(childDialog.closeButton.hasFocus(), "the 1st dialog button " +
+                "gained focus but lost it afterwards");
+
+            frame.checkBlockedFrame(robot, "A document modal Dialog from " +
+                "this Frame's child hierarchy should block this frame");
+
+            childDialog.checkUnblockedDialog(robot,
+                "This is a document modal childDialog.");
+
+            childDialog.clickOpenButton(robot);
+            robot.waitForIdle(delay);
+
+            window.checkBlockedWindow(robot,
+                "A document modal dialog having a parent belonging " +
+                "to this Window's document hierarchy is displayed.");
+
+            dialog.checkBlockedDialog(robot,
+                "A document modal child dialog should block this Dialog.");
+
+            robot.waitForIdle(delay);
+
+        } finally {
+            EventQueue.invokeAndWait(this::closeAll);
+        }
+    }
+
+    private void closeAll() {
+        if (dialog != null) { dialog.dispose(); }
+        if ( frame != null) {  frame.dispose(); }
+        if (window != null) { window.dispose(); }
+        if (childDialog != null) { childDialog.dispose(); }
+    }
+
+
+    class CustomFrame extends TestFrame {
+
+        @Override
+        public void doOpenAction() {
+            if (childDialog != null) { childDialog.setVisible(true); }
+        }
+    }
+
+    class CustomDialog extends TestDialog {
+
+        public CustomDialog(Dialog d) { super(d); }
+
+        @Override
+        public void doOpenAction() {
+            if (window != null) { window.setVisible(true); }
+        }
+    }
+
+
+    public static void main(String[] args) throws Exception {
+        (new BlockingDocModalTest()).doTest();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/awt/Modal/ModalBlockingTests/BlockingFDAppModalTest.java	Mon Jul 21 13:17:43 2014 +0400
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.awt.Dialog;
+
+/*
+ * @test
+ * @bug 8049617
+ * @summary Check whether an application modal Dialog created with a Frame
+ *          constructor receives focus, whether its components receive focus
+ *          and respond to key events. Check also the correctness
+ *          of the blocking behavior for the parent Frame.
+ *
+ * @library ../helpers ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @build Flag
+ * @build TestDialog
+ * @build TestFrame
+ * @run main BlockingFDAppModalTest
+ */
+
+public class BlockingFDAppModalTest {
+
+    public static void main(String[] args) throws Exception {
+        (new BlockingFDTest(Dialog.ModalityType.APPLICATION_MODAL)).doTest();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/awt/Modal/ModalBlockingTests/BlockingFDDocModalTest.java	Mon Jul 21 13:17:43 2014 +0400
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.awt.Dialog;
+
+/*
+ * @test
+ * @bug 8049617
+ * @summary Check whether a document modal Dialog created with a Frame
+ *          constructor receives focus, whether its components receive focus
+ *          and respond to key events. Check also the correctness
+ *          of the blocking behavior for the parent Frame.
+ *
+ * @library ../helpers ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @build Flag
+ * @build TestDialog
+ * @build TestFrame
+ * @run main BlockingFDDocModalTest
+ */
+
+public class BlockingFDDocModalTest {
+
+    public static void main(String[] args) throws Exception {
+        (new BlockingFDTest(Dialog.ModalityType.DOCUMENT_MODAL)).doTest();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/awt/Modal/ModalBlockingTests/BlockingFDModelessTest.java	Mon Jul 21 13:17:43 2014 +0400
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.awt.Dialog;
+
+/*
+ * @test
+ * @bug 8049617
+ * @summary Check whether a modeless Dialog created with a Frame
+ *          constructor receives focus, whether its components receive focus
+ *          and respond to key events. Check also the correctness
+ *          of the blocking behavior for the parent Frame.
+ *
+ * @library ../helpers ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @build Flag
+ * @build TestDialog
+ * @build TestFrame
+ * @run main BlockingFDModelessTest
+ */
+
+public class BlockingFDModelessTest {
+
+    public static void main(String[] args) throws Exception {
+        (new BlockingFDTest(Dialog.ModalityType.MODELESS)).doTest();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/awt/Modal/ModalBlockingTests/BlockingFDNonModalTest.java	Mon Jul 21 13:17:43 2014 +0400
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+
+/*
+ * @test
+ * @bug 8049617
+ * @summary Check whether a non-modal Dialog created with a Frame
+ *          constructor receives focus, whether its components receive focus
+ *          and respond to key events. Check also the correctness
+ *          of the blocking behavior for the parent Frame.
+ *
+ * @library ../helpers ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @build Flag
+ * @build TestDialog
+ * @build TestFrame
+ * @run main BlockingFDNonModalTest
+ */
+
+public class BlockingFDNonModalTest {
+
+    public static void main(String[] args) throws Exception {
+        (new BlockingFDTest(null)).doTest();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/awt/Modal/ModalBlockingTests/BlockingFDSetModalTest.java	Mon Jul 21 13:17:43 2014 +0400
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+
+/*
+ * @test
+ * @bug 8049617
+ * @summary Check whether a modal Dialog created with a Frame
+ *          constructor receives focus, whether its components receive focus
+ *          and respond to key events. Check also the correctness
+ *          of the blocking behavior for the parent Frame.
+ *
+ * @library ../helpers ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @build Flag
+ * @build TestDialog
+ * @build TestFrame
+ * @run main BlockingFDSetModalTest
+ */
+
+public class BlockingFDSetModalTest {
+
+    public static void main(String[] args) throws Exception {
+        (new BlockingFDTest()).doTest();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/awt/Modal/ModalBlockingTests/BlockingFDTest.java	Mon Jul 21 13:17:43 2014 +0400
@@ -0,0 +1,124 @@
+/*
+ * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.awt.*;
+import static jdk.testlibrary.Asserts.*;
+
+
+// FD: Frame -> Dialog
+
+public class BlockingFDTest {
+
+    private TestFrame  frame;
+    private TestDialog dialog;
+
+    private static final int delay = 500;
+    private final ExtendedRobot robot;
+
+    private final Dialog.ModalityType modalityType;
+    private final boolean setModal;
+
+    private BlockingFDTest(Dialog.ModalityType modType, boolean modal) throws Exception {
+
+        modalityType = modType;
+        setModal = modal;
+
+        robot = new ExtendedRobot();
+        EventQueue.invokeLater(this::createGUI);
+    }
+
+    public BlockingFDTest(Dialog.ModalityType modType) throws Exception {
+        this(modType, false);
+    }
+
+    public BlockingFDTest() throws Exception {
+        this(null, true);
+    }
+
+    private void createGUI() {
+
+        frame = new CustomFrame();
+        frame.setLocation(50, 50);
+        dialog = new TestDialog(frame);
+        if (setModal) {
+            dialog.setModal(true);
+        } else if (modalityType != null) {
+            dialog.setModalityType(modalityType);
+        }
+        dialog.setLocation(250, 50);
+
+        frame.setVisible(true);
+    }
+
+    public void doTest() throws Exception {
+
+        try {
+
+            robot.waitForIdle(delay);
+
+            frame.clickOpenButton(robot);
+            robot.waitForIdle(delay);
+
+            dialog.activated.waitForFlagTriggered();
+            assertTrue(dialog.activated.flag(), "Dialog did not trigger " +
+                "Window Activated event when it became visible");
+
+            dialog.closeGained.waitForFlagTriggered();
+            assertTrue(dialog.closeGained.flag(), "the 1st Dialog button " +
+                "did not gain focus when it became visible");
+
+            assertTrue(dialog.closeButton.hasFocus(), "the 1st Dialog button " +
+                "gained the focus but lost it afterwards");
+
+            if ((modalityType == Dialog.ModalityType.APPLICATION_MODAL) ||
+                (modalityType == Dialog.ModalityType.DOCUMENT_MODAL) ||
+                (modalityType == Dialog.ModalityType.TOOLKIT_MODAL) ||
+                setModal)
+            {
+                frame.checkBlockedFrame(robot,
+                    "Frame is the parent of a visible " + modalityType + " Dialog.");
+            } else {
+                frame.checkUnblockedFrame(robot,
+                    "Frame is the parent of a visible " + modalityType + " Dialog.");
+            }
+            robot.waitForIdle(delay);
+
+        } finally {
+            EventQueue.invokeAndWait(this::closeAll);
+        }
+    }
+
+    private void closeAll() {
+        if (frame  != null) {  frame.dispose(); }
+        if (dialog != null) { dialog.dispose(); }
+    }
+
+
+    class CustomFrame extends TestFrame {
+
+        @Override
+        public void doOpenAction() {
+            if (dialog != null) { dialog.setVisible(true); }
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/awt/Modal/ModalBlockingTests/BlockingFDToolkitModalTest.java	Mon Jul 21 13:17:43 2014 +0400
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.awt.Dialog;
+
+/*
+ * @test
+ * @bug 8049617
+ * @summary Check whether a toolkit modal Dialog created with a Frame
+ *          constructor receives focus, whether its components receive focus
+ *          and respond to key events. Check also the correctness
+ *          of the blocking behavior for the parent Frame.
+ *
+ * @library ../helpers ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @build Flag
+ * @build TestDialog
+ * @build TestFrame
+ * @run main BlockingFDToolkitModalTest
+ */
+
+public class BlockingFDToolkitModalTest {
+
+    public static void main(String[] args) throws Exception {
+        (new BlockingFDTest(Dialog.ModalityType.TOOLKIT_MODAL)).doTest();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/awt/Modal/ModalBlockingTests/BlockingFDWDocModal1Test.java	Mon Jul 21 13:17:43 2014 +0400
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.awt.Dialog;
+
+/*
+ * @test
+ * @bug 8049617
+ * @summary Check whether a document modal Dialog created with a null Frame
+ *          constructor receives focus; whether its components receive focus
+ *          and respond to key events, when there are other windows shown.
+ *          Check also the correctness of blocking behavior for other windows shown.
+ *
+ * @library ../helpers ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @build Flag
+ * @build TestDialog
+ * @build TestFrame
+ * @build TestWindow
+ * @run main BlockingFDWDocModal1Test
+ */
+
+public class BlockingFDWDocModal1Test {
+
+    public static void main(String[] args) throws Exception {
+        (new BlockingFDWTest(Dialog.ModalityType.DOCUMENT_MODAL,
+            BlockingFDWTest.DialogOwner.NULL_FRAME)).doTest();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/awt/Modal/ModalBlockingTests/BlockingFDWDocModal2Test.java	Mon Jul 21 13:17:43 2014 +0400
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.awt.Dialog;
+
+/*
+ * @test
+ * @bug 8049617
+ * @summary Check whether a document modal Dialog created with a null Dialog
+ *          constructor receives focus; whether its components receive focus
+ *          and respond to key events, when there are other windows shown.
+ *          Check also the correctness of blocking behavior for other windows shown.
+ *
+ * @library ../helpers ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @build Flag
+ * @build TestDialog
+ * @build TestFrame
+ * @build TestWindow
+ * @run main BlockingFDWDocModal2Test
+ */
+
+public class BlockingFDWDocModal2Test {
+
+    public static void main(String[] args) throws Exception {
+        (new BlockingFDWTest(Dialog.ModalityType.DOCUMENT_MODAL,
+            BlockingFDWTest.DialogOwner.NULL_DIALOG)).doTest();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/awt/Modal/ModalBlockingTests/BlockingFDWDocModal3Test.java	Mon Jul 21 13:17:43 2014 +0400
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.awt.Dialog;
+
+/*
+ * @test
+ * @bug 8049617
+ * @summary Check whether a document modal Dialog created with a hidden Frame
+ *          constructor receives focus; whether its components receive focus
+ *          and respond to key events, when there are other windows shown.
+ *          Check also the correctness of blocking behavior for other windows shown.
+ *
+ * @library ../helpers ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @build Flag
+ * @build TestDialog
+ * @build TestFrame
+ * @build TestWindow
+ * @run main BlockingFDWDocModal3Test
+ */
+
+public class BlockingFDWDocModal3Test {
+
+    public static void main(String[] args) throws Exception {
+        (new BlockingFDWTest(Dialog.ModalityType.DOCUMENT_MODAL,
+            BlockingFDWTest.DialogOwner.HIDDEN_FRAME)).doTest();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/awt/Modal/ModalBlockingTests/BlockingFDWDocModal4Test.java	Mon Jul 21 13:17:43 2014 +0400
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.awt.Dialog;
+
+/*
+ * @test
+ * @bug 8049617
+ * @summary Check whether a document modal Dialog created with a hidden Dialog
+ *          constructor receives focus; whether its components receive focus
+ *          and respond to key events, when there are other windows shown.
+ *          Check also the correctness of blocking behavior for other windows shown.
+ *
+ * @library ../helpers ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @build Flag
+ * @build TestDialog
+ * @build TestFrame
+ * @build TestWindow
+ * @run main BlockingFDWDocModal4Test
+ */
+
+public class BlockingFDWDocModal4Test {
+
+    public static void main(String[] args) throws Exception {
+        (new BlockingFDWTest(Dialog.ModalityType.DOCUMENT_MODAL,
+            BlockingFDWTest.DialogOwner.HIDDEN_DIALOG)).doTest();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/awt/Modal/ModalBlockingTests/BlockingFDWModeless1Test.java	Mon Jul 21 13:17:43 2014 +0400
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.awt.Dialog;
+
+/*
+ * @test
+ * @bug 8049617
+ * @summary Check whether a modeless Dialog created with a null Frame
+ *          constructor receives focus; whether its components receive focus
+ *          and respond to key events, when there are other windows shown.
+ *          Check also the correctness of blocking behavior for other windows shown.
+ *
+ * @library ../helpers ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @build Flag
+ * @build TestDialog
+ * @build TestFrame
+ * @build TestWindow
+ * @run main BlockingFDWModeless1Test
+ */
+
+public class BlockingFDWModeless1Test {
+
+    public static void main(String[] args) throws Exception {
+        (new BlockingFDWTest(Dialog.ModalityType.MODELESS,
+            BlockingFDWTest.DialogOwner.NULL_FRAME)).doTest();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/awt/Modal/ModalBlockingTests/BlockingFDWModeless2Test.java	Mon Jul 21 13:17:43 2014 +0400
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.awt.Dialog;
+
+/*
+ * @test
+ * @bug 8049617
+ * @summary Check whether a modeless Dialog created with a null Dialog
+ *          constructor receives focus; whether its components receive focus
+ *          and respond to key events, when there are other windows shown.
+ *          Check also the correctness of blocking behavior for other windows shown.
+ *
+ * @library ../helpers ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @build Flag
+ * @build TestDialog
+ * @build TestFrame
+ * @build TestWindow
+ * @run main BlockingFDWModeless2Test
+ */
+
+public class BlockingFDWModeless2Test {
+
+    public static void main(String[] args) throws Exception {
+        (new BlockingFDWTest(Dialog.ModalityType.MODELESS,
+            BlockingFDWTest.DialogOwner.NULL_DIALOG)).doTest();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/awt/Modal/ModalBlockingTests/BlockingFDWModeless3Test.java	Mon Jul 21 13:17:43 2014 +0400
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.awt.Dialog;
+
+/*
+ * @test
+ * @bug 8049617
+ * @summary Check whether a modeless Dialog created with a hidden Frame
+ *          constructor receives focus; whether its components receive focus
+ *          and respond to key events, when there are other windows shown.
+ *          Check also the correctness of blocking behavior for other windows shown.
+ *
+ * @library ../helpers ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @build Flag
+ * @build TestDialog
+ * @build TestFrame
+ * @build TestWindow
+ * @run main BlockingFDWModeless3Test
+ */
+
+public class BlockingFDWModeless3Test {
+
+    public static void main(String[] args) throws Exception {
+        (new BlockingFDWTest(Dialog.ModalityType.MODELESS,
+            BlockingFDWTest.DialogOwner.HIDDEN_FRAME)).doTest();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/awt/Modal/ModalBlockingTests/BlockingFDWModeless4Test.java	Mon Jul 21 13:17:43 2014 +0400
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.awt.Dialog;
+
+/*
+ * @test
+ * @bug 8049617
+ * @summary Check whether a modeless Dialog created with a hidden Dialog
+ *          constructor receives focus; whether its components receive focus
+ *          and respond to key events, when there are other windows shown.
+ *          Check also the correctness of blocking behavior for other windows shown.
+ *
+ * @library ../helpers ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @build Flag
+ * @build TestDialog
+ * @build TestFrame
+ * @build TestWindow
+ * @run main BlockingFDWModeless4Test
+ */
+
+public class BlockingFDWModeless4Test {
+
+    public static void main(String[] args) throws Exception {
+        (new BlockingFDWTest(Dialog.ModalityType.MODELESS,
+            BlockingFDWTest.DialogOwner.HIDDEN_DIALOG)).doTest();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/awt/Modal/ModalBlockingTests/BlockingFDWNonModal1Test.java	Mon Jul 21 13:17:43 2014 +0400
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8049617
+ * @summary Check whether a non-modal Dialog created with a null Frame
+ *          constructor receives focus; whether its components receive focus
+ *          and respond to key events, when there are other windows shown.
+ *          Check also the correctness of blocking behavior for other windows shown.
+ *
+ * @library ../helpers ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @build Flag
+ * @build TestDialog
+ * @build TestFrame
+ * @build TestWindow
+ * @run main BlockingFDWNonModal1Test
+ */
+
+public class BlockingFDWNonModal1Test {
+
+    public static void main(String[] args) throws Exception {
+        (new BlockingFDWTest(null,
+            BlockingFDWTest.DialogOwner.NULL_FRAME)).doTest();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/awt/Modal/ModalBlockingTests/BlockingFDWNonModal2Test.java	Mon Jul 21 13:17:43 2014 +0400
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+
+/*
+ * @test
+ * @bug 8049617
+ * @summary Check whether a non-modal Dialog created with a null Dialog
+ *          constructor receives focus; whether its components receive focus
+ *          and respond to key events, when there are other windows shown.
+ *          Check also the correctness of blocking behavior for other windows shown.
+ *
+ * @library ../helpers ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @build Flag
+ * @build TestDialog
+ * @build TestFrame
+ * @build TestWindow
+ * @run main BlockingFDWNonModal2Test
+ */
+
+public class BlockingFDWNonModal2Test {
+
+    public static void main(String[] args) throws Exception {
+        (new BlockingFDWTest(null,
+            BlockingFDWTest.DialogOwner.NULL_DIALOG)).doTest();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/awt/Modal/ModalBlockingTests/BlockingFDWNonModal3Test.java	Mon Jul 21 13:17:43 2014 +0400
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+
+/*
+ * @test
+ * @bug 8049617
+ * @summary Check whether a non-modal Dialog created with a hidden Frame
+ *          constructor receives focus; whether its components receive focus
+ *          and respond to key events, when there are other windows shown.
+ *          Check also the correctness of blocking behavior for other windows shown.
+ *
+ * @library ../helpers ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @build Flag
+ * @build TestDialog
+ * @build TestFrame
+ * @build TestWindow
+ * @run main BlockingFDWNonModal3Test
+ */
+
+public class BlockingFDWNonModal3Test {
+
+    public static void main(String[] args) throws Exception {
+        (new BlockingFDWTest(null,
+            BlockingFDWTest.DialogOwner.HIDDEN_FRAME)).doTest();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/awt/Modal/ModalBlockingTests/BlockingFDWNonModal4Test.java	Mon Jul 21 13:17:43 2014 +0400
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+
+/*
+ * @test
+ * @bug 8049617
+ * @summary Check whether a non-modal Dialog created with a hidden Dialog
+ *          constructor receives focus; whether its components receive focus
+ *          and respond to key events, when there are other windows shown.
+ *          Check also the correctness of blocking behavior for other windows shown.
+ *
+ * @library ../helpers ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @build Flag
+ * @build TestDialog
+ * @build TestFrame
+ * @build TestWindow
+ * @run main BlockingFDWNonModal4Test
+ */
+
+public class BlockingFDWNonModal4Test {
+
+    public static void main(String[] args) throws Exception {
+        (new BlockingFDWTest(null,
+            BlockingFDWTest.DialogOwner.HIDDEN_DIALOG)).doTest();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/awt/Modal/ModalBlockingTests/BlockingFDWTest.java	Mon Jul 21 13:17:43 2014 +0400
@@ -0,0 +1,162 @@
+/*
+ * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+
+import java.awt.*;
+import static jdk.testlibrary.Asserts.*;
+
+
+// FDW: Frame -> Dialog -> Window
+
+public class BlockingFDWTest {
+
+    private TestFrame  frame;
+    private TestDialog dialog;
+    private TestWindow window;
+
+    private Dialog hiddenDialog;
+    private Frame  hiddenFrame;
+
+    private static final int delay = 500;
+    private final ExtendedRobot robot;
+
+    public enum DialogOwner {HIDDEN_DIALOG, NULL_DIALOG, HIDDEN_FRAME, NULL_FRAME};
+
+    public BlockingFDWTest(Dialog.ModalityType modalityType,
+                           DialogOwner         owner) throws Exception {
+
+        robot = new ExtendedRobot();
+        EventQueue.invokeLater(() -> { createGUI(modalityType, owner); });
+    }
+
+    private void createGUI(Dialog.ModalityType modalityType,
+                           DialogOwner         owner) {
+
+        frame = new CustomFrame();
+        frame.setLocation(50, 50);
+
+        switch (owner) {
+            case HIDDEN_DIALOG:
+                hiddenDialog = new Dialog((Frame) null);
+                dialog = new CustomDialog(hiddenDialog);
+                break;
+            case NULL_DIALOG:
+                dialog = new CustomDialog((Dialog) null);
+                break;
+            case HIDDEN_FRAME:
+                hiddenFrame = new Frame();
+                dialog = new CustomDialog(hiddenFrame);
+                break;
+            case NULL_FRAME:
+                dialog = new CustomDialog((Frame) null);
+                break;
+        }
+
+        assertFalse(dialog == null, "error: null dialog");
+
+        dialog.setLocation(250, 50);
+        if (modalityType != null) {
+            dialog.setModalityType(modalityType);
+        }
+
+        window = new TestWindow(frame);
+        window.setLocation(450, 50);
+
+        frame.setVisible(true);
+    }
+
+    public void doTest() throws Exception {
+
+        try {
+
+            robot.waitForIdle(delay);
+
+            frame.clickOpenButton(robot);
+            robot.waitForIdle(delay);
+
+            dialog.activated.waitForFlagTriggered();
+            assertTrue(dialog.activated.flag(), "Dialog did not trigger " +
+                "Window Activated event when it became visible");
+
+            dialog.closeGained.waitForFlagTriggered();
+            assertTrue(dialog.closeGained.flag(), "the 1st Dialog button " +
+                "did not gain focus when it became visible");
+
+            assertTrue(dialog.closeButton.hasFocus(), "the 1st Dialog button " +
+                "gained the focus but lost it afterwards");
+
+            frame.checkUnblockedFrame(robot, "A " + dialog.getModalityType() + " dialog is visible.");
+
+            dialog.checkUnblockedDialog(robot, "A Frame is visible.");
+
+            dialog.openClicked.reset();
+            dialog.clickOpenButton(robot);
+            robot.waitForIdle(delay);
+
+            window.checkUnblockedWindow(robot,
+                "A Frame and a " + dialog.getModalityType() + " Dialog are visible.");
+            robot.waitForIdle(delay);
+
+        } finally {
+            EventQueue.invokeAndWait(this::closeAll);
+        }
+    }
+
+    private void closeAll() {
+        if (frame  != null) {  frame.dispose(); }
+        if (dialog != null) { dialog.dispose(); }
+        if (window != null) { window.dispose(); }
+        if (hiddenDialog != null) { hiddenDialog.dispose(); }
+        if (hiddenFrame  != null) {  hiddenFrame.dispose(); }
+    }
+
+
+    class CustomFrame extends TestFrame {
+
+        @Override
+        public void doOpenAction() {
+            if (dialog != null) { dialog.setVisible(true); }
+        }
+    }
+
+    class CustomDialog extends TestDialog {
+
+        public CustomDialog(Dialog dialog) {
+            super(dialog);
+        }
+
+        public CustomDialog(Frame frame) {
+            super(frame);
+        }
+
+        @Override
+        public void doOpenAction() {
+            if (window != null) { window.setVisible(true); }
+        }
+
+        @Override
+        public void doCloseAction() {
+            this.dispose();
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/awt/Modal/ModalBlockingTests/BlockingWindowsAppModal1Test.java	Mon Jul 21 13:17:43 2014 +0400
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.awt.Dialog;
+
+/*
+ * @test
+ * @bug 8049617
+ * @summary Check whether an application modal Dialog created with a null Frame
+ *          constructor receives focus; whether its components receive focus
+ *          and respond to key events, when there are other windows shown.
+ *          Also check the correctness of blocking behavior for other windows shown.
+ *
+ * @library ../helpers ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @build Flag
+ * @build TestDialog
+ * @build TestFrame
+ * @build TestWindow
+ * @run main BlockingWindowsAppModal1Test
+ */
+
+public class BlockingWindowsAppModal1Test {
+
+    public static void main(String[] args) throws Exception {
+        (new BlockingWindowsTest(Dialog.ModalityType.APPLICATION_MODAL,
+                BlockingWindowsTest.DialogOwner.NULL_FRAME)).doTest();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/awt/Modal/ModalBlockingTests/BlockingWindowsAppModal2Test.java	Mon Jul 21 13:17:43 2014 +0400
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.awt.Dialog;
+
+/*
+ * @test
+ * @bug 8049617
+ * @summary Check whether an application modal Dialog created with a null Dialog
+ *          constructor receives focus; whether its components receive focus
+ *          and respond to key events, when there are other windows shown.
+ *          Also check the correctness of blocking behavior for other windows shown.
+ *
+ * @library ../helpers ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @build Flag
+ * @build TestDialog
+ * @build TestFrame
+ * @build TestWindow
+ * @run main BlockingWindowsAppModal2Test
+ */
+
+public class BlockingWindowsAppModal2Test {
+
+    public static void main(String[] args) throws Exception {
+        (new BlockingWindowsTest(Dialog.ModalityType.APPLICATION_MODAL,
+                BlockingWindowsTest.DialogOwner.NULL_DIALOG)).doTest();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/awt/Modal/ModalBlockingTests/BlockingWindowsAppModal3Test.java	Mon Jul 21 13:17:43 2014 +0400
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.awt.Dialog;
+
+/*
+ * @test
+ * @bug 8049617
+ * @summary Check whether an application modal Dialog created with a hidden Frame
+ *          constructor receives focus; whether its components receive focus
+ *          and respond to key events, when there are other windows shown.
+ *          Also check the correctness of blocking behavior for other windows shown.
+ *
+ * @library ../helpers ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @build Flag
+ * @build TestDialog
+ * @build TestFrame
+ * @build TestWindow
+ * @run main BlockingWindowsAppModal3Test
+ */
+
+public class BlockingWindowsAppModal3Test {
+
+    public static void main(String[] args) throws Exception {
+        (new BlockingWindowsTest(Dialog.ModalityType.APPLICATION_MODAL,
+                BlockingWindowsTest.DialogOwner.HIDDEN_FRAME)).doTest();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/awt/Modal/ModalBlockingTests/BlockingWindowsAppModal4Test.java	Mon Jul 21 13:17:43 2014 +0400
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.awt.Dialog;
+
+/*
+ * @test
+ * @bug 8049617
+ * @summary Check whether an application modal Dialog created with a hidden Dialog
+ *          constructor receives focus; whether its components receive focus
+ *          and respond to key events, when there are other windows shown.
+ *          Also check the correctness of blocking behavior for other windows shown.
+ *
+ * @library ../helpers ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @build Flag
+ * @build TestDialog
+ * @build TestFrame
+ * @build TestWindow
+ * @run main BlockingWindowsAppModal4Test
+ */
+
+public class BlockingWindowsAppModal4Test {
+
+    public static void main(String[] args) throws Exception {
+        (new BlockingWindowsTest(Dialog.ModalityType.APPLICATION_MODAL,
+                BlockingWindowsTest.DialogOwner.HIDDEN_DIALOG)).doTest();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/awt/Modal/ModalBlockingTests/BlockingWindowsAppModal5Test.java	Mon Jul 21 13:17:43 2014 +0400
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.awt.Dialog;
+
+/*
+ * @test
+ * @bug 8049617
+ * @summary Check whether an application modal Dialog created with a Frame
+ *          constructor receives focus; whether its components receive focus
+ *          and respond to key events, when there are other windows shown.
+ *          Also check the correctness of blocking behavior for other windows shown.
+ *
+ * @library ../helpers ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @build Flag
+ * @build TestDialog
+ * @build TestFrame
+ * @build TestWindow
+ * @run main BlockingWindowsAppModal5Test
+ */
+
+public class BlockingWindowsAppModal5Test {
+
+    public static void main(String[] args) throws Exception {
+        (new BlockingWindowsTest(Dialog.ModalityType.APPLICATION_MODAL,
+                BlockingWindowsTest.DialogOwner.FRAME)).doTest();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/awt/Modal/ModalBlockingTests/BlockingWindowsAppModal6Test.java	Mon Jul 21 13:17:43 2014 +0400
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.awt.Dialog;
+
+/*
+ * @test
+ * @bug 8049617
+ * @summary Check whether an application modal Dialog created with a Dialog
+ *          constructor receives focus; whether its components receive focus
+ *          and respond to key events, when there are other windows shown.
+ *          Also check the correctness of blocking behavior for other windows shown.
+ *
+ * @library ../helpers ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @build Flag
+ * @build TestDialog
+ * @build TestFrame
+ * @build TestWindow
+ * @run main BlockingWindowsAppModal6Test
+ */
+
+public class BlockingWindowsAppModal6Test {
+
+    public static void main(String[] args) throws Exception {
+        (new BlockingWindowsTest(Dialog.ModalityType.APPLICATION_MODAL,
+                BlockingWindowsTest.DialogOwner.DIALOG)).doTest();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/awt/Modal/ModalBlockingTests/BlockingWindowsDocModal1Test.java	Mon Jul 21 13:17:43 2014 +0400
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.awt.Dialog;
+
+/*
+ * @test
+ * @bug 8049617
+ * @summary Check whether a document modal Dialog created with a Frame
+ *          constructor receives focus; whether its components receive focus
+ *          and respond to key events, when there are other windows shown.
+ *          Also check the correctness of blocking behavior for other windows shown.
+ *
+ * @library ../helpers ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @build Flag
+ * @build TestDialog
+ * @build TestFrame
+ * @build TestWindow
+ * @run main BlockingWindowsDocModal1Test
+ */
+
+public class BlockingWindowsDocModal1Test {
+
+    public static void main(String[] args) throws Exception {
+        (new BlockingWindowsDocModalTest(
+                BlockingWindowsDocModalTest.Parent.FRAME)).doTest();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/awt/Modal/ModalBlockingTests/BlockingWindowsDocModal2Test.java	Mon Jul 21 13:17:43 2014 +0400
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.awt.Dialog;
+
+/*
+ * @test
+ * @bug 8049617
+ * @summary Check whether a document modal Dialog created with a Dialog
+ *          constructor receives focus; whether its components receive focus
+ *          and respond to key events, when there are other windows shown.
+ *          Also check the correctness of blocking behavior for other windows shown.
+ *
+ * @library ../helpers ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @build Flag
+ * @build TestDialog
+ * @build TestFrame
+ * @build TestWindow
+ * @run main BlockingWindowsDocModal2Test
+ */
+
+public class BlockingWindowsDocModal2Test {
+
+    public static void main(String[] args) throws Exception {
+        (new BlockingWindowsDocModalTest(
+                BlockingWindowsDocModalTest.Parent.DIALOG)).doTest();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/awt/Modal/ModalBlockingTests/BlockingWindowsDocModalTest.java	Mon Jul 21 13:17:43 2014 +0400
@@ -0,0 +1,211 @@
+/*
+ * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+
+import java.awt.*;
+import java.awt.event.KeyEvent;
+import static jdk.testlibrary.Asserts.*;
+
+import java.util.List;
+import java.util.ArrayList;
+
+public class BlockingWindowsDocModalTest {
+
+    private ParentDialog parentDialog;
+    private ParentFrame  parentFrame;
+    private CustomDialog dialog;
+    private TestDialog secondDialog, childDialog;
+    private TestFrame  secondFrame;
+    private TestWindow window, childWindow, secondWindow;
+
+
+    private static final int delay = 500;
+    private final ExtendedRobot robot;
+
+    private List<Window> allWindows;
+
+    public enum Parent {DIALOG, FRAME};
+    private Parent root;
+
+    public BlockingWindowsDocModalTest(Parent p) throws Exception {
+
+        root = p;
+
+        robot = new ExtendedRobot();
+        EventQueue.invokeLater(this::createGUI);
+    }
+
+    private void createGUI() {
+
+        allWindows = new ArrayList<>();
+
+        switch (root) {
+            case DIALOG:
+                parentDialog = new ParentDialog((Dialog) null);
+                parentDialog.setLocation(50, 50);
+                parentDialog.setVisible(true);
+                allWindows.add(parentDialog);
+
+                dialog = new CustomDialog(parentDialog);
+                secondDialog = new TestDialog(parentDialog);
+                window = new TestWindow(parentDialog);
+                break;
+            case FRAME:
+                parentFrame = new ParentFrame();
+                parentFrame.setLocation(50, 50);
+                parentFrame.setVisible(true);
+                allWindows.add(parentFrame);
+
+                dialog = new CustomDialog(parentFrame);
+                secondDialog = new TestDialog(parentFrame);
+                window = new TestWindow(parentFrame);
+                break;
+        }
+
+        allWindows.add(dialog);
+        allWindows.add(secondDialog);
+        allWindows.add(window);
+
+        dialog.setModalityType(Dialog.ModalityType.DOCUMENT_MODAL);
+        dialog.setLocation(250, 50);
+        window.setLocation(450, 50);
+        secondDialog.setLocation(450, 250);
+
+        secondFrame = new TestFrame();
+        allWindows.add(secondFrame);
+        secondFrame.setLocation(50, 250);
+
+        secondWindow = new TestWindow(secondFrame);
+        allWindows.add(secondWindow);
+        secondWindow.setLocation(250, 250);
+
+        childDialog = new TestDialog(dialog);
+        allWindows.add(childDialog);
+        childDialog.setLocation(250, 450);
+
+        childWindow = new TestWindow(dialog);
+        allWindows.add(childWindow);
+        childWindow.setLocation(50, 450);
+    }
+
+    public void doTest() throws Exception {
+
+        try {
+            robot.waitForIdle(delay);
+
+            if (root == Parent.DIALOG) {
+                parentDialog.clickOpenButton(robot);
+            } else { //Parent.FRAME
+                parentFrame.clickOpenButton(robot);
+            }
+            robot.waitForIdle(delay);
+
+            dialog.activated.waitForFlagTriggered();
+            assertTrue(dialog.activated.flag(), "Dialog did not trigger " +
+                "Window Acivated event when it became visible");
+
+            dialog.closeGained.waitForFlagTriggered();
+            assertTrue(dialog.closeGained.flag(),
+                "the 1st Dialog button didn't gain focus");
+
+            assertTrue(dialog.closeButton.hasFocus(), "the 1st Dialog button " +
+                "gained focus but lost it afterwards");
+
+            dialog.openGained.reset();
+            robot.type(KeyEvent.VK_TAB);
+
+            dialog.openGained.waitForFlagTriggered();
+            assertTrue(dialog.openGained.flag(), "Tab navigation did not happen properly on Dialog; " +
+                "Open button did not gain focus on tab press when parent frame is visible");
+
+            dialog.clickOpenButton(robot);
+            robot.waitForIdle(delay);
+
+            secondFrame.checkUnblockedFrame(robot,
+                "A document modal dialog and its parent are visible.");
+            secondWindow.checkUnblockedWindow(robot,
+                "A Frame and a document modal Dialog are visible.");
+
+            if (root == Parent.DIALOG) {
+                parentDialog.checkBlockedDialog(robot, "Dialog is a parent of a document modal dialog.");
+            } else { //Parent.FRAME
+                parentFrame.checkBlockedFrame(robot, "Frame is a parent of a document modal dialog.");
+            }
+
+            secondDialog.checkBlockedDialog(robot,
+                "The parent of the Dialog is also the parent of a document modal dialog");
+            window.checkBlockedWindow(robot,
+                "The parent of the Window is also the parent of a document modal dialog");
+
+            childWindow.checkUnblockedWindow(robot,
+                "The parent of the Window is a document modal dialog");
+            childDialog.checkUnblockedDialog(robot,
+                "The parent of the Dialog is a document modal dialog");
+            robot.waitForIdle(delay);
+
+        } finally {
+            EventQueue.invokeAndWait(this::closeAll);
+        }
+    }
+
+    private void closeAll() {
+        for (Window w: allWindows) {
+            if (w != null) { w.dispose(); }
+        }
+    }
+
+    class ParentDialog extends TestDialog {
+
+        public ParentDialog(Dialog d) { super(d); }
+
+        @Override
+        public void doOpenAction() {
+            if (dialog != null) { dialog.setVisible(true); }
+        }
+    }
+
+    class ParentFrame extends TestFrame {
+
+        @Override
+        public void doOpenAction() {
+            if (dialog != null) { dialog.setVisible(true); }
+        }
+
+    }
+
+    class CustomDialog extends TestDialog {
+
+        public CustomDialog(Dialog d) { super(d); }
+        public CustomDialog(Frame f)  { super(f); }
+
+        @Override
+        public void doOpenAction() {
+            if (secondFrame  != null) {  secondFrame.setVisible(true); }
+            if (secondWindow != null) { secondWindow.setVisible(true); }
+            if (secondDialog != null) { secondDialog.setVisible(true); }
+            if (window != null) { window.setVisible(true); }
+            if (childWindow != null) { childWindow.setVisible(true); }
+            if (childDialog != null) { childDialog.setVisible(true); }
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/awt/Modal/ModalBlockingTests/BlockingWindowsSetModal1Test.java	Mon Jul 21 13:17:43 2014 +0400
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+
+/*
+ * @test
+ * @bug 8049617
+ * @summary Check whether a modal Dialog created with a null Frame
+ *          constructor receives focus; whether its components receive focus
+ *          and respond to key events, when there are other windows shown.
+ *          Also check the correctness of blocking behavior for other windows shown.
+ *
+ * @library ../helpers ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @build Flag
+ * @build TestDialog
+ * @build TestFrame
+ * @build TestWindow
+ * @run main BlockingWindowsSetModal1Test
+ */
+
+public class BlockingWindowsSetModal1Test {
+
+    public static void main(String[] args) throws Exception {
+        (new BlockingWindowsTest(
+                BlockingWindowsTest.DialogOwner.NULL_FRAME)).doTest();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/awt/Modal/ModalBlockingTests/BlockingWindowsSetModal2Test.java	Mon Jul 21 13:17:43 2014 +0400
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+
+/*
+ * @test
+ * @bug 8049617
+ * @summary Check whether a modal Dialog created with a null Dialog
+ *          constructor receives focus; whether its components receive focus
+ *          and respond to key events, when there are other windows shown.
+ *          Also check the correctness of blocking behavior for other windows shown.
+ *
+ * @library ../helpers ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @build Flag
+ * @build TestDialog
+ * @build TestFrame
+ * @build TestWindow
+ * @run main BlockingWindowsSetModal2Test
+ */
+
+public class BlockingWindowsSetModal2Test {
+
+    public static void main(String[] args) throws Exception {
+        (new BlockingWindowsTest(
+                BlockingWindowsTest.DialogOwner.NULL_DIALOG)).doTest();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/awt/Modal/ModalBlockingTests/BlockingWindowsSetModal3Test.java	Mon Jul 21 13:17:43 2014 +0400
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+
+/*
+ * @test
+ * @bug 8049617
+ * @summary Check whether a modal Dialog created with a hidden Frame
+ *          constructor receives focus; whether its components receive focus
+ *          and respond to key events, when there are other windows shown.
+ *          Also check the correctness of blocking behavior for other windows shown.
+ *
+ * @library ../helpers ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @build Flag
+ * @build TestDialog
+ * @build TestFrame
+ * @build TestWindow
+ * @run main BlockingWindowsSetModal3Test
+ */
+
+public class BlockingWindowsSetModal3Test {
+
+    public static void main(String[] args) throws Exception {
+        (new BlockingWindowsTest(
+                BlockingWindowsTest.DialogOwner.HIDDEN_FRAME)).doTest();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/awt/Modal/ModalBlockingTests/BlockingWindowsSetModal4Test.java	Mon Jul 21 13:17:43 2014 +0400
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+
+/*
+ * @test
+ * @bug 8049617
+ * @summary Check whether a modal Dialog created with a hidden Dialog
+ *          constructor receives focus; whether its components receive focus
+ *          and respond to key events, when there are other windows shown.
+ *          Also check the correctness of blocking behavior for other windows shown.
+ *
+ * @library ../helpers ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @build Flag
+ * @build TestDialog
+ * @build TestFrame
+ * @build TestWindow
+ * @run main BlockingWindowsSetModal4Test
+ */
+
+public class BlockingWindowsSetModal4Test {
+
+    public static void main(String[] args) throws Exception {
+        (new BlockingWindowsTest(
+                BlockingWindowsTest.DialogOwner.HIDDEN_DIALOG)).doTest();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/awt/Modal/ModalBlockingTests/BlockingWindowsSetModal5Test.java	Mon Jul 21 13:17:43 2014 +0400
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+
+/*
+ * @test
+ * @bug 8049617
+ * @summary Check whether a modal Dialog created with a Frame
+ *          constructor receives focus; whether its components receive focus
+ *          and respond to key events, when there are other windows shown.
+ *          Also check the correctness of blocking behavior for other windows shown.
+ *
+ * @library ../helpers ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @build Flag
+ * @build TestDialog
+ * @build TestFrame
+ * @build TestWindow
+ * @run main BlockingWindowsSetModal5Test
+ */
+
+public class BlockingWindowsSetModal5Test {
+
+    public static void main(String[] args) throws Exception {
+        (new BlockingWindowsTest(
+                BlockingWindowsTest.DialogOwner.FRAME)).doTest();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/awt/Modal/ModalBlockingTests/BlockingWindowsSetModal6Test.java	Mon Jul 21 13:17:43 2014 +0400
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+
+/*
+ * @test
+ * @bug 8049617
+ * @summary Check whether a modal Dialog created with a Dialog
+ *          constructor receives focus; whether its components receive focus
+ *          and respond to key events, when there are other windows shown.
+ *          Also check the correctness of blocking behavior for other windows shown.
+ *
+ * @library ../helpers ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @build Flag
+ * @build TestDialog
+ * @build TestFrame
+ * @build TestWindow
+ * @run main BlockingWindowsSetModal6Test
+ */
+
+public class BlockingWindowsSetModal6Test {
+
+    public static void main(String[] args) throws Exception {
+        (new BlockingWindowsTest(
+                BlockingWindowsTest.DialogOwner.DIALOG)).doTest();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/awt/Modal/ModalBlockingTests/BlockingWindowsTest.java	Mon Jul 21 13:17:43 2014 +0400
@@ -0,0 +1,299 @@
+/*
+ * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import static jdk.testlibrary.Asserts.*;
+
+import java.awt.*;
+import java.util.List;
+import java.util.ArrayList;
+
+public class BlockingWindowsTest {
+
+    private TestDialog dialog, childDialog, secondDialog, dummyDialog, parentDialog;
+    private TestFrame frame, secondFrame;
+    private TestWindow window, childWindow;
+
+    private static final int delay = 500;
+    private final ExtendedRobot robot;
+
+    private List<Window> allWindows;
+
+    private Dialog hiddenDialog;
+    private Frame  hiddenFrame;
+
+    private Dialog.ModalityType modalityType;
+
+    public enum DialogOwner {HIDDEN_DIALOG, NULL_DIALOG, HIDDEN_FRAME, NULL_FRAME, DIALOG, FRAME};
+
+    private BlockingWindowsTest(Dialog.ModalityType modType,
+                                boolean             setModal,
+                                DialogOwner         owner) throws Exception {
+
+        modalityType = modType;
+        robot = new ExtendedRobot();
+        EventQueue.invokeLater(() -> {
+            createGUI(setModal, owner);
+        });
+    }
+
+    public BlockingWindowsTest(
+            Dialog.ModalityType modalityType, DialogOwner owner) throws Exception {
+        this(modalityType, false, owner);
+    }
+
+    public BlockingWindowsTest(DialogOwner owner) throws Exception {
+        this(null, true, owner);
+    }
+
+    private void createGUI(boolean     setModal,
+                           DialogOwner owner) {
+
+        allWindows = new ArrayList<>();
+
+        if (owner != DialogOwner.DIALOG) {
+            frame = new CustomFrame();
+            frame.setLocation(50, 50);
+            frame.setVisible(true);
+            allWindows.add(frame);
+        }
+
+        switch (owner) {
+            case DIALOG:
+                parentDialog = new ParentDialog((Dialog) null);
+                parentDialog.setLocation(50, 50);
+                parentDialog.setVisible(true);
+                allWindows.add(parentDialog);
+                dialog = new CustomDialog(parentDialog);
+                break;
+            case FRAME:
+                dialog = new CustomDialog(frame);
+                break;
+            case HIDDEN_DIALOG:
+                hiddenDialog = new Dialog((Frame) null);
+                dialog = new CustomDialog(hiddenDialog);
+                allWindows.add(hiddenDialog);
+                break;
+            case NULL_DIALOG:
+                dialog = new CustomDialog((Dialog) null);
+                break;
+            case HIDDEN_FRAME:
+                hiddenFrame = new Frame();
+                dialog = new CustomDialog(hiddenFrame);
+                allWindows.add(hiddenFrame);
+                break;
+            case NULL_FRAME:
+                dialog = new CustomDialog((Frame) null);
+                break;
+        }
+
+        assertFalse(dialog == null, "error: null dialog");
+
+        if (setModal) {
+            dialog.setModal(true);
+        } else if (modalityType != null) {
+            dialog.setModalityType(modalityType);
+        }
+
+        dialog.setLocation(250, 50);
+        allWindows.add(dialog);
+
+        if (owner == DialogOwner.DIALOG) {
+            window = new TestWindow(parentDialog);
+        } else {
+            window = new TestWindow(frame);
+        }
+
+        window.setLocation(50, 250);
+        allWindows.add(window);
+
+        if (owner == DialogOwner.DIALOG) {
+            dummyDialog = new TestDialog(parentDialog);
+        } else {
+            dummyDialog = new TestDialog(frame);
+        }
+        dummyDialog.setLocation(450, 450);
+        allWindows.add(dummyDialog);
+
+        childWindow = new CustomWindow(dialog);
+        childWindow.setLocation(450, 50);
+        allWindows.add(childWindow);
+
+        childDialog = new TestDialog(dialog);
+        childDialog.setLocation(450, 250);
+        allWindows.add(childDialog);
+
+        if (owner == DialogOwner.DIALOG) {
+            secondDialog = new CustomDialog(parentDialog);
+        } else {
+            secondDialog = new CustomDialog(frame);
+        }
+        if (setModal) {
+            secondDialog.setModal(true);
+        } else if (modalityType != null) {
+            secondDialog.setModalityType(modalityType);
+        }
+
+        secondDialog.setLocation(50, 450);
+        allWindows.add(secondDialog);
+
+        secondFrame = new TestFrame();
+        secondFrame.setLocation(250, 450);
+        allWindows.add(secondFrame);
+    }
+
+    public void doTest() throws Exception {
+
+        try {
+
+            robot.waitForIdle(delay);
+
+            if (parentDialog == null) { frame.clickOpenButton(robot); }
+            else { parentDialog.clickOpenButton(robot); }
+            robot.waitForIdle(delay);
+
+            dialog.activated.waitForFlagTriggered();
+            assertTrue(dialog.activated.flag(), "Dialog did not trigger " +
+                "Window Activated event when it became visible");
+
+            dialog.closeGained.waitForFlagTriggered();
+            assertTrue(dialog.closeGained.flag(), "The first button did not gain focus " +
+                "when the dialog became visible");
+
+            assertTrue(dialog.closeButton.hasFocus(), "The first dialog button " +
+                "gained focus, but lost it afterwards");
+
+            if (parentDialog == null) {
+                frame.checkBlockedFrame(robot, modalityType + " Dialog is visible.");
+            } else {
+                parentDialog.checkBlockedDialog(robot, modalityType + " Dialog is visible.");
+            }
+
+            dialog.checkUnblockedDialog(robot, "A Frame is visible.");
+
+            dialog.openClicked.reset();
+            dialog.clickOpenButton(robot);
+            robot.waitForIdle(delay);
+
+            assertFalse(window.focusGained.flag(), "Window gained focus on becoming " +
+                "visible when Frame and Dialog are visible");
+
+            window.checkBlockedWindow(robot,
+                "The parent of the Window is blocked by " + modalityType + " Dialog.");
+
+            dummyDialog.checkBlockedDialog(robot,
+                "The parent of the Dialog is blocked by " + modalityType + " Dialog.");
+
+            childDialog.checkUnblockedDialog(robot,
+                "The parent of the Dialog is " + modalityType + " Dialog");
+
+            childWindow.checkUnblockedWindow(robot,
+                "The parent of the Window is " + modalityType + " Dialog");
+
+            childWindow.openClicked.reset();
+            childWindow.clickOpenButton(robot);
+            robot.waitForIdle(delay);
+
+            secondDialog.checkUnblockedDialog(robot,
+                "The dialog is " + modalityType + ", the parent of the dialog " +
+                "is blocked by another " + modalityType + " dialog.");
+
+            secondFrame.checkBlockedFrame(robot,
+                modalityType + " dialog is displayed immediately after showing " +
+                "this frame. Another modal dialog is alreay visible");
+
+            secondDialog.clickCloseButton(robot);
+            robot.waitForIdle(delay);
+
+            childWindow.checkUnblockedWindow(robot, "A blocking dialog was closed.");
+            robot.waitForIdle(delay);
+
+        } finally {
+            EventQueue.invokeAndWait(this::closeAll);
+        }
+    }
+
+    private void closeAll() {
+        for (Window w: allWindows) {
+            if (w != null) { w.dispose(); }
+        }
+    }
+
+
+    class CustomFrame extends TestFrame {
+
+        @Override
+        public void doOpenAction() {
+            if (dialog != null) { dialog.setVisible(true); }
+        }
+    }
+
+    class CustomDialog extends TestDialog {
+
+        public CustomDialog(Dialog dialog) {
+            super(dialog);
+        }
+
+        public CustomDialog(Frame frame) {
+            super(frame);
+        }
+
+        @Override
+        public void doOpenAction() {
+            if (window != null) { window.setVisible(true); }
+            if (dummyDialog != null) { dummyDialog.setVisible(true); }
+            if (childWindow != null) { childWindow.setVisible(true); }
+            if (childDialog != null) { childDialog.setVisible(true); }
+        }
+
+        @Override
+        public void doCloseAction() {
+            this.dispose();
+        }
+    }
+
+    class CustomWindow extends TestWindow {
+
+        public CustomWindow(Window parent) {
+            super(parent);
+        }
+
+        @Override
+        public void doOpenAction() {
+            if (secondFrame  != null) {  secondFrame.setVisible(true); }
+            if (secondDialog != null) { secondDialog.setVisible(true); }
+        }
+    }
+
+    class ParentDialog extends TestDialog {
+
+        public ParentDialog(Dialog d) { super(d); }
+
+        @Override
+        public void doOpenAction() {
+            if (dialog != null) {
+                dialog.setVisible(true);
+            }
+        }
+    }
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/awt/Modal/ModalBlockingTests/BlockingWindowsToolkitModal1Test.java	Mon Jul 21 13:17:43 2014 +0400
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.awt.Dialog;
+
+/*
+ * @test
+ * @bug 8049617
+ * @summary Check whether a toolkit modal Dialog created with a null Frame
+ *          constructor receives focus; whether its components receive focus
+ *          and respond to key events, when there are other windows shown.
+ *          Also check the correctness of blocking behavior for other windows shown.
+ *
+ * @library ../helpers ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @build Flag
+ * @build TestDialog
+ * @build TestFrame
+ * @build TestWindow
+ * @run main BlockingWindowsToolkitModal1Test
+ */
+
+public class BlockingWindowsToolkitModal1Test {
+
+    public static void main(String[] args) throws Exception {
+        (new BlockingWindowsTest(Dialog.ModalityType.TOOLKIT_MODAL,
+                BlockingWindowsTest.DialogOwner.NULL_FRAME)).doTest();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/awt/Modal/ModalBlockingTests/BlockingWindowsToolkitModal2Test.java	Mon Jul 21 13:17:43 2014 +0400
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.awt.Dialog;
+
+/*
+ * @test
+ * @bug 8049617
+ * @summary Check whether a toolkit modal Dialog created with a null Dialog
+ *          constructor receives focus; whether its components receive focus
+ *          and respond to key events, when there are other windows shown.
+ *          Also check the correctness of blocking behavior for other windows shown.
+ *
+ * @library ../helpers ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @build Flag
+ * @build TestDialog
+ * @build TestFrame
+ * @build TestWindow
+ * @run main BlockingWindowsToolkitModal2Test
+ */
+
+public class BlockingWindowsToolkitModal2Test {
+
+    public static void main(String[] args) throws Exception {
+        (new BlockingWindowsTest(Dialog.ModalityType.TOOLKIT_MODAL,
+                BlockingWindowsTest.DialogOwner.NULL_DIALOG)).doTest();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/awt/Modal/ModalBlockingTests/BlockingWindowsToolkitModal3Test.java	Mon Jul 21 13:17:43 2014 +0400
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.awt.Dialog;
+
+/*
+ * @test
+ * @bug 8049617
+ * @summary Check whether a toolkit modal Dialog created with a hidden Frame
+ *          constructor receives focus; whether its components receive focus
+ *          and respond to key events, when there are other windows shown.
+ *          Also check the correctness of blocking behavior for other windows shown.
+ *
+ * @library ../helpers ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @build Flag
+ * @build TestDialog
+ * @build TestFrame
+ * @build TestWindow
+ * @run main BlockingWindowsToolkitModal3Test
+ */
+
+public class BlockingWindowsToolkitModal3Test {
+
+    public static void main(String[] args) throws Exception {
+        (new BlockingWindowsTest(Dialog.ModalityType.TOOLKIT_MODAL,
+                BlockingWindowsTest.DialogOwner.HIDDEN_FRAME)).doTest();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/awt/Modal/ModalBlockingTests/BlockingWindowsToolkitModal4Test.java	Mon Jul 21 13:17:43 2014 +0400
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.awt.Dialog;
+
+/*
+ * @test
+ * @bug 8049617
+ * @summary Check whether a toolkit modal Dialog created with a hidden Dialog
+ *          constructor receives focus; whether its components receive focus
+ *          and respond to key events, when there are other windows shown.
+ *          Also check the correctness of blocking behavior for other windows shown.
+ *
+ * @library ../helpers ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @build Flag
+ * @build TestDialog
+ * @build TestFrame
+ * @build TestWindow
+ * @run main BlockingWindowsToolkitModal4Test
+ */
+
+public class BlockingWindowsToolkitModal4Test {
+
+    public static void main(String[] args) throws Exception {
+        (new BlockingWindowsTest(Dialog.ModalityType.TOOLKIT_MODAL,
+                BlockingWindowsTest.DialogOwner.HIDDEN_DIALOG)).doTest();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/awt/Modal/ModalBlockingTests/BlockingWindowsToolkitModal5Test.java	Mon Jul 21 13:17:43 2014 +0400
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.awt.Dialog;
+
+/*
+ * @test
+ * @bug 8049617
+ * @summary Check whether a toolkit modal Dialog created with a Frame
+ *          constructor receives focus; whether its components receive focus
+ *          and respond to key events, when there are other windows shown.
+ *          Also check the correctness of blocking behavior for other windows shown.
+ *
+ * @library ../helpers ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @build Flag
+ * @build TestDialog
+ * @build TestFrame
+ * @build TestWindow
+ * @run main BlockingWindowsToolkitModal5Test
+ */
+
+public class BlockingWindowsToolkitModal5Test {
+
+    public static void main(String[] args) throws Exception {
+        (new BlockingWindowsTest(Dialog.ModalityType.TOOLKIT_MODAL,
+                BlockingWindowsTest.DialogOwner.FRAME)).doTest();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/awt/Modal/ModalBlockingTests/BlockingWindowsToolkitModal6Test.java	Mon Jul 21 13:17:43 2014 +0400
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.awt.Dialog;
+
+/*
+ * @test
+ * @bug 8049617
+ * @summary Check whether a toolkit modal Dialog created with a Dialog
+ *          constructor receives focus; whether its components receive focus
+ *          and respond to key events, when there are other windows shown.
+ *          Also check the correctness of blocking behavior for other windows shown.
+ *
+ * @library ../helpers ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @build Flag
+ * @build TestDialog
+ * @build TestFrame
+ * @build TestWindow
+ * @run main BlockingWindowsToolkitModal6Test
+ */
+
+public class BlockingWindowsToolkitModal6Test {
+
+    public static void main(String[] args) throws Exception {
+        (new BlockingWindowsTest(Dialog.ModalityType.TOOLKIT_MODAL,
+                BlockingWindowsTest.DialogOwner.DIALOG)).doTest();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/awt/Modal/ModalBlockingTests/UnblockedDialogAppModalTest.java	Mon Jul 21 13:17:43 2014 +0400
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.awt.Dialog;
+
+/*
+ * @test
+ * @bug 8049617
+ * @summary Check whether an application modal Dialog receives focus; check
+ *          if its components receive focus and respond to key events
+ *
+ * @library ../helpers ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @build Flag
+ * @build TestDialog
+ * @run main UnblockedDialogAppModalTest
+ */
+
+public class UnblockedDialogAppModalTest {
+
+    public static void main(String[] args) throws Exception {
+        (new UnblockedDialogTest(Dialog.ModalityType.APPLICATION_MODAL)).doTest();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/awt/Modal/ModalBlockingTests/UnblockedDialogDocModalTest.java	Mon Jul 21 13:17:43 2014 +0400
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.awt.Dialog;
+
+/*
+ * @test
+ * @bug 8049617
+ * @summary Check whether a document modal Dialog receives focus; check
+ *          if its components receive focus and respond to key events
+ *
+ * @library ../helpers ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @build Flag
+ * @build TestDialog
+ * @run main UnblockedDialogDocModalTest
+ */
+
+public class UnblockedDialogDocModalTest {
+
+    public static void main(String[] args) throws Exception {
+        (new UnblockedDialogTest(Dialog.ModalityType.DOCUMENT_MODAL)).doTest();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/awt/Modal/ModalBlockingTests/UnblockedDialogModelessTest.java	Mon Jul 21 13:17:43 2014 +0400
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.awt.Dialog;
+
+/*
+ * @test
+ * @bug 8049617
+ * @summary Check whether a modeless Dialog receives focus; check
+ *          if its components receive focus and respond to key events
+ *
+ * @library ../helpers ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @build Flag
+ * @build TestDialog
+ * @run main UnblockedDialogModelessTest
+ */
+
+public class UnblockedDialogModelessTest {
+
+    public static void main(String[] args) throws Exception {
+        (new UnblockedDialogTest(Dialog.ModalityType.MODELESS)).doTest();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/awt/Modal/ModalBlockingTests/UnblockedDialogNonModalTest.java	Mon Jul 21 13:17:43 2014 +0400
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+
+/*
+ * @test
+ * @bug 8049617
+ * @summary Check whether a non-modal Dialog receives focus; check
+ *          if its components receive focus and respond to key events
+ *
+ * @library ../helpers ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @build Flag
+ * @build TestDialog
+ * @run main UnblockedDialogNonModalTest
+ */
+
+public class UnblockedDialogNonModalTest {
+
+    public static void main(String[] args) throws Exception {
+        (new UnblockedDialogTest(null)).doTest();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/awt/Modal/ModalBlockingTests/UnblockedDialogSetModalTest.java	Mon Jul 21 13:17:43 2014 +0400
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+
+/*
+ * @test
+ * @bug 8049617
+ * @summary Check whether a modal Dialog receives focus; check
+ *          if its components receive focus and respond to key events
+ *
+ * @library ../helpers ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @build Flag
+ * @build TestDialog
+ * @run main UnblockedDialogSetModalTest
+ */
+
+public class UnblockedDialogSetModalTest {
+
+    public static void main(String[] args) throws Exception {
+        (new UnblockedDialogTest()).doTest();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/awt/Modal/ModalBlockingTests/UnblockedDialogTest.java	Mon Jul 21 13:17:43 2014 +0400
@@ -0,0 +1,123 @@
+/*
+ * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.awt.*;
+import static jdk.testlibrary.Asserts.*;
+
+
+public class UnblockedDialogTest {
+
+    private TestDialog dialog;
+
+    private static final int delay = 500;
+    private final ExtendedRobot robot;
+
+    private Dialog parentDialog;
+    private Frame  parentFrame;
+
+    private enum DialogOwner {HIDDEN_DIALOG, HIDDEN_FRAME, NULL_DIALOG, NULL_FRAME};
+
+    Dialog.ModalityType modalityType;
+    boolean setModal;
+
+    private UnblockedDialogTest(Dialog.ModalityType modType,
+                                boolean             set) throws Exception {
+
+        robot = new ExtendedRobot();
+        modalityType = modType;
+        setModal = set;
+    }
+
+    public UnblockedDialogTest(Dialog.ModalityType modType) throws Exception {
+        this(modType, false);
+    }
+
+    public UnblockedDialogTest() throws Exception { this(null, true); }
+
+
+    private void createGUI(DialogOwner owner) {
+
+        switch (owner) {
+            case HIDDEN_DIALOG:
+                parentDialog = new Dialog((Frame) null);
+                dialog = new TestDialog(parentDialog);
+                break;
+            case NULL_DIALOG:
+                dialog = new TestDialog((Dialog) null);
+                break;
+            case HIDDEN_FRAME:
+                parentFrame = new Frame();
+                dialog = new TestDialog(parentFrame);
+                break;
+            case NULL_FRAME:
+                dialog = new TestDialog((Frame) null);
+                break;
+        }
+
+        assertFalse(dialog == null, "error: null dialog");
+
+        dialog.setLocation(50, 50);
+        if (setModal) {
+            dialog.setModal(true);
+        } else if (modalityType != null) {
+            dialog.setModalityType(modalityType);
+        }
+
+        dialog.setVisible(true);
+    }
+
+    public void doTest() throws Exception {
+
+        try {
+
+            robot.waitForIdle(delay);
+
+            for (DialogOwner owner: DialogOwner.values()) {
+
+                EventQueue.invokeLater(() -> { createGUI(owner); });
+
+                robot.waitForIdle(delay);
+
+                dialog.activated.waitForFlagTriggered();
+                assertTrue(dialog.activated.flag(), "Dialog did not trigger " +
+                    "Window Activated event when it became visible");
+
+                dialog.closeGained.waitForFlagTriggered();
+                assertTrue(dialog.closeGained.flag(), "The 1st button did not " +
+                    "gain focus when the dialog became visible");
+
+                dialog.checkUnblockedDialog(robot, "");
+                robot.waitForIdle(delay);
+            }
+
+        } finally {
+            EventQueue.invokeAndWait(this::closeAll);
+        }
+    }
+
+    private void closeAll() {
+        if (dialog != null) { dialog.dispose(); }
+        if (parentDialog != null) { parentDialog.dispose(); }
+        if (parentFrame  != null) {  parentFrame.dispose(); }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/awt/Modal/ModalBlockingTests/UnblockedDialogToolkitModalTest.java	Mon Jul 21 13:17:43 2014 +0400
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.awt.Dialog;
+
+/*
+ * @test
+ * @bug 8049617
+ * @summary Check whether a toolkit modal Dialog receives focus; check
+ *          if its components receive focus and respond to key events
+ *
+ * @library ../helpers ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @build Flag
+ * @build TestDialog
+ * @run main UnblockedDialogToolkitModalTest
+ */
+
+public class UnblockedDialogToolkitModalTest {
+
+    public static void main(String[] args) throws Exception {
+        (new UnblockedDialogTest(Dialog.ModalityType.TOOLKIT_MODAL)).doTest();
+    }
+}
--- a/test/java/awt/Modal/helpers/TestFrame.java	Mon Jul 21 12:29:45 2014 +0400
+++ b/test/java/awt/Modal/helpers/TestFrame.java	Mon Jul 21 13:17:43 2014 +0400
@@ -292,13 +292,13 @@
         robot.waitForIdle(delay);
 
         assertFalse(dummyClicked.flag(),
-            "DummyButton on blocked Window triggered action when clicked. " + message);
+            "DummyButton on blocked Frame triggered action when clicked. " + message);
 
         assertFalse(dummyGained.flag(),
-            "DummyButton on blocked Window gained focus when clicked. " + message);
+            "DummyButton on blocked Frame gained focus when clicked. " + message);
 
         assertFalse(focusGained.flag(),
-            "A blocked Dialog gained focus when component clicked. " + message);
+            "A blocked Frame gained focus when component clicked. " + message);
     }
 
     public void checkUnblockedFrame(ExtendedRobot robot,