Closed Bug 786639 Opened 7 years ago Closed 7 years ago

XPCChromeObjectWrapper __exposedProps__ should expose the content of typed arrays like UInt8Array

Categories

(Core :: XPConnect, defect)

defect
Not set

Tracking

()

RESOLVED FIXED
mozilla18

People

(Reporter: asuth, Assigned: asuth)

References

Details

Attachments

(1 file)

For navigator.mozTCPSocket, we currently create a UInt8Array in a chrome context.  Inside the chrome context, data on the array is accessible and has values.  For example arr[0] === 50.  When exposed into content via __exposedProps__, arr[0] === undefined.

Known reasonable workarounds are to:
- Create the UInt8Array off of the content window so there is no XPCCOW involved, but instead the chrome sees the array via an XPCNativeWrapper and has access to it.

Known silly workarounds are to:
- List all of the indices that exist/could exist on the __exposedProps__ for the typed array.
Blocks: 786666
I think we just need to modify the check in AccessCheck.cpp. Currently we do JS_IsArrayObject, and we should replace this with (JS_IsArrayObject || JS_IsTypedArrayObject).

http://mxr.mozilla.org/mozilla-central/source/js/xpconnect/wrappers/AccessCheck.cpp#421

Andrew, I'm pretty backlogged getting back from vacation. Are you able to put together a patch+test here? I can do it at some point, but it might be a little while.
Sure, here you go.  I've added a test to the cows test from bug 760109 that tests '.length' and data '[0]'.

Without the fix, I get:
14 INFO TEST-PASS | chrome://mochitests/content/chrome/js/xpconnect/tests/chrome/test_bug760109.xul | Able to check typed array length - 3 should equal 3
15 ERROR TEST-UNEXPECTED-FAIL | chrome://mochitests/content/chrome/js/xpconnect/tests/chrome/test_bug760109.xul | Able to access typed array data - got undefined, expected 10

With the fix, I get:
14 INFO TEST-PASS | chrome://mochitests/content/chrome/js/xpconnect/tests/chrome/test_bug760109.xul | Able to check typed array length - 3 should equal 3
15 INFO TEST-PASS | chrome://mochitests/content/chrome/js/xpconnect/tests/chrome/test_bug760109.xul | Able to access typed array data - 10 should equal 10
Assignee: mrbkap → bugmail
Attachment #658334 - Flags: review?(bobbyholley+bmo)
Comment on attachment 658334 [details] [diff] [review]
Treat typed arrays like normal arrays with test

Looks great! r=bholley
Attachment #658334 - Flags: review?(bobbyholley+bmo) → review+
https://hg.mozilla.org/mozilla-central/rev/460d24605a7b
Status: ASSIGNED → RESOLVED
Closed: 7 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla18
You need to log in before you can comment on or make changes to this bug.