Bug 188111 - REGRESSION(r263094): [GTK][WPE] API test /webkit/WebKitWebContext/languages is failing
Summary: REGRESSION(r263094): [GTK][WPE] API test /webkit/WebKitWebContext/languages i...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKitGTK (show other bugs)
Version: Other
Hardware: PC Linux
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-07-27 12:23 PDT by Michael Catanzaro
Modified: 2021-03-02 15:24 PST (History)
8 users (show)

See Also:


Attachments
Patch (10.68 KB, patch)
2021-02-24 03:09 PST, Carlos Garcia Campos
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Michael Catanzaro 2018-07-27 12:23:38 PDT
API test /webkit/WebKitWebContext/languages always fails:

/webkit/WebKitWebContext/languages:                                 FAIL
ERROR:/home/slave/webkitgtk/gtk-linux-64-release/build/Tools/TestWebKitAPI/Tests/WebKitGLib/TestWebKitWebContext.cpp:476:void testWebContextLanguages(WebViewTest*, gconstpointer): assertion failed: (!javascriptResult)
Comment 1 Michael Catanzaro 2021-01-21 09:26:27 PST
Nowadays it fails even earlier:

ERROR:../../Tools/TestWebKitAPI/Tests/WebKitGLib/TestWebKitWebContext.cpp:359:void testWebContextLanguages(WebViewTest*, gconstpointer): assertion failed (mainResourceDataSize == strlen(expectedLanguages)): (5 == 25)

Problem is the language is set to "en-US" rather than the expected "en,ES-es;q=0.90,dE;q=0.80".
Comment 2 Carlos Garcia Campos 2021-02-24 02:44:04 PST
(In reply to Michael Catanzaro from comment #1)
> Nowadays it fails even earlier:
> 
> ERROR:../../Tools/TestWebKitAPI/Tests/WebKitGLib/TestWebKitWebContext.cpp:
> 359:void testWebContextLanguages(WebViewTest*, gconstpointer): assertion
> failed (mainResourceDataSize == strlen(expectedLanguages)): (5 == 25)
> 
> Problem is the language is set to "en-US" rather than the expected
> "en,ES-es;q=0.90,dE;q=0.80".

This one is fixed by bug #222347
Comment 3 Carlos Garcia Campos 2021-02-24 03:09:34 PST
Created attachment 421392 [details]
Patch
Comment 4 EWS Watchlist 2021-02-24 03:10:37 PST
Thanks for the patch. If this patch contains new public API please make sure it follows the guidelines for new WebKit2 GTK+ API. See https://trac.webkit.org/wiki/WebKitGTK/AddingNewWebKit2API
Comment 5 Michael Catanzaro 2021-02-24 06:56:07 PST
Comment on attachment 421392 [details]
Patch

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

I was a bit confused how we wound up with a bug from 2018 fixing a regression from 2020. I see you just repurposed this bug to fix the new problem. OK.

> Source/WebKit/ChangeLog:9
> +        are no loner sending the new overrides to the web process. Instead of calling overrideUserPreferredLanguages()

no longer
Comment 6 Michael Catanzaro 2021-02-24 06:56:25 PST
Hi Chris, could you review this one please?
Comment 7 Carlos Garcia Campos 2021-02-24 22:54:50 PST
I didn't know this bug was so old.
Comment 8 Michael Catanzaro 2021-02-25 08:09:02 PST
Comment on attachment 421392 [details]
Patch

Anyway it looks good to me, but requires owner approval (ideally from Chris).
Comment 9 Chris Dumez 2021-02-25 08:48:46 PST
Comment on attachment 421392 [details]
Patch

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

> Source/WebKit/UIProcess/WebProcessPool.cpp:-308
> -    addLanguageChangeObserver(this, languageChanged);

I don't understand why we are getting rid of the language change observer in the UIProcess. Seems like we would want to know and notify the WebProcesses if the user changed the language, no?
Comment 10 Carlos Garcia Campos 2021-02-25 23:10:24 PST
(In reply to Chris Dumez from comment #9)
> Comment on attachment 421392 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=421392&action=review
> 
> > Source/WebKit/UIProcess/WebProcessPool.cpp:-308
> > -    addLanguageChangeObserver(this, languageChanged);
> 
> I don't understand why we are getting rid of the language change observer in
> the UIProcess. Seems like we would want to know and notify the WebProcesses
> if the user changed the language, no?

Because after this patch overrideUserPreferredLanguages() is no longer called from the UI process. Right now is only called from the GLib API, unless I'm missing something.
Comment 11 Carlos Garcia Campos 2021-03-01 03:12:44 PST
Chris, are you ok with this then?
Comment 12 Chris Dumez 2021-03-02 08:27:07 PST
(In reply to Carlos Garcia Campos from comment #11)
> Chris, are you ok with this then?

I will look into this today. If this is not used on macOS then how do we detect and apply language change on macOS? macOS definitely has to do it in the UIProcess (and not WebProcess) due to sandboxing reasons). Seems like either macOS uses this or it doesn't and we may have a bug to fix (or there is another mechanism that macOS uses and that I am missing).
Comment 13 Chris Dumez 2021-03-02 10:16:23 PST
Comment on attachment 421392 [details]
Patch

LGTM. The WebProcess is able to listen to change notification on macOS.
Comment 14 EWS 2021-03-02 10:25:43 PST
Committed r273735: <https://commits.webkit.org/r273735>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 421392 [details].