From d16ddc8b5d78935ae649b49e8869ec3719137b3d Mon Sep 17 00:00:00 2001 From: Victor Costan Date: Mon, 12 Dec 2016 16:18:06 -0800 Subject: [PATCH] EventWatcher: reject waitingFor promise during test cleanup. EventWatcher installs a test cleanup function that removes its event listeners. For this reason, if the EventWatcher's wait_for created a promise that is still pending when the test ends, the promise will never be resolved or rejected. This omission turns into a problem when the EventWatcher's wait_for promise ends up in the promise chain used by promise_test. If an assertion fails in a step() callback, the test's done() method is called, which cleans up the EventWatcher's listener. So, a failure in a single promise_test can block the whole promise chain and prevent all subsequent tests from running. This commit fixes the issue described above by having any pending EventWatcher promise get rejected when the event listeners get removed. --- testharness.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/testharness.js b/testharness.js index a6e7913..fc4b069 100644 --- a/testharness.js +++ b/testharness.js @@ -613,6 +613,11 @@ policies and contribution forms [3]. for (var i = 0; i < eventTypes.length; i++) { watchedNode.removeEventListener(eventTypes[i], eventHandler, false); } + + if (waitingFor) { + waitingFor.reject(new Error('Test ended while waiting for event')); + waitingFor = null; + } }; test.add_cleanup(stop_watching);