Bug 206217 - Substitute data lost after reload
Summary: Substitute data lost after reload
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: Page Loading (show other bugs)
Version: Other
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-01-14 01:04 PST by Alexander Kurtakov
Modified: 2020-01-27 16:04 PST (History)
14 users (show)

See Also:


Attachments
Snippet to reproduce (1.63 KB, text/x-csrc)
2020-01-14 01:05 PST, Alexander Kurtakov
no flags Details
Initial browser window (10.45 KB, image/png)
2020-01-14 01:07 PST, Alexander Kurtakov
no flags Details
Window after reload (94.22 KB, image/png)
2020-01-14 01:07 PST, Alexander Kurtakov
no flags Details
Patch (17.25 KB, patch)
2020-01-24 04:42 PST, Carlos Garcia Campos
no flags Details | Formatted Diff | Diff
Patch (17.25 KB, patch)
2020-01-24 04:45 PST, Carlos Garcia Campos
mcatanzaro: review-
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Alexander Kurtakov 2020-01-14 01:04:30 PST
How to reproduce:
1.Run the attached snippet.
2. Observe "Hello World" displayed in the window
3. Right click and from the context menu choose reload.
4. Content changes to file browser displaying content of /

Expected result:
Hello World still displayed.
Comment 1 Alexander Kurtakov 2020-01-14 01:05:23 PST
Created attachment 387630 [details]
Snippet to reproduce
Comment 2 Alexander Kurtakov 2020-01-14 01:07:07 PST
Created attachment 387631 [details]
Initial browser window
Comment 3 Alexander Kurtakov 2020-01-14 01:07:36 PST
Created attachment 387632 [details]
Window after reload
Comment 4 Alexander Kurtakov 2020-01-14 01:14:53 PST
Happens on Fedora 31 with webkit2gtk3-2.26.2-1.fc31.x86_64 but I got reports that it happens on Fedora 30 too.
Initially reported as https://bugs.eclipse.org/bugs/show_bug.cgi?id=558846
Comment 5 Carlos Garcia Campos 2020-01-24 04:37:37 PST
This is not port specific.
Comment 6 Carlos Garcia Campos 2020-01-24 04:42:05 PST
Created attachment 388675 [details]
Patch
Comment 7 Carlos Garcia Campos 2020-01-24 04:45:10 PST
Created attachment 388676 [details]
Patch
Comment 8 Michael Catanzaro 2020-01-24 07:20:12 PST
Comment on attachment 388676 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=388676&action=review

Nice tests! (As usual.)

I notice the red EWS are all failing on preexisting/unrelated contentfiltering layout test failures. Looks like the Mac test results are just in bad state ATM.

> Tools/TestWebKitAPI/Tests/WebKitGLib/TestLoaderClient.cpp:239
> +    webkit_web_view_set_custom_charset(test->m_webView, "utf8");

