Fixes for using OOPHM while developing a FF plugin, and fixes a case where
getting a property appears to succeed but returns an undefined value.

Patch by: mmstrac
Review by: jat


git-svn-id: https://google-web-toolkit.googlecode.com/svn/trunk@6009 8db76d5a-ed1c-0410-87a9-c151d255dfc7
diff --git a/plugins/xpcom/FFSessionHandler.cpp b/plugins/xpcom/FFSessionHandler.cpp
index 09fa9e1..2d74fbe 100755
--- a/plugins/xpcom/FFSessionHandler.cpp
+++ b/plugins/xpcom/FFSessionHandler.cpp
@@ -43,6 +43,11 @@
   if (NS_FAILED(stack->Peek(&cx))) {
     return NULL;
   }
+
+  if (cx == nsnull) {
+    Debug::log(Debug::Error) << "Null context" << Debug::flush;
+  }  
+
   return cx;
 }
 
@@ -80,7 +85,12 @@
 
 void FFSessionHandler::getToStringTearOff(JSContext* ctx) {
   jsval funcVal;
-  if (!JS_GetProperty(ctx, global, "__gwt_makeTearOff", &funcVal)) {
+
+  Debug::log(Debug::Debugging) << "Getting function \"__gwt_makeTearOff\""
+        << Debug::flush;
+
+  if (!JS_GetProperty(ctx, global, "__gwt_makeTearOff", &funcVal)
+      || funcVal == JSVAL_VOID) {
     Debug::log(Debug::Error) << "Could not get function \"__gwt_makeTearOff\""
         << Debug::flush;
     return;
@@ -202,8 +212,10 @@
 
   jsval funcVal;
   // TODO: handle non-ASCII method names
-  if (!JS_GetProperty(ctx, global, methodName.c_str(), &funcVal)) {
-    Debug::log(Debug::Error) << "Could not get function " << methodName << Debug::flush;
+  if (!JS_GetProperty(ctx, global, methodName.c_str(), &funcVal)
+      || funcVal == JSVAL_VOID) {
+    Debug::log(Debug::Error) << "Could not get function " << methodName
+        << Debug::flush;
     return true;
   }