Closed Bug 1783100 Opened 2 years ago Closed 2 years ago

Remove osfile.jsm from devtools/

Categories

(DevTools :: General, task, P3)

task

Tracking

(firefox110 fixed)

RESOLVED FIXED
110 Branch
Tracking Status
firefox110 --- fixed

People

(Reporter: barret, Assigned: barret, NeedInfo)

References

Details

Attachments

(1 file, 1 obsolete file)

Bug 1779574 re-added a usage of OSFile.jsm because DevTools was attempting to use IOUtils in the child process, which is not allowed.

Depends on: 1771608

It looks like DevToolsUtils.fetch is an old implementation of something like the standard fetch method for devtools, which is only used in a couple of places outside tests. It's causing us issues with removing OSFile.jsm usage due to some of the weird handling it has of file URIs.

Is there any chance the devtools team would be able to remove the uses of DevtoolsUtils.fetch and replace them with normal fetch calls? It would help with removing the last remaining uses of OSFile.

Outside of tests, a quick scan found the following uses, though there may be others we missed when looking:

Component: OS.File → General
Flags: needinfo?(odvarko)
Product: Toolkit → DevTools
Summary: Remove osfile.jsm usage from devtools/ → Remove DevToolsUtils.fetch

Alex, looks like we use DevToolsUtils.fetch for loading JS sources and stylesheets text (and perhaps source maps somewhere?). Is anything blocking us from using the standard fetch API?

Flags: needinfo?(odvarko) → needinfo?(poirot.alex)

