Skip to main content
diff options
authorLeo Ufimtsev2017-11-06 16:52:38 +0000
committerLeo Ufimtsev2017-12-01 18:45:15 +0000
commit8009c3b86dee4f50191b785f9c121ef5cdd24746 (patch)
tree5f6294dc2ffef1f164dda77b88c91b00de2fe096 /bundles/org.eclipse.swt/Eclipse SWT Browser
parent382c1d03f132e44887b0dcb83fdb7f7578ef9db2 (diff)
Bug 510905 [Webkit2] BrowserFunction with return value back to
Javascript (PRIOR TO MERGING, SWT BINARY REPO NEEDS TO BE PATCHED) Webkit2 moved it's webprocess into a separate process. For javascript to call a function, it needs to do so via the separate process. To interact with the separate process, we need to implement a webextension, which is a separate '.so' file loaded at run time. The extension needs to reside in it's own folder otherwise webkit will try to load the other .so files as extensions. (See changes). Communication between the extension and the main process is done via a gdbus channel. Javascript/Java types are packaged into GVariants and transmitted via gdbus. Compilation of the webextension requires webkit2gtk package to be present on build servers. Tests: - All jUnits pass - SWT Snippet (307) that use BrowserFunction work. - Attached local snippet can be used to test sending various paramaters over gdbus and receiving them back prints to main webview. - Child eclipse works fine with the patch. - Afaik, no known error/warnings are produced. (If there are, let me know). This might break 32bit build of SWT though, not tested on 32 bit. Patch set log: -------------- Patchset 6: - Passing webview as string in javascript function. Patchset 8: - Implemented dynamic gdbus bindigs on SWT/Java side. Works. (fairly large patch) Patchset 9: - Implemented gdbus bindings on client side, such that it can reach server. (working) Patchset 10: - Added GVariant conversion functions on SWT side. Works. - Moved code out of to reside only in WebKitGTK Patchset 11: - Figured out how to provide return value as an object array. Added snippet to show how to provide a string return value. (working) Patchset 12: - Passed webview pointer, index and token to Java. - Fixed typo in type definition. > (Working) Patchset 13: - Now passing javascript arguments along through gdbus to java. > (Working) Patchset 14: (Week 46) - Implemented support for 'null'. (use byte as magic number). - Found that there is a bug in how I deal with return value in gdbus, gdbus returns an array (always). Need to return first item in array. Patchset 15: (Week 46) - Implemented proper return value of java to javascript. - Found that js calls with no paramaters call() fail, need to fix. Patchset 16: (Week 46) - Implemented support for empty arrays (including calls without args). - Code tidy. - Found that I need to implement input argument verification from JS call and from java code ran by user, otherwise gdbus can crash. Patchset 17: (Week 46) - Implement checking of user-input arguments, to ensure it won't break gdbus connection. Patchset 18: (Week 46) - Implemented checking of return value from userfunction, so bad return value doesn't break gdbus. - Code tidy/polish. - Need to implement lazy loading of gdbus, only init gdbus for the first function that we instantiate. - Also still getting warning when loading webkit library. Patchset 19: [Week 47] - Implemented lazy loading of gdbus, to only load when needed. - wrapped getPID() into lock, otherwise had strange debug/execution behaviour. Patchset 20: [Week 47] - Two BrowserInstances with Two BrowserFunctions seem to hang (snippet), (need to investigate) Patchset 21: [W47] - Removed redundant print statements. Cleaned up code. Patchset 22: [W47] - Moved Webkit extension initialization logic into a callback, so that it's guaranteed to be loaded at the most optimal time. (All jUnits pass). Patchset 23: [W47] - Removed redundant println. Patchset 24: [W47] - Implemented mechanism by which webextension is compiled and loaded from a folder. (This needs a patch to binary project's Patchset 25: [W47] - Code tidy. Patch complete (ish). Patchset 26: [W47] - forgot to add files to patchset 25. Patchset 27: [W47] - Verified that Browser widget will continue to work if webextension fails to load. - Added relevant warnings. Patchset 28: - Minor update on SWT_LIB_VERSIONS. Change-Id: Iccfc48bc78774ac4120aafd976186381f247c562 Signed-off-by: Leo Ufimtsev <>
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/WebBrowser.java2
1 files changed, 1 insertions, 1 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Browser/common/org/eclipse/swt/browser/ b/bundles/org.eclipse.swt/Eclipse SWT Browser/common/org/eclipse/swt/browser/
index d04ac5ccaa..8cb99b2961 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT Browser/common/org/eclipse/swt/browser/
+++ b/bundles/org.eclipse.swt/Eclipse SWT Browser/common/org/eclipse/swt/browser/
@@ -403,7 +403,7 @@ public Object evaluate (String script) throws SWTException {
BrowserFunction function = new EvaluateFunction (browser, ""); // $NON-NLS-1$
int index = getNextFunctionIndex ();
function.index = index;
- function.isEvaluate = true;
+ function.isEvaluate = true; // Note, Webkit2 doesn't use 'isEvaluate' machinery because it doesn't use a function for evaluation.
registerFunction (function);
String functionName = EXECUTE_ID + index;

Back to the top