Changed the plugin code, in response to changes in HtmlUnit's internal Api in
htmlunit 2.6+

Patch by: kjin
Review (and suggestions) by: amitmanjhi



git-svn-id: https://google-web-toolkit.googlecode.com/svn/branches/farewellSwt@6309 8db76d5a-ed1c-0410-87a9-c151d255dfc7
diff --git a/dev/oophm/src/com/google/gwt/dev/shell/HostedModePluginObject.java b/dev/oophm/src/com/google/gwt/dev/shell/HostedModePluginObject.java
index 01953da..a4d15cc 100644
--- a/dev/oophm/src/com/google/gwt/dev/shell/HostedModePluginObject.java
+++ b/dev/oophm/src/com/google/gwt/dev/shell/HostedModePluginObject.java
@@ -15,6 +15,7 @@
  */
 package com.google.gwt.dev.shell;
 
+import com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine;
 import com.gargoylesoftware.htmlunit.javascript.host.Window;
 
 import net.sourceforge.htmlunit.corejs.javascript.Context;
@@ -140,10 +141,20 @@
   private Scriptable disconnectMethod;
   private Scriptable initMethod;
   private Window window;
+  private JavaScriptEngine jsEngine;
 
   private BrowserChannelClient browserChannelClient;
 
   /**
+   * Creates a HostedModePluginObject with the passed-in JavaScriptEngine.
+   * 
+   * @param jsEngine The JavaScriptEngine.
+   */
+  public HostedModePluginObject(JavaScriptEngine jsEngine) {
+    this.jsEngine = jsEngine;
+  }
+
+  /**
    * Initiate a hosted mode connection to the requested port and load the
    * requested module.
    * 
@@ -166,10 +177,10 @@
         + version + "), window=" + System.identityHashCode(window) + ")");
 
     try {
-      HtmlUnitSessionHandler htmlUnitSessionHandler = new HtmlUnitSessionHandler(window);
-      browserChannelClient = new BrowserChannelClient(
-          addressParts, url, sessionKey, module, version,
-          htmlUnitSessionHandler);
+      HtmlUnitSessionHandler htmlUnitSessionHandler = new HtmlUnitSessionHandler(
+          window, jsEngine);
+      browserChannelClient = new BrowserChannelClient(addressParts, url,
+          sessionKey, module, version, htmlUnitSessionHandler);
       htmlUnitSessionHandler.setSessionData(new SessionData(
           htmlUnitSessionHandler, browserChannelClient));
       return browserChannelClient.process();
diff --git a/dev/oophm/src/com/google/gwt/dev/shell/HtmlUnitSessionHandler.java b/dev/oophm/src/com/google/gwt/dev/shell/HtmlUnitSessionHandler.java
index 876b03d..ac44098 100644
--- a/dev/oophm/src/com/google/gwt/dev/shell/HtmlUnitSessionHandler.java
+++ b/dev/oophm/src/com/google/gwt/dev/shell/HtmlUnitSessionHandler.java
@@ -107,10 +107,10 @@
 
   private final Window window;
 
-  HtmlUnitSessionHandler(Window window) {
+  HtmlUnitSessionHandler(Window window, JavaScriptEngine jsEngine) {
     this.window = window;
     logger.setMaxDetail(TreeLogger.ERROR);
-    jsEngine = this.window.getJavaScriptEngine();
+    this.jsEngine = jsEngine;
     htmlPage = (HtmlPage) this.window.getWebWindow().getEnclosedPage();
     logger.log(TreeLogger.INFO, "jsEngine = " + jsEngine + ", HtmlPage = "
         + htmlPage);
diff --git a/user/src/com/google/gwt/junit/RunStyleHtmlUnit.java b/user/src/com/google/gwt/junit/RunStyleHtmlUnit.java
index dcf5d63..0da84e2 100644
--- a/user/src/com/google/gwt/junit/RunStyleHtmlUnit.java
+++ b/user/src/com/google/gwt/junit/RunStyleHtmlUnit.java
@@ -122,7 +122,7 @@
         webClient.setJavaScriptEngine(hostedEngine);
       }
     }
-}
+  }
 
   /**
    * JavaScriptEngine subclass that provides a hook of initializing the
@@ -143,7 +143,7 @@
       super.initialize(webWindow);
       Window window = (Window) webWindow.getScriptObject();
       window.defineProperty("__gwt_HostedModePlugin",
-          new HostedModePluginObject(), ScriptableObject.READONLY);
+          new HostedModePluginObject(this), ScriptableObject.READONLY);
     }
   }
 
@@ -184,7 +184,7 @@
   public RunStyleHtmlUnit(JUnitShell shell) {
     super(shell);
   }
-  
+
   @Override
   public boolean initialize(String args) {
     if (args == null || args.length() == 0) {
@@ -203,7 +203,7 @@
     browsers = Collections.unmodifiableSet(browserSet);
     return true;
   }
-  
+
   @Override
   public void launchModule(String moduleName) {
     for (BrowserVersion browser : browsers) {