diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:14:29 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:14:29 +0000 |
commit | fbaf0bb26397aa498eb9156f06d5a6fe34dd7dd8 (patch) | |
tree | 4c1ccaf5486d4f2009f9a338a98a83e886e29c97 /testing/marionette/harness/marionette_harness/tests/unit | |
parent | Releasing progress-linux version 124.0.1-1~progress7.99u1. (diff) | |
download | firefox-fbaf0bb26397aa498eb9156f06d5a6fe34dd7dd8.tar.xz firefox-fbaf0bb26397aa498eb9156f06d5a6fe34dd7dd8.zip |
Merging upstream version 125.0.1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/marionette/harness/marionette_harness/tests/unit')
4 files changed, 58 insertions, 7 deletions
diff --git a/testing/marionette/harness/marionette_harness/tests/unit/test_addons.py b/testing/marionette/harness/marionette_harness/tests/unit/test_addons.py index 1611739e5f..1552dc8d6f 100644 --- a/testing/marionette/harness/marionette_harness/tests/unit/test_addons.py +++ b/testing/marionette/harness/marionette_harness/tests/unit/test_addons.py @@ -32,8 +32,8 @@ class TestAddons(MarionetteTestCase): addons = self.marionette.execute_async_script( """ const [resolve] = arguments; - const { AddonManager } = ChromeUtils.import( - "resource://gre/modules/AddonManager.jsm" + const { AddonManager } = ChromeUtils.importESModule( + "resource://gre/modules/AddonManager.sys.mjs" ); async function getAllAddons() { @@ -54,8 +54,8 @@ class TestAddons(MarionetteTestCase): addon_id = self.marionette.execute_async_script( """ const [addonId, resolve] = arguments; - const { AddonManager } = ChromeUtils.import( - "resource://gre/modules/AddonManager.jsm" + const { AddonManager } = ChromeUtils.importESModule( + "resource://gre/modules/AddonManager.sys.mjs" ); async function uninstall() { diff --git a/testing/marionette/harness/marionette_harness/tests/unit/test_pagesource.py b/testing/marionette/harness/marionette_harness/tests/unit/test_pagesource.py index e3799bc0d6..45ea1ed757 100644 --- a/testing/marionette/harness/marionette_harness/tests/unit/test_pagesource.py +++ b/testing/marionette/harness/marionette_harness/tests/unit/test_pagesource.py @@ -47,6 +47,6 @@ class TestPageSource(MarionetteTestCase): import re self.assertEqual( - re.sub("\s", "", source), "<xml><foo><bar>baz</bar></foo></xml>" + re.sub(r"\s", "", source), "<xml><foo><bar>baz</bar></foo></xml>" ) self.assertEqual(source, from_web_api) diff --git a/testing/marionette/harness/marionette_harness/tests/unit/test_set_permission.py b/testing/marionette/harness/marionette_harness/tests/unit/test_set_permission.py new file mode 100644 index 0000000000..476d9c5729 --- /dev/null +++ b/testing/marionette/harness/marionette_harness/tests/unit/test_set_permission.py @@ -0,0 +1,50 @@ +# 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 marionette_driver import errors +from marionette_harness import MarionetteTestCase + + +class TestSetPermission(MarionetteTestCase): + def setUp(self): + super().setUp() + test_empty = self.marionette.absolute_url("empty.html") + self.marionette.set_pref("marionette.setpermission.enabled", True) + self.marionette.navigate(test_empty) + + def query_permission(self, descriptor): + return self.marionette.execute_script( + """ + return navigator.permissions.query(arguments[0]).then(status => status.state) + """, + script_args=(descriptor,), + ) + + def test_granted(self): + self.marionette.set_permission({"name": "midi"}, "granted") + self.assertEqual(self.query_permission({"name": "midi"}), "granted") + + def test_denied(self): + self.marionette.set_permission({"name": "midi"}, "denied") + self.assertEqual(self.query_permission({"name": "midi"}), "denied") + + def test_prompt(self): + self.marionette.set_permission({"name": "midi"}, "prompt") + self.assertEqual(self.query_permission({"name": "midi"}), "prompt") + + def test_invalid_name(self): + with self.assertRaises(errors.InvalidArgumentException): + self.marionette.set_permission({"name": "firefox"}, "granted") + + def test_invalid_state(self): + with self.assertRaises(errors.InvalidArgumentException): + self.marionette.set_permission({"name": "midi"}, "default") + + def test_extra_flags(self): + self.marionette.set_permission({"name": "midi"}, "granted") + self.marionette.set_permission({"name": "midi", "sysex": True}, "prompt") + self.assertEqual(self.query_permission({"name": "midi"}), "granted") + self.assertEqual( + self.query_permission({"name": "midi", "sysex": True}), "prompt" + ) diff --git a/testing/marionette/harness/marionette_harness/tests/unit/unit-tests.toml b/testing/marionette/harness/marionette_harness/tests/unit/unit-tests.toml index e8675e4897..1f39da959e 100644 --- a/testing/marionette/harness/marionette_harness/tests/unit/unit-tests.toml +++ b/testing/marionette/harness/marionette_harness/tests/unit/unit-tests.toml @@ -112,8 +112,7 @@ skip-if = ["!manage_instance"] ["test_profile_management.py"] skip-if = [ - "!manage_instance", - "debug && (os == 'mac' || os == 'linux')", # Bug 1450355 + "!manage_instance" ] ["test_proxy.py"] @@ -138,6 +137,8 @@ skip-if = ["os == 'mac'"] # bug 1674411 ["test_session.py"] +["test_set_permission.py"] + ["test_skip_setup.py"] ["test_switch_frame.py"] |