Testing Native API Integration and Crash Handling in NW.js
This test suite implements core testing utilities for NW.js native API integration, focusing on renderer crash handling and process control. It establishes essential test hooks for validating native bindings and crash recovery scenarios within the NW.js framework.
Test Coverage Overview
Implementation Analysis
Technical Details
Best Practices Demonstrated
nwjs/nwJs
src/resources/api_nw_test.js
var nwNatives = requireNative('nw_natives');
apiBridge.registerCustomHook(function(bindingsAPI) {
var apiFunctions = bindingsAPI.apiFunctions;
apiFunctions.setHandleRequest('crashRenderer', function() {
nwNatives.crashRenderer();
});
apiFunctions.setHandleRequest('done', function() {
nw.process.exit(0);
});
apiFunctions.setHandleRequest('fail', function() {
nw.process.exit(1);
});
apiFunctions.setHandleRequest('assert', function(value, message) {
if (!value) { console.log(message); nw.process.exit(1); }
});
});