diff options
Diffstat (limited to 'bundles/org.eclipse.swt/Eclipse SWT Browser/common/org/eclipse/swt/browser/Browser.java')
-rw-r--r-- | bundles/org.eclipse.swt/Eclipse SWT Browser/common/org/eclipse/swt/browser/Browser.java | 52 |
1 files changed, 51 insertions, 1 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Browser/common/org/eclipse/swt/browser/Browser.java b/bundles/org.eclipse.swt/Eclipse SWT Browser/common/org/eclipse/swt/browser/Browser.java index 4ade087959..03cb1201c5 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT Browser/common/org/eclipse/swt/browser/Browser.java +++ b/bundles/org.eclipse.swt/Eclipse SWT Browser/common/org/eclipse/swt/browser/Browser.java @@ -606,8 +606,58 @@ public boolean close () { */ public Object evaluate (String script) throws SWTException { checkWidget(); + return evaluate (script, false); +} + +/** + * Returns the result, if any, of executing the specified script. + * <p> + * Evaluates a script containing javascript commands in the context of + * the current document. If document-defined functions or properties + * are accessed by the script then this method should not be invoked + * until the document has finished loading (<code>ProgressListener.completed()</code> + * gives notification of this). + * </p><p> + * If the script returns a value with a supported type then a java + * representation of the value is returned. The supported + * javascript -> java mappings are: + * <ul> + * <li>javascript null or undefined -> <code>null</code></li> + * <li>javascript number -> <code>java.lang.Double</code></li> + * <li>javascript string -> <code>java.lang.String</code></li> + * <li>javascript boolean -> <code>java.lang.Boolean</code></li> + * <li>javascript array whose elements are all of supported types -> <code>java.lang.Object[]</code></li> + * </ul> + * The <code>trusted</code> parameter affects the security context the script will be executed in. + * Specifying <code>true</code> for trusted executes in chrome security context <code>false</code> for trusted + * runs in normal security context. + * + * An <code>SWTException</code> is thrown if the return value has an + * unsupported type, or if evaluating the script causes a javascript + * error to be thrown. + * + * @param script the script with javascript commands + * @param trusted <code>false</code> if the rendered page should be granted restricted + * + * @return the return value, if any, of executing the script + * + * @exception IllegalArgumentException <ul> + * <li>ERROR_NULL_ARGUMENT - if the script is null</li> + * </ul> + * + * @exception SWTException <ul> + * <li>ERROR_FAILED_EVALUATE when the script evaluation causes a javascript error to be thrown</li> + * <li>ERROR_INVALID_RETURN_VALUE when the script returns a value of unsupported type</li> + * <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li> + * <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li> + * </ul> + * + * @see ProgressListener#completed(ProgressEvent) + */ +public Object evaluate (String script, boolean trusted) throws SWTException { + checkWidget(); if (script == null) SWT.error (SWT.ERROR_NULL_ARGUMENT); - return webBrowser.evaluate (script); + return webBrowser.evaluate (script, trusted); } /** |