Author: [email protected]
Date: Tue Jun 2 14:59:18 2009
New Revision: 5497
Modified:
branches/snapshot-2009.05.12-r5406/user/build.xml
branches/snapshot-2009.05.12-r5406/user/src/com/google/gwt/dom/client/Element.java
branches/snapshot-2009.05.12-r5406/user/src/com/google/gwt/dom/client/Node.java
branches/snapshot-2009.05.12-r5406/user/test/com/google/gwt/dom/client/NodeTest.java
Log:
Merge r5332 from releases/1.6 - add null checks on Element/Node.is and a
test.
Modified: branches/snapshot-2009.05.12-r5406/user/build.xml
==============================================================================
--- branches/snapshot-2009.05.12-r5406/user/build.xml (original)
+++ branches/snapshot-2009.05.12-r5406/user/build.xml Tue Jun 2 14:59:18
2009
@@ -100,6 +100,15 @@
</gwt.junit>
</target>
+ <target name="pretty-test" description="Run a remote test using a
manually launched browser at the given host and path">
+ <echo message="Performing remote browser testing using a manually
launched browser" />
+ <gwt.junit test.args="${test.args} -out www -style PRETTY -web"
test.out="${junit.out}/manual" test.cases="default.web.tests" >
+ <extraclasspaths>
+ <pathelement location="${gwt.build}/out/dev/core/bin-test" />
+ </extraclasspaths>
+ </gwt.junit>
+ </target>
+
<target name="selenium-test" description="Run a remote test using
Selenium RC test at the given host and path" if="gwt.selenium.hosts">
<echo message="Performing remote browser testing using Selenium RC at
${gwt.selenium.hosts}" />
<gwt.junit test.args="${test.args} -out www -selenium
${gwt.selenium.hosts}" test.out="${junit.out}/selenium"
test.cases="default.web.tests" >
Modified:
branches/snapshot-2009.05.12-r5406/user/src/com/google/gwt/dom/client/Element.java
==============================================================================
---
branches/snapshot-2009.05.12-r5406/user/src/com/google/gwt/dom/client/Element.java
(original)
+++
branches/snapshot-2009.05.12-r5406/user/src/com/google/gwt/dom/client/Element.java
Tue Jun 2 14:59:18 2009
@@ -42,7 +42,8 @@
/**
* Determines whether the given {...@link JavaScriptObject} can be cast to
an
- * {...@link Element}.
+ * {...@link Element}. A <code>null</code> object will cause this method to
+ * return <code>false</code>.
*/
public static boolean is(JavaScriptObject o) {
if (Node.is(o)) {
@@ -53,9 +54,11 @@
/**
* Determine whether the given {...@link Node} can be cast to an {...@link
Element}.
+ * A <code>null</code> node will cause this method to return
+ * <code>false</code>.
*/
public static boolean is(Node node) {
- return node.getNodeType() == Node.ELEMENT_NODE;
+ return (node != null) && (node.getNodeType() == Node.ELEMENT_NODE);
}
protected Element() {
Modified:
branches/snapshot-2009.05.12-r5406/user/src/com/google/gwt/dom/client/Node.java
==============================================================================
---
branches/snapshot-2009.05.12-r5406/user/src/com/google/gwt/dom/client/Node.java
(original)
+++
branches/snapshot-2009.05.12-r5406/user/src/com/google/gwt/dom/client/Node.java
Tue Jun 2 14:59:18 2009
@@ -50,10 +50,12 @@
}
/**
- * Determines whether the given {...@link JavaScriptObject} is a DOM node.
+ * Determines whether the given {...@link JavaScriptObject} is a DOM node. A
+ * <code>null</code> object will cause this method to return
+ * <code>false</code>.
*/
public static native boolean is(JavaScriptObject o) /*-{
- return !!o.nodeType;
+ return (!!o) && (!!o.nodeType);
}-*/;
protected Node() {
Modified:
branches/snapshot-2009.05.12-r5406/user/test/com/google/gwt/dom/client/NodeTest.java
==============================================================================
---
branches/snapshot-2009.05.12-r5406/user/test/com/google/gwt/dom/client/NodeTest.java
(original)
+++
branches/snapshot-2009.05.12-r5406/user/test/com/google/gwt/dom/client/NodeTest.java
Tue Jun 2 14:59:18 2009
@@ -15,6 +15,7 @@
*/
package com.google.gwt.dom.client;
+import com.google.gwt.core.client.JavaScriptObject;
import com.google.gwt.junit.client.GWTTestCase;
/**
@@ -187,6 +188,19 @@
assertFalse(childDiv.isOrHasChild(div));
assertFalse(text.isOrHasChild(div));
+ }
+
+ /**
+ * Tests Element.is() and Element.as().
+ */
+ public void testIsAndAs() {
+ assertTrue(Node.is(Document.get()));
+
+ JavaScriptObject text = Document.get().createTextNode("foo");
+ assertTrue(Node.is(text));
+
+ // Node.is(null) is allowed and should return false.
+ assertFalse(Node.is(null));
}
/**
--~--~---------~--~----~------------~-------~--~----~
http://groups.google.com/group/Google-Web-Toolkit-Contributors
-~----------~----~----~----~------~----~------~--~---