Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spawn new Firefox for external page links utilizing MimeType=x-scheme-handler/extlink #428

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

KKoukiou
Copy link
Contributor

@KKoukiou KKoukiou commented Sep 4, 2024

AwesomeScreenshot-10_9_2024.6_00_35PM.webm

@KKoukiou KKoukiou marked this pull request as draft September 4, 2024 11:26
@stransky
Copy link

How do you have configured the launcher? And how do you open the external link? Please try to run on terminal

xdg-open your_link

are there more firefox instances run?

@stransky
Copy link

Please attach your config files for the x-scheme-handler/extlink here, thanks.

@KKoukiou
Copy link
Contributor Author

@stransky After some debugging I figured out the the reason for the 'double windows' was a 'target="_blank"' attribute in the link definition.

@stransky
Copy link

@stransky After some debugging I figured out the the reason for the 'double windows' was a 'target="_blank"' attribute in the link definition.

Awesome!

@KKoukiou KKoukiou force-pushed the firefox-extlink branch 7 times, most recently from 4542f9f to b419010 Compare September 13, 2024 14:44
@KKoukiou KKoukiou marked this pull request as ready for review September 13, 2024 14:45
@KKoukiou KKoukiou removed the no-test label Sep 13, 2024
@KKoukiou
Copy link
Contributor Author

KKoukiou commented Sep 13, 2024

@stransky is almost works nice, just one last detail that I was not able to figure out yet. Maybe you have it easier.
href links that are clicked are working as expected, with opening the extlink links into the new browser window.

However, we have for the 'Report a bug' dialog another way to open the link to bugzilla, with the filled report.

This uses window.open("https://bugzilla.redhat.com.. following the details of the bug filled it.

I replaced the https with extlink like in the hrefs, and this indeed opens a new browser window, but additionaly it opens a blank tab in the current anaconda-webui browser.

I can easily reproduce if I write window.open("extlink://github.com") in the anaconda-webui browser console.

Any suggestions what is the difference between href link handling and window.open.

Thanks in advance.

~~
/Update:
I thought initially it's because of the missing href in the link. But it seems unrealated.
~~

@KKoukiou KKoukiou force-pushed the firefox-extlink branch 5 times, most recently from c709c45 to 8ea67b6 Compare September 17, 2024 08:15
@KKoukiou
Copy link
Contributor Author

@stransky can you take a look at #428 (comment) please for some hint?

@stransky
Copy link

Yes will look at it.

@KKoukiou
Copy link
Contributor Author

Yes will look at it.

@stransky friendly reminder that I still need some help hear when you dont have your hands full (Just in case it fell through :))

@stransky
Copy link

Sorry for the delay, will look at it.

@stransky
Copy link

stransky commented Sep 25, 2024

Can you post me an example of the broken link which creates extra tab? I tested it and I can't reproduce. I tested random concur link like:
<a href="extlink://us2.concursolutions.com/nui/signin?targetURL=%2Fnui%2Fexpense%2Freport%2F3F3ED96FABE14717B07B">External launcher 2</a>
an it works as expected.

@stransky
Copy link

Please share full href link which is broken for you.
Thanks.

@KKoukiou
Copy link
Contributor Author

