]> source.dussan.org Git - vaadin-framework.git/commitdiff
Ensure window is closed even if close listener throws an exception (#10779)
authorArtur Signell <artur@vaadin.com>
Mon, 21 Jan 2013 19:52:00 +0000 (21:52 +0200)
committerArtur Signell <artur@vaadin.com>
Mon, 21 Jan 2013 19:54:01 +0000 (21:54 +0200)
Change-Id: I58621c5f5ff01ccc96de3b602aac35f6fa01aa5b

server/src/com/vaadin/ui/UI.java
uitest/src/com/vaadin/tests/components/window/WindowWithInvalidCloseListener.html [new file with mode: 0644]
uitest/src/com/vaadin/tests/components/window/WindowWithInvalidCloseListener.java [new file with mode: 0644]

index 1babc077b80e85cfed6520f608183b89b9b54e38..7e54aa01a0dd425e42c21eaa1f5d47fa0d46ce07 100644 (file)
@@ -428,8 +428,8 @@ public abstract class UI extends AbstractSingleComponentContainer implements
             return false;
         }
         window.setParent(null);
-        window.fireClose();
         markAsDirty();
+        window.fireClose();
 
         return true;
     }
diff --git a/uitest/src/com/vaadin/tests/components/window/WindowWithInvalidCloseListener.html b/uitest/src/com/vaadin/tests/components/window/WindowWithInvalidCloseListener.html
new file mode 100644 (file)
index 0000000..923276b
--- /dev/null
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head profile="http://selenium-ide.openqa.org/profiles/test-case">
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+<link rel="selenium.base" href="http://localhost:8888/" />
+<title>New Test</title>
+</head>
+<body>
+<table cellpadding="1" cellspacing="1" border="1">
+<thead>
+<tr><td rowspan="1" colspan="3">New Test</td></tr>
+</thead><tbody>
+<tr>
+       <td>open</td>
+       <td>/run/com.vaadin.tests.components.window.WindowWithInvalidCloseListener?restartApplication</td>
+       <td></td>
+</tr>
+<tr>
+       <td>mouseClick</td>
+       <td>vaadin=runcomvaadintestscomponentswindowWindowWithInvalidCloseListener::/VWindow[0]/domChild[0]/domChild[0]/domChild[1]</td>
+       <td>6,7</td>
+</tr>
+<tr>
+       <td>assertElementNotPresent</td>
+       <td>vaadin=runcomvaadintestscomponentswindowWindowWithInvalidCloseListener::/VWindow[0]</td>
+       <td></td>
+</tr>
+
+</tbody></table>
+</body>
+</html>
diff --git a/uitest/src/com/vaadin/tests/components/window/WindowWithInvalidCloseListener.java b/uitest/src/com/vaadin/tests/components/window/WindowWithInvalidCloseListener.java
new file mode 100644 (file)
index 0000000..991b562
--- /dev/null
@@ -0,0 +1,35 @@
+package com.vaadin.tests.components.window;
+
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.tests.components.AbstractTestUI;
+import com.vaadin.ui.Window;
+import com.vaadin.ui.Window.CloseEvent;
+import com.vaadin.ui.Window.CloseListener;
+
+public class WindowWithInvalidCloseListener extends AbstractTestUI {
+
+    @Override
+    protected void setup(VaadinRequest request) {
+        Window w = new Window("Close me");
+        w.addCloseListener(new CloseListener() {
+
+            @Override
+            public void windowClose(CloseEvent e) {
+                throw new RuntimeException(
+                        "Close listener intentionally failed");
+            }
+        });
+        addWindow(w);
+    }
+
+    @Override
+    protected String getTestDescription() {
+        return "The window has a close listener which throws an exception. This should not prevent the window from being closed.";
+    }
+
+    @Override
+    protected Integer getTicketNumber() {
+        return 10779;
+    }
+
+}