Wow! This is cool. But it seems a little inefficient. May we use something similar this?
https://github.com/mozilla-b2g/gaia/blob/4da57191b7e3ca153a22d017068f3332f9dcf580/apps/sms/test/unit/attachment_test.js#L74