Closed Bug 1220304 Opened 9 years ago Closed 9 years ago

Fix DOM tests that create files to work with e10s

Categories

(Core :: DOM: Core & HTML, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla45
Tracking Status
e10s + ---
firefox45 --- fixed

People

(Reporter: mccr8, Assigned: mccr8)

References

(Blocks 1 open bug)

Details

Attachments

(5 files, 7 obsolete files)

9.27 KB, patch
baku
: review+
Details | Diff | Splinter Review
6.67 KB, patch
baku
: review+
Details | Diff | Splinter Review
12.38 KB, patch
baku
: review+
Details | Diff | Splinter Review
4.46 KB, patch
baku
: review+
Details | Diff | Splinter Review
3.88 KB, patch
baku
: review+
Details | Diff | Splinter Review
There are a number of mochitest plain tests that create files using the directory service in order to perform a test, including the following: dom/base/test/websocket_hybi/test_send-blob.html dom/archivereader/test/test_basic.html dom/base/test/test_XHRSendData.html You can't use the directory service in the child process like this, so the tests are disabled.
Andrea, do you have some existing method for doing these kinds of tests in the child process? Or do we need to figure something out?
Flags: needinfo?(amarchesini)
(In reply to Andrew McCreight [:mccr8] from comment #1) > Andrea, do you have some existing method for doing these kinds of tests in > the child process? Or do we need to figure something out? We can create a File just doing: new File([42], "something.txt"); But the problem here is that we want a file that has 'real' path. I guess it's better to figure something out for testing. Maybe some ChromeOnly ctor of some custom file obj?
Flags: needinfo?(amarchesini)
Blocks: e10s-tests
tracking-e10s: --- → +
I'll take a look at these.
Assignee: nobody → continuation
I implemented a new SpecialPowers API for creating files. In a content Mochitest, you call SpecialPowers.openFiles() with a description of the files you want to be created (the non-directory part of the file and the contents) and success and failure callbacks. Once the files are created, the sucess callback is called with an array of File objects. If they weren't created, the failure callback is called. There is also a SpecialPowers method to close all of the files. Andrea, does this look like a reasonable API? (I don't particularly need feedback on all of the SpecialPowers plumbing, as I'll get some feedback on that from somebody who works on mochitest stuff.) Also, is this an okay way to create File objects? The existing code seems to all do this: var fileList = document.getElementById('fileList'); SpecialPowers.wrap(fileList).value = testFile.path; ...but it seems like maybe this is just a hacky way to create a File in a mochitest? I've also converted the ArchiveReader tests, if you'd like to see that. Those were even easier to convert, as they already were organized around callbacks.
Attachment #8685169 - Flags: feedback?(amarchesini)
Comment on attachment 8685169 [details] [diff] [review] SpecialPowers service for creating a file. Review of attachment 8685169 [details] [diff] [review]: ----------------------------------------------------------------- I would like to have these files removed when SimpleTest.finish() is executed. Alternatively we should throw an error/exception if removeFiles() is not called. ::: dom/base/test/test_XHRSendData.html @@ +247,5 @@ > } > } > } > finally { > + SpecialPowers.removeFiles(); can we do this automagically when finish() is called? ::: testing/specialpowers/components/SpecialPowersObserver.js @@ +163,5 @@ > this._messageManager.removeMessageListener("SPPrefService", this); > this._messageManager.removeMessageListener("SPProcessCrashService", this); > this._messageManager.removeMessageListener("SPPingService", this); > this._messageManager.removeMessageListener("SpecialPowers.Quit", this); > + this._messageManager.removeMessageListener("SpecialPowers.Focus", this) ;
Attachment #8685169 - Flags: feedback?(amarchesini) → feedback+
(In reply to Andrea Marchesini (:baku) from comment #5) > I would like to have these files removed when SimpleTest.finish() is > executed. That's a good idea. I think SpecialPowers.pushPermissions() does that, so I should be able to do that.
Jed created simpleFileOpener.js which is basically the same idea, and is used in dom/html/test/test_bug143220.html and dom/html/test/test_bug1146116.html, so those would ideally also be converted to use this.
Depends on: 1223510
Comment on attachment 8685169 [details] [diff] [review] SpecialPowers service for creating a file. Review of attachment 8685169 [details] [diff] [review]: ----------------------------------------------------------------- ::: dom/base/test/test_XHRSendData.html @@ +247,5 @@ > } > } > } > finally { > + SpecialPowers.removeFiles(); SimpleTest.registerCleanupFunction may be useful here. ::: testing/specialpowers/components/SpecialPowersObserver.js @@ +165,5 @@ > this._messageManager.removeMessageListener("SPPingService", this); > this._messageManager.removeMessageListener("SpecialPowers.Quit", this); > + this._messageManager.removeMessageListener("SpecialPowers.Focus", this) > + this._messageManager.removeMessageListener("SpecialPowers.OpenFiles", this); > + this._messageManager.removeMessageListener("SpecialPowers.RemoveFiles", this);; I think I found where that missing semicolon went. @@ +282,5 @@ > + let testFile = Services.dirsvc.get("ProfD", Ci.nsIFile); > + testFile.append(request.name); > + if (request.data) { > + let outStream = Cc["@mozilla.org/network/file-output-stream;1"].createInstance(Ci.nsIFileOutputStream); > + outStream.init(testFile, 0x02 | 0x08 | 0x20, 0666, 0); Nit: can this have a comment to explain that it's PR_WRONLY | PR_CREATE_FILE | PR_TRUNCATE?
(In reply to Jed Davis [:jld] from comment #8) > SimpleTest.registerCleanupFunction may be useful here. I tried that, but SimpleTest doesn't seem to be in scope of specialpowers.js. I'll just try calling removeFiles directly in SimpleTest and hope that is okay. > Nit: can this have a comment to explain that it's PR_WRONLY | PR_CREATE_FILE > | PR_TRUNCATE? Good point.
Depends on: 1223831
I'm not going to ask for review until I get bug 1223831 reviewed, in case the API changes. There are a number of patches, but the changes are very similar and not complex. try: https://treeherder.mozilla.org/#/jobs?repo=try&revision=0258ece2c04d
This one can get reviewed now.
Attachment #8686101 - Flags: review?(amarchesini)
Attachment #8685169 - Attachment is obsolete: true
Attachment #8686101 - Flags: review?(amarchesini) → review+
Attachment #8686098 - Attachment is obsolete: true
Attachment #8686100 - Attachment is obsolete: true
Attachment #8686099 - Attachment is obsolete: true
Attachment #8686102 - Attachment is obsolete: true
Attachment #8686284 - Attachment is obsolete: true
Attachment #8686285 - Attachment is obsolete: true
There are more tests to be converted. I might put them in a separate bug depending on how that goes.
Attachment #8687278 - Flags: review?(amarchesini)
Attachment #8687273 - Flags: review?(amarchesini) → review+
Attachment #8687274 - Flags: review?(amarchesini) → review+
Attachment #8687275 - Flags: review?(amarchesini) → review+
Comment on attachment 8687278 [details] [diff] [review] part 4b - Make dom/base/test/test_websocket.html use SpecialPowers.createFiles(). Review of attachment 8687278 [details] [diff] [review]: ----------------------------------------------------------------- So bad that we cannot have this test in b2g yet.
Attachment #8687278 - Flags: review?(amarchesini) → review+
Keywords: checkin-needed
Depends on: 1156489
No longer depends on: 1156489
Component: DOM → DOM: Core & HTML
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: