[Extensions] Make it possible to export a custom object

Currently the JavaScript shim receives an "export" object which you are supposed
to add properties. But what if you want to export an object created in the shim
instead? This patch adds support for that: now, by returning an object, it gets
exported at the root of the API namespace instead of the "export" object.
[Extensions] Add tests for exporting objects in the JavaScript shim

The test verifies if both methods of exporting objects (hanging properties
on the "export" object or return an custom object) are working fine.