Community
Participate
Working Groups
For use by Mylar web connector we'd need access to the org.eclipse.swt.browser.Browser's session information- namely cookies. Also interesting might be DOM access via api. While the execute() method allows javascript execution, it does not return any data. Thanks, Andreas
There is an existing request for Browser DOM access via Browser api, see bug 57477. There are currently two other ways to accomplish this: 1. execute() can be used as demonstrated in (yes they're hacky): -> http://dev.eclipse.org/viewcvs/index.cgi/%7Echeckout%7E/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet160.java -> http://dev.eclipse.org/viewcvs/index.cgi/%7Echeckout%7E/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet161.java 2. Use a SWT.MOZILLA-style Browser instead and do it via JavaXPCOM. Removing DOM from the title since bug 57477 already exists for this.
Grant, can you please elaborate how can we set cookies into the browser instance before opening some external url?
Comment 1 discusses accessing the browser's DOM. I don't think there's currently a way to set cookies in the Browser, except: 1. If javascript can do this then execute() may be your friend here (may need to set url to about:blank first). 2. The Silver Bullet, a SWT.MOZILLA-style Browser + JavaXPCOM could probably do this.
I am not a javascript expert, but the problem with setting cookies from javascript before loading page is the browser's own security restrictions, so it won't allow to set cookies from the code loaded from some foreign domain. I also been told that SWT.MOZILLA browser is not reliable yet comparing to the old browser.
The ugly (but sofar only?) way working around this would be to navigate to the target repository, set cookie information and reload page. Similarly, when browser widget is closed, last action should be to read the cookie information- if URL is still within the original starting domain and/or path.
Wau! I didn't think of such multistep process. Though it is still unclear how would we know that page need to be reloaded? Seems like it would require to track all pages that don't have cookies set.
Mhhm. I was imagining this process (for editing the bug): 1) open browser at web repository url; use addProgressListener(ProgressListener) to get notified about load finished. Widget might be invisble at that time 2) use execute() to set the cookies using javascript setCookie(), check http://techpatterns.com/downloads/javascript_cookies.php 3) repeat step 1), widget is visible now 4) user does whatever- we'll need to listen for widget destruction or navigation events through ProgressListener 5) if widget is closed or navigated, we use execute() again to get the current cookies and associate them with the repository This should be enough for a 90% solution of handling simple login?
Btw this is not only needed for web connector, but for all connectors- e.g. bugzilla when voting.
The Mylar connector specific stuff should probably be discussed on bug 163120.
*** Bug 83420 has been marked as a duplicate of this bug. ***
Cookie API was added in 3.5M6 (Browser.get/setCookie()). Also note that new API Browser.evaluate() will evaluate a JS string and return the result.