Skip to content

SWT Browser widget does not open target="_blank" links #1845

@flaviodonze

Description

@flaviodonze

Describe the bug
Up to Eclipse version 2024-12 if a link with target="_blank" was clicked within a SWT Browser widget a new window with the according link was opened. In 2024-09 this was working, after 2024-12 and with the current integration I20250218-0600 no window is opened.
This happens with the Edge -Dorg.eclipse.swt.browser.DefaultType=edge.

To Reproduce
A standalone SWT snippet to reproduce the behavior (see below).
Also attached a complete project with different target definitions (2024-09, 2024-12, 4.35-builds): browser-app.zip


Image

package browserapp;

import org.eclipse.swt.SWT;
import org.eclipse.swt.browser.Browser;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.layout.RowLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.part.ViewPart;

public class View extends ViewPart {
	public static final String ID = "browser-app.view";

	@Override
	public void createPartControl(Composite parent) {
		parent.setLayout(new RowLayout());
		Button runButton = new Button(parent, SWT.PUSH);
		runButton.setText("open");
		runButton.addSelectionListener(new SelectionAdapter() {
			@Override
			public void widgetSelected(SelectionEvent e) {
				Shell shell = new Shell(Display.getDefault().getActiveShell(), SWT.CLOSE);
				shell.setLayout(new FillLayout(SWT.HORIZONTAL));

				Browser browser = new Browser(shell, SWT.NONE);
				browser.setUrl("https://github.com/eclipse-platform/eclipse.platform.swt");
				shell.open();
			}
		});
	}

	@Override
	public void setFocus() {
	}
}

Expected behavior
target="_blank" link opens a new window.

Environment:

  1. Select the platform(s) on which the behavior is seen:
    • All OS
    • Windows
    • Linux
    • macOS
  1. Additional OS info (e.g. OS version, Linux Desktop, etc)
    Windows 11

  2. JRE/JDK version
    JDK 21.0.6

Version since
Eclipse or SWT version since when the behavior is seen: 2024-12 (4.34)

Metadata

Metadata

Assignees

No one assigned

    Labels

    edgeEdge Browser

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions