зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1374762 - Allow Marionette to handle the safe mode dialog. r=ato
In safe mode the command line hander arguments are getting parsed after the safe mode dialog has been closed. As such Marionette is not getting enabled before, and cannot close the dialog. To workaround the problem the "command-line-startup" observer notification can be used, which allows to parse the given arguments before the dialog. MozReview-Commit-ID: LWzUKCnM0YK --HG-- extra : rebase_source : 5dd538eabbfb76a0d19440eb9fa5ac431bd86f0b
This commit is contained in:
Родитель
e31175ba5d
Коммит
16a0e92f1c
|
@ -155,11 +155,21 @@ MarionetteComponent.prototype.handle = function(cmdLine) {
|
|||
|
||||
MarionetteComponent.prototype.observe = function(subject, topic, data) {
|
||||
switch (topic) {
|
||||
case "command-line-startup":
|
||||
Services.obs.removeObserver(this, topic);
|
||||
this.handle(subject);
|
||||
|
||||
case "profile-after-change":
|
||||
// Using sessionstore-windows-restored as the xpcom category doesn't
|
||||
// seem to work, so we wait for that by adding an observer here.
|
||||
Services.obs.addObserver(this, "sessionstore-windows-restored");
|
||||
|
||||
// In safe mode the command line handlers are getting parsed after the
|
||||
// safe mode dialog has been closed. To allow Marionette to start earlier,
|
||||
// register the CLI startup observer notification for special-cased
|
||||
// handlers, which gets fired before the dialog.
|
||||
Services.obs.addObserver(this, "command-line-startup");
|
||||
|
||||
prefs.readFromEnvironment(ENV_PRESERVE_PREFS);
|
||||
|
||||
if (this.enabled) {
|
||||
|
@ -229,6 +239,7 @@ MarionetteComponent.prototype.suppressSafeModeDialog = function(win) {
|
|||
win.addEventListener("load", () => {
|
||||
if (win.document.getElementById("safeModeDialog")) {
|
||||
// accept the dialog to start in safe-mode
|
||||
this.logger.debug("Safe Mode detected. Going to suspress the dialog now.");
|
||||
win.setTimeout(() => {
|
||||
win.document.documentElement.getButton("accept").click();
|
||||
});
|
||||
|
|
|
@ -0,0 +1,36 @@
|
|||
# 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/.
|
||||
|
||||
import copy
|
||||
|
||||
from marionette_harness import MarionetteTestCase
|
||||
|
||||
|
||||
class TestCommandLineArguments(MarionetteTestCase):
|
||||
|
||||
def setUp(self):
|
||||
super(TestCommandLineArguments, self).setUp()
|
||||
|
||||
self.orig_arguments = copy.copy(self.marionette.instance.app_args)
|
||||
|
||||
def tearDown(self):
|
||||
self.marionette.instance.app_args = self.orig_arguments
|
||||
self.marionette.quit(clean=True)
|
||||
|
||||
super(TestCommandLineArguments, self).tearDown()
|
||||
|
||||
def test_start_in_safe_mode(self):
|
||||
self.marionette.instance.app_args.append("-safe-mode")
|
||||
|
||||
self.marionette.quit()
|
||||
self.marionette.start_session()
|
||||
|
||||
with self.marionette.using_context("chrome"):
|
||||
safe_mode = self.marionette.execute_script("""
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
return Services.appinfo.inSafeMode;
|
||||
""")
|
||||
|
||||
self.assertTrue(safe_mode, "Safe Mode has not been enabled")
|
|
@ -1,4 +1,6 @@
|
|||
[test_marionette.py]
|
||||
[test_cli_arguments.py]
|
||||
skip-if = manage_instance == false || appname == 'fennec' # Bug 1298921 and bug 1322993
|
||||
[test_geckoinstance.py]
|
||||
[test_data_driven.py]
|
||||
[test_session.py]
|
||||
|
|
Загрузка…
Ссылка в новой задаче