== Example Consider the following XPCShell test:
function doSomething() {
OS.File.writeAtomic("/a path that doesn't exist", "foo");
}
add_test(function() {
// ...
doSomething();
// ...
});
This test raises an error and fails to catch it. Until now, this test
used to pass with a warning. It will now fail with a message
"A promise chain failed to handle a rejection - Error during operation
'write'"
This is particularly useful for tracking subsystems that completely
forget to handle errors or tasks that forget to call `yield`.
Here, the test should have looked like
add_task(function*() {
// ...
yield doSomething();
// ...
});
== Opting out
You should not need to opt out of this feature. However, if you really,
really, really need to, take a look at Promise.Debugging in Promise.jsm.
This contains the methods you need to opt-out.
== Any questions?
If you have any question, please feel free to get in touch with either
myself or Paolo.
Cheers,
David
On 28/05/14 21:30, David Rajchenbach-Teller wrote:
> Dear everyone,
>
> After weeks tracking and fixing blockers, we are in the process of
> attempting to land bug 976205. If this sticks, it will change the
> behavior of xpcshell tests with respect to uncaught asynchronous errors:
> uncaught promise rejections using Promise.jsm will cause
> TEST-UNEXPECTED-FAIL.
>
>
> Rationales:
> 1. uncaught exceptions have always been treated as errors, there is no
> reason to assume that promise rejections, which implement the same
> behavior as exceptions, are different;
> 2. experience has shown that ignoring promise rejections could very
> easily hide a real bug.
>
>
> Precautions:
> In order to make sure that all uncaught rejections are reported and to
> make it easier to pinpoint their sources, we had to make a single
> assumption. Namely, we assume if a call to `add_task` leaves a rejected
> promise without any error-handler, this rejection will remain uncaught.
> So far, this heuristic hasn't caused any false positive.
>
>
> We intend to progressively extend this policy to:
> - mochitests (bug 1016387);
> - addon-sdk tests (bug 998277);
> - DOM Promise (bug 989960).
>
> Cheers,
> David
>
>
>
> _______________________________________________
> dev-platform mailing list
> [email protected]
> https://lists.mozilla.org/listinfo/dev-platform
>
--
David Rajchenbach-Teller, PhD
Performance Team, Mozilla
signature.asc
Description: OpenPGP digital signature
_______________________________________________ dev-platform mailing list [email protected] https://lists.mozilla.org/listinfo/dev-platform