@stransky links with href work as expected. (See comment #428 (comment))

The problem is that we have one Link in the UI - where we need cant specify href (<a href=...) but instead we asynchronously run window.open with the onClick event.

This causes the problem. You can easily reproduce if you write window.open("extlink://github.com") in the anaconda-webui browser console.

@stransky
Copy link

Can you attach the webpage you use which contains the window.open() code?

@KKoukiou
Copy link
Contributor Author

Can you attach the webpage you use which contains the window.open() code?

The window.open is ran from the browser console where Web UI runs. How do you want me to attach that web page?

@stransky
Copy link

If you ask users to submit the bug report, which HTML/JS construction is used by Web UI HTML code to perform it? Does the Web UI HTML page contains something like:

<input type='button' value='Submit' onclick='window.open("extlink://github.com")'>
or so?

Or do you ask users to open browser console and type window.open() there?

@KKoukiou
Copy link
Contributor Author

@stransky oh sure - it's a <a onclick='window.open("extlink://github.com")'>

@stransky
Copy link

stransky commented Sep 25, 2024

<a onclick='window.open("extlink://github.com")'>
doesn't produce any visible HTML element which can be clicked on. Are you sure it's correct? Please provide me complete HTML code of the page. Thanks.

@stransky
Copy link

Okay, I expect you use something like
<a onclick='window.open("extlink://github.com")'>Submit</a>

@stransky
Copy link

You may use window.location.replace() instead of open():
<a onclick='window.location.replace("extlink://github.com")'>Submit</a>

@KKoukiou
Copy link
Contributor Author

<a onclick='window.open("extlink://github.com")'> doesn't produce any visible HTML element which can be clicked on. Are you sure it's correct? Please provide me complete HTML code of the page. Thanks.

The HTML content as copied as from browser is:

<a aria-disabled="false" class="pf-v5-c-button pf-m-primary pf-m-progress" data-ouia-component-type="PF5/Button" data-ouia-safe="true" data-ouia-component-id="OUIA-Generated-Button-primary-2"><span class="pf-v5-c-button__icon pf-m-start"><svg class="pf-v5-svg" viewBox="0 0 512 512" fill="currentColor" aria-hidden="true" role="img" width="1em" height="1em"><path d="M432,320H400a16,16,0,0,0-16,16V448H64V128H208a16,16,0,0,0,16-16V80a16,16,0,0,0-16-16H48A48,48,0,0,0,0,112V464a48,48,0,0,0,48,48H400a48,48,0,0,0,48-48V336A16,16,0,0,0,432,320ZM488,0h-128c-21.37,0-32.05,25.91-17,41l35.73,35.73L135,320.37a24,24,0,0,0,0,34L157.67,377a24,24,0,0,0,34,0L435.28,133.32,471,169c15,15,41,4.5,41-17V24A24,24,0,0,0,488,0Z"></path></svg></span>Report issue</a>

Trying your suggestion thanks :)

@stransky
Copy link

btw. It took me 2 mins with google, the answer is right here:
https://stackoverflow.com/questions/8454510/open-url-in-same-window-and-in-same-tab

* Extended firefox-theme to include an extlink profile for opening external links.
* Disabled the popup asking for verification by using dom.disable_beforeunload,
  preventing the confirmation dialog when closing the window.
* Removed the custom window.onbeforeunload = () => "";, as it interfered with the
  external window opening behavior.

Note: A new approach will be needed to prevent the window from closing, as the previous method is no longer in use.
@KKoukiou
Copy link
Contributor Author

This is ready for review.

@garrett
Copy link
Contributor

garrett commented Sep 30, 2024

Err uh... that's completely invalid HTML...

 <a onclick='window.location.replace("extlink://github.com")'>Submit</a>

An anchor tag needs either a name if it's being linked to (but this is a deprecated usage) or an href. No exceptions.

This can only be written as <a href="https://github.com/" target="_blank">Demo</a> and then you could hijack it with JS, but it must have an href, and it needs to have a target when it's in-browser, especially since we're intending on this being used from a remote browser someday.

If it's supposed to be a button, then it should be a button. But it cannot be an <a> like this. https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#onclick_events

@stransky
Copy link

Err uh... that's completely invalid HTML...

 <a onclick='window.location.replace("extlink://github.com")'>Submit</a>

An anchor tag needs either a name if it's being linked to (but this is a deprecated usage) or an href. No exceptions.

This is just an example how replace window.open() with window.location.replace() to open a link in the same window. I guess you can incorporate it to WebUI accordingly.

@garrett
Copy link
Contributor

garrett commented Sep 30, 2024

Right, it's an example, but it's definite not an example of valid HTML, and not really the right way to do things.

@KKoukiou KKoukiou removed the no-test label Oct 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants