Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLakshmi Shanmugam2015-03-18 12:02:22 +0000
committerLakshmi Shanmugam2015-03-18 12:02:37 +0000
commit6608b0af915e3e359127fb98e6d8ba6099381359 (patch)
tree0ea405155c109c647e721c542eae3bd3d5be37b9 /bundles/org.eclipse.swt/Eclipse SWT Browser
parent5a2233010f7e94fd6c1309096fb18e83dc79b8ce (diff)
downloadeclipse.platform.swt-6608b0af915e3e359127fb98e6d8ba6099381359.tar.gz
eclipse.platform.swt-6608b0af915e3e359127fb98e6d8ba6099381359.tar.xz
eclipse.platform.swt-6608b0af915e3e359127fb98e6d8ba6099381359.zip
Bug 429739 - Permission denied to access property ''
Move API to browser class
Diffstat (limited to 'bundles/org.eclipse.swt/Eclipse SWT Browser')
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT Browser/common/org/eclipse/swt/browser/Browser.java52
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT Browser/common/org/eclipse/swt/browser/WebBrowser.java5
2 files changed, 56 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);
}
/**
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Browser/common/org/eclipse/swt/browser/WebBrowser.java b/bundles/org.eclipse.swt/Eclipse SWT Browser/common/org/eclipse/swt/browser/WebBrowser.java
index 5870984d24..eec950e9a3 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT Browser/common/org/eclipse/swt/browser/WebBrowser.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Browser/common/org/eclipse/swt/browser/WebBrowser.java
@@ -390,6 +390,11 @@ public void destroyFunction (BrowserFunction function) {
public abstract boolean execute (String script);
+public Object evaluate (String script, boolean trusted) {
+ if (!trusted) return evaluate(script);
+ return null;
+}
+
public Object evaluate (String script) throws SWTException {
BrowserFunction function = new EvaluateFunction (browser, ""); // $NON-NLS-1$
int index = getNextFunctionIndex ();

Back to the top