summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohannes Dahlström <johannesd@vaadin.com>2012-11-01 13:12:07 +0200
committerVaadin Code Review <review@vaadin.com>2012-11-01 12:04:37 +0000
commitdbf982bb3b3ddccba00fbc889a0130feac2a6d2d (patch)
tree7a573a3241058ee4114bd4d6b1677c9ed4b20560
parent008b582c66166b1a2e7ada4510e3a3d8be433a10 (diff)
downloadvaadin-framework-dbf982bb3b3ddccba00fbc889a0130feac2a6d2d.tar.gz
vaadin-framework-dbf982bb3b3ddccba00fbc889a0130feac2a6d2d.zip
Fix client-side NPE in Image without a source (#10101)
Change-Id: I7911dffd8700dc166f7b8669d291a0e34cb43daf
-rw-r--r--client/src/com/vaadin/client/ui/image/ImageConnector.java9
-rw-r--r--uitest/src/com/vaadin/tests/components/abstractembedded/EmbeddedWithNullSource.html27
-rw-r--r--uitest/src/com/vaadin/tests/components/abstractembedded/EmbeddedWithNullSource.java48
3 files changed, 81 insertions, 3 deletions
diff --git a/client/src/com/vaadin/client/ui/image/ImageConnector.java b/client/src/com/vaadin/client/ui/image/ImageConnector.java
index 22067b051e..17ce058c5d 100644
--- a/client/src/com/vaadin/client/ui/image/ImageConnector.java
+++ b/client/src/com/vaadin/client/ui/image/ImageConnector.java
@@ -48,9 +48,12 @@ public class ImageConnector extends AbstractComponentConnector {
clickEventHandler.handleEventHandlerRegistration();
- getWidget().setUrl(
- getResourceUrl(AbstractEmbeddedState.SOURCE_RESOURCE));
- getWidget().setAltText(getState().alternateText);
+ String url = getResourceUrl(AbstractEmbeddedState.SOURCE_RESOURCE);
+ getWidget().setUrl(url != null ? url : "");
+
+ String alt = getState().alternateText;
+ // Some browsers turn a null alt text into a literal "null"
+ getWidget().setAltText(alt != null ? alt : "");
}
protected final ClickEventHandler clickEventHandler = new ClickEventHandler(
diff --git a/uitest/src/com/vaadin/tests/components/abstractembedded/EmbeddedWithNullSource.html b/uitest/src/com/vaadin/tests/components/abstractembedded/EmbeddedWithNullSource.html
new file mode 100644
index 0000000000..37186bd901
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/abstractembedded/EmbeddedWithNullSource.html
@@ -0,0 +1,27 @@
+<?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="" />
+<title>EmbeddedWithNullSource</title>
+</head>
+<body>
+<table cellpadding="1" cellspacing="1" border="1">
+<thead>
+<tr><td rowspan="1" colspan="3">EmbeddedWithNullSource</td></tr>
+</thead><tbody>
+<tr>
+ <td>open</td>
+ <td>/run/EmbeddedWithNullSource?restartApplication</td>
+ <td></td>
+</tr>
+<tr>
+ <td>screenCapture</td>
+ <td></td>
+ <td></td>
+</tr>
+
+</tbody></table>
+</body>
+</html>
diff --git a/uitest/src/com/vaadin/tests/components/abstractembedded/EmbeddedWithNullSource.java b/uitest/src/com/vaadin/tests/components/abstractembedded/EmbeddedWithNullSource.java
new file mode 100644
index 0000000000..e6b51399e9
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/abstractembedded/EmbeddedWithNullSource.java
@@ -0,0 +1,48 @@
+package com.vaadin.tests.components.abstractembedded;
+
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.ui.AbstractEmbedded;
+import com.vaadin.ui.BrowserFrame;
+import com.vaadin.ui.Flash;
+import com.vaadin.ui.Image;
+
+public class EmbeddedWithNullSource extends TestBase {
+
+ @Override
+ protected void setup() {
+ AbstractEmbedded e;
+
+ e = new Image("Image w/o alt text");
+ addComponent(e);
+
+ e = new Image("Image w/ alt text");
+ e.setAlternateText("Image");
+ addComponent(e);
+
+ e = new Flash("Flash w/o alt text");
+ addComponent(e);
+
+ e = new Flash("Flash w/ alt text");
+ e.setAlternateText("Flash");
+ addComponent(e);
+
+ e = new BrowserFrame("BrowserFrame w/o alt text");
+ addComponent(e);
+
+ e = new BrowserFrame("BrowserFrame w/ alt text");
+ e.setAlternateText("BrowserFrame");
+ addComponent(e);
+
+ }
+
+ @Override
+ protected String getDescription() {
+ return "Image without a source causes a client-side NPE";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 10101;
+ }
+
+}