summaryrefslogtreecommitdiffstats
path: root/devtools
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-17 09:04:05 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-17 09:04:05 +0000
commit6391fbb73e25d3f7af15213274c2a3bfe1bc7af5 (patch)
treed2c6903d55ffdba0655dc473a5ad44c2ecf59df8 /devtools
parentReleasing progress-linux version 115.11.0esr-1~deb12u1progress7u1. (diff)
downloadfirefox-esr-6391fbb73e25d3f7af15213274c2a3bfe1bc7af5.tar.xz
firefox-esr-6391fbb73e25d3f7af15213274c2a3bfe1bc7af5.zip
Merging upstream version 115.12.0esr.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'devtools')
-rw-r--r--devtools/shared/DevToolsUtils.js38
-rw-r--r--devtools/startup/tests/browser/browser_command_line_urls.js3
2 files changed, 18 insertions, 23 deletions
diff --git a/devtools/shared/DevToolsUtils.js b/devtools/shared/DevToolsUtils.js
index 2a9979b456..d2b38836c7 100644
--- a/devtools/shared/DevToolsUtils.js
+++ b/devtools/shared/DevToolsUtils.js
@@ -718,11 +718,7 @@ function mainThreadFetch(
* @param {Object} options - The options object passed to @method fetch.
* @return {nsIChannel} - The newly created channel. Throws on failure.
*/
-function newChannelForURL(
- url,
- { policy, window, principal },
- recursing = false
-) {
+function newChannelForURL(url, { policy, window, principal }) {
const securityFlags =
Ci.nsILoadInfo.SEC_ALLOW_CROSS_ORIGIN_SEC_CONTEXT_IS_NULL;
@@ -735,6 +731,19 @@ function newChannelForURL(
// scheme to see if it helps.
uri = Services.io.newURI("file://" + url);
}
+
+ // In xpcshell tests on Windows, opening the channel
+ // can throw NS_ERROR_UNKNOWN_PROTOCOL if the external protocol isn't
+ // supported by Windows, so we also need to handle that case here if
+ // parsing the URL above doesn't throw.
+ const handler = Services.io.getProtocolHandler(uri.scheme);
+ if (
+ handler instanceof Ci.nsIExternalProtocolHandler &&
+ !handler.externalAppExistsForScheme(uri.scheme)
+ ) {
+ uri = Services.io.newURI("file://" + url);
+ }
+
const channelOptions = {
contentPolicyType: policy,
securityFlags,
@@ -766,24 +775,7 @@ function newChannelForURL(
channelOptions.loadingPrincipal = prin;
}
- try {
- return NetUtil.newChannel(channelOptions);
- } catch (e) {
- // Don't infinitely recurse if newChannel keeps throwing.
- if (recursing) {
- throw e;
- }
-
- // In xpcshell tests on Windows, nsExternalProtocolHandler::NewChannel()
- // can throw NS_ERROR_UNKNOWN_PROTOCOL if the external protocol isn't
- // supported by Windows, so we also need to handle the exception here if
- // parsing the URL above doesn't throw.
- return newChannelForURL(
- "file://" + url,
- { policy, window, principal },
- /* recursing */ true
- );
- }
+ return NetUtil.newChannel(channelOptions);
}
// Fetch is defined differently depending on whether we are on the main thread
diff --git a/devtools/startup/tests/browser/browser_command_line_urls.js b/devtools/startup/tests/browser/browser_command_line_urls.js
index e435d08406..99c5214eac 100644
--- a/devtools/startup/tests/browser/browser_command_line_urls.js
+++ b/devtools/startup/tests/browser/browser_command_line_urls.js
@@ -93,6 +93,9 @@ add_task(async function openingWithDevToolsButUnknownSource() {
);
await SpecialPowers.spawn(gBrowser.selectedBrowser, [], async function () {
+ // View source may not have updated the selection just yet
+ ContentTaskUtils.waitForCondition(() => !!content.getSelection());
+
const selection = content.getSelection();
Assert.equal(
selection.toString(),