Closed Bug 1676942 Opened 1 year ago Closed 1 year ago

Add equivalent of CommonUtils.{read,write}JSON to IOUtils

Categories

(Toolkit :: OS.File, task)

task

Tracking

()

RESOLVED FIXED
86 Branch
Tracking Status
firefox86 --- fixed

People

(Reporter: barret, Assigned: barret)

References

(Blocks 1 open bug)

Details

Attachments

(4 files)

Some usages of CommonUtils are just importing it to use read/writeJSON, e.g.https://searchfox.org/mozilla-central/rev/5a1a34953a26117f3be1a00db20c8bbdc03273d6/toolkit/modules/ProfileAge.jsm#153

This is more instances of "import a module just to do IO", which we are trying to avoid.

Depends on: 1677000
Blocks: 1649598

RunOnBackgroundThread has been renamed to RunOnBackgroundThreadAndResolve. The
body dealing with calling InvokeAsync for calling a function on the background
event target and returning a MozPromise has been refactored into a new
function, RunOnBackgroundThread.

This allows us to have more complicated IOUtils methods that do not simply
resolve their promises to whatever is returned by the background methods.

Depends on D99001

Attachment #9191798 - Attachment description: Bug 1676942 - Refactor RunOnBackgroundThread r?gijs,emalysz → Bug 1676942 - Refactor RunOnBackgroundThread r?nika

This patch is a minor cleanup based on prior feedback to make all of IOUtils
consistent.

Depends on D99155

Pushed by brennie@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/3595d192a9e0
Refactor RunOnBackgroundThread r=nika
https://hg.mozilla.org/integration/autoland/rev/3cc0c110b0ec
Add IOUtils::ReadJSON r=nika,tcampbell
https://hg.mozilla.org/integration/autoland/rev/ac0d932fe580
Add IOUtils::WriteJSON r=nika,tcampbell
https://hg.mozilla.org/integration/autoland/rev/cbd8324d869d
Replace remaining usage of NS_ENSURE_TRUE in IOUtils r=nika

Backed out for failures on test_ioutils_read_write_json.html

backout: https://hg.mozilla.org/integration/autoland/rev/0a254d8f2ed1dd4201a3c59009a60868cc116f3b

push: https://treeherder.mozilla.org/jobs?repo=autoland&revision=cbd8324d869da1b13c4d00c896ad43fd9ba33d83&group_state=expanded

failure log: https://treeherder.mozilla.org/logviewer?job_id=326859535&repo=autoland&lineNumber=119689

[task 2021-01-15T21:15:45.306Z] 21:15:45 INFO - TEST-PASS | dom/system/tests/ioutils/test_ioutils_read_write_json.html | C:\Users\task_1610743855\AppData\Local\Temp\test_ioutils_read_json_not_exists.tmp should not exist
[task 2021-01-15T21:15:45.306Z] 21:15:45 INFO - Buffered messages finished
[task 2021-01-15T21:15:45.307Z] 21:15:45 INFO - TEST-UNEXPECTED-FAIL | dom/system/tests/ioutils/test_ioutils_read_write_json.html | TypeError: promise.then is not a function - Should not throw any errors
[task 2021-01-15T21:15:45.307Z] 21:15:45 INFO - proto.rejects/<@resource://testing-common/Assert.jsm:501:8
[task 2021-01-15T21:15:45.307Z] 21:15:45 INFO - Promise@resource://gre/modules/Promise-backend.js:419:14
[task 2021-01-15T21:15:45.307Z] 21:15:45 INFO - proto.rejects@resource://testing-common/Assert.jsm:499:10
[task 2021-01-15T21:15:45.307Z] 21:15:45 INFO - read_json@chrome://mochitests/content/chrome/dom/system/tests/ioutils/test_ioutils_read_write_json.html:77:20
[task 2021-01-15T21:15:45.307Z] 21:15:45 INFO - GECKO(10248) | MEMORY STAT | vsize 2104261MB | vsizeMaxContiguous 65036462MB | residentFast 309MB | heapAllocated 116MB
[task 2021-01-15T21:15:45.307Z] 21:15:45 INFO - TEST-OK | dom/system/tests/ioutils/test_ioutils_read_write_json.html | took 193ms

Flags: needinfo?(brennie)
Pushed by brennie@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/b037f116b5e9
Refactor RunOnBackgroundThread r=nika
https://hg.mozilla.org/integration/autoland/rev/a2db746501c5
Add IOUtils::ReadJSON r=nika,tcampbell
https://hg.mozilla.org/integration/autoland/rev/1e4fe7771587
Add IOUtils::WriteJSON r=nika,tcampbell
https://hg.mozilla.org/integration/autoland/rev/1c0fd915e7e3
Replace remaining usage of NS_ENSURE_TRUE in IOUtils r=nika
Flags: needinfo?(brennie)
You need to log in before you can comment on or make changes to this bug.