diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 14:29:10 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 14:29:10 +0000 |
commit | 2aa4a82499d4becd2284cdb482213d541b8804dd (patch) | |
tree | b80bf8bf13c3766139fbacc530efd0dd9d54394c /extensions/pref/autoconfig/test/marionette/test_autoconfig.py | |
parent | Initial commit. (diff) | |
download | firefox-2aa4a82499d4becd2284cdb482213d541b8804dd.tar.xz firefox-2aa4a82499d4becd2284cdb482213d541b8804dd.zip |
Adding upstream version 86.0.1.upstream/86.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'extensions/pref/autoconfig/test/marionette/test_autoconfig.py')
-rw-r--r-- | extensions/pref/autoconfig/test/marionette/test_autoconfig.py | 103 |
1 files changed, 103 insertions, 0 deletions
diff --git a/extensions/pref/autoconfig/test/marionette/test_autoconfig.py b/extensions/pref/autoconfig/test/marionette/test_autoconfig.py new file mode 100644 index 0000000000..2cf520f86a --- /dev/null +++ b/extensions/pref/autoconfig/test/marionette/test_autoconfig.py @@ -0,0 +1,103 @@ +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. + +from __future__ import absolute_import + +import os +import shutil + +from marionette_harness import MarionetteTestCase + + +class TestAutoConfig(MarionetteTestCase): + def tearDown(self): + self.marionette.quit(clean=True) + + if hasattr(self, "pref_file"): + os.remove(self.pref_file) + if hasattr(self, "autoconfig_file"): + os.remove(self.autoconfig_file) + + super(TestAutoConfig, self).tearDown() + + def pref_has_user_value(self, pref): + with self.marionette.using_context("chrome"): + return self.marionette.execute_script( + """ + return Services.prefs.prefHasUserValue(arguments[0]); + """, + script_args=(pref,), + ) + + def pref_is_locked(self, pref): + with self.marionette.using_context("chrome"): + return self.marionette.execute_script( + """ + return Services.prefs.prefIsLocked(arguments[0]); + """, + script_args=(pref,), + ) + + def test_autoconfig(self): + with self.marionette.using_context("chrome"): + self.exe_dir = self.marionette.execute_script( + """ + return Services.dirsvc.get("GreD", Ci.nsIFile).path; + """ + ) + + self.marionette.quit() + + test_dir = os.path.dirname(__file__) + self.pref_file = os.path.join(self.exe_dir, "defaults", "pref", "autoconfig.js") + shutil.copyfile(os.path.join(test_dir, "autoconfig.js"), self.pref_file) + self.autoconfig_file = os.path.join(self.exe_dir, "autoconfig.cfg") + shutil.copyfile(os.path.join(test_dir, "autoconfig.cfg"), self.autoconfig_file) + + self.marionette.start_session() + + with self.marionette.using_context("chrome"): + self.assertTrue( + self.pref_has_user_value("_autoconfig_.test.userpref"), + "Pref should have user value", + ) + + self.assertEqual( + self.marionette.get_pref("_autoconfig_.test.userpref"), + "userpref", + "User pref should be set", + ) + + self.assertEqual( + self.marionette.get_pref("_autoconfig_.test.defaultpref", True), + "defaultpref", + "Default pref should be set", + ) + + self.assertTrue( + self.pref_is_locked("_autoconfig_.test.lockpref"), + "Pref should be locked", + ) + + self.assertEqual( + self.marionette.get_pref("_autoconfig_.test.lockpref"), + "lockpref", + "Locked pref should be set", + ) + + self.assertFalse( + self.pref_is_locked("_autoconfig_.test.unlockpref"), + "Pref should be unlocked", + ) + + self.assertEqual( + self.marionette.get_pref("_autoconfig_.test.unlockpref"), + "unlockpref", + "Unlocked pref should be set", + ) + + self.assertFalse( + self.pref_has_user_value("_autoconfig_.test.clearpref"), + "Pref should be cleared", + ) |