GitLab is used only for code review, issue tracking and project management. Canonical locations for source code are still https://gitweb.torproject.org/ https://git.torproject.org/ and git-rw.torproject.org.

Commit df0350fc authored by Kathleen Brade's avatar Kathleen Brade

Bug 33906: Fix Tor-Launcher issues for Firefox 75

The <wizard> and <dialog> elements can no longer be used as root elements.
Adapt to the use of shadow DOM within the <wizard> implemention.
Migrate the locale picker from the general.useragent.locale preference to
  intl.locale.requested.
parent 32603f68
<?xml version="1.0"?> <?xml version="1.0"?>
<!-- <!--
- Copyright (c) 2019, The Tor Project, Inc. - Copyright (c) 2020, The Tor Project, Inc.
- See LICENSE for licensing information. - See LICENSE for licensing information.
- vim: set sw=2 sts=2 ts=8 et syntax=xml: - vim: set sw=2 sts=2 ts=8 et syntax=xml:
--> -->
...@@ -9,15 +9,16 @@ ...@@ -9,15 +9,16 @@
<?xml-stylesheet href="chrome://torlauncher/skin/network-settings.css" <?xml-stylesheet href="chrome://torlauncher/skin/network-settings.css"
type="text/css"?> type="text/css"?>
<!DOCTYPE wizard SYSTEM "chrome://torlauncher/locale/network-settings.dtd"> <!DOCTYPE window SYSTEM "chrome://torlauncher/locale/network-settings.dtd">
<wizard id="TorLauncherLocalePicker" <window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" torwizard="true"
title="&torlauncher.localePicker.title;" title="&torlauncher.localePicker.title;"
windowtype="TorLauncher:LocalePicker" windowtype="TorLauncher:LocalePicker"
persist="screenX screenY" persist="screenX screenY"
onload="initLocaleDialog();"> onload="initLocaleDialog();">
<wizard id="TorLauncherLocalePicker">
<script type="application/x-javascript" <script type="application/x-javascript"
src="chrome://torlauncher/content/network-settings.js"/> src="chrome://torlauncher/content/network-settings.js"/>
...@@ -37,3 +38,4 @@ ...@@ -37,3 +38,4 @@
<label id="forAssistance"/> <label id="forAssistance"/>
</hbox> </hbox>
</wizard> </wizard>
</window>
<!-- <!--
- Copyright (c) 2019, The Tor Project, Inc. - Copyright (c) 2020, The Tor Project, Inc.
- See LICENSE for licensing information. - See LICENSE for licensing information.
- vim: set sw=2 sts=2 ts=8 et syntax=xml: - vim: set sw=2 sts=2 ts=8 et syntax=xml:
--> -->
...@@ -8,18 +8,19 @@ ...@@ -8,18 +8,19 @@
<?xml-stylesheet href="chrome://torlauncher/skin/network-settings.css" <?xml-stylesheet href="chrome://torlauncher/skin/network-settings.css"
type="text/css"?> type="text/css"?>
<!DOCTYPE wizard SYSTEM "chrome://torlauncher/locale/network-settings.dtd"> <!DOCTYPE window SYSTEM "chrome://torlauncher/locale/network-settings.dtd">
<wizard id="TorNetworkSettings" <window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
xmlns:html="http://www.w3.org/1999/xhtml" xmlns:html="http://www.w3.org/1999/xhtml"
defaulttitle="&torsettings.wizard.title.default;" torwizard="true"
windowtype="TorLauncher:NetworkSettings" windowtype="TorLauncher:NetworkSettings"
persist="screenX screenY" persist="screenX screenY"
buttonlabelextra2="&torsettings.copyLog;"
onload="initDialog();" onload="initDialog();"
onunload="deinitDialog();"> onunload="deinitDialog();">
<wizard id="TorNetworkSettings"
defaulttitle="&torsettings.wizard.title.default;"
buttonlabelextra2="&torsettings.copyLog;">
<script type="application/x-javascript" <script type="application/x-javascript"
src="chrome://torlauncher/content/network-settings.js"/> src="chrome://torlauncher/content/network-settings.js"/>
...@@ -129,3 +130,4 @@ ...@@ -129,3 +130,4 @@
</hbox> </hbox>
<panel id="copyLogFeedbackPanel"/> <panel id="copyLogFeedbackPanel"/>
</wizard> </wizard>
</window>
// Copyright (c) 2019, The Tor Project, Inc. // Copyright (c) 2020, The Tor Project, Inc.
// See LICENSE for licensing information. // See LICENSE for licensing information.
// //
// vim: set sw=2 sts=2 ts=8 et syntax=javascript: // vim: set sw=2 sts=2 ts=8 et syntax=javascript:
...@@ -20,7 +20,7 @@ XPCOMUtils.defineLazyModuleGetter(this, "TorLauncherBridgeDB", ...@@ -20,7 +20,7 @@ XPCOMUtils.defineLazyModuleGetter(this, "TorLauncherBridgeDB",
"resource://torlauncher/modules/tl-bridgedb.jsm"); "resource://torlauncher/modules/tl-bridgedb.jsm");
const kPrefPromptForLocale = "extensions.torlauncher.prompt_for_locale"; const kPrefPromptForLocale = "extensions.torlauncher.prompt_for_locale";
const kPrefLocale = "general.useragent.locale"; const kPrefLocale = "intl.locale.requested";
const kPrefMatchOSLocale = "intl.locale.matchOS"; const kPrefMatchOSLocale = "intl.locale.matchOS";
// The recommended type is listed first in the dropdown menu. // The recommended type is listed first in the dropdown menu.
...@@ -138,7 +138,7 @@ function initDialogCommon() ...@@ -138,7 +138,7 @@ function initDialogCommon()
let wizardElem = getWizard(); let wizardElem = getWizard();
let haveWizard = (wizardElem != null); let haveWizard = (wizardElem != null);
let cancelBtn = document.documentElement.getButton("cancel"); let cancelBtn = getButton("cancel");
if (cancelBtn) if (cancelBtn)
{ {
gCancelLabelStr = cancelBtn.label; gCancelLabelStr = cancelBtn.label;
...@@ -151,6 +151,18 @@ function initDialogCommon() ...@@ -151,6 +151,18 @@ function initDialogCommon()
if (haveWizard) if (haveWizard)
{ {
// Apply styles to elements within the wizard element's shadow DOM.
let wizardPageBox = wizardElem.shadowRoot.querySelector(".wizard-page-box");
if (wizardPageBox)
{
wizardPageBox.style.padding = "0px";
wizardPageBox.style.margin = "14px 20px 18px 20px";
}
let wizardHeader = wizardElem.shadowRoot.querySelector(".wizard-header");
if (wizardHeader)
wizardHeader.style.display = "none";
// Hide the Tor Browser logo and associated separator element if the // Hide the Tor Browser logo and associated separator element if the
// TOR_HIDE_BROWSER_LOGO environment variable is set. // TOR_HIDE_BROWSER_LOGO environment variable is set.
let env = Cc["@mozilla.org/process/environment;1"] let env = Cc["@mozilla.org/process/environment;1"]
...@@ -291,16 +303,16 @@ function initDialog() ...@@ -291,16 +303,16 @@ function initDialog()
}); });
// Relabel the accept button to be "Connect" // Relabel the accept button to be "Connect"
let okBtn = document.documentElement.getButton("accept"); let okBtn = getButton("accept");
if (okBtn) if (okBtn)
okBtn.label = TorLauncherUtil.getLocalizedString("connect"); okBtn.label = TorLauncherUtil.getLocalizedString("connect");
// Set "Copy Tor Log" label and move it after the Quit (cancel) button. // Set "Copy Tor Log" label and move it after the Quit (cancel) button.
let copyLogBtn = document.documentElement.getButton("extra2"); let copyLogBtn = getButton("extra2");
if (copyLogBtn) if (copyLogBtn)
{ {
copyLogBtn.label = wizardElem.getAttribute("buttonlabelextra2"); copyLogBtn.label = wizardElem.getAttribute("buttonlabelextra2");
let cancelBtn = document.documentElement.getButton("cancel"); let cancelBtn = getButton("cancel");
if (cancelBtn && TorLauncherUtil.isMac) if (cancelBtn && TorLauncherUtil.isMac)
cancelBtn.parentNode.insertBefore(copyLogBtn, cancelBtn.nextSibling); cancelBtn.parentNode.insertBefore(copyLogBtn, cancelBtn.nextSibling);
} }
...@@ -312,7 +324,7 @@ function initDialog() ...@@ -312,7 +324,7 @@ function initDialog()
} }
// Use "Connect" as the finish button label (on the last wizard page). // Use "Connect" as the finish button label (on the last wizard page).
let finishBtn = document.documentElement.getButton("finish"); let finishBtn = getButton("finish");
if (finishBtn) if (finishBtn)
{ {
finishBtn.label = TorLauncherUtil.getLocalizedString("connect"); finishBtn.label = TorLauncherUtil.getLocalizedString("connect");
...@@ -320,7 +332,7 @@ function initDialog() ...@@ -320,7 +332,7 @@ function initDialog()
} }
// Set Discard Settings back button label to match the wizard Back button. // Set Discard Settings back button label to match the wizard Back button.
let wizardBackBtn = document.documentElement.getButton("back"); let wizardBackBtn = getButton("back");
let backBtn = document.getElementById("discardSettingsGoBack"); let backBtn = document.getElementById("discardSettingsGoBack");
if (wizardBackBtn && backBtn) if (wizardBackBtn && backBtn)
backBtn.label = wizardBackBtn.label; backBtn.label = wizardBackBtn.label;
...@@ -374,11 +386,18 @@ function initLocaleDialog() ...@@ -374,11 +386,18 @@ function initLocaleDialog()
// Replace the finish button's label ("Done") with the next button's // Replace the finish button's label ("Done") with the next button's
// label ("Next" or "Continue"). // label ("Next" or "Continue").
let nextBtn = document.documentElement.getButton("next"); let nextBtn = getButton("next");
let doneBtn = document.documentElement.getButton("finish"); let doneBtn = getButton("finish");
if (nextBtn && doneBtn) if (nextBtn && doneBtn)
doneBtn.label = nextBtn.label; doneBtn.label = nextBtn.label;
// The locale picker does not use the "Back" and "Next" buttons; hide them.
let backBtn = getButton("back");
if (backBtn)
backBtn.style.display = "none";
if (nextBtn)
nextBtn.style.display = "none";
let { AddonManager } = Cu.import("resource://gre/modules/AddonManager.jsm"); let { AddonManager } = Cu.import("resource://gre/modules/AddonManager.jsm");
let addonsPromise = AddonManager.getAddonsByTypes(["locale"]); let addonsPromise = AddonManager.getAddonsByTypes(["locale"]);
addonsPromise.then(aLangPackAddons => addonsPromise.then(aLangPackAddons =>
...@@ -432,13 +451,9 @@ function populateLocaleList(aLangPackAddons) ...@@ -432,13 +451,9 @@ function populateLocaleList(aLangPackAddons)
}; };
// Retrieve the current locale so we can select it within the list by default. // Retrieve the current locale so we can select it within the list by default.
let curLocale; let curLocale = Services.locale.requestedLocale;
try if (curLocale)
{ curLocale = curLocale.toLowerCase();
let chromeRegSvc = Cc["@mozilla.org/chrome/chrome-registry;1"]
.getService(Ci.nsIXULChromeRegistry);
curLocale = chromeRegSvc.getSelectedLocale("global").toLowerCase();
} catch (e) {}
// Build a list of language info objects (language code plus friendly name). // Build a list of language info objects (language code plus friendly name).
let foundCurLocale = false; let foundCurLocale = false;
...@@ -485,9 +500,9 @@ function populateLocaleList(aLangPackAddons) ...@@ -485,9 +500,9 @@ function populateLocaleList(aLangPackAddons)
let localeList = document.getElementById(kLocaleList); let localeList = document.getElementById(kLocaleList);
for (let infoObj of langInfo) for (let infoObj of langInfo)
{ {
let listItem = document.createElement("richlistitem"); let listItem = document.createXULElement("richlistitem");
listItem.setAttribute("value", infoObj.langCode); listItem.setAttribute("value", infoObj.langCode);
let label = document.createElement("label"); let label = document.createXULElement("label");
label.value = infoObj.langName; label.value = infoObj.langName;
listItem.appendChild(label); listItem.appendChild(label);
localeList.appendChild(listItem); localeList.appendChild(listItem);
...@@ -517,7 +532,7 @@ function maxWidthOfContent() ...@@ -517,7 +532,7 @@ function maxWidthOfContent()
for (let i = 0; i < buttons.length; ++i) for (let i = 0; i < buttons.length; ++i)
showOrHideButton(buttons[i], true, false); showOrHideButton(buttons[i], true, false);
let btn = document.documentElement.getButton("cancel"); let btn = getButton("cancel");
let btnContainer = btn.parentElement; let btnContainer = btn.parentElement;
const kWarningIconWidth = 20; // skin/warning.png is 16 plus some margin const kWarningIconWidth = 20; // skin/warning.png is 16 plus some margin
...@@ -991,7 +1006,7 @@ function updateBootstrapProgress(aStatusObj) ...@@ -991,7 +1006,7 @@ function updateBootstrapProgress(aStatusObj)
// visibility=hidden instead of XUL hidden=true so that the "For // visibility=hidden instead of XUL hidden=true so that the "For
// Assistance" text does not move. // Assistance" text does not move.
let btnID = getWizard() ? "finish" : "cancel"; let btnID = getWizard() ? "finish" : "cancel";
let btn = document.documentElement.getButton(btnID); let btn = getButton(btnID);
if (btn) if (btn)
btn.style.visibility = "hidden"; btn.style.visibility = "hidden";
window.setTimeout(function() { close(); }, 250); window.setTimeout(function() { close(); }, 250);
...@@ -1248,7 +1263,7 @@ function isShowingErrorOverlay() ...@@ -1248,7 +1263,7 @@ function isShowingErrorOverlay()
function showCopyLogButton(aHaveErrorOrWarning) function showCopyLogButton(aHaveErrorOrWarning)
{ {
let copyLogBtn = document.documentElement.getButton("extra2"); let copyLogBtn = getButton("extra2");
if (copyLogBtn) if (copyLogBtn)
{ {
let haveWizard = (getWizard() != null); let haveWizard = (getWizard() != null);
...@@ -1272,7 +1287,7 @@ function showCopyLogButton(aHaveErrorOrWarning) ...@@ -1272,7 +1287,7 @@ function showCopyLogButton(aHaveErrorOrWarning)
function restoreCopyLogVisibility() function restoreCopyLogVisibility()
{ {
let copyLogBtn = document.documentElement.getButton("extra2"); let copyLogBtn = getButton("extra2");
if (!copyLogBtn) if (!copyLogBtn)
return; return;
...@@ -1288,14 +1303,10 @@ function restoreCopyLogVisibility() ...@@ -1288,14 +1303,10 @@ function restoreCopyLogVisibility()
// Network Settings window. // Network Settings window.
function showOrHideDialogButtons(aShow) function showOrHideDialogButtons(aShow)
{ {
let buttonContainer = document.getAnonymousElementByAttribute( let wizard = getWizard();
document.documentElement, "anonid", "buttons"); let buttonContainer = wizard
if (!buttonContainer) ? wizard.shadowRoot.querySelector(".wizard-buttons")
{ : document.querySelector(".dialog-button-box");
// The wizard uses "Buttons" (capital 'B').
buttonContainer = document.getAnonymousElementByAttribute(
document.documentElement, "anonid", "Buttons");
}
if (buttonContainer) if (buttonContainer)
{ {
...@@ -1328,7 +1339,7 @@ function setButtonAttr(aID, aAttr, aValue) ...@@ -1328,7 +1339,7 @@ function setButtonAttr(aID, aAttr, aValue)
if (!aID || !aAttr) if (!aID || !aAttr)
return null; return null;
let btn = document.documentElement.getButton(aID); // dialog buttons let btn = getButton(aID); // dialog buttons
if (!btn) if (!btn)
btn = document.getElementById(aID); // other buttons btn = document.getElementById(aID); // other buttons
if (btn) if (btn)
...@@ -1428,7 +1439,7 @@ function showMenuListPlaceholderText(aElemID) ...@@ -1428,7 +1439,7 @@ function showMenuListPlaceholderText(aElemID)
function overrideButtonLabel(aID, aLabel) function overrideButtonLabel(aID, aLabel)
{ {
let btn = document.documentElement.getButton(aID); let btn = getButton(aID);
if (btn) if (btn)
{ {
btn.setAttribute("origLabel", btn.label); btn.setAttribute("origLabel", btn.label);
...@@ -1446,7 +1457,7 @@ function overrideButtonLabelWithKey(aID, aLabelKey) ...@@ -1446,7 +1457,7 @@ function overrideButtonLabelWithKey(aID, aLabelKey)
function restoreButtonLabel(aID) function restoreButtonLabel(aID)
{ {
var btn = document.documentElement.getButton(aID); var btn = getButton(aID);
if (btn) if (btn)
{ {
var oldLabel = btn.getAttribute("origLabel"); var oldLabel = btn.getAttribute("origLabel");
...@@ -1641,7 +1652,7 @@ function onCopyLog() ...@@ -1641,7 +1652,7 @@ function onCopyLog()
chSvc.copyString(gProtocolSvc.TorGetLog(countObj)); chSvc.copyString(gProtocolSvc.TorGetLog(countObj));
// Display a feedback popup that fades away after a few seconds. // Display a feedback popup that fades away after a few seconds.
let copyLogBtn = document.documentElement.getButton("extra2"); let copyLogBtn = getButton("extra2");
let panel = document.getElementById(kCopyLogFeedbackPanel); let panel = document.getElementById(kCopyLogFeedbackPanel);
if (copyLogBtn && panel) if (copyLogBtn && panel)
{ {
...@@ -2570,6 +2581,13 @@ function getElemValue(aID, aDefaultValue) ...@@ -2570,6 +2581,13 @@ function getElemValue(aID, aDefaultValue)
} }
function getButton(aButtonName)
{
let dialogOrWizard = document.documentElement.firstChild;
return dialogOrWizard.getButton(aButtonName);
}
// Hide and show groupbox based on aElem's checked state. aElem may be a // Hide and show groupbox based on aElem's checked state. aElem may be a
// checkbox or radio element. // checkbox or radio element.
function toggleElemUI(aElem) function toggleElemUI(aElem)
......
<?xml version="1.0"?> <?xml version="1.0"?>
<!-- <!--
- Copyright (c) 2019, The Tor Project, Inc. - Copyright (c) 2020, The Tor Project, Inc.
- See LICENSE for licensing information. - See LICENSE for licensing information.
- vim: set sw=2 sts=2 ts=8 et syntax=xml: - vim: set sw=2 sts=2 ts=8 et syntax=xml:
--> -->
...@@ -9,19 +9,19 @@ ...@@ -9,19 +9,19 @@
<?xml-stylesheet href="chrome://torlauncher/skin/network-settings.css" <?xml-stylesheet href="chrome://torlauncher/skin/network-settings.css"
type="text/css"?> type="text/css"?>
<!DOCTYPE dialog SYSTEM "chrome://torlauncher/locale/network-settings.dtd"> <!DOCTYPE window SYSTEM "chrome://torlauncher/locale/network-settings.dtd">
<dialog id="TorNetworkSettings" <window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
xmlns:html="http://www.w3.org/1999/xhtml" xmlns:html="http://www.w3.org/1999/xhtml"
title="&torsettings.dialog.title;" title="&torsettings.dialog.title;"
windowtype="TorLauncher:NetworkSettings" windowtype="TorLauncher:NetworkSettings"
persist="screenX screenY" persist="screenX screenY"
buttons="accept,cancel,extra2"
buttonlabelextra2="&torsettings.copyLog;"
onload="initDialog();" onload="initDialog();"
onunload="deinitDialog();"> onunload="deinitDialog();">
<dialog id="TorNetworkSettings"
buttons="accept,cancel,extra2"
buttonlabelextra2="&torsettings.copyLog;">
<script type="application/x-javascript" <script type="application/x-javascript"
src="chrome://torlauncher/content/network-settings.js"/> src="chrome://torlauncher/content/network-settings.js"/>
...@@ -86,3 +86,4 @@ ...@@ -86,3 +86,4 @@
</vbox> </vbox>
</stack> </stack>
</dialog> </dialog>
</window>
/* /*
* Copyright (c) 2019, The Tor Project, Inc. * Copyright (c) 2020, The Tor Project, Inc.
* See LICENSE for licensing information. * See LICENSE for licensing information.
* *
* vim: set sw=2 sts=2 ts=8 et syntax=css: * vim: set sw=2 sts=2 ts=8 et syntax=css:
...@@ -7,36 +7,29 @@ ...@@ -7,36 +7,29 @@
@namespace html "http://www.w3.org/1999/xhtml"; @namespace html "http://www.w3.org/1999/xhtml";
dialog { window {
width: 45em; width: 45em;
height: 41em; height: 41em;
font: -moz-dialog; font: -moz-dialog;
} }
dialog.os-windows { window.os-windows {
width: 49em; width: 49em;
height: 42em; height: 42em;
} }
wizard { window[torwizard="true"] {
width: 45em; width: 45em;
height: 38em; height: 38em;
font: -moz-dialog; font: -moz-dialog;
padding-top: 0px; padding-top: 0px;
} }
wizard.os-windows { window[torwizard="true"].os-windows {
width: 49em; width: 49em;
height: 44em; height: 44em;
} }
.wizard-page-box {
padding: 0px;
margin: 14px 20px 18px 20px;
}
wizard .wizard-header { display: none; }
#forAssistance { #forAssistance {
margin-left: 12px; margin-left: 12px;
margin-bottom: 6px; margin-bottom: 6px;
...@@ -104,11 +97,6 @@ wizard[tor_hide_browser_logo="true"] .tbb-logo { ...@@ -104,11 +97,6 @@ wizard[tor_hide_browser_logo="true"] .tbb-logo {
display: none; display: none;
} }
wizard#TorLauncherLocalePicker button[dlgtype="back"],
wizard#TorLauncherLocalePicker button[dlgtype="next"] {
display: none;
}
/* Show menulist placeholder text in gray. */ /* Show menulist placeholder text in gray. */
#defaultBridgeType:not([value]) .menulist-label, #defaultBridgeType:not([value]) .menulist-label,
#defaultBridgeType[value=""] .menulist-label, #defaultBridgeType[value=""] .menulist-label,
...@@ -124,8 +112,7 @@ wizard#TorLauncherLocalePicker button[dlgtype="next"] { ...@@ -124,8 +112,7 @@ wizard#TorLauncherLocalePicker button[dlgtype="next"] {
margin-left: 1.8em; margin-left: 1.8em;
} }
dialog.os-mac #bridgeList, window.os-mac #bridgeList {
wizard.os-mac #bridgeList {
font-size: 90%; font-size: 90%;
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment