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)
Core
DOM: Core & HTML
Tracking
()
RESOLVED
FIXED
mozilla45
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.
Assignee | ||
Comment 1•9 years ago
|
||
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)
Comment 2•9 years ago
|
||
(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)
Updated•9 years ago
|
Blocks: e10s-tests
tracking-e10s:
--- → +
Assignee | ||
Comment 4•9 years ago
|
||
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 5•9 years ago
|
||
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+
Assignee | ||
Comment 6•9 years ago
|
||
(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.
Assignee | ||
Comment 7•9 years ago
|
||
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.
Comment 8•9 years ago
|
||
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?
Assignee | ||
Comment 9•9 years ago
|
||
(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.
Assignee | ||
Comment 10•9 years ago
|
||
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
Assignee | ||
Comment 11•9 years ago
|
||
Assignee | ||
Comment 12•9 years ago
|
||
Assignee | ||
Comment 13•9 years ago
|
||
This one can get reviewed now.
Attachment #8686101 -
Flags: review?(amarchesini)
Assignee | ||
Comment 14•9 years ago
|
||
Assignee | ||
Updated•9 years ago
|
Attachment #8685169 -
Attachment is obsolete: true
Updated•9 years ago
|
Attachment #8686101 -
Flags: review?(amarchesini) → review+
Assignee | ||
Comment 15•9 years ago
|
||
Fixed some spacing.
Assignee | ||
Updated•9 years ago
|
Attachment #8686098 -
Attachment is obsolete: true
Attachment #8686100 -
Attachment is obsolete: true
Assignee | ||
Comment 16•9 years ago
|
||
Fixed some spacing.
Assignee | ||
Comment 17•9 years ago
|
||
b2g and linux try: https://treeherder.mozilla.org/#/jobs?repo=try&revision=9789c598b8a4
Attachment #8687273 -
Flags: review?(amarchesini)
Assignee | ||
Updated•9 years ago
|
Attachment #8686099 -
Attachment is obsolete: true
Attachment #8686102 -
Attachment is obsolete: true
Attachment #8686284 -
Attachment is obsolete: true
Attachment #8686285 -
Attachment is obsolete: true
Assignee | ||
Comment 18•9 years ago
|
||
Attachment #8687274 -
Flags: review?(amarchesini)
Assignee | ||
Comment 19•9 years ago
|
||
Attachment #8687275 -
Flags: review?(amarchesini)
Assignee | ||
Comment 20•9 years ago
|
||
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)
Updated•9 years ago
|
Attachment #8687273 -
Flags: review?(amarchesini) → review+
Updated•9 years ago
|
Attachment #8687274 -
Flags: review?(amarchesini) → review+
Updated•9 years ago
|
Attachment #8687275 -
Flags: review?(amarchesini) → review+
Comment 21•9 years ago
|
||
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+
Assignee | ||
Updated•9 years ago
|
Keywords: checkin-needed
Comment 22•9 years ago
|
||
https://hg.mozilla.org/integration/mozilla-inbound/rev/3ea86ea60f92
https://hg.mozilla.org/integration/mozilla-inbound/rev/e80dce92846e
https://hg.mozilla.org/integration/mozilla-inbound/rev/86e44caf8c2a
https://hg.mozilla.org/integration/mozilla-inbound/rev/b21c04934076
https://hg.mozilla.org/integration/mozilla-inbound/rev/a499b2470c33
Keywords: checkin-needed
Comment 23•9 years ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/3ea86ea60f92
https://hg.mozilla.org/mozilla-central/rev/e80dce92846e
https://hg.mozilla.org/mozilla-central/rev/86e44caf8c2a
https://hg.mozilla.org/mozilla-central/rev/b21c04934076
https://hg.mozilla.org/mozilla-central/rev/a499b2470c33
Status: NEW → RESOLVED
Closed: 9 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla45
Updated•6 years ago
|
Component: DOM → DOM: Core & HTML
You need to log in
before you can comment on or make changes to this bug.
Description
•