Closed
Description
Links are not opened if xterm.js is inside an iframe on safari.
Details
- Safari Version 14.1.1 (16611.2.7.1.4)
- Mac OS Big Sur, Version 1.4 (20F71):
- "xterm": "4.16.0",
"xterm-addon-web-links": "0.5.0"
Steps to reproduce
- Install
xterm-addon-web-links
extension - Open
xterm.js
instance in an iframe - Set permissions to an iframe to allow popups and scripts:
sandbox="allow-top-navigation-by-user-activation allow-popups allow-popups-to-escape-sandbox allow-scripts"
- Type any website name, f.e
https://google.com
- Hover and click on the link above
This is caused by setting window.opener = null
. What is the value of opening a windows and setting URL separately? It could be smth like this (i anyway don't need a window without a URL opened).function handleLink(event: MouseEvent, uri: string): void {
try {
window.open(uri, 'noopener');
} catch (error){
console.warn('Opening link blocked due to: ', error);
}
}
Minimalistic example to reproduce same behaviour without xterm.js:
index.html
<!DOCTYPE html>
<html>
<body>
<button onclick="newWindow = window.open(); newWindow.opener = null; newWindow.location.href='https://google.com' ">Button doesn't open a URL</button>
<button onclick="window.open('https://google.com', 'noopener')">Button opens a URL</button>
</body>
</html>
iframe.html
<!DOCTYPE html>
<html>
<body>
<iframe
src="index.html"
sandbox="allow-top-navigation-by-user-activation allow-popups allow-popups-to-escape-sandbox allow-scripts">
</iframe>
</body>
</html>