Closed
Bug 761159
Opened 12 years ago
Closed 12 years ago
FileHandle: Better handling of the end of file state
Categories
(Core :: DOM: Core & HTML, defect)
Core
DOM: Core & HTML
Tracking
()
RESOLVED
FIXED
mozilla16
Tracking | Status | |
---|---|---|
firefox13 | --- | affected |
firefox14 | --- | unaffected |
firefox15 | --- | verified |
firefox16 | --- | fixed |
People
(Reporter: janv, Assigned: janv)
Details
Attachments
(2 files, 3 obsolete files)
12.98 KB,
patch
|
sicking
:
review+
akeybl
:
approval-mozilla-aurora+
|
Details | Diff | Splinter Review |
722 bytes,
patch
|
janv
:
review+
|
Details | Diff | Splinter Review |
No description provided.
Assignee | ||
Comment 1•12 years ago
|
||
- readAsArrayBuffer(), readAsText() and truncate() throws when the location is in the end of file state (LL_MAXUINT / Infinity) - write() behaves as append() when in the end of file state - it's possible to set the state by calling |.location = Infinity| I'll write a test, but I need feedback on this approach first
Attachment #629786 -
Flags: feedback?(jonas)
I'd rather that .write throws when in the end-of-file state. Seems strange that someone would call .append and then .write. That way we are also free to make write-after-append work however we want later if we decide to. I.e. we could change it so that .append doesn't affect .location at all if we decide that's better behavior. I'd rather make |.location = null| be what puts us in the end-of-file state. That way x.location = x.location is always a no-op.
Oh, and we should make .location return null in the end-of-file state. That way we can define it as |attribute long long? location| in the idl once we use WebIDL.
Assignee | ||
Comment 4•12 years ago
|
||
Attachment #629786 -
Attachment is obsolete: true
Attachment #629786 -
Flags: feedback?(jonas)
Attachment #629886 -
Flags: review?(jonas)
Comment on attachment 629886 [details] [diff] [review] patch Review of attachment 629886 [details] [diff] [review]: ----------------------------------------------------------------- ::: dom/file/LockedFile.cpp @@ +516,5 @@ > + } > + else { > + if (mLocation <= JSVAL_INT_MAX) { > + *aLocation = INT_TO_JSVAL(mLocation); > + } I don't think you need this special-case. Just use JS_NewNumberValue all the time. @@ +730,5 @@ > nsresult rv = helper->Enqueue(); > NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_FILEHANDLE_UNKNOWN_ERR); > > if (aOptionalArgCount) { > + mLocation = aSize; Wait, this needs to be |mLocation = location|, right? Otherwise mLocation will be set to 0 if the argument isn't specified. Sorry, I missed this in the previous patch that already landed.
Attachment #629886 -
Flags: review?(jonas) → review+
Assignee | ||
Comment 6•12 years ago
|
||
Comment on attachment 633831 [details] [diff] [review] updated patch Review of attachment 633831 [details] [diff] [review]: ----------------------------------------------------------------- r=me ::: dom/file/LockedFile.cpp @@ +533,5 @@ > + return NS_OK; > + } > + > + PRUint64 location; > + if (xpc::ValueToUint64(aCx, aLocation, &location)) { Nit: I would have reversed the check here and put the error handling in the branch. As to keep the common code flow to be the one that reaches the end of the function. Up to you. @@ +708,5 @@ > + PRUint64 location; > + if (aOptionalArgCount) { > + // Just in case someone calls us from C++ > + if (aSize == LL_MAXUINT) { > + return NS_ERROR_TYPE_ERR; I'd prefer to just MOZ_ASSERT that aSize != LL_MAXUINT. That's a better way to keep people from doing that.
Attachment #633831 -
Flags: review?(jonas) → review+
Assignee | ||
Updated•12 years ago
|
Attachment #629886 -
Attachment is obsolete: true
Assignee | ||
Comment 8•12 years ago
|
||
Both comments addressed. http://hg.mozilla.org/mozilla-central/rev/0ee6b0ed0446
Status: ASSIGNED → RESOLVED
Closed: 12 years ago
Resolution: --- → FIXED
Comment 9•12 years ago
|
||
This breaks my OpenBSD builds.. dom/file/LockedFile.cpp:537: error: invalid conversion from 'PRUint64*' to 'uint64_t*' xpc::ValueToUint64 expects a uint64_t* as last arg and gets a PRUint64*. Trying some casting vodoo..
Comment on attachment 633831 [details] [diff] [review] updated patch [Approval Request Comment] Bug caused by (feature/regressing bug #): Bug 726593 User impact if declined: Would result in that web developers would have a somewhat inconsistent behavior for the new FileHandle API. Ideally developers would be able to stop worrying about this after 6 weeks when FF16 is released, but we're still not great at getting users to the latest version. I.e. we'd like to fix known issues in the first release of this API. Testing completed (on m-c, etc.): Patch includes thorough automated tests. Risk to taking this patch (and alternatives if risky): Very low risk. Only affects an API which was added in Firefox 15, so no existing websites or internal code uses it. Absolute worst case this API doesn't work in Firefox 15, but even that is very unlikely since the patch only affects edge cases and is will testsed. String or UUID changes made by this patch: Changes the UUID of an interface introduced in Firefox 15. No string changes.
Attachment #633831 -
Flags: approval-mozilla-aurora?
Comment 11•12 years ago
|
||
Attached patch fixes the build for me, dunno if that's the best fix.
Comment on attachment 633888 [details] [diff] [review] cast location to uint64_t* I think it'd be better to change 'location' to be of type uint64_t. And, only if needed, add a cast when assigning into mLocation.
Assignee | ||
Comment 13•12 years ago
|
||
yeah, could you try something like: uint64_t location; if (!xpc::ValueToUint64(aCx, aLocation, &location)) { return NS_ERROR_TYPE_ERR; } mLocation = location; // eventually change to: mLocation = static_cast<PRUint64>(location);
Assignee | ||
Updated•12 years ago
|
OS: Mac OS X → All
Hardware: x86 → All
Target Milestone: --- → mozilla16
Comment 14•12 years ago
|
||
That also works, and it even seems the cast when assigning to mLocation isnt needed.
Attachment #633888 -
Attachment is obsolete: true
Attachment #633895 -
Flags: review?(Jan.Varga)
Assignee | ||
Updated•12 years ago
|
Attachment #633895 -
Flags: review?(Jan.Varga) → review+
Comment 17•12 years ago
|
||
Comment on attachment 633831 [details] [diff] [review] updated patch [Triage Comment] Risk and UUID changes are limited to the new API. Approving for Aurora 15.
Attachment #633831 -
Flags: approval-mozilla-aurora? → approval-mozilla-aurora+
Comment 18•12 years ago
|
||
To whoever commits that to aurora (i can, if needed...) dont forget to also take https://hg.mozilla.org/mozilla-central/rev/449cfd3737cd :)
https://hg.mozilla.org/releases/mozilla-aurora/rev/deb42e7fb841 https://hg.mozilla.org/releases/mozilla-aurora/rev/5ada4bb636a2
status-firefox13:
--- → affected
status-firefox14:
--- → unaffected
status-firefox15:
--- → fixed
status-firefox16:
--- → fixed
Comment 20•12 years ago
|
||
The automated tests for this fix pass on all the OSs: https://tbpl.mozilla.org/php/getParsedLog.php?id=14174727&full=1&branch=mozilla-beta https://tbpl.mozilla.org/php/getParsedLog.php?id=14178339&full=1&branch=mozilla-beta https://tbpl.mozilla.org/php/getParsedLog.php?id=14178942&full=1&branch=mozilla-beta https://tbpl.mozilla.org/php/getParsedLog.php?id=14175380&full=1&branch=mozilla-beta
Updated•5 years ago
|
Component: DOM → DOM: Core & HTML
You need to log in
before you can comment on or make changes to this bug.
Description
•