I guess you're testing the reload that occurs when you change the charset? That's far from obvious, so it could use a comment.
Comment 9 Alex Christensen 2020-01-24 11:19:07 PST
(In reply to Michael Catanzaro from comment #8)
> I notice the red EWS are all failing on preexisting/unrelated
> contentfiltering layout test failures. Looks like the Mac test results are
> just in bad state ATM.
This is not true.  Those are regressions from this patch.  Content filtering uses document loaders and substitute data, and calls reload in PolicyChecker::checkNavigationPolicy

This patch is an API-breaking change which changes behavior that has existed for many, many years.  I don't think we want to do it.

If you load a string that has <script>window.location.reload(true)</script> do we want to change that, too?
Comment 10 Michael Catanzaro 2020-01-24 11:40:17 PST
Comment on attachment 388676 [details]
Patch

Sorry, I checked the waterfall and noticed the Mac bots were in bad state, but didn't check to see the exact test failures.
Comment 11 Michael Catanzaro 2020-01-24 11:43:02 PST
(In reply to Alex Christensen from comment #9)
> This patch is an API-breaking change which changes behavior that has existed
> for many, many years.  I don't think we want to do it.

The current behavior is clearly wrong, though. If we reload the page we should reload the current data.

> If you load a string that has <script>window.location.reload(true)</script>
> do we want to change that, too?

It would be a silly thing to do, but why treat it any differently from loading a normal webpage that does that?
Comment 12 Michael Catanzaro 2020-01-24 14:53:31 PST
(In reply to Michael Catanzaro from comment #11)
> The current behavior is clearly wrong, though. If we reload the page we
> should reload the current data.

Actually maybe you're right. If we reload the substitute data, then, for example, we'd wind up reloading an error page instead of attempting to actually reload the page. I bet that would break both Safari and Epiphany.
Comment 13 Michael Catanzaro 2020-01-24 18:00:41 PST
Comment on attachment 388676 [details]
Patch

After thinking more about this, I'm pretty sure Alex is right. Trying to change this could break a lot of things. Carlos, do you agree?
Comment 14 Carlos Garcia Campos 2020-01-27 00:28:52 PST
(In reply to Michael Catanzaro from comment #12)
> (In reply to Michael Catanzaro from comment #11)
> > The current behavior is clearly wrong, though. If we reload the page we
> > should reload the current data.
> 
> Actually maybe you're right. If we reload the substitute data, then, for
> example, we'd wind up reloading an error page instead of attempting to
> actually reload the page. I bet that would break both Safari and Epiphany.

Right, in case of having alternate URL we should always load the alternate URL.
Comment 15 Carlos Garcia Campos 2020-01-27 00:30:31 PST
(In reply to Michael Catanzaro from comment #13)
> Comment on attachment 388676 [details]
> Patch
> 
> After thinking more about this, I'm pretty sure Alex is right. Trying to
> change this could break a lot of things. Carlos, do you agree?

I don't mind, TBH, I was just trying to fix this bug. Current behavior doesn't look right for sure, but maybe we can just ignore reloads instead of loading the base URL if we don't want to reload the substituted data.
Comment 16 Michael Catanzaro 2020-01-27 06:41:36 PST
(In reply to Carlos Garcia Campos from comment #15)
> I don't mind, TBH, I was just trying to fix this bug. Current behavior
> doesn't look right for sure,

It doesn't look right when looking at this example, but it's easy to see why we can't change it.

> but maybe we can just ignore reloads instead of
> loading the base URL if we don't want to reload the substituted data.

Say the user hits bug #203620, or a random network failure, or other spurious error, and winds up viewing a network error page. Do you want refresh to be ignored, or to reload the network error page? Of course not: you want it to try reloading the original page. Displaying error pages is even the documented use-case of webkit_web_view_load_alternate_html(). What we need here is better documentation to clarify that the alternate data will not be used when reloaded and that the application is responsible for handling that if required. Or, if this is really important, we could add new API to let the API user choose, but I doubt it's that important.
Comment 17 Carlos Garcia Campos 2020-01-27 06:45:40 PST
(In reply to Michael Catanzaro from comment #16)
> (In reply to Carlos Garcia Campos from comment #15)
> > I don't mind, TBH, I was just trying to fix this bug. Current behavior
> > doesn't look right for sure,
> 
> It doesn't look right when looking at this example, but it's easy to see why
> we can't change it.
> 
> > but maybe we can just ignore reloads instead of
> > loading the base URL if we don't want to reload the substituted data.
> 
> Say the user hits bug #203620, or a random network failure, or other
> spurious error, and winds up viewing a network error page. Do you want
> refresh to be ignored, or to reload the network error page? Of course not:
> you want it to try reloading the original page. Displaying error pages is
> even the documented use-case of webkit_web_view_load_alternate_html(). What
> we need here is better documentation to clarify that the alternate data will
> not be used when reloaded and that the application is responsible for
> handling that if required. Or, if this is really important, we could add new
> API to let the API user choose, but I doubt it's that important.

I said in the previous comment that in case of having an alternate URL we should always load the alternate URL. The question is what to do in all other cases.
Comment 18 Michael Catanzaro 2020-01-27 16:04:59 PST
OK, I don't know. :)