test_engines_on_restart.py (1393B)
1 # This Source Code Form is subject to the terms of the Mozilla Public 2 # License, v. 2.0. If a copy of the MPL was not distributed with this 3 # file, You can obtain one at http://mozilla.org/MPL/2.0/. 4 5 import textwrap 6 7 from marionette_harness.marionette_test import MarionetteTestCase 8 9 10 class TestEnginesOnRestart(MarionetteTestCase): 11 def setUp(self): 12 super().setUp() 13 self.marionette.enforce_gecko_prefs({ 14 "browser.search.log": True, 15 }) 16 17 def get_default_search_engine(self): 18 """Retrieve the identifier of the default search engine.""" 19 20 script = """\ 21 let [resolve] = arguments; 22 let searchService = Components.classes[ 23 "@mozilla.org/browser/search-service;1"] 24 .getService(Components.interfaces.nsISearchService); 25 return searchService.init().then(function () { 26 resolve(searchService.defaultEngine.id); 27 }); 28 """ 29 30 with self.marionette.using_context(self.marionette.CONTEXT_CHROME): 31 return self.marionette.execute_async_script(textwrap.dedent(script)) 32 33 def test_engines(self): 34 self.assertEqual(self.get_default_search_engine(), "google") 35 self.marionette.set_pref("intl.locale.requested", "kk_KZ") 36 self.marionette.restart(clean=False, in_app=True) 37 self.assertEqual(self.get_default_search_engine(), "google")