Open Bug 1578987 Opened 3 months ago Updated 3 months ago

Recommended preferences aren't reset when closing Firefox (started with -marionette option)

Categories

(Testing :: Marionette, defect, P3)

defect

Tracking

(Not tracked)

People

(Reporter: kenichi.ando, Unassigned)

Details

Attachments

(2 files)

User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.132 Safari/537.36

Steps to reproduce:

  1. Install Japanese (Mozc) as input source on Ubuntu
  2. Launch Firefox with -marionette option (Robot icon is displayed in the address bar)
  3. Switch the input source to Japanese (Mozc) and change the input mode to Hiragana
  4. Select any text field and type Japanese words

Confirmed the issue on Firefox 68.0.2 (64-bit) on Ubuntu 18.04.2 LTS.

Actual results:

For example, when 'a' key is typed, 'a' is displayed, though the input mode is Hiragana.

Expected results:

When 'a' key is typed, 'あ' should be displayed.

OS: Unspecified → Linux
Hardware: Unspecified → x86_64
Component: Untriaged → Marionette
Product: Firefox → Testing

Are you really sure this happens only when Firefox has been started with -marionette? Marionette doesn't intercept any user input, and as such I cannot see how this is possible. If it differs please attach screenshots to this bug. Thanks.

Flags: needinfo?(kenichi.ando)

Hi Henrik,
Thank you for the response. I re-verified the issue and realized that the steps I first provided were not exactly correct.

Here are the revised steps to reproduce the issue:

  1. Install Japanese (Mozc) as input source on Ubuntu
  2. Launch Firefox with -marionette option (Robot icon is displayed in the address bar)
  3. Switch the input source to Japanese (Mozc) and change the input mode to Hiragana
  4. Confirm that Japanese text input works fine
  5. Quit the browser
  6. Launch Firefox normally (without -marionette)
  7. Try Japanese text input again
    => Can't input Japanese text (Please see the screenshot in the attachment.)

The problem here is not marionette itself, but it seems that the profile gets something wrong after launching with marionette.
To recover the Japanese input on Firefox, it needs to create a new profile from "about:profiles".

Flags: needinfo?(kenichi.ando)
Attached image Screenshot.png

I have additional information.
When Firefox is launched by webdriver, Japanese input does not work as well.
I run the following python script on terminal, and try to input Japanese into the browser. However, alphabets are entered. I attached the Screenshot2.png.

Python script:

from selenium import webdriver
driver = webdriver.Firefox()
driver.get("https://bugzilla.org/")

Please let me know if you need any other information. Thanks.

Attached image Screenshot2.png

Update:
Launching Firefox with marionette adds the following config in prefs.js.

  • user_pref("focusmanager.testmode", true);

I found that enabling focusmanager.testmode prevents from inputting Japanese text.

When I tried disabling this preference explicitly, Japanese input works fine even though marionette is enabled.

from selenium import webdriver
from selenium.webdriver import FirefoxProfile

profile = FirefoxProfile()
profile.set_preference("focusmanager.testmode", False)
driver = webdriver.Firefox(firefox_profile=profile)
driver.get("https://bugzilla.org/") 
Summary: Can't input Japanese text when Firefox opens with -marionette option on Ubuntu → Can't input Japanese text when Firefox opens with focusmanager.testmode enabled on Ubuntu
Component: Marionette → Firefox UI Tests

Did this use to work or is it a regression?

Component: Firefox UI Tests → Marionette
Flags: needinfo?(kenichi.ando)
QA Contact: hskupin

I confirmed that the issue can be reproduced on FF45 and FF47 on Ubuntu x86-64, when focusmanager.testmode is enabled. So it's not a regression.

Flags: needinfo?(kenichi.ando)

Kenichi, can you please try to create a new profile yourself, and only set this preference? Given your feedback so far this doesn't seem to be a problem with Marionette but IME input or focus manager. Please report back so that I can move this bug into the correct component.

Flags: needinfo?(kenichi.ando)

Hi Henrik,
I tried the following.

  1. Go to about:profiles -> Create a new profile -> set as default profile -> Restart
  2. Japanese input works fine
  3. Go to about:config -> Set focusmanager.testmode to true -> Restart
  4. Japanese input does not work

Looks like the issue is caused by that preference, not Marionette. Can you please re-assign this to the right component?
Thanks.

Flags: needinfo?(kenichi.ando)

Thanks for your help investigating this! It's good to see that we got this nailed down to a specific preference.

Masayuki, any idea why this could happen with the focusmanager.testmode enabled only? If not, who else could know.

Component: Marionette → Editor
Flags: needinfo?(masayuki)
Product: Testing → Core

Although I'm not familiar with the pref, but according to the code around nsFocusManager::sTestMode, nsFocusManager changes its management of focused widget. Therefore, IME may not work as expected. That must be by design. So, I think that the code which set the pref must restore before shutting itself down.

Flags: needinfo?(masayuki)

