Closed Bug 1317394 Opened 4 years ago Closed 3 years ago

DataView.prototype.byteLength and byteOffset should throw when the underlying buffer is detached

Categories

(Core :: JavaScript: Standard Library, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla57
Tracking Status
firefox53 --- affected
firefox57 --- fixed

People

(Reporter: anba, Assigned: evilpie)

References

(Blocks 1 open bug)

Details

Attachments

(1 file)

Test case:
---
var ab = new ArrayBuffer(10);
var dv = new DataView(ab)
detachArrayBuffer(ab);
dv.byteLength; // Or: dv.byteOffset;
---

Expected: Throws TypeError
Actual: No exception thrown


Also see bug 1079853.
Somehow I never uploaded this patch, but I think there is nothing wrong with it.
Assignee: nobody → evilpies
Attachment #8906269 - Flags: review?(andrebargull)
Attachment #8906269 - Attachment is patch: true
Comment on attachment 8906269 [details] [diff] [review]
Throw on detached ArrayBuffer in DataView getters

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

Nothing wrong with the patch itself, but I'm wondering about web-compatibility. AFAICS, no other browser is currently throwing a TypeError for detached buffers in the byteLength and byteOffset getters. Do you think it's still okay to let this change ride the trains to release, or is it more safe to restrict it to nightly+beta for a longer time until we're sure it won't break web-sites?
Attachment #8906269 - Flags: review?(andrebargull) → review+
Oh, maybe that's why I never bothered with this. My feeling tells me DataView aren't actually used much and detached array buffers are probably also not that common. Making it Nightly only at least for the 57 cycle sounds like a good idea anyway.
Pushed by evilpies@gmail.com:
https://hg.mozilla.org/integration/mozilla-inbound/rev/a31657380189
Make DataView getters throw for detached array buffers in Nightly. r=anba
Blocks: 1398839
Pushed by evilpies@gmail.com:
https://hg.mozilla.org/integration/mozilla-inbound/rev/b7f103d256b9
Fix bustage on CLOSED TREE by changing an old test.
https://hg.mozilla.org/mozilla-central/rev/a31657380189
https://hg.mozilla.org/mozilla-central/rev/b7f103d256b9
Status: NEW → RESOLVED
Closed: 3 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla57
You need to log in before you can comment on or make changes to this bug.