Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 334221

Summary: [Browser] evaluate(script) loses return value
Product: [RT] RAP Reporter: Dominik G. <digga1404>
Component: RWTAssignee: Project Inbox <rap-inbox>
Status: RESOLVED FIXED QA Contact:
Severity: major    
Priority: P3    
Version: 1.4   
Target Milestone: 1.4 M5   
Hardware: All   
OS: All   
Whiteboard:

Description Dominik G. CLA 2011-01-13 02:50:12 EST
The parseArguments() method of the BrowserLCA class returns the wrong value if there are '"' chars inside 
the returned result String of a script that is executed by the evaluate() function of the Browser class. 
I think the value returned by 
 WidgetLCAUtil.readPropertyValue( browser, PARAM_EVALUATE_RESULT )
is already wrong.  

Environment: Firefox 3.6.13 on Win7

The bug occurs using RAP 1.4 M4

Steps to reproduce (using the snippet below):
* press the test button
* look at the console
-> console content
<a>123,456</a>
null
<a id='xyz'>123,456</a>


Expected:
<a>123,456</a>
<a id="xyz">123,456</a>
<a id='xyz'>123,456</a>


Here is the snippet to reproduce:

import org.eclipse.rwt.lifecycle.IEntryPoint;
import org.eclipse.swt.SWT;
import org.eclipse.swt.browser.Browser;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;

public class BrowserEvaluateSnippet implements IEntryPoint {

	public int createUI() {
		Display display = new Display();
		Shell shell = new Shell(display, SWT.TITLE);
		createContent(shell);
		shell.layout();
		shell.open();

		while (!shell.isDisposed()) {
			if (!display.readAndDispatch()) {
				display.sleep();
			}
		}
		return 0;
	}

	private void createContent(Shell shell) {
		shell.setLayout(new GridLayout(1, false));

		final Browser browser = new Browser(shell, SWT.NONE);
		browser.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
		browser.setText("<html></html>");

		Button button = new Button(shell, SWT.PUSH);
		button.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false));
		button.setText("Test");

		button.addSelectionListener(new SelectionListener() {

			public void widgetSelected(SelectionEvent e) {
				doit();
			}

			public void widgetDefaultSelected(SelectionEvent e) {
				doit();
			}

			private void doit() {
				System.err.println(browser.evaluate("return '<a>123,456</a>';"));
				System.err.println(browser.evaluate("return '<a id=\"xyz\">123,456</a>';"));
				System.err.println(browser.evaluate("return \"<a id='xyz'>123,456</a>\";"));
			}

		});
	}

}
Comment 1 Ivan Furnadjiev CLA 2011-01-13 04:33:35 EST
Fixed in CVS HEAD. Test added for Browser.js#objectToString method.