Bug 923607 - Suppress safe-mode dialog when starting in safe-mode; r=automatedtester

This commit is contained in:
Tim Taubert 2013-10-15 11:20:35 -07:00
Родитель b659cfdccd
Коммит c7ecd71e9e
1 изменённых файлов: 24 добавлений и 0 удалений

Просмотреть файл

@ -93,6 +93,12 @@ MarionetteComponent.prototype = {
if (enabledPref) {
this.enabled = true;
this.logger.info("marionette enabled via build flag and pref");
// We want to suppress the modal dialog that's shown
// when starting up in safe-mode to enable testing.
if (Services.appinfo.inSafeMode) {
this.observerService.addObserver(this, "domwindowopened", false);
}
}
else {
this.logger.info("marionette not enabled via pref");
@ -105,6 +111,10 @@ MarionetteComponent.prototype = {
this.observerService.addObserver(this, "xpcom-shutdown", false);
this.init();
break;
case "domwindowopened":
this.observerService.removeObserver(this, aTopic);
this._suppressSafeModeDialog(aSubject);
break;
case "xpcom-shutdown":
this.observerService.removeObserver(this, "xpcom-shutdown");
this.uninit();
@ -112,6 +122,20 @@ MarionetteComponent.prototype = {
}
},
_suppressSafeModeDialog: function mc_suppressSafeModeDialog(aWindow) {
// Wait for the modal dialog to finish loading.
aWindow.addEventListener("load", function onLoad() {
aWindow.removeEventListener("load", onLoad);
if (aWindow.document.getElementById("safeModeDialog")) {
aWindow.setTimeout(() => {
// Accept the dialog to start in safe-mode.
aWindow.document.documentElement.getButton("accept").click();
});
}
});
},
init: function mc_init() {
if (!this._loaded && this.enabled && this.finalUiStartup) {
this._loaded = true;