зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1361837 - Update restart unit tests to not activate sessionrestore. r=ato
The restart unit tests were using the preference browser.startup.page with its value set to 3. This actually causes sessionrestore to restore the session during the next startup. Given that there is a race condition in retrieving window handles (bug 1363368) it's better to use another default preference which does not trigger this behavior. MozReview-Commit-ID: 4m7qHxgI504 --HG-- extra : rebase_source : d5e29c0357dfcbe8395681f57000a7a1db769178
This commit is contained in:
Родитель
efa8951e8a
Коммит
67c8a43439
|
@ -4,7 +4,7 @@
|
|||
|
||||
from marionette_driver import errors
|
||||
|
||||
from marionette_harness import MarionetteTestCase
|
||||
from marionette_harness import MarionetteTestCase, skip
|
||||
|
||||
|
||||
class TestServerQuitApplication(MarionetteTestCase):
|
||||
|
@ -72,29 +72,40 @@ class TestQuitRestart(MarionetteTestCase):
|
|||
self.pid = self.marionette.process_id
|
||||
self.session_id = self.marionette.session_id
|
||||
|
||||
self.assertNotEqual(
|
||||
self.marionette.get_pref("browser.startup.page"), 3)
|
||||
self.marionette.set_pref("browser.startup.page", 3)
|
||||
# Use a preference to check that the restart was successful. If its
|
||||
# value has not been forced, a restart will cause a reset of it.
|
||||
self.assertNotEqual(self.marionette.get_pref("startup.homepage_welcome_url"),
|
||||
"about:")
|
||||
self.marionette.set_pref("startup.homepage_welcome_url", "about:")
|
||||
|
||||
def tearDown(self):
|
||||
# Ensure to restart a session if none exist for clean-up
|
||||
if self.marionette.session is None:
|
||||
self.marionette.start_session()
|
||||
|
||||
self.marionette.clear_pref("browser.startup.page")
|
||||
self.marionette.clear_pref("startup.homepage_welcome_url")
|
||||
|
||||
MarionetteTestCase.tearDown(self)
|
||||
|
||||
def shutdown(self, restart=False):
|
||||
self.marionette.set_context("chrome")
|
||||
self.marionette.execute_script("""
|
||||
Components.utils.import("resource://gre/modules/Services.jsm");
|
||||
let flags = Ci.nsIAppStartup.eAttemptQuit;
|
||||
if (arguments[0]) {
|
||||
flags |= Ci.nsIAppStartup.eRestart;
|
||||
}
|
||||
Services.startup.quit(flags);
|
||||
""", script_args=(restart,))
|
||||
|
||||
def test_force_restart(self):
|
||||
self.marionette.restart()
|
||||
self.assertEqual(self.marionette.session_id, self.session_id)
|
||||
|
||||
# A forced restart will cause a new process id
|
||||
self.assertNotEqual(self.marionette.process_id, self.pid)
|
||||
|
||||
# If a preference value is not forced, a restart will cause a reset
|
||||
self.assertNotEqual(
|
||||
self.marionette.get_pref("browser.startup.page"), 3)
|
||||
self.assertNotEqual(self.marionette.get_pref("startup.homepage_welcome_url"),
|
||||
"about:")
|
||||
|
||||
def test_force_quit(self):
|
||||
self.marionette.quit()
|
||||
|
@ -105,17 +116,19 @@ class TestQuitRestart(MarionetteTestCase):
|
|||
|
||||
self.marionette.start_session()
|
||||
self.assertNotEqual(self.marionette.session_id, self.session_id)
|
||||
self.assertNotEqual(
|
||||
self.marionette.get_pref("browser.startup.page"), 3)
|
||||
self.assertNotEqual(self.marionette.get_pref("startup.homepage_welcome_url"),
|
||||
"about:")
|
||||
|
||||
@skip("Bug 1363368 - Wrong window handles after in_app restarts")
|
||||
def test_in_app_clean_restart(self):
|
||||
# Test that in_app and clean cannot be used in combination
|
||||
with self.assertRaises(ValueError):
|
||||
self.marionette.restart(in_app=True, clean=True)
|
||||
|
||||
@skip("Bug 1363368 - Wrong window handles after in_app restarts")
|
||||
def test_in_app_restart(self):
|
||||
# Bug 1361837
|
||||
if self.marionette.session_capabilities["platformName"] == "darwin":
|
||||
return
|
||||
if self.marionette.session_capabilities["platformName"] != "windows_nt":
|
||||
skip("Bug 1363368 - Wrong window handles after in_app restarts")
|
||||
|
||||
self.marionette.restart(in_app=True)
|
||||
self.assertEqual(self.marionette.session_id, self.session_id)
|
||||
|
@ -126,14 +139,13 @@ class TestQuitRestart(MarionetteTestCase):
|
|||
else:
|
||||
self.assertNotEqual(self.marionette.process_id, self.pid)
|
||||
|
||||
# If a preference value is not forced, a restart will cause a reset
|
||||
self.assertNotEqual(
|
||||
self.marionette.get_pref("browser.startup.page"), 3)
|
||||
self.assertNotEqual(self.marionette.get_pref("startup.homepage_welcome_url"),
|
||||
"about:")
|
||||
|
||||
@skip("Bug 1363368 - Wrong window handles after in_app restarts")
|
||||
def test_in_app_restart_with_callback(self):
|
||||
# Bug 1361837
|
||||
if self.marionette.session_capabilities["platformName"] == "darwin":
|
||||
return
|
||||
if self.marionette.session_capabilities["platformName"] != "windows_nt":
|
||||
skip("Bug 1363368 - Wrong window handles after in_app restarts")
|
||||
|
||||
self.marionette.restart(in_app=True,
|
||||
callback=lambda: self.shutdown(restart=True))
|
||||
|
@ -146,11 +158,14 @@ class TestQuitRestart(MarionetteTestCase):
|
|||
else:
|
||||
self.assertNotEqual(self.marionette.process_id, self.pid)
|
||||
|
||||
# If a preference value is not forced, a restart will cause a reset
|
||||
self.assertNotEqual(
|
||||
self.marionette.get_pref("browser.startup.page"), 3)
|
||||
self.assertNotEqual(self.marionette.get_pref("startup.homepage_welcome_url"),
|
||||
"about:")
|
||||
|
||||
@skip("Bug 1363368 - Wrong window handles after in_app restarts")
|
||||
def test_in_app_quit(self):
|
||||
if self.marionette.session_capabilities["platformName"] != "windows_nt":
|
||||
skip("Bug 1363368 - Wrong window handles after in_app restarts")
|
||||
|
||||
self.marionette.quit(in_app=True)
|
||||
|
||||
self.assertEqual(self.marionette.session, None)
|
||||
|
@ -159,10 +174,14 @@ class TestQuitRestart(MarionetteTestCase):
|
|||
|
||||
self.marionette.start_session()
|
||||
self.assertNotEqual(self.marionette.session_id, self.session_id)
|
||||
self.assertNotEqual(
|
||||
self.marionette.get_pref("browser.startup.page"), 3)
|
||||
self.assertNotEqual(self.marionette.get_pref("startup.homepage_welcome_url"),
|
||||
"about:")
|
||||
|
||||
@skip("Bug 1363368 - Wrong window handles after in_app restarts")
|
||||
def test_in_app_quit_with_callback(self):
|
||||
if self.marionette.session_capabilities["platformName"] != "windows_nt":
|
||||
skip("Bug 1363368 - Wrong window handles after in_app restarts")
|
||||
|
||||
self.marionette.quit(in_app=True, callback=self.shutdown)
|
||||
self.assertEqual(self.marionette.session, None)
|
||||
with self.assertRaisesRegexp(errors.MarionetteException, "Please start a session"):
|
||||
|
@ -170,13 +189,13 @@ class TestQuitRestart(MarionetteTestCase):
|
|||
|
||||
self.marionette.start_session()
|
||||
self.assertNotEqual(self.marionette.session_id, self.session_id)
|
||||
self.assertNotEqual(
|
||||
self.marionette.get_pref("browser.startup.page"), 3)
|
||||
self.assertNotEqual(self.marionette.get_pref("startup.homepage_welcome_url"),
|
||||
"about:")
|
||||
|
||||
@skip("Bug 1363368 - Wrong window handles after in_app restarts")
|
||||
def test_reset_context_after_quit_by_set_context(self):
|
||||
# Bug 1361837
|
||||
if self.marionette.session_capabilities["platformName"] == "darwin":
|
||||
return
|
||||
if self.marionette.session_capabilities["platformName"] != "windows_nt":
|
||||
skip("Bug 1363368 - Wrong window handles after in_app restarts")
|
||||
|
||||
# Check that we are in content context which is used by default in
|
||||
# Marionette
|
||||
|
@ -190,10 +209,10 @@ class TestQuitRestart(MarionetteTestCase):
|
|||
self.assertNotIn("chrome://", self.marionette.get_url(),
|
||||
"Not in content context after quit with using_context")
|
||||
|
||||
@skip("Bug 1363368 - Wrong window handles after in_app restarts")
|
||||
def test_reset_context_after_quit_by_using_context(self):
|
||||
# Bug 1361837
|
||||
if self.marionette.session_capabilities["platformName"] == "darwin":
|
||||
return
|
||||
if self.marionette.session_capabilities["platformName"] != "windows_nt":
|
||||
skip("Bug 1363368 - Wrong window handles after in_app restarts")
|
||||
|
||||
# Check that we are in content context which is used by default in
|
||||
# Marionette
|
||||
|
@ -207,10 +226,10 @@ class TestQuitRestart(MarionetteTestCase):
|
|||
self.assertNotIn("chrome://", self.marionette.get_url(),
|
||||
"Not in content context after quit with using_context")
|
||||
|
||||
@skip("Bug 1363368 - Wrong window handles after in_app restarts")
|
||||
def test_keep_context_after_restart_by_set_context(self):
|
||||
# Bug 1361837
|
||||
if self.marionette.session_capabilities["platformName"] == "darwin":
|
||||
return
|
||||
if self.marionette.session_capabilities["platformName"] != "windows_nt":
|
||||
skip("Bug 1363368 - Wrong window handles after in_app restarts")
|
||||
|
||||
# Check that we are in content context which is used by default in
|
||||
# Marionette
|
||||
|
@ -230,10 +249,10 @@ class TestQuitRestart(MarionetteTestCase):
|
|||
self.assertIn("chrome://", self.marionette.get_url(),
|
||||
"Not in chrome context after a restart with set_context")
|
||||
|
||||
@skip("Bug 1363368 - Wrong window handles after in_app restarts")
|
||||
def test_keep_context_after_restart_by_using_context(self):
|
||||
# Bug 1361837
|
||||
if self.marionette.session_capabilities["platformName"] == "darwin":
|
||||
return
|
||||
if self.marionette.session_capabilities["platformName"] != "windows_nt":
|
||||
skip("Bug 1363368 - Wrong window handles after in_app restarts")
|
||||
|
||||
# Check that we are in content context which is used by default in
|
||||
# Marionette
|
||||
|
@ -252,14 +271,3 @@ class TestQuitRestart(MarionetteTestCase):
|
|||
|
||||
self.assertIn("chrome://", self.marionette.get_url(),
|
||||
"Not in chrome context after a restart with using_context")
|
||||
|
||||
def shutdown(self, restart=False):
|
||||
self.marionette.set_context("chrome")
|
||||
self.marionette.execute_script("""
|
||||
Components.utils.import("resource://gre/modules/Services.jsm");
|
||||
let flags = Ci.nsIAppStartup.eAttemptQuit;
|
||||
if (arguments[0]) {
|
||||
flags |= Ci.nsIAppStartup.eRestart;
|
||||
}
|
||||
Services.startup.quit(flags);
|
||||
""", script_args=(restart,))
|
||||
|
|
Загрузка…
Ссылка в новой задаче