Closed Bug 1223831 Opened 9 years ago Closed 9 years ago

Add SpecialPowers API for creating files

Categories

(Testing :: Mochitest, defect)

defect
Not set
normal

Tracking

(firefox45 fixed)

RESOLVED FIXED
mozilla45
Tracking Status
firefox45 --- fixed

People

(Reporter: mccr8, Assigned: mccr8)

References

Details

Attachments

(2 files)

Creating a file in the profile directory with a specific name and contents is a very common operation in a number of DOM tests (see bug 1220304), so I think it makes sense to add a SpecialPowers API to do this in an e10s-compatible way.
Andrea, please review the File API stuff in SpecialPowersObserver.js, as I don't really know what I'm doing there. Joel for the rest. Well and that too if you want.

See bug 1220304 for examples of how this is used.

try run: https://treeherder.mozilla.org/#/jobs?repo=try&revision=0258ece2c04d
Attachment #8686164 - Flags: review?(jmaher)
Attachment #8686164 - Flags: review?(amarchesini)
Comment on attachment 8686164 [details] [diff] [review]
SpecialPowers API to create files in an e10s-compatible way.

Review of attachment 8686164 [details] [diff] [review]:
-----------------------------------------------------------------

I like this patch in general, it is pretty good and clean.  I would like some unittests for this in https://dxr.mozilla.org/mozilla-central/source/testing/mochitest/tests/Harness_sanity/ directory.  This also gives a clear example of how to use this.
Attachment #8686164 - Flags: review?(jmaher) → review-
Comment on attachment 8686164 [details] [diff] [review]
SpecialPowers API to create files in an e10s-compatible way.

Review of attachment 8686164 [details] [diff] [review]:
-----------------------------------------------------------------

Are you planning to update the existing mochitests in follow-ups?
Attachment #8686164 - Flags: review?(amarchesini) → review+
(In reply to Andrea Marchesini (:baku) from comment #3)
> Are you planning to update the existing mochitests in follow-ups?

Yes, the patches I have so far are in the blocking bug.
I added some basic tests. I check that the result has the expected length, but I'm not really sure how to check the contents so I didn't do that. This is probably good enough.

I don't check that remove files actually removes the files. We're putting them in the profile directory so I think it isn't a huge deal.

Funnily enough, I did accidentally trigger a bug while writing the tests, in "case "SpecialPowers.FilesCreated"" and the other one: we have to clear the _createFiles* handlers before we call them, in case there's a nested handler. I fixed that.
Attachment #8686844 - Flags: review?(jmaher)
Comment on attachment 8686844 [details] [diff] [review]
SpecialPowers API to create files in an e10s-compatible way.

Review of attachment 8686844 [details] [diff] [review]:
-----------------------------------------------------------------

thanks!
Attachment #8686844 - Flags: review?(jmaher) → review+
https://hg.mozilla.org/mozilla-central/rev/dbbf92e8a141
Status: NEW → RESOLVED
Closed: 9 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla45
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: