summaryrefslogtreecommitdiffstats
path: root/testing/marionette/harness/marionette_harness/tests/unit/test_windowless.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
commit26a029d407be480d791972afb5975cf62c9360a6 (patch)
treef435a8308119effd964b339f76abb83a57c29483 /testing/marionette/harness/marionette_harness/tests/unit/test_windowless.py
parentInitial commit. (diff)
downloadfirefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz
firefox-26a029d407be480d791972afb5975cf62c9360a6.zip
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r--testing/marionette/harness/marionette_harness/tests/unit/test_windowless.py60
1 files changed, 60 insertions, 0 deletions
diff --git a/testing/marionette/harness/marionette_harness/tests/unit/test_windowless.py b/testing/marionette/harness/marionette_harness/tests/unit/test_windowless.py
new file mode 100644
index 0000000000..e8e98350f7
--- /dev/null
+++ b/testing/marionette/harness/marionette_harness/tests/unit/test_windowless.py
@@ -0,0 +1,60 @@
+# 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, Wait
+from marionette_harness import MarionetteTestCase
+
+
+class TestWindowless(MarionetteTestCase):
+ def setUp(self):
+ super(TestWindowless, self).setUp()
+
+ self.marionette.delete_session()
+ self.marionette.start_session({"moz:windowless": True})
+
+ def tearDown(self):
+ # Reset the browser and active WebDriver session
+ self.marionette.restart(in_app=True)
+ self.marionette.delete_session()
+
+ super(TestWindowless, self).tearDown()
+
+ def wait_for_first_window(self):
+ wait = Wait(
+ self.marionette,
+ ignored_exceptions=errors.NoSuchWindowException,
+ timeout=5,
+ )
+ return wait.until(lambda _: self.marionette.window_handles)
+
+ def test_last_chrome_window_can_be_closed(self):
+ with self.marionette.using_context("chrome"):
+ handles = self.marionette.chrome_window_handles
+ self.assertGreater(len(handles), 0)
+ self.marionette.switch_to_window(handles[0])
+ self.marionette.close_chrome_window()
+ self.assertEqual(len(self.marionette.chrome_window_handles), 0)
+
+ def test_last_content_window_can_be_closed(self):
+ handles = self.marionette.window_handles
+ self.assertGreater(len(handles), 0)
+ self.marionette.switch_to_window(handles[0])
+ self.marionette.close()
+ self.assertEqual(len(self.marionette.window_handles), 0)
+
+ def test_no_window_handles_after_silent_restart(self):
+ # Check that windows are present, but not after a silent restart
+ handles = self.marionette.window_handles
+ self.assertGreater(len(handles), 0)
+
+ self.marionette.restart(silent=True)
+ with self.assertRaises(errors.TimeoutException):
+ self.wait_for_first_window()
+
+ # After a normal restart a browser window will be opened again
+ self.marionette.restart(in_app=True)
+ handles = self.wait_for_first_window()
+
+ self.assertGreater(len(handles), 0)
+ self.marionette.switch_to_window(handles[0])