| Summary: | [Browser][Xulrunner] When browser is using XULRunner, the browser.evaluate function is always returning null | ||||||
|---|---|---|---|---|---|---|---|
| Product: | [Eclipse Project] Platform | Reporter: | Sravan Kumar Lakkimsetti <sravankumarl> | ||||
| Component: | SWT | Assignee: | Lakshmi P Shanmugam <lshanmug> | ||||
| Status: | VERIFIED FIXED | QA Contact: | |||||
| Severity: | normal | ||||||
| Priority: | P3 | CC: | arunkumar.thondapu, lshanmug, matthew.painter, nathaniel.gibson, niraj.modi | ||||
| Version: | 4.5 | Flags: | niraj.modi:
review+
arunkumar.thondapu: review+ |
||||
| Target Milestone: | 4.5 RC1 | ||||||
| Hardware: | PC | ||||||
| OS: | All | ||||||
| See Also: |
https://bugs.eclipse.org/bugs/show_bug.cgi?id=421905 https://bugs.eclipse.org/bugs/show_bug.cgi?id=429739 https://git.eclipse.org/r/47880 https://git.eclipse.org/r/47883 https://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/?id=6b28578ec575cf9b9bc42578b2cd2a249f83e1ad https://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/?id=6a69a1fd95a7e88062f2270d5c638a035c824208 |
||||||
| Whiteboard: | |||||||
| Bug Depends on: | |||||||
| Bug Blocks: | 437700 | ||||||
| Attachments: |
|
||||||
|
Description
Sravan Kumar Lakkimsetti
(In reply to Sravan Kumar Lakkimsetti from comment #0) > Tested this using Snippet308. This particular problem happens with Xulrunner > 10, xulrunner 24. doesnot happen with Xulrunner 1.9. Similar behavior on Windows as well, Snippet308 works with xulrunner1.9.2 only and not with xulrunner24, xulrunner10 & xulrunner1.9.1 (In reply to Niraj Modi from comment #1) > (In reply to Sravan Kumar Lakkimsetti from comment #0) > > Tested this using Snippet308. This particular problem happens with Xulrunner > > 10, xulrunner 24. doesnot happen with Xulrunner 1.9. > > Similar behavior on Windows as well, Snippet308 works with xulrunner1.9.2 > only and not with xulrunner24, xulrunner10 & xulrunner1.9.1 Same problem on Mac too. Using Browser.evaluate(script, false) works. *** Bug 421905 has been marked as a duplicate of this bug. *** If you run a script with elevated security in XUL >=24, you will need to use window.document rather than just document, as the script is not run within the context of the window, rather in the context of the chrome. (In reply to Matt Painter from comment #4) > If you run a script with elevated security in XUL >=24, you will need to use > window.document rather than just document, as the script is not run within > the context of the window, rather in the context of the chrome. Also, there should be no change in behaviour for XUL<24: https://github.com/eclipse/eclipse.platform.swt/blob/1343f2a0af658526a93fb8a0e3f0af288c7972f2/bundles/org.eclipse.swt/Eclipse%20SWT%20Mozilla/common/org/eclipse/swt/browser/Mozilla.java#L1399 It was decided that the "trusted" value should default to true, but I was lobbying for it to false by default because it was the most secure and compatible with existing code (e.g. window.document vs document) (In reply to Matt Painter from comment #5) > (In reply to Matt Painter from comment #4) > > If you run a script with elevated security in XUL >=24, you will need to use > > window.document rather than just document, as the script is not run within > > the context of the window, rather in the context of the chrome. > > Also, there should be no change in behaviour for XUL<24: > > https://github.com/eclipse/eclipse.platform.swt/blob/ > 1343f2a0af658526a93fb8a0e3f0af288c7972f2/bundles/org.eclipse.swt/ > Eclipse%20SWT%20Mozilla/common/org/eclipse/swt/browser/Mozilla.java#L1399 > > It was decided that the "trusted" value should default to true, but I was > lobbying for it to false by default because it was the most secure and > compatible with existing code (e.g. window.document vs document) The main idea behind having "trusted" = true as the default behavior is to make sure that we don't break the existing client code that uses evaluate() API. Existing client code using evaluate can run script with chrome code with XUL < 24. So, the idea was to keep the same behavior for XUL >= 24. But, I'm not sure if it is right to require that the existing code be modified for evaluate(script) to work.
> The main idea behind having "trusted" = true as the default behavior is to
> make sure that we don't break the existing client code that uses evaluate()
> API.
> Existing client code using evaluate can run script with chrome code with XUL
> < 24. So, the idea was to keep the same behavior for XUL >= 24.
> But, I'm not sure if it is right to require that the existing code be
> modified for evaluate(script) to work.
IMHO it should be changed so trusted=false by default; the only client code this would require changing is code requiring chrome-level privileges *when* the client app upgrades their XUL version (which as someone with a client app I find reasonable). Most people are just going to be running DOM-level code.
Proposed approach to the fix looks good. Created attachment 253457 [details]
modified evaluate(script)
The javadoc of evaluate(script) mentions that the script is executed in the context of the current document. Modified evaluate(script) so that the behavior is as per javadoc.
New Gerrit change created: https://git.eclipse.org/r/47881 New Gerrit change created: https://git.eclipse.org/r/47880 Arun, can you please review the 2 patches. https://git.eclipse.org/r/47881 is to fix the issue for versions < 24. https://git.eclipse.org/r/47881 is to fix the issue for versions >= 24. New Gerrit change created: https://git.eclipse.org/r/47883 (In reply to Lakshmi Shanmugam from comment #12) > Arun, can you please review the 2 patches. > https://git.eclipse.org/r/47881 is to fix the issue for versions < 24. > https://git.eclipse.org/r/47881 is to fix the issue for versions >= 24. Correction https://git.eclipse.org/r/47880 is to fix the issue for versions < 24. https://git.eclipse.org/r/47883 is to fix the issue for versions >= 24. (In reply to Lakshmi Shanmugam from comment #14) > (In reply to Lakshmi Shanmugam from comment #12) > > Arun, can you please review the 2 patches. > > https://git.eclipse.org/r/47881 is to fix the issue for versions < 24. > > https://git.eclipse.org/r/47881 is to fix the issue for versions >= 24. > Correction > https://git.eclipse.org/r/47880 is to fix the issue for versions < 24. > https://git.eclipse.org/r/47883 is to fix the issue for versions >= 24. I've reviewed them and both patches look good for merging. Gerrit change https://git.eclipse.org/r/47880 was merged to [master]. Commit: http://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/?id=6b28578ec575cf9b9bc42578b2cd2a249f83e1ad Gerrit change https://git.eclipse.org/r/47883 was merged to [master]. Commit: http://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/?id=6a69a1fd95a7e88062f2270d5c638a035c824208 (In reply to Arun Thondapu from comment #15) > (In reply to Lakshmi Shanmugam from comment #14) > > (In reply to Lakshmi Shanmugam from comment #12) > > > Arun, can you please review the 2 patches. > > > https://git.eclipse.org/r/47881 is to fix the issue for versions < 24. > > > https://git.eclipse.org/r/47881 is to fix the issue for versions >= 24. > > Correction > > https://git.eclipse.org/r/47880 is to fix the issue for versions < 24. > > https://git.eclipse.org/r/47883 is to fix the issue for versions >= 24. > > I've reviewed them and both patches look good for merging. Thanks Arun! I've verified the fix with I20150513-2000 on Mac and XULRunner 24 & 31. I've verified the fix with I20150513-2000 on linux with xulrunner 10 and 24 |