(In reply to Nika Layzell [:nika] (ni? for response) from comment #1)

It looks like DevToolsUtils.fetch is an old implementation of something like the standard fetch method for devtools, which is only used in a couple of places outside tests. It's causing us issues with removing OSFile.jsm usage due to some of the weird handling it has of file URIs.

Is there any chance the devtools team would be able to remove the uses of DevtoolsUtils.fetch and replace them with normal fetch calls? It would help with removing the last remaining uses of OSFile.

We probably depend on features that aren't exposed by the standard fetch.
I'm especially thinking about all the privileged flags we set on the channel over here:
https://searchfox.org/mozilla-central/rev/dd216c1307a2bf1b0d2465b9749fa86dac44303a/devtools/shared/DevToolsUtils.js#528-552
Other than that, we would probably benefit from reusing the standard fetch when it comes to read the response body, we have lots very old and cryptic code here.

If we are able to use fetch by passing a channel, that would ease to migration, otherwise we may have to expose new ChromeOnly flag. Would that be reasonable option?

Having said that OS.file is used only in one particular workaround:
https://searchfox.org/mozilla-central/rev/dd216c1307a2bf1b0d2465b9749fa86dac44303a/devtools/shared/DevToolsUtils.js#647-665
We could probably look into getting rid of this workaround, and drop the last usage of OS.file.

(I'm off most of next week, but I could probably spend some time on this soon)

Attached file WIP: - Remove osfile.jsm from devtools (obsolete) (deleted) —
Attachment #9305966 - Attachment is obsolete: true

I'm going to use this bug for removing OSFile.jsm from DevToolsUtils -- removing DevtoolsUtils.fetch() can be spun off into another bug if needed, :ochameau

Assignee: nobody → brennie
Summary: Remove DevToolsUtils.fetch → Remove osfile.jsm from devtools/
Pushed by brennie@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/af7353099e41 Remove osfile.jsm usage from DevToolsUtils.js r=ochameau

Backed out for causing dt failures on browser_dbg-features-source-text-content.js.

Push with failures

Failure log

Backout link

[task 2022-12-15T03:20:23.591Z] 03:20:23     INFO - TEST-PASS | devtools/client/debugger/test/mochitest/browser_dbg-features-source-text-content.js | We loaded the garbaged script twice as we lost its content - 
[task 2022-12-15T03:20:23.592Z] 03:20:23     INFO - Leaving test bound testGarbageCollectedSourceTextContent
[task 2022-12-15T03:20:23.592Z] 03:20:23     INFO - Entering test bound testFailingHtmlSource
[task 2022-12-15T03:20:23.593Z] 03:20:23     INFO - Test failure in retrieving html page sources
[task 2022-12-15T03:20:23.593Z] 03:20:23     INFO - Adding a new tab with URL: http://localhost:49659/200-then-404-page.html
[task 2022-12-15T03:20:23.593Z] 03:20:23     INFO - Buffered messages logged at 03:20:23
[task 2022-12-15T03:20:23.594Z] 03:20:23     INFO - Tab added and finished loading
[task 2022-12-15T03:20:23.594Z] 03:20:23     INFO - Opening the toolbox
[task 2022-12-15T03:20:23.595Z] 03:20:23     INFO - Console message: [JavaScript Error: "Content Security Policy: The page’s settings blocked the loading of a resource at inline (“default-src”)." {file: "chrome://global/content/customElements.js" line: 500 column: 24 source: "display: none !important"}]
[task 2022-12-15T03:20:23.595Z] 03:20:23     INFO - Console message: [JavaScript Error: "Content Security Policy: The page’s settings blocked the loading of a resource at inline (“default-src”)." {file: "chrome://global/content/customElements.js" line: 500}]
[task 2022-12-15T03:20:23.596Z] 03:20:23     INFO - Console message: [JavaScript Error: "Content Security Policy: The page’s settings blocked the loading of a resource at inline (“default-src”)." {file: "chrome://global/content/elements/panel.js" line: 62}]
[task 2022-12-15T03:20:23.596Z] 03:20:23     INFO - Console message: [JavaScript Error: "Content Security Policy: The page’s settings blocked the loading of a resource at inline (“default-src”)." {file: "chrome://global/content/customElements.js" line: 500 column: 24 source: "display: none !important"}]
[task 2022-12-15T03:20:23.597Z] 03:20:23     INFO - Console message: [JavaScript Error: "Content Security Policy: The page’s settings blocked the loading of a resource at inline (“default-src”)." {file: "chrome://global/content/customElements.js" line: 500}]
[task 2022-12-15T03:20:23.597Z] 03:20:23     INFO - Console message: [JavaScript Error: "Content Security Policy: The page’s settings blocked the loading of a resource at inline (“default-src”)." {file: "chrome://global/content/elements/panel.js" line: 62}]
[task 2022-12-15T03:20:23.598Z] 03:20:23     INFO - Toolbox opened and focused
[task 2022-12-15T03:20:23.598Z] 03:20:23     INFO - Waiting on sources: 200-then-404-page.html
[task 2022-12-15T03:20:23.599Z] 03:20:23     INFO - Finished waiting on sources: 200-then-404-page.html
[task 2022-12-15T03:20:23.599Z] 03:20:23     INFO - Console message: [JavaScript Warning: "Use of nsIFile in content process is deprecated." {file: "resource://gre/modules/NetUtil.jsm" line: 251}]
[task 2022-12-15T03:20:23.599Z] 03:20:23     INFO - Buffered messages finished
[task 2022-12-15T03:20:23.600Z] 03:20:23     INFO - TEST-UNEXPECTED-FAIL | devtools/client/debugger/test/mochitest/browser_dbg-features-source-text-content.js | Display failure error - 
[task 2022-12-15T03:20:23.600Z] 03:20:23     INFO - Stack trace:
[task 2022-12-15T03:20:23.600Z] 03:20:23     INFO - chrome://mochikit/content/browser-test.js:test_ok:1449
[task 2022-12-15T03:20:23.600Z] 03:20:23     INFO - chrome://mochitests/content/browser/devtools/client/debugger/test/mochitest/browser_dbg-features-source-text-content.js:testFailingHtmlSource:460
[task 2022-12-15T03:20:23.601Z] 03:20:23     INFO - chrome://mochikit/content/browser-test.js:handleTask:1037
[task 2022-12-15T03:20:23.601Z] 03:20:23     INFO - chrome://mochikit/content/browser-test.js:_runTaskBasedTest:1109
[task 2022-12-15T03:20:23.601Z] 03:20:23     INFO - chrome://mochikit/content/browser-test.js:Tester_execTest:1244
[task 2022-12-15T03:20:23.601Z] 03:20:23     INFO - chrome://mochikit/content/browser-test.js:nextTest/<:1026
[task 2022-12-15T03:20:23.601Z] 03:20:23     INFO - chrome://mochikit/content/tests/SimpleTest/SimpleTest.js:SimpleTest.waitForFocus/<:1036
[task 2022-12-15T03:20:23.601Z] 03:20:23     INFO - Leaving test bound testFailingHtmlSource
[task 2022-12-15T03:20:23.602Z] 03:20:23     INFO - Entering test bound testLoadingHtmlSource
[task 2022-12-15T03:20:23.602Z] 03:20:23     INFO - Test loading progress of html page sources
[task 2022-12-15T03:20:23.602Z] 03:20:23     INFO - Adding a new tab with URL: http://localhost:49659/slow-loading-page.html
[task 2022-12-15T03:20:23.844Z] 03:20:23     INFO - Tab added and finished loading
[task 2022-12-15T03:20:23.844Z] 03:20:23     INFO - Opening the toolbox
[task 2022-12-15T03:20:23.981Z] 03:20:23     INFO - Console message: [JavaScript Error: "Content Security Policy: The page’s settings blocked the loading of a resource at inline (“default-src”)." {file: "chrome://global/content/customElements.js" line: 500 column: 24 source: "display: none !important"}]
[task 2022-12-15T03:20:23.981Z] 03:20:23     INFO - Console message: [JavaScript Error: "Content Security Policy: The page’s settings blocked the loading of a resource at inline (“default-src”)." {file: "chrome://global/content/customElements.js" line: 500}]
[task 2022-12-15T03:20:23.982Z] 03:20:23     INFO - Console message: [JavaScript Error: "Content Security Policy: The page’s settings blocked the loading of a resource at inline (“default-src”)." {file: "chrome://global/content/elements/panel.js" line: 62}]
[task 2022-12-15T03:20:24.153Z] 03:20:24     INFO - Console message: [JavaScript Error: "Content Security Policy: The page’s settings blocked the loading of a resource at inline (“default-src”)." {file: "chrome://global/content/customElements.js" line: 500 column: 24 source: "display: none !important"}]
[task 2022-12-15T03:20:24.154Z] 03:20:24     INFO - Console message: [JavaScript Error: "Content Security Policy: The page’s settings blocked the loading of a resource at inline (“default-src”)." {file: "chrome://global/content/customElements.js" line: 500}]
[task 2022-12-15T03:20:24.154Z] 03:20:24     INFO - Console message: [JavaScript Error: "Content Security Policy: The page’s settings blocked the loading of a resource at inline (“default-src”)." {file: "chrome://global/content/elements/panel.js" line: 62}]
[task 2022-12-15T03:20:24.185Z] 03:20:24     INFO - Toolbox opened and focused
[task 2022-12-15T03:20:24.185Z] 03:20:24     INFO - Waiting on sources: slow-loading-page.html
[task 2022-12-15T03:20:24.186Z] 03:20:24     INFO - Finished waiting on sources: slow-loading-page.html
[task 2022-12-15T03:20:24.230Z] 03:20:24     INFO - Wait for a second HTTP request to be made for the html page
[task 2022-12-15T03:20:24.231Z] 03:20:24     INFO - Console message: [JavaScript Warning: "Use of nsIFile in content process is deprecated." {file: "resource://gre/modules/NetUtil.jsm" line: 251}]
[task 2022-12-15T03:20:24.265Z] 03:20:24     INFO - TEST-PASS | devtools/client/debugger/test/mochitest/browser_dbg-features-source-text-content.js | The source is still loading until we release the network request -
Flags: needinfo?(brennie)
Flags: needinfo?(brennie)
Pushed by brennie@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/3d1ffeb03b66 Remove osfile.jsm usage from DevToolsUtils.js r=ochameau
Status: NEW → RESOLVED
Closed: 2 years ago
Resolution: --- → FIXED
Target Milestone: --- → 110 Branch
Blocks: 1817036
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: