- Add-on SDK Promises
- DOM Promises
Promises are becoming an important part of interfaces in production code, and interoperability between these different implementations is becoming a concern as those have subtle differences or relevant limitations.
It is therefore important to reach a point where we don't pay the maintenance cost of different implementations across all the products.
With the stabilization of the DOM/ES6 Promises specification in late January 2013 for the subset of functionality that we need, we can now identify the DOM Promises implementation as the final migration target. This implementation, however, has a number of limitations over Promise.jsm, related to debuggability. In order of importance:
- bug 966452 - DOM Promises should report all unhandled rejections to the Console on GC
- bug 966471 - DOM Promise state, value and reason should be inspectable in the debugger
- bug 966472 - DOM Promise handlers should be inspectable in the debugger
Since Promise.jsm currently implements a subset of the DOM Promises interface and behaves in the same way as far as code is concerned, then migration to Promise.jsm is an appropriate intermediate step. The major work is related to porting the Add-on SDK Promises, in particular these bugs are on file:
- bug 887923 - Switch Task.jsm to use Promise.jsm
- bug 881050 - Use the new "Promise.jsm" implementation in Developer Tools
The sooner we complete the migration, the less new code will be written that depends on behavior that is incorrect according to the specification.
Unification towards DOM Promises can proceed on two parallel tracks:
- Remove all uses of Add-on SDK Promises from mozilla-central
- Implement new DOM Promises features, then migrate Promise.jsm to use DOM Promises internally
The first goal is the most important, to be ideally completed in a short time. The last step after both have completed would be to deprecate Promise.jsm and migrate all callers to directly use DOM Promises.
The overall Promises work is tracked in bug 856878.