diff --git a/xpcom/tests/unit/test_nsIProcess.js b/xpcom/tests/unit/test_nsIProcess.js index c39fe694c2c7..318804990f47 100644 --- a/xpcom/tests/unit/test_nsIProcess.js +++ b/xpcom/tests/unit/test_nsIProcess.js @@ -235,6 +235,8 @@ function test_notify_killed() function test_kill_2() { var file = get_test_program("TestQuickReturn"); + var thread = Components.classes["@mozilla.org/thread-manager;1"] + .getService().currentThread; for (var i = 0; i < 1000; i++) { var process = Components.classes["@mozilla.org/process/util;1"] @@ -248,6 +250,12 @@ function test_kill_2() } catch (e) { } } + + // We need to ensure that we process any events on the main thread - + // this allow threads to clean up properly and avoid out of memory + // errors during the test. + while (thread.hasPendingEvents()) + thread.processNextEvent(false); } function run_test() {