From 4fa576deda65a46f1f85c94239d56a3e9fa57f18 Mon Sep 17 00:00:00 2001 From: Gijs Kruitbosch Date: Tue, 3 Aug 2021 18:32:50 +0000 Subject: [PATCH] Bug 1723723 - stop using getURLSpecFromFile from JS code to avoid mainthread IO, r=florian Differential Revision: https://phabricator.services.mozilla.com/D121620 --- browser/components/preferences/main.js | 8 ++++---- dom/fetch/tests/browser_blobFromFile.js | 2 +- dom/xhr/tests/browser_blobFromFile.js | 2 +- services/sync/tps/extensions/tps/resource/tps.jsm | 2 +- toolkit/components/apppicker/content/appPicker.js | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/browser/components/preferences/main.js b/browser/components/preferences/main.js index 5fd217081898..8aaedd3cd386 100644 --- a/browser/components/preferences/main.js +++ b/browser/components/preferences/main.js @@ -2808,7 +2808,7 @@ var gMainPane = { var fph = Services.io .getProtocolHandler("file") .QueryInterface(Ci.nsIFileProtocolHandler); - var urlSpec = fph.getURLSpecFromFile(aFile); + var urlSpec = fph.getURLSpecFromActualFile(aFile); return "moz-icon://" + urlSpec + "?size=16"; }, @@ -3064,19 +3064,19 @@ var gMainPane = { downloadFolder.value = currentDirPref.value ? `\u2066${currentDirPref.value.path}\u2069` : ""; - iconUrlSpec = fph.getURLSpecFromFile(currentDirPref.value); + iconUrlSpec = fph.getURLSpecFromDir(currentDirPref.value); } else if (folderIndex == 1) { // 'Downloads' [downloadFolder.value] = await document.l10n.formatValues([ { id: "downloads-folder-name" }, ]); - iconUrlSpec = fph.getURLSpecFromFile(await this._indexToFolder(1)); + iconUrlSpec = fph.getURLSpecFromDir(await this._indexToFolder(1)); } else { // 'Desktop' [downloadFolder.value] = await document.l10n.formatValues([ { id: "desktop-folder-name" }, ]); - iconUrlSpec = fph.getURLSpecFromFile( + iconUrlSpec = fph.getURLSpecFromDir( await this._getDownloadsFolder("Desktop") ); } diff --git a/dom/fetch/tests/browser_blobFromFile.js b/dom/fetch/tests/browser_blobFromFile.js index 155f42047781..80c9a13113a7 100644 --- a/dom/fetch/tests/browser_blobFromFile.js +++ b/dom/fetch/tests/browser_blobFromFile.js @@ -32,7 +32,7 @@ add_task(async function test() { .getProtocolHandler("file") .QueryInterface(Ci.nsIFileProtocolHandler); - let fileURL = fileHandler.getURLSpecFromFile(file); + let fileURL = fileHandler.getURLSpecFromActualFile(file); info("Opening url: " + fileURL); let tab = BrowserTestUtils.addTab(gBrowser, fileURL); diff --git a/dom/xhr/tests/browser_blobFromFile.js b/dom/xhr/tests/browser_blobFromFile.js index 47909b0979cb..b2a6923045b7 100644 --- a/dom/xhr/tests/browser_blobFromFile.js +++ b/dom/xhr/tests/browser_blobFromFile.js @@ -29,7 +29,7 @@ add_task(async function test() { .getProtocolHandler("file") .QueryInterface(Ci.nsIFileProtocolHandler); - let fileURL = fileHandler.getURLSpecFromFile(file); + let fileURL = fileHandler.getURLSpecFromActualFile(file); info("Opening url: " + fileURL); let tab = BrowserTestUtils.addTab(gBrowser, fileURL); diff --git a/services/sync/tps/extensions/tps/resource/tps.jsm b/services/sync/tps/extensions/tps/resource/tps.jsm index 044e31118444..2b2536be51b2 100644 --- a/services/sync/tps/extensions/tps/resource/tps.jsm +++ b/services/sync/tps/extensions/tps/resource/tps.jsm @@ -1032,7 +1032,7 @@ var TPS = { testFile, "testing/modules/ajv-4.1.1.js" ); - let ajvURL = fileProtocolHandler.getURLSpecFromFile(ajvFile); + let ajvURL = fileProtocolHandler.getURLSpecFromActualFile(ajvFile); let ns = {}; ChromeUtils.import(ajvURL, ns); let ajv = new ns.Ajv({ async: "co*" }); diff --git a/toolkit/components/apppicker/content/appPicker.js b/toolkit/components/apppicker/content/appPicker.js index 8f1d059a8647..d2a2e0b483d0 100644 --- a/toolkit/components/apppicker/content/appPicker.js +++ b/toolkit/components/apppicker/content/appPicker.js @@ -128,7 +128,7 @@ AppPicker.prototype = { return ""; } - var urlSpec = fph.getURLSpecFromFile(file); + var urlSpec = fph.getURLSpecFromActualFile(file); return "moz-icon://" + urlSpec + "?size=32"; },