WebPlatformForEmbedded / WPEWebKit

WPE WebKit port (downstream)
213 stars 136 forks source link

URL loading detection #1106

Closed modeveci closed 11 months ago

modeveci commented 1 year ago

The detection of a selected URL has been successfully loaded or failed to load. Available signals from webkit: notify-uri load-changed load-failed

There are 3 use-cases;

  1. notify-uri with wrong not_valid_url
  2. load-changed with WEBKIT_LOAD_STARTED
  3. notify-uri with current url (domain.com) as the new url is wrong
  4. load-failed with wrong not_valid_url

Could you please describe what is the proper way to handle success or failed url load detection? Why is there a notify-uri with current url in case of load-failed is not signalled yet?

magomez commented 1 year ago

@modeveci, in which version of wpe is this reproducible?

modeveci commented 1 year ago

wpe-2.38 and prior versions

rychem commented 1 year ago

@magomez @modeveci would you be kind to share any update for this ticket?

magomez commented 1 year ago

I've been giving a look to the sequence of signals that are emitted in both of the cases that you comment. As you mention, for the valid URL case, we get the notify-uri signal with the new URL, and then the load-changed one three times, for WEBKIT_LOAD_STARTED, WEBKIT_LOAD_COMMITTED and WEBKIT_LOAD_FINISHED.

For the wrong URL case, we have:

So, ir order to know whether the page was able to load or not.

It may happen that a redirect can change the URL we're trying to load. In that case, the view's URL will change to reflect the redirected one, and you'll get a load-changed signal with WEBKIT_LOAD_REDIRECTED. In that case, you have to take into account that the load-failed signal will come for the redirected URL and not the original one, or that the URL that you get with webkit_web_view_get_uri() is the redirected one as well.

magomez commented 1 year ago

One detail more, in case it's interesting for you. The load-failed callback returns a gboolean. By returning TRUE, the default handler is not executed, and you have the behavior that you explained. If that callback returns FALSE, then the default handler is executed after your callback, which loads an error page. In this case you'll have the same behavior than before, but there will be some extra signals that correspond to the error page that's shown:

modeveci commented 11 months ago

Thank you @magomez for info. Closing the ticket!