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

Bug 543055

Summary: BrowserFunction not injected when the url is relative but contains "://"
Product: [RT] RAP Reporter: Hiromu Hota <hiromu.hota>
Component: RWTAssignee: Project Inbox <rap-inbox>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3    
Version: unspecified   
Target Milestone: 3.8   
Hardware: All   
OS: All   
See Also: https://git.eclipse.org/r/134526
https://git.eclipse.org/c/rap/org.eclipse.rap.git/commit/?id=420869781fe230fcfd0e31c069c351b454cc4c83
Whiteboard:

Description Hiromu Hota CLA 2018-12-26 19:35:33 EST
With the following example, the BrowserFunction "func" should be injected to the target url ("/get?file=file://example.com/test.csv") but it is not.

```
      Browser browser = new Browser(parent, SWT.NONE);
      browser.setUrl( "/get?file=file://example.com/test.csv" );
      new BrowserFunction( browser, "func" ) {
        @Override public Object function( Object[] arguments ) {
          return null;
        }
      };
```

The root cause can be found at https://github.com/eclipse/rap/blob/c2e5c61868ca5369a94f2c80e64ab445ef1938bc/bundles/org.eclipse.rap.rwt/js/rwt/widgets/Browser.js#L179-L180
```
        if( src.indexOf( "://" ) === -1 ) { // relative path?
          src = document.URL; // works since we only check that the domain matches
        }
        accessible = src.indexOf( this.getContentDocument().domain ) !== -1;
```

Because of the query string that contains "://", it is not recognized as a relative path.
As a result, `this._attachBrowserFunctions();` is not executed at https://github.com/eclipse/rap/blob/c2e5c61868ca5369a94f2c80e64ab445ef1938bc/bundles/org.eclipse.rap.rwt/js/rwt/widgets/Browser.js#L120.
Comment 1 Eclipse Genie CLA 2018-12-26 19:42:10 EST
New Gerrit change created: https://git.eclipse.org/r/134526