-
-
Notifications
You must be signed in to change notification settings - Fork 17
Use case for Chrome Apps #1
Description
Apologies for what follows as it's a bit of a (long) braindump.
Please feel free to close if I have missed the intention/direction of the project.
TL;DR; Will this project support browser based node implementations?
So myself and a couple of others have kicked of a small project called https://github.com/chromiumify
The idea is to martial all the packages that implement the node api in Chrome Apps as a coherent node runtime.
Currently we have implementations of http, dgram, net, fs and serialport (see https://github.com/chromiumify/project-list#project-list) and I thought it might be useful to share some initial thoughts.
1. Sync API
Having the Sync calls in core is a problem as you can't implement them if you are in a pure JS environment.
e.g. The Chrome App environment has a large set of comparable calls for an implementation of
an 'os' module but this is not feasible as the chrome api is async
See (https://github.com/No9/chrome-os/blob/master/chrome.js#L38) for a sketch of the issue.
My initial thought here is to suggest that the test suite for each module should be broken into sync and async
i.e. ('os-sync-tests') and ('os-tests')
This approach also highlights that all sync calls such as the os.cpu() should also have corresponding async calls specified in the tests.
The async shim could be implemented in userland for node.js but would give alternative runtime implementers options.
2. Porting tests
One of the largest amounts of time spent in the chrome-fs port https://github.com/No9/chrome-fs port is migrating the tests
This is because most of the tests in core rely on the sync api and or process.exit and static fixture folders.
It would be great if these dependencies could be removed in the case of sync and process.exit and removing the need for a fixtures folder
I have ported some of the fs tests to this approach
https://github.com/No9/chrome-fs/tree/master/test/simple
While it's time consuming it's should be possible.
3. Test Coverage
It would be nice if the test suits could output an API coverage document something along the lines of https://github.com/No9/chrome-fs#api-status (?) so it's easy for folks to see what is and isn't available from that implementation.
The node browser projects (chromiumify and browserify) are more loosely coupled allowing core APIs to be swapped out according to needs so this would be great to have for end users.
4. Approach
Are there any ideas for the implementation of the test suite/JSAPI specification?
My hunch was that each module would mirror the abstract-leveldown approach https://github.com/Level/abstract-leveldown but that is very presumptuous as there are probably other ways to go about this too.
Anyway hope some of this is useful.