summaryrefslogtreecommitdiffstats
path: root/testing/marionette/harness
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 01:13:33 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 01:13:33 +0000
commit086c044dc34dfc0f74fbe41f4ecb402b2cd34884 (patch)
treea4f824bd33cb075dd5aa3eb5a0a94af221bbe83a /testing/marionette/harness
parentAdding debian version 124.0.1-1. (diff)
downloadfirefox-086c044dc34dfc0f74fbe41f4ecb402b2cd34884.tar.xz
firefox-086c044dc34dfc0f74fbe41f4ecb402b2cd34884.zip
Merging upstream version 125.0.1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/marionette/harness')
-rw-r--r--testing/marionette/harness/marionette_harness/runner/base.py2
-rw-r--r--testing/marionette/harness/marionette_harness/tests/unit/test_addons.py8
-rw-r--r--testing/marionette/harness/marionette_harness/tests/unit/test_pagesource.py2
-rw-r--r--testing/marionette/harness/marionette_harness/tests/unit/test_set_permission.py50
-rw-r--r--testing/marionette/harness/marionette_harness/tests/unit/unit-tests.toml5
-rw-r--r--testing/marionette/harness/marionette_harness/www/dom/indexedDB/basicIDB_PBM.html2
-rw-r--r--testing/marionette/harness/marionette_harness/www/html5/geolocation.js2
-rw-r--r--testing/marionette/harness/setup.py2
8 files changed, 62 insertions, 11 deletions
diff --git a/testing/marionette/harness/marionette_harness/runner/base.py b/testing/marionette/harness/marionette_harness/runner/base.py
index b5ddc2d788..a042ac01ab 100644
--- a/testing/marionette/harness/marionette_harness/runner/base.py
+++ b/testing/marionette/harness/marionette_harness/runner/base.py
@@ -730,7 +730,7 @@ class BaseMarionetteTestRunner(object):
@property
def filename_pattern(self):
if self._filename_pattern is None:
- self._filename_pattern = re.compile("^test(((_.+?)+?\.((py))))$")
+ self._filename_pattern = re.compile(r"^test(((_.+?)+?\.((py))))$")
return self._filename_pattern
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"]
diff --git a/testing/marionette/harness/marionette_harness/www/dom/indexedDB/basicIDB_PBM.html b/testing/marionette/harness/marionette_harness/www/dom/indexedDB/basicIDB_PBM.html
index 90472d64d2..8b0b425b81 100644
--- a/testing/marionette/harness/marionette_harness/www/dom/indexedDB/basicIDB_PBM.html
+++ b/testing/marionette/harness/marionette_harness/www/dom/indexedDB/basicIDB_PBM.html
@@ -10,7 +10,7 @@
var req = indexedDB.open(name, ver);
req.onerror = reject;
- req.onsuccess = (event) => {
+ req.onsuccess = () => {
resolve(req.result);
};
diff --git a/testing/marionette/harness/marionette_harness/www/html5/geolocation.js b/testing/marionette/harness/marionette_harness/www/html5/geolocation.js
index 4fb4a4747b..1c0132a732 100644
--- a/testing/marionette/harness/marionette_harness/www/html5/geolocation.js
+++ b/testing/marionette/harness/marionette_harness/www/html5/geolocation.js
@@ -17,7 +17,7 @@ function success(position) {
message.innerHTML += "<p>Altitude: " + position.coords.altitude + "</p>";
}
-function error(msg) {
+function error() {
let message = document.getElementById("status");
message.innerHTML = "Failed to get geolocation.";
}
diff --git a/testing/marionette/harness/setup.py b/testing/marionette/harness/setup.py
index fd43cdb969..cf3a255009 100644
--- a/testing/marionette/harness/setup.py
+++ b/testing/marionette/harness/setup.py
@@ -17,7 +17,7 @@ def read(*parts):
def get_version():
return re.findall(
- '__version__ = "([\d\.]+)"', read("marionette_harness", "__init__.py"), re.M
+ r'__version__ = "([\d\.]+)"', read("marionette_harness", "__init__.py"), re.M
)[0]