Open Bug 1978075 Opened 1 month ago Updated 5 days ago

sync-about-blank: "emulation.setLocaleOverride" doesn't persist past reloads

Categories

(Remote Protocol :: WebDriver BiDi, defect, P3)

defect

Tracking

(Not tracked)

ASSIGNED

People

(Reporter: vhilla, Assigned: vhilla)

References

(Depends on 1 open bug)

Details

(Whiteboard: [webdriver:m17][webdriver:external])

Attachments

(2 files, 3 obsolete files)

I just rebased bug 543435 (sync-about-blank) onto bug 1968952 (add "emulation.setLocaleOverride") and /webdriver/tests/bidi/emulation/set_locale_override/user_contexts.py subtest test_set_to_user_context_and_then_to_context is failing. There might be two aspects.

In bug 1967705, I added a blocking mechanism to browsing_context.create so that it waits for the configuration module to complete, given about:blank cannot be parser-blocked. Maybe we should do the same for browsing_context.reload.

I wrote a prototype for blocking reload on configuration, but that didn't help. I checked from in the logs that during the reload, context.languageOverride is set and BrowsingContext::DidSet(FieldIndex<IDX_LanguageOverride>, nsString&& aOldValue) called. But it early-returns as the value didn't change while JS_GetDefaultLocale doesn't anymore correspond to the override.

Depends on: sync-about-blank
See Also: → 1967705, 1968951, 1968952

Interestingly, I tried adding a test to dom/base/test/browser_language_override.js and that seemed to work. The override does stay through something like this:

tab.linkedBrowser.reloadWithFlags(Ci.nsIWebNavigation.LOAD_FLAGS_NONE);
await BrowserTestUtils.browserLoaded(browser);
await assertLanguageOverridden(browser, languageOverride);

pernosco for user_context.py: https://pernos.co/debug/EBgIDtXuAm_1fvZHnAPmqg/index.html

I'm confused. Before and after reload, the call to JSRuntime::getDefaultLocale has the same context (at least by memory location) and takes the early return for defaultLocale. There's no call to JSRuntime::setDefaultLocale in between, but the return value changes. I changed defaultLocale to private, no compile errors, same issue. Though the process seems to change.

Ah, reloading seems to preserve the JS runtime, but a cross-process redirect doesn't. So I found two issues.


Bug 1968951 doesn't re-apply the override if the JS runtime changes. In this case, this happens as a cross-process redirect changes the content process. I attached a variation of browser_language_override.js to test this. Note that BrowsingContext languageOverride is unchanged and it doesn't work to just set it to the override again.

const CROSS_PAGE_URL = PAGE_URL.replace(".com", ".org");
await BrowserTestUtils.startLoadingURIString(browser, CROSS_PAGE_URL);
await BrowserTestUtils.browserLoaded(browser, false, CROSS_PAGE_URL);
is(browsingContext.languageOverride, languageOverride);  // pass
await assertLanguageOverridden(browser, languageOverride);  // fail

For some reason, reload in user_context.py causes a cross-process redirect with bug 543435...

I worry the override also won't be applied to new subframes.

(In reply to Vincent Hilla [:vhilla] from comment #5)

I worry the override also won't be applied to new subframes.

Yes, looks like that's right. I've created a separate bug 1978533 for it, and I will fix it now. In the scope of the fix I'm going to remove the restriction for only setting the value when it's different from the one already set on browsing context. I think that should probably help with reload as well? We maybe still have to add a waiting mechanics for reload on about:blank, but then it should fix the test_set_to_user_context_and_then_to_context test, right?

Blocks: 1978533
Assignee: nobody → vhilla
Status: NEW → ASSIGNED

Yes, always setting the value on the runtime and having a waiting mechanic for browsing_context.reload should fix test_set_to_user_context_and_then_to_context. I attached my WIP patch for such a mechanic.

I think a cross-process navigation outside of webdriver might continue to evade the locale override. See the attached browser test. But maybe we don't care about that.

Thanks for taking bug 1978533!

Comment on attachment 9502086 [details]
Bug 1978075 - Allow setting languageOverride even if the browsing context already holds the same value.

Revision D258193 was moved to bug 1978533. Setting attachment 9502086 [details] to obsolete.

Attachment #9502086 - Attachment is obsolete: true

Comment on attachment 9502087 [details]
Bug 1978075 - [bidi] Apply the locale override also when iframes are created.

Revision D258194 was moved to bug 1978533. Setting attachment 9502087 [details] to obsolete.

Attachment #9502087 - Attachment is obsolete: true

Comment on attachment 9502088 [details]
Bug 1978075 - [wdspec] Add test for calling "emulation.setLocaleOverride" on the page with iframes.

Revision D258195 was moved to bug 1978533. Setting attachment 9502088 [details] to obsolete.

Attachment #9502088 - Attachment is obsolete: true
Severity: -- → S3
Priority: -- → P3
Whiteboard: [webdriver:m17][webdriver:external]

Vincent, I assume this blocks bug 543435 instead?

You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: