forked from mirrors/gecko-dev
Bug 1889232 - Removed firefox-bridge and firefox-private-bridge protocol creation r=mhughes,Gijs,firefox-desktop-core-reviewers
Differential Revision: https://phabricator.services.mozilla.com/D206419
This commit is contained in:
parent
85a29bfa16
commit
78d468b22c
8 changed files with 285 additions and 429 deletions
|
|
@ -232,22 +232,6 @@
|
|||
<string>file</string>
|
||||
</array>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>CFBundleURLName</key>
|
||||
<string>Firefox Protocol</string>
|
||||
<key>CFBundleURLSchemes</key>
|
||||
<array>
|
||||
<string>firefox-bridge</string>
|
||||
</array>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>CFBundleURLName</key>
|
||||
<string>Firefox Private Browsing Protocol</string>
|
||||
<key>CFBundleURLSchemes</key>
|
||||
<array>
|
||||
<string>firefox-private-bridge</string>
|
||||
</array>
|
||||
</dict>
|
||||
</array>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>@MAC_BUNDLE_VERSION@</string>
|
||||
|
|
|
|||
|
|
@ -60,62 +60,8 @@ function shouldLoadURI(aURI) {
|
|||
return false;
|
||||
}
|
||||
|
||||
function validateFirefoxProtocol(aCmdLine, launchedWithArg_osint) {
|
||||
let paramCount = 0;
|
||||
// Only accept one parameter when we're handling the protocol.
|
||||
for (let i = 0; i < aCmdLine.length; i++) {
|
||||
if (!aCmdLine.getArgument(i).startsWith("-")) {
|
||||
paramCount++;
|
||||
}
|
||||
if (paramCount > 1) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
// `-osint` and handling registered file types and protocols is Windows-only.
|
||||
return AppConstants.platform != "win" || launchedWithArg_osint;
|
||||
}
|
||||
|
||||
function resolveURIInternal(
|
||||
aCmdLine,
|
||||
aArgument,
|
||||
launchedWithArg_osint = false
|
||||
) {
|
||||
function resolveURIInternal(aCmdLine, aArgument) {
|
||||
let principal = lazy.gSystemPrincipal;
|
||||
|
||||
// If using Firefox protocol handler remove it from URI
|
||||
// at this stage. This is before we would otherwise
|
||||
// record telemetry so do that here.
|
||||
let handleFirefoxProtocol = protocol => {
|
||||
let protocolWithColon = protocol + ":";
|
||||
if (aArgument.startsWith(protocolWithColon)) {
|
||||
if (!validateFirefoxProtocol(aCmdLine, launchedWithArg_osint)) {
|
||||
throw new Error(
|
||||
"Invalid use of Firefox-bridge and Firefox-private-bridge protocols."
|
||||
);
|
||||
}
|
||||
aArgument = aArgument.substring(protocolWithColon.length);
|
||||
|
||||
if (
|
||||
!aArgument.startsWith("http://") &&
|
||||
!aArgument.startsWith("https://")
|
||||
) {
|
||||
throw new Error(
|
||||
"Firefox-bridge and Firefox-private-bridge protocols can only be used in conjunction with http and https urls."
|
||||
);
|
||||
}
|
||||
|
||||
principal = Services.scriptSecurityManager.createNullPrincipal({});
|
||||
Services.telemetry.keyedScalarAdd(
|
||||
"os.environment.launched_to_handle",
|
||||
protocol,
|
||||
1
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
handleFirefoxProtocol("firefox-bridge");
|
||||
handleFirefoxProtocol("firefox-private-bridge");
|
||||
|
||||
var uri = aCmdLine.resolveURI(aArgument);
|
||||
var uriFixup = Services.uriFixup;
|
||||
|
||||
|
|
@ -602,17 +548,7 @@ nsBrowserContentHandler.prototype = {
|
|||
"private-window",
|
||||
false
|
||||
);
|
||||
// Check for Firefox private browsing protocol handler here.
|
||||
let url = null;
|
||||
let urlFlagIdx = cmdLine.findFlag("url", false);
|
||||
if (urlFlagIdx > -1 && cmdLine.length > 1) {
|
||||
url = cmdLine.getArgument(urlFlagIdx + 1);
|
||||
}
|
||||
if (privateWindowParam || url?.startsWith("firefox-private-bridge:")) {
|
||||
// Check if the osint flag is present on Windows
|
||||
let launchedWithArg_osint =
|
||||
AppConstants.platform == "win" &&
|
||||
cmdLine.findFlag("osint", false) == 0;
|
||||
if (privateWindowParam) {
|
||||
let forcePrivate = true;
|
||||
let resolvedInfo;
|
||||
if (!lazy.PrivateBrowsingUtils.enabled) {
|
||||
|
|
@ -623,19 +559,8 @@ nsBrowserContentHandler.prototype = {
|
|||
uri: Services.io.newURI("about:privatebrowsing"),
|
||||
principal: lazy.gSystemPrincipal,
|
||||
};
|
||||
} else if (url?.startsWith("firefox-private-bridge:")) {
|
||||
cmdLine.removeArguments(urlFlagIdx, urlFlagIdx + 1);
|
||||
resolvedInfo = resolveURIInternal(
|
||||
cmdLine,
|
||||
url,
|
||||
launchedWithArg_osint
|
||||
);
|
||||
} else {
|
||||
resolvedInfo = resolveURIInternal(
|
||||
cmdLine,
|
||||
privateWindowParam,
|
||||
launchedWithArg_osint
|
||||
);
|
||||
resolvedInfo = resolveURIInternal(cmdLine, privateWindowParam);
|
||||
}
|
||||
handURIToExistingBrowser(
|
||||
resolvedInfo.uri,
|
||||
|
|
@ -1430,11 +1355,7 @@ nsDefaultCommandLineHandler.prototype = {
|
|||
try {
|
||||
var ar;
|
||||
while ((ar = cmdLine.handleFlagWithParam("url", false))) {
|
||||
let { uri, principal } = resolveURIInternal(
|
||||
cmdLine,
|
||||
ar,
|
||||
launchedWithArg_osint
|
||||
);
|
||||
let { uri, principal } = resolveURIInternal(cmdLine, ar);
|
||||
urilist.push(uri);
|
||||
principalList.push(principal);
|
||||
|
||||
|
|
@ -1506,9 +1427,6 @@ nsDefaultCommandLineHandler.prototype = {
|
|||
}
|
||||
|
||||
// Can't open multiple URLs without using system principal.
|
||||
// The firefox-bridge and firefox-private-bridge protocols should only
|
||||
// accept a single URL due to using the -osint option
|
||||
// so this isn't very relevant.
|
||||
var URLlist = urilist.filter(shouldLoadURI).map(u => u.spec);
|
||||
if (URLlist.length) {
|
||||
openBrowserWindow(cmdLine, lazy.gSystemPrincipal, URLlist);
|
||||
|
|
|
|||
|
|
@ -3769,7 +3769,7 @@ BrowserGlue.prototype = {
|
|||
_migrateUI() {
|
||||
// Use an increasing number to keep track of the current migration state.
|
||||
// Completely unrelated to the current Firefox release number.
|
||||
const UI_VERSION = 144;
|
||||
const UI_VERSION = 145;
|
||||
const BROWSER_DOCURL = AppConstants.BROWSER_CHROME_URL;
|
||||
|
||||
if (!Services.prefs.prefHasUserValue("browser.migration.version")) {
|
||||
|
|
@ -3777,12 +3777,6 @@ BrowserGlue.prototype = {
|
|||
Services.prefs.setIntPref("browser.migration.version", UI_VERSION);
|
||||
this._isNewProfile = true;
|
||||
|
||||
if (AppConstants.platform == "win") {
|
||||
// Ensure that the Firefox Bridge protocols are registered for the new profile.
|
||||
// No-op if they are registered for the user or the local machine already.
|
||||
lazy.FirefoxBridgeExtensionUtils.maybeRegisterFirefoxBridgeProtocols();
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -4383,24 +4377,7 @@ BrowserGlue.prototype = {
|
|||
}
|
||||
|
||||
if (currentUIVersion < 143) {
|
||||
if (AppConstants.platform == "win") {
|
||||
// In Firefox 122, we enabled the firefox and firefox-private protocols.
|
||||
// We switched over to using firefox-bridge and firefox-private-bridge,
|
||||
// but we want to clean up the use of the other protocols.
|
||||
lazy.FirefoxBridgeExtensionUtils.maybeDeleteBridgeProtocolRegistryEntries();
|
||||
|
||||
// Register the new firefox bridge related protocols now
|
||||
lazy.FirefoxBridgeExtensionUtils.maybeRegisterFirefoxBridgeProtocols();
|
||||
|
||||
// Clean up the old user prefs from FX 122
|
||||
Services.prefs.clearUserPref(
|
||||
"network.protocol-handler.external.firefox"
|
||||
);
|
||||
Services.prefs.clearUserPref(
|
||||
"network.protocol-handler.external.firefox-private"
|
||||
);
|
||||
Services.prefs.clearUserPref("browser.shell.customProtocolsRegistered");
|
||||
}
|
||||
// Version 143 has been superseded by version 145 below.
|
||||
}
|
||||
|
||||
if (currentUIVersion < 144) {
|
||||
|
|
@ -4420,6 +4397,40 @@ BrowserGlue.prototype = {
|
|||
}
|
||||
}
|
||||
|
||||
if (currentUIVersion < 145) {
|
||||
if (AppConstants.platform == "win") {
|
||||
// In Firefox 122, we enabled the firefox and firefox-private protocols.
|
||||
// We switched over to using firefox-bridge and firefox-private-bridge,
|
||||
// but we want to clean up the use of the other protocols.
|
||||
lazy.FirefoxBridgeExtensionUtils.maybeDeleteBridgeProtocolRegistryEntries(
|
||||
lazy.FirefoxBridgeExtensionUtils.OLD_PUBLIC_PROTOCOL,
|
||||
lazy.FirefoxBridgeExtensionUtils.OLD_PRIVATE_PROTOCOL
|
||||
);
|
||||
|
||||
// Clean up the old user prefs from FX 122
|
||||
Services.prefs.clearUserPref(
|
||||
"network.protocol-handler.external.firefox"
|
||||
);
|
||||
Services.prefs.clearUserPref(
|
||||
"network.protocol-handler.external.firefox-private"
|
||||
);
|
||||
|
||||
// In Firefox 126, we switched over to using native messaging so the
|
||||
// protocols are no longer necessary even in firefox-bridge and
|
||||
// firefox-private-bridge form
|
||||
lazy.FirefoxBridgeExtensionUtils.maybeDeleteBridgeProtocolRegistryEntries(
|
||||
lazy.FirefoxBridgeExtensionUtils.PUBLIC_PROTOCOL,
|
||||
lazy.FirefoxBridgeExtensionUtils.PRIVATE_PROTOCOL
|
||||
);
|
||||
Services.prefs.clearUserPref(
|
||||
"network.protocol-handler.external.firefox-bridge"
|
||||
);
|
||||
Services.prefs.clearUserPref(
|
||||
"network.protocol-handler.external.firefox-private-bridge"
|
||||
);
|
||||
Services.prefs.clearUserPref("browser.shell.customProtocolsRegistered");
|
||||
}
|
||||
}
|
||||
// Update the migration version.
|
||||
Services.prefs.setIntPref("browser.migration.version", UI_VERSION);
|
||||
},
|
||||
|
|
|
|||
|
|
@ -91,18 +91,6 @@
|
|||
<uap:Logo>Assets\Document44x44.png</uap:Logo>
|
||||
</uap3:Protocol>
|
||||
</uap3:Extension>
|
||||
<uap3:Extension Category="windows.protocol">
|
||||
<uap3:Protocol Name="firefox-bridge" Parameters="-osint -url "%1"">
|
||||
<uap:DisplayName>Firefox Bridge Protocol</uap:DisplayName>
|
||||
<uap:Logo>Assets\Document44x44.png</uap:Logo>
|
||||
</uap3:Protocol>
|
||||
</uap3:Extension>
|
||||
<uap3:Extension Category="windows.protocol">
|
||||
<uap3:Protocol Name="firefox-private-bridge" Parameters="-osint -private-window "%1"">
|
||||
<uap:DisplayName>Firefox Private Bridge Protocol</uap:DisplayName>
|
||||
<uap:Logo>Assets\Document44x44.png</uap:Logo>
|
||||
</uap3:Protocol>
|
||||
</uap3:Extension>
|
||||
<!-- COM registrations for the notification server. -->
|
||||
<com:Extension Category="windows.comServer">
|
||||
<com:ComServer>
|
||||
|
|
|
|||
|
|
@ -474,25 +474,6 @@ Section "-Application" APP_IDX
|
|||
${AddDisabledDDEHandlerValues} "FirefoxURL-$AppUserModelID" "$2" "$8,${IDI_DOCUMENT_ZERO_BASED}" \
|
||||
"${AppRegName} URL" "true"
|
||||
|
||||
; Create protocol registry keys for FirefoxBridge extensions - only if not already set
|
||||
SetShellVarContext current ; Set SHCTX to HKCU
|
||||
!define FIREFOX_PROTOCOL "firefox-bridge"
|
||||
ClearErrors
|
||||
ReadRegStr $0 SHCTX "Software\Classes\${FIREFOX_PROTOCOL}" ""
|
||||
${If} $0 == ""
|
||||
${AddDisabledDDEHandlerValues} "${FIREFOX_PROTOCOL}" "$2" "$8,${IDI_APPICON_ZERO_BASED}" \
|
||||
"Firefox Bridge Protocol" "true"
|
||||
${EndIf}
|
||||
|
||||
!define FIREFOX_PRIVATE_PROTOCOL "firefox-private-bridge"
|
||||
ClearErrors
|
||||
ReadRegStr $0 SHCTX "Software\Classes\${FIREFOX_PRIVATE_PROTOCOL}" ""
|
||||
${If} $0 == ""
|
||||
${AddDisabledDDEHandlerValues} "${FIREFOX_PRIVATE_PROTOCOL}" "$\"$8$\" -osint -private-window $\"%1$\"" \
|
||||
"$8,${IDI_PBICON_PB_EXE_ZERO_BASED}" "Firefox Private Bridge Protocol" "true"
|
||||
${EndIf}
|
||||
SetShellVarContext all ; Set SHCTX to HKLM
|
||||
|
||||
; The keys below can be set in HKCU if needed.
|
||||
${If} $TmpVal == "HKLM"
|
||||
; Set the Start Menu Internet and Registered App HKLM registry keys.
|
||||
|
|
|
|||
|
|
@ -56,6 +56,10 @@ export const FirefoxBridgeExtensionUtils = {
|
|||
* In Firefox 122, we enabled the firefox and firefox-private protocols.
|
||||
* We switched over to using firefox-bridge and firefox-private-bridge,
|
||||
*
|
||||
* In Firefox 126, we deleted the above firefox-bridge and
|
||||
* firefox-private-bridge protocols in favor of using native
|
||||
* messaging so we are only keeping the deletion code.
|
||||
*
|
||||
* but we want to clean up the use of the other protocols.
|
||||
*
|
||||
* deleteBridgeProtocolRegistryEntryHelper handles everything outside of the logic needed for
|
||||
|
|
@ -66,7 +70,15 @@ export const FirefoxBridgeExtensionUtils = {
|
|||
* them with. If the entries are changed in any way, it is assumed that the user
|
||||
* mucked with them manually and knows what they are doing.
|
||||
*/
|
||||
|
||||
PUBLIC_PROTOCOL: "firefox-bridge",
|
||||
PRIVATE_PROTOCOL: "firefox-private-bridge",
|
||||
OLD_PUBLIC_PROTOCOL: "firefox",
|
||||
OLD_PRIVATE_PROTOCOL: "firefox-private",
|
||||
|
||||
maybeDeleteBridgeProtocolRegistryEntries(
|
||||
publicProtocol = this.PUBLIC_PROTOCOL,
|
||||
privateProtocol = this.PRIVATE_PROTOCOL,
|
||||
deleteBridgeProtocolRegistryEntryHelper = new DeleteBridgeProtocolRegistryEntryHelperImplementation()
|
||||
) {
|
||||
try {
|
||||
|
|
@ -110,9 +122,9 @@ export const FirefoxBridgeExtensionUtils = {
|
|||
}
|
||||
};
|
||||
|
||||
maybeDeleteRegistryKey("firefox", `\"${path}\" -osint -url \"%1\"`);
|
||||
maybeDeleteRegistryKey(publicProtocol, `\"${path}\" -osint -url \"%1\"`);
|
||||
maybeDeleteRegistryKey(
|
||||
"firefox-private",
|
||||
privateProtocol,
|
||||
`\"${path}\" -osint -private-window \"%1\"`
|
||||
);
|
||||
} catch (err) {
|
||||
|
|
@ -122,111 +134,6 @@ export const FirefoxBridgeExtensionUtils = {
|
|||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Registers the firefox-bridge and firefox-private-bridge protocols
|
||||
* on the Windows platform.
|
||||
*/
|
||||
maybeRegisterFirefoxBridgeProtocols() {
|
||||
const FIREFOX_BRIDGE_HANDLER_NAME = "firefox-bridge";
|
||||
const FIREFOX_PRIVATE_BRIDGE_HANDLER_NAME = "firefox-private-bridge";
|
||||
const path = Services.dirsvc.get("XREExeF", Ci.nsIFile).path;
|
||||
let wrk = Cc["@mozilla.org/windows-registry-key;1"].createInstance(
|
||||
Ci.nsIWindowsRegKey
|
||||
);
|
||||
try {
|
||||
wrk.open(wrk.ROOT_KEY_CLASSES_ROOT, "", wrk.ACCESS_READ);
|
||||
let FxSet = wrk.hasChild(FIREFOX_BRIDGE_HANDLER_NAME);
|
||||
let FxPrivateSet = wrk.hasChild(FIREFOX_PRIVATE_BRIDGE_HANDLER_NAME);
|
||||
wrk.close();
|
||||
if (FxSet && FxPrivateSet) {
|
||||
return;
|
||||
}
|
||||
wrk.open(wrk.ROOT_KEY_CURRENT_USER, "Software\\Classes", wrk.ACCESS_ALL);
|
||||
const maybeUpdateRegistry = (isSetAlready, handler, protocolName) => {
|
||||
if (isSetAlready) {
|
||||
return;
|
||||
}
|
||||
let FxKey = wrk.createChild(handler, wrk.ACCESS_ALL);
|
||||
try {
|
||||
// Write URL protocol key
|
||||
FxKey.writeStringValue("", protocolName);
|
||||
FxKey.writeStringValue("URL Protocol", "");
|
||||
FxKey.close();
|
||||
// Write defaultIcon key
|
||||
FxKey.create(
|
||||
FxKey.ROOT_KEY_CURRENT_USER,
|
||||
"Software\\Classes\\" + handler + "\\DefaultIcon",
|
||||
FxKey.ACCESS_ALL
|
||||
);
|
||||
FxKey.open(
|
||||
FxKey.ROOT_KEY_CURRENT_USER,
|
||||
"Software\\Classes\\" + handler + "\\DefaultIcon",
|
||||
FxKey.ACCESS_ALL
|
||||
);
|
||||
FxKey.writeStringValue("", `\"${path}\",1`);
|
||||
FxKey.close();
|
||||
// Write shell\\open\\command key
|
||||
FxKey.create(
|
||||
FxKey.ROOT_KEY_CURRENT_USER,
|
||||
"Software\\Classes\\" + handler + "\\shell",
|
||||
FxKey.ACCESS_ALL
|
||||
);
|
||||
FxKey.create(
|
||||
FxKey.ROOT_KEY_CURRENT_USER,
|
||||
"Software\\Classes\\" + handler + "\\shell\\open",
|
||||
FxKey.ACCESS_ALL
|
||||
);
|
||||
FxKey.create(
|
||||
FxKey.ROOT_KEY_CURRENT_USER,
|
||||
"Software\\Classes\\" + handler + "\\shell\\open\\command",
|
||||
FxKey.ACCESS_ALL
|
||||
);
|
||||
FxKey.open(
|
||||
FxKey.ROOT_KEY_CURRENT_USER,
|
||||
"Software\\Classes\\" + handler + "\\shell\\open\\command",
|
||||
FxKey.ACCESS_ALL
|
||||
);
|
||||
if (handler == FIREFOX_PRIVATE_BRIDGE_HANDLER_NAME) {
|
||||
FxKey.writeStringValue(
|
||||
"",
|
||||
`\"${path}\" -osint -private-window \"%1\"`
|
||||
);
|
||||
} else {
|
||||
FxKey.writeStringValue("", `\"${path}\" -osint -url \"%1\"`);
|
||||
}
|
||||
} catch (ex) {
|
||||
console.error(ex);
|
||||
} finally {
|
||||
FxKey.close();
|
||||
}
|
||||
};
|
||||
|
||||
try {
|
||||
maybeUpdateRegistry(
|
||||
FxSet,
|
||||
FIREFOX_BRIDGE_HANDLER_NAME,
|
||||
"URL:Firefox Bridge Protocol"
|
||||
);
|
||||
} catch (ex) {
|
||||
console.error(ex);
|
||||
}
|
||||
|
||||
try {
|
||||
maybeUpdateRegistry(
|
||||
FxPrivateSet,
|
||||
FIREFOX_PRIVATE_BRIDGE_HANDLER_NAME,
|
||||
"URL:Firefox Private Bridge Protocol"
|
||||
);
|
||||
} catch (ex) {
|
||||
console.error(ex);
|
||||
}
|
||||
} catch (ex) {
|
||||
console.error(ex);
|
||||
} finally {
|
||||
wrk.close();
|
||||
}
|
||||
},
|
||||
|
||||
getNativeMessagingHostId() {
|
||||
let nativeMessagingHostId = "org.mozilla.firefox_bridge_nmh";
|
||||
if (AppConstants.NIGHTLY_BUILD) {
|
||||
|
|
|
|||
|
|
@ -7,9 +7,10 @@ const { FirefoxBridgeExtensionUtils } = ChromeUtils.importESModule(
|
|||
"resource:///modules/FirefoxBridgeExtensionUtils.sys.mjs"
|
||||
);
|
||||
|
||||
const FIREFOX_SHELL_OPEN_COMMAND_PATH = "firefox\\shell\\open\\command";
|
||||
const FIREFOX_PRIVATE_SHELL_OPEN_COMMAND_PATH =
|
||||
"firefox-private\\shell\\open\\command";
|
||||
const OLD_FIREFOX_SHELL_OPEN_COMMAND_PATH = `${FirefoxBridgeExtensionUtils.OLD_PUBLIC_PROTOCOL}\\shell\\open\\command`;
|
||||
const OLD_FIREFOX_PRIVATE_SHELL_OPEN_COMMAND_PATH = `${FirefoxBridgeExtensionUtils.OLD_PRIVATE_PROTOCOL}\\shell\\open\\command`;
|
||||
const FIREFOX_SHELL_OPEN_COMMAND_PATH = `${FirefoxBridgeExtensionUtils.PUBLIC_PROTOCOL}\\shell\\open\\command`;
|
||||
const FIREFOX_PRIVATE_SHELL_OPEN_COMMAND_PATH = `${FirefoxBridgeExtensionUtils.PRIVATE_PROTOCOL}\\shell\\open\\command`;
|
||||
|
||||
class StubbedRegistryKey {
|
||||
#children;
|
||||
|
|
@ -145,206 +146,274 @@ class StubbedDeleteBridgeProtocolRegistryEntryHelper {
|
|||
}
|
||||
|
||||
add_task(async function test_DeleteWhenSameFirefoxInstall() {
|
||||
const applicationPath = "testPath";
|
||||
for (let protocols of [
|
||||
[
|
||||
FirefoxBridgeExtensionUtils.OLD_PUBLIC_PROTOCOL,
|
||||
FirefoxBridgeExtensionUtils.OLD_PRIVATE_PROTOCOL,
|
||||
OLD_FIREFOX_SHELL_OPEN_COMMAND_PATH,
|
||||
OLD_FIREFOX_PRIVATE_SHELL_OPEN_COMMAND_PATH,
|
||||
],
|
||||
[
|
||||
FirefoxBridgeExtensionUtils.PUBLIC_PROTOCOL,
|
||||
FirefoxBridgeExtensionUtils.PRIVATE_PROTOCOL,
|
||||
FIREFOX_SHELL_OPEN_COMMAND_PATH,
|
||||
FIREFOX_PRIVATE_SHELL_OPEN_COMMAND_PATH,
|
||||
],
|
||||
]) {
|
||||
let [publicProtocol, privateProtocol, publicPath, privatePath] = protocols;
|
||||
const applicationPath = "testPath";
|
||||
|
||||
const firefoxEntries = new Map();
|
||||
firefoxEntries.set("", `\"${applicationPath}\" -osint -url \"%1\"`);
|
||||
const firefoxEntries = new Map();
|
||||
firefoxEntries.set("", `\"${applicationPath}\" -osint -url \"%1\"`);
|
||||
|
||||
const firefoxProtocolRegKey = new StubbedRegistryKey(
|
||||
new Map(),
|
||||
firefoxEntries
|
||||
);
|
||||
const firefoxProtocolRegKey = new StubbedRegistryKey(
|
||||
new Map(),
|
||||
firefoxEntries
|
||||
);
|
||||
|
||||
const firefoxPrivateEntries = new Map();
|
||||
firefoxPrivateEntries.set(
|
||||
"",
|
||||
`\"${applicationPath}\" -osint -private-window \"%1\"`
|
||||
);
|
||||
const firefoxPrivateProtocolRegKey = new StubbedRegistryKey(
|
||||
new Map(),
|
||||
firefoxPrivateEntries
|
||||
);
|
||||
const firefoxPrivateEntries = new Map();
|
||||
firefoxPrivateEntries.set(
|
||||
"",
|
||||
`\"${applicationPath}\" -osint -private-window \"%1\"`
|
||||
);
|
||||
const firefoxPrivateProtocolRegKey = new StubbedRegistryKey(
|
||||
new Map(),
|
||||
firefoxPrivateEntries
|
||||
);
|
||||
|
||||
const children = new Map();
|
||||
children.set(FIREFOX_SHELL_OPEN_COMMAND_PATH, firefoxProtocolRegKey);
|
||||
children.set(
|
||||
FIREFOX_PRIVATE_SHELL_OPEN_COMMAND_PATH,
|
||||
firefoxPrivateProtocolRegKey
|
||||
);
|
||||
const children = new Map();
|
||||
children.set(publicPath, firefoxProtocolRegKey);
|
||||
children.set(privatePath, firefoxPrivateProtocolRegKey);
|
||||
|
||||
const registryRootKey = new StubbedRegistryKey(children, new Map());
|
||||
const registryRootKey = new StubbedRegistryKey(children, new Map());
|
||||
|
||||
const stubbedDeleteBridgeProtocolRegistryHelper =
|
||||
new StubbedDeleteBridgeProtocolRegistryEntryHelper({
|
||||
applicationPath,
|
||||
registryRootKey,
|
||||
});
|
||||
const stubbedDeleteBridgeProtocolRegistryHelper =
|
||||
new StubbedDeleteBridgeProtocolRegistryEntryHelper({
|
||||
applicationPath,
|
||||
registryRootKey,
|
||||
});
|
||||
|
||||
FirefoxBridgeExtensionUtils.maybeDeleteBridgeProtocolRegistryEntries(
|
||||
stubbedDeleteBridgeProtocolRegistryHelper
|
||||
);
|
||||
FirefoxBridgeExtensionUtils.maybeDeleteBridgeProtocolRegistryEntries(
|
||||
publicProtocol,
|
||||
privateProtocol,
|
||||
stubbedDeleteBridgeProtocolRegistryHelper
|
||||
);
|
||||
|
||||
ok(registryRootKey.wasCloseCalled, "Root key closed");
|
||||
ok(registryRootKey.wasCloseCalled, "Root key closed");
|
||||
|
||||
ok(firefoxProtocolRegKey.wasOpenedForRead, "Firefox key opened");
|
||||
ok(firefoxProtocolRegKey.wasCloseCalled, "Firefox key closed");
|
||||
ok(
|
||||
registryRootKey.isChildDeleted("firefox"),
|
||||
"Firefox protocol registry entry deleted"
|
||||
);
|
||||
ok(firefoxProtocolRegKey.wasOpenedForRead, "Firefox key opened");
|
||||
ok(firefoxProtocolRegKey.wasCloseCalled, "Firefox key closed");
|
||||
ok(
|
||||
registryRootKey.isChildDeleted(publicProtocol),
|
||||
"Firefox protocol registry entry deleted"
|
||||
);
|
||||
|
||||
ok(
|
||||
firefoxPrivateProtocolRegKey.wasOpenedForRead,
|
||||
"Firefox private key opened"
|
||||
);
|
||||
ok(firefoxPrivateProtocolRegKey.wasCloseCalled, "Firefox private key closed");
|
||||
ok(
|
||||
registryRootKey.isChildDeleted("firefox-private"),
|
||||
"Firefox private protocol registry entry deleted"
|
||||
);
|
||||
ok(
|
||||
firefoxPrivateProtocolRegKey.wasOpenedForRead,
|
||||
"Firefox private key opened"
|
||||
);
|
||||
ok(
|
||||
firefoxPrivateProtocolRegKey.wasCloseCalled,
|
||||
"Firefox private key closed"
|
||||
);
|
||||
ok(
|
||||
registryRootKey.isChildDeleted(privateProtocol),
|
||||
"Firefox private protocol registry entry deleted"
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
add_task(async function test_DeleteWhenDifferentFirefoxInstall() {
|
||||
const applicationPath = "testPath";
|
||||
const badApplicationPath = "testPath2";
|
||||
for (let protocols of [
|
||||
[
|
||||
FirefoxBridgeExtensionUtils.OLD_PUBLIC_PROTOCOL,
|
||||
FirefoxBridgeExtensionUtils.OLD_PRIVATE_PROTOCOL,
|
||||
OLD_FIREFOX_SHELL_OPEN_COMMAND_PATH,
|
||||
OLD_FIREFOX_PRIVATE_SHELL_OPEN_COMMAND_PATH,
|
||||
],
|
||||
[
|
||||
FirefoxBridgeExtensionUtils.PUBLIC_PROTOCOL,
|
||||
FirefoxBridgeExtensionUtils.PRIVATE_PROTOCOL,
|
||||
FIREFOX_SHELL_OPEN_COMMAND_PATH,
|
||||
FIREFOX_PRIVATE_SHELL_OPEN_COMMAND_PATH,
|
||||
],
|
||||
]) {
|
||||
let [publicProtocol, privateProtocol, publicPath, privatePath] = protocols;
|
||||
const applicationPath = "testPath";
|
||||
const badApplicationPath = "testPath2";
|
||||
|
||||
const firefoxEntries = new Map();
|
||||
firefoxEntries.set("", `\"${badApplicationPath}\" -osint -url \"%1\"`);
|
||||
const firefoxEntries = new Map();
|
||||
firefoxEntries.set("", `\"${badApplicationPath}\" -osint -url \"%1\"`);
|
||||
|
||||
const firefoxProtocolRegKey = new StubbedRegistryKey(
|
||||
new Map(),
|
||||
firefoxEntries
|
||||
);
|
||||
const firefoxProtocolRegKey = new StubbedRegistryKey(
|
||||
new Map(),
|
||||
firefoxEntries
|
||||
);
|
||||
|
||||
const firefoxPrivateEntries = new Map();
|
||||
firefoxPrivateEntries.set(
|
||||
"",
|
||||
`\"${badApplicationPath}\" -osint -private-window \"%1\"`
|
||||
);
|
||||
const firefoxPrivateProtocolRegKey = new StubbedRegistryKey(
|
||||
new Map(),
|
||||
firefoxPrivateEntries
|
||||
);
|
||||
const firefoxPrivateEntries = new Map();
|
||||
firefoxPrivateEntries.set(
|
||||
"",
|
||||
`\"${badApplicationPath}\" -osint -private-window \"%1\"`
|
||||
);
|
||||
const firefoxPrivateProtocolRegKey = new StubbedRegistryKey(
|
||||
new Map(),
|
||||
firefoxPrivateEntries
|
||||
);
|
||||
|
||||
const children = new Map();
|
||||
children.set(FIREFOX_SHELL_OPEN_COMMAND_PATH, firefoxProtocolRegKey);
|
||||
children.set(
|
||||
FIREFOX_PRIVATE_SHELL_OPEN_COMMAND_PATH,
|
||||
firefoxPrivateProtocolRegKey
|
||||
);
|
||||
const children = new Map();
|
||||
children.set(publicPath, firefoxProtocolRegKey);
|
||||
children.set(privatePath, firefoxPrivateProtocolRegKey);
|
||||
|
||||
const registryRootKey = new StubbedRegistryKey(children, new Map());
|
||||
const registryRootKey = new StubbedRegistryKey(children, new Map());
|
||||
|
||||
const stubbedDeleteBridgeProtocolRegistryHelper =
|
||||
new StubbedDeleteBridgeProtocolRegistryEntryHelper({
|
||||
applicationPath,
|
||||
registryRootKey,
|
||||
});
|
||||
const stubbedDeleteBridgeProtocolRegistryHelper =
|
||||
new StubbedDeleteBridgeProtocolRegistryEntryHelper({
|
||||
applicationPath,
|
||||
registryRootKey,
|
||||
});
|
||||
|
||||
FirefoxBridgeExtensionUtils.maybeDeleteBridgeProtocolRegistryEntries(
|
||||
stubbedDeleteBridgeProtocolRegistryHelper
|
||||
);
|
||||
FirefoxBridgeExtensionUtils.maybeDeleteBridgeProtocolRegistryEntries(
|
||||
publicProtocol,
|
||||
privateProtocol,
|
||||
stubbedDeleteBridgeProtocolRegistryHelper
|
||||
);
|
||||
|
||||
ok(registryRootKey.wasCloseCalled, "Root key closed");
|
||||
ok(registryRootKey.wasCloseCalled, "Root key closed");
|
||||
|
||||
ok(firefoxProtocolRegKey.wasOpenedForRead, "Firefox key opened");
|
||||
ok(firefoxProtocolRegKey.wasCloseCalled, "Firefox key closed");
|
||||
ok(
|
||||
!registryRootKey.isChildDeleted("firefox"),
|
||||
"Firefox protocol registry entry not deleted"
|
||||
);
|
||||
ok(firefoxProtocolRegKey.wasOpenedForRead, "Firefox key opened");
|
||||
ok(firefoxProtocolRegKey.wasCloseCalled, "Firefox key closed");
|
||||
ok(
|
||||
!registryRootKey.isChildDeleted(publicProtocol),
|
||||
"Firefox protocol registry entry not deleted"
|
||||
);
|
||||
|
||||
ok(
|
||||
firefoxPrivateProtocolRegKey.wasOpenedForRead,
|
||||
"Firefox private key opened"
|
||||
);
|
||||
ok(firefoxPrivateProtocolRegKey.wasCloseCalled, "Firefox private key closed");
|
||||
ok(
|
||||
!registryRootKey.isChildDeleted("firefox-private"),
|
||||
"Firefox private protocol registry entry not deleted"
|
||||
);
|
||||
ok(
|
||||
firefoxPrivateProtocolRegKey.wasOpenedForRead,
|
||||
"Firefox private key opened"
|
||||
);
|
||||
ok(
|
||||
firefoxPrivateProtocolRegKey.wasCloseCalled,
|
||||
"Firefox private key closed"
|
||||
);
|
||||
ok(
|
||||
!registryRootKey.isChildDeleted(privateProtocol),
|
||||
"Firefox private protocol registry entry not deleted"
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
add_task(async function test_DeleteWhenNoRegistryEntries() {
|
||||
const applicationPath = "testPath";
|
||||
for (let protocols of [
|
||||
[
|
||||
FirefoxBridgeExtensionUtils.OLD_PUBLIC_PROTOCOL,
|
||||
FirefoxBridgeExtensionUtils.OLD_PRIVATE_PROTOCOL,
|
||||
OLD_FIREFOX_PRIVATE_SHELL_OPEN_COMMAND_PATH,
|
||||
],
|
||||
[
|
||||
FirefoxBridgeExtensionUtils.PUBLIC_PROTOCOL,
|
||||
FirefoxBridgeExtensionUtils.PRIVATE_PROTOCOL,
|
||||
FIREFOX_PRIVATE_SHELL_OPEN_COMMAND_PATH,
|
||||
],
|
||||
]) {
|
||||
let [publicProtocol, privateProtocol, privatePath] = protocols;
|
||||
const applicationPath = "testPath";
|
||||
|
||||
const firefoxPrivateEntries = new Map();
|
||||
const firefoxPrivateProtocolRegKey = new StubbedRegistryKey(
|
||||
new Map(),
|
||||
firefoxPrivateEntries
|
||||
);
|
||||
const firefoxPrivateEntries = new Map();
|
||||
const firefoxPrivateProtocolRegKey = new StubbedRegistryKey(
|
||||
new Map(),
|
||||
firefoxPrivateEntries
|
||||
);
|
||||
|
||||
const children = new Map();
|
||||
children.set(
|
||||
FIREFOX_PRIVATE_SHELL_OPEN_COMMAND_PATH,
|
||||
firefoxPrivateProtocolRegKey
|
||||
);
|
||||
const children = new Map();
|
||||
children.set(privatePath, firefoxPrivateProtocolRegKey);
|
||||
|
||||
const registryRootKey = new StubbedRegistryKey(children, new Map());
|
||||
const registryRootKey = new StubbedRegistryKey(children, new Map());
|
||||
|
||||
const stubbedDeleteBridgeProtocolRegistryHelper =
|
||||
new StubbedDeleteBridgeProtocolRegistryEntryHelper({
|
||||
applicationPath,
|
||||
registryRootKey,
|
||||
});
|
||||
const stubbedDeleteBridgeProtocolRegistryHelper =
|
||||
new StubbedDeleteBridgeProtocolRegistryEntryHelper({
|
||||
applicationPath,
|
||||
registryRootKey,
|
||||
});
|
||||
|
||||
FirefoxBridgeExtensionUtils.maybeDeleteBridgeProtocolRegistryEntries(
|
||||
stubbedDeleteBridgeProtocolRegistryHelper
|
||||
);
|
||||
FirefoxBridgeExtensionUtils.maybeDeleteBridgeProtocolRegistryEntries(
|
||||
publicProtocol,
|
||||
privateProtocol,
|
||||
stubbedDeleteBridgeProtocolRegistryHelper
|
||||
);
|
||||
|
||||
ok(registryRootKey.wasCloseCalled, "Root key closed");
|
||||
ok(registryRootKey.wasCloseCalled, "Root key closed");
|
||||
|
||||
ok(
|
||||
firefoxPrivateProtocolRegKey.wasOpenedForRead,
|
||||
"Firefox private key opened"
|
||||
);
|
||||
ok(firefoxPrivateProtocolRegKey.wasCloseCalled, "Firefox private key closed");
|
||||
ok(
|
||||
!registryRootKey.isChildDeleted("firefox"),
|
||||
"Firefox protocol registry entry deleted when it shouldn't be"
|
||||
);
|
||||
ok(
|
||||
!registryRootKey.isChildDeleted("firefox-private"),
|
||||
"Firefox private protocol registry deleted when it shouldn't be"
|
||||
);
|
||||
ok(
|
||||
firefoxPrivateProtocolRegKey.wasOpenedForRead,
|
||||
"Firefox private key opened"
|
||||
);
|
||||
ok(
|
||||
firefoxPrivateProtocolRegKey.wasCloseCalled,
|
||||
"Firefox private key closed"
|
||||
);
|
||||
ok(
|
||||
!registryRootKey.isChildDeleted(publicProtocol),
|
||||
"Firefox protocol registry entry deleted when it shouldn't be"
|
||||
);
|
||||
ok(
|
||||
!registryRootKey.isChildDeleted(privateProtocol),
|
||||
"Firefox private protocol registry deleted when it shouldn't be"
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
add_task(async function test_DeleteWhenUnexpectedRegistryEntries() {
|
||||
const applicationPath = "testPath";
|
||||
for (let protocols of [
|
||||
[
|
||||
FirefoxBridgeExtensionUtils.OLD_PUBLIC_PROTOCOL,
|
||||
FirefoxBridgeExtensionUtils.OLD_PRIVATE_PROTOCOL,
|
||||
OLD_FIREFOX_SHELL_OPEN_COMMAND_PATH,
|
||||
],
|
||||
[
|
||||
FirefoxBridgeExtensionUtils.PUBLIC_PROTOCOL,
|
||||
FirefoxBridgeExtensionUtils.PRIVATE_PROTOCOL,
|
||||
FIREFOX_SHELL_OPEN_COMMAND_PATH,
|
||||
],
|
||||
]) {
|
||||
let [publicProtocol, privateProtocol, publicPath] = protocols;
|
||||
const applicationPath = "testPath";
|
||||
|
||||
const firefoxEntries = new Map();
|
||||
firefoxEntries.set("", `\"${applicationPath}\" -osint -url \"%1\"`);
|
||||
firefoxEntries.set("extraEntry", "extraValue");
|
||||
const firefoxProtocolRegKey = new StubbedRegistryKey(
|
||||
new Map(),
|
||||
firefoxEntries
|
||||
);
|
||||
const firefoxEntries = new Map();
|
||||
firefoxEntries.set("", `\"${applicationPath}\" -osint -url \"%1\"`);
|
||||
firefoxEntries.set("extraEntry", "extraValue");
|
||||
const firefoxProtocolRegKey = new StubbedRegistryKey(
|
||||
new Map(),
|
||||
firefoxEntries
|
||||
);
|
||||
|
||||
const children = new Map();
|
||||
children.set(FIREFOX_SHELL_OPEN_COMMAND_PATH, firefoxProtocolRegKey);
|
||||
const children = new Map();
|
||||
children.set(publicPath, firefoxProtocolRegKey);
|
||||
|
||||
const registryRootKey = new StubbedRegistryKey(children, new Map());
|
||||
const registryRootKey = new StubbedRegistryKey(children, new Map());
|
||||
|
||||
const stubbedDeleteBridgeProtocolRegistryHelper =
|
||||
new StubbedDeleteBridgeProtocolRegistryEntryHelper({
|
||||
applicationPath,
|
||||
registryRootKey,
|
||||
});
|
||||
const stubbedDeleteBridgeProtocolRegistryHelper =
|
||||
new StubbedDeleteBridgeProtocolRegistryEntryHelper({
|
||||
applicationPath,
|
||||
registryRootKey,
|
||||
});
|
||||
|
||||
FirefoxBridgeExtensionUtils.maybeDeleteBridgeProtocolRegistryEntries(
|
||||
stubbedDeleteBridgeProtocolRegistryHelper
|
||||
);
|
||||
FirefoxBridgeExtensionUtils.maybeDeleteBridgeProtocolRegistryEntries(
|
||||
publicProtocol,
|
||||
privateProtocol,
|
||||
stubbedDeleteBridgeProtocolRegistryHelper
|
||||
);
|
||||
|
||||
ok(registryRootKey.wasCloseCalled, "Root key closed");
|
||||
ok(registryRootKey.wasCloseCalled, "Root key closed");
|
||||
|
||||
ok(firefoxProtocolRegKey.wasOpenedForRead, "Firefox key opened");
|
||||
ok(firefoxProtocolRegKey.wasCloseCalled, "Firefox key closed");
|
||||
ok(
|
||||
!registryRootKey.isChildDeleted("firefox"),
|
||||
"Firefox protocol registry entry deleted when it shouldn't be"
|
||||
);
|
||||
ok(
|
||||
!registryRootKey.isChildDeleted("firefox-private"),
|
||||
"Firefox private protocol registry deleted when it shouldn't be"
|
||||
);
|
||||
ok(firefoxProtocolRegKey.wasOpenedForRead, "Firefox key opened");
|
||||
ok(firefoxProtocolRegKey.wasCloseCalled, "Firefox key closed");
|
||||
ok(
|
||||
!registryRootKey.isChildDeleted(publicProtocol),
|
||||
"Firefox protocol registry entry deleted when it shouldn't be"
|
||||
);
|
||||
ok(
|
||||
!registryRootKey.isChildDeleted(privateProtocol),
|
||||
"Firefox private protocol registry deleted when it shouldn't be"
|
||||
);
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1101,8 +1101,6 @@ pref("network.protocol-handler.external.disk", false);
|
|||
pref("network.protocol-handler.external.disks", false);
|
||||
pref("network.protocol-handler.external.afp", false);
|
||||
pref("network.protocol-handler.external.moz-icon", false);
|
||||
pref("network.protocol-handler.external.firefox-bridge", false);
|
||||
pref("network.protocol-handler.external.firefox-private-bridge", false);
|
||||
|
||||
// Don't allow external protocol handlers for common typos
|
||||
pref("network.protocol-handler.external.ttp", false); // http
|
||||
|
|
|
|||
Loading…
Reference in a new issue