(In reply to Masayuki Nakano [:masayuki] (he/him)(JST, +0900)(no pain of the broken bone, but the corset blocks me to concentrate) from comment #12)

Although I'm not familiar with the pref, but according to the code around nsFocusManager::sTestMode, nsFocusManager changes its management of focused widget. Therefore, IME may not work as expected. That must be by design. So, I think that the code which set the pref must restore before shutting itself down.

Thanks. Then lets ask Neil if this is a bug which needs to be fixed, or a wontfix for the focusmanager test mode.

Flags: needinfo?(enndeakin)

Focus test mode is only for running automated tests in a background window while doing something else in a different application. It only handles specific usages of this and isn't intended to be used for non-automated test purposes. Specifically, it doesn't try to bring any native windows (such as ime windows I would guess) forward.

Flags: needinfo?(enndeakin)

Ok, and it's unlikely that such a scenario would be necessary for testing purposes. As such I assume we can close this bug?

Also note that in general profiles as created by Marionette shouldn't be re-used for something else as running tests with Marionette.

Component: Editor → User events and focus handling

(In reply to Henrik Skupin (:whimboo) [⌚️UTC+2] from comment #15)

Also note that in general profiles as created by Marionette shouldn't be re-used for something else as running tests with Marionette.

According to the step 6 of comment 2, the profile is used automatically at next normal start of Firefox. I think that we should avoid this if possible.

(In reply to Masayuki Nakano [:masayuki] (he/him)(JST, +0900)(no pain of the broken bone, but the corset blocks me to concentrate) from comment #16)

According to the step 6 of comment 2, the profile is used automatically at next normal start of Firefox. I think that we should avoid this if possible.

Oh, yes! That is indeed a problem, which I actually didn't notice. So by using an existing user profile and starting Firefox with -marionette, we set recommended preferences [1] because the preference marionette.prefs.recommended is set to true by default [2].

Usually we reset all of those preferences again in uninit() [3] which is called when Marionette receives the xpcom-will-shutdown observer notification. So whether this notification doesn't get sent out (what I cannot believe), or something in our code isn't able to reset the preferences.

I wonder if we better should set the default for marionette.prefs.recommended to false. This would be in alignment to recommended and not required.

Andreas, what's your take?

[1] https://searchfox.org/mozilla-central/rev/588814f2edddf0e132d77d326ddae50911e8bad1/testing/marionette/components/marionette.js#488
[2] https://searchfox.org/mozilla-central/rev/588814f2edddf0e132d77d326ddae50911e8bad1/modules/libpref/init/all.js#4850
[3] https://searchfox.org/mozilla-central/rev/588814f2edddf0e132d77d326ddae50911e8bad1/testing/marionette/components/marionette.js#516
[4] https://searchfox.org/mozilla-central/rev/588814f2edddf0e132d77d326ddae50911e8bad1/testing/marionette/components/marionette.js#444-447

Status: UNCONFIRMED → NEW
Component: User events and focus handling → Marionette
Ever confirmed: true
Flags: needinfo?(ato)
OS: Linux → All
Priority: -- → P3
Product: Core → Testing
Hardware: x86_64 → All
Summary: Can't input Japanese text when Firefox opens with focusmanager.testmode enabled on Ubuntu → Recommended preferences aren't reset when closing Firefox (started with -marionette option)
Version: 68 Branch → Trunk

Maybe we should also have an observer for this particular preference, and turn on/off all those custom values when it gets changed.

(In reply to Henrik Skupin (:whimboo) [⌚️UTC+2] from comment #17)

I wonder if we better should set the default for
marionette.prefs.recommended to false. This would be in
alignment to recommended and not required.

The recommended preferences are required to achieve WebDriver
conformance.

Flags: needinfo?(ato)

(In reply to Andreas Tolfsen 「:ato」 from comment #19)

I wonder if we better should set the default for
marionette.prefs.recommended to false. This would be in
alignment to recommended and not required.

The recommended preferences are required to achieve WebDriver
conformance.

Right, and as such the question is if WebDriver clients like geckodriver should flip this pref to true, or if we always want to have those preferences set when running with Marionette enabled. For the latter we really, really have to ensure that the state of all of them is getting reset during a clean shutdown - it won't work for SIGKILL, crashes and such, which will leave them behind until the next clean shutdown.

WebDriver clients should not have to do anything special to get
WebDriver conformance out of a WebDriver implementation. The set
of preferences are essential to ensure Marionette operates the way
users expect it to. Disabling marionette.prefs.recommended should
only be done in the knowledge one is entering uncharted terriority.

For the reasons you give, it seems unlikely that we can guarantee
preferences absolutely will be reset before Firefox quits. Perhaps
this is an argument for moving all of the prefs to geckodriver,
since we don’t actually have that many direct users of Marionette
anymore. The other test harnesses in central use
testing/marionette/client/marionette_driver/geckoinstance.py which
explicitly opt out of the recommended preferences.

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