Bug 433400 - SWT Snippet308 fails with IBM JRE

Change-Id: Ica24808e705e9c57a7a3b95bd34e4e7d19837901
Signed-off-by: Niraj Modi <niraj.modi@in.ibm.com>
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Browser/win32/org/eclipse/swt/browser/IE.java b/bundles/org.eclipse.swt/Eclipse SWT Browser/win32/org/eclipse/swt/browser/IE.java
index 8690246..a02a3c1 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT Browser/win32/org/eclipse/swt/browser/IE.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Browser/win32/org/eclipse/swt/browser/IE.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2003, 2013 IBM Corporation and others.
+ * Copyright (c) 2003, 2014 IBM Corporation and others.
  * All rights reserved. This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License v1.0
  * which accompanies this distribution, and is available at
@@ -602,6 +602,21 @@
 							if (browser.isDisposed()) return;
 
 							/*
+							* With the IBM 64-bit JVM an unexpected document complete event occurs before
+							* the native browser's DOM has been built. Filter this premature event based
+							* on the browser's ready state.
+							*/
+							int[] rgdispid = auto.getIDsOfNames(new String[] { "ReadyState" }); //$NON-NLS-1$
+							Variant pVarResult = auto.getProperty(rgdispid[0]);
+							if (pVarResult != null) {
+								int readyState = pVarResult.getInt();
+								pVarResult.dispose ();
+								if (readyState != READYSTATE_COMPLETE) {
+									break;
+								}
+							}
+
+							/*
 							 * Note.  The completion of the page loading is detected as
 							 * described in the MSDN article "Determine when a page is
 							 * done loading in WebBrowser Control".