Chromium Code Reviews| Index: test/mjsunit/es6/debug-promises/evaluate-across-microtasks.js |
| diff --git a/test/mjsunit/es6/debug-promises/evaluate-across-microtasks.js b/test/mjsunit/es6/debug-promises/evaluate-across-microtasks.js |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..0d68dcd67eaa009c6e76388502c50fa10019bc39 |
| --- /dev/null |
| +++ b/test/mjsunit/es6/debug-promises/evaluate-across-microtasks.js |
| @@ -0,0 +1,63 @@ |
| +// Copyright 2014 the V8 project authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| +// Flags: --expose-debug-as debug |
| + |
| +var Debug = debug.Debug; |
| +var listenerComplete = false; |
| +var exception = null; |
| +var count = 0; |
| +var log = []; |
| + |
| +function LogX(x) { |
| + var stored_count = count; |
| + return function() { |
| + log.push(`[${stored_count}] ${x}`); |
| + }; |
| +} |
| + |
| +var expectation = [ "[0] debugger", "[1] start", "[1] then 1", "[1] then 2", |
| + "[1] then 3", "[1] debugger", "[2] then 1", "[2] then 2", |
| + "[1] catch", "[2] then 3", "[2] debugger", "[3] then 1", |
| + "[3] then 2", "[2] catch", "[3] then 3", "[3] debugger" ]; |
| + |
| +function DebuggerStatement() { |
| + log.push(`[${count}] debugger`); |
| + if (count++ < 3) { |
| + debugger; |
| + } else { |
| + try { |
|
caitp (gmail)
2016/05/31 11:44:32
I think we hit this because d8 won't die if the mi
Yang
2016/06/01 08:55:21
Good point. I haven't found a good way to do this
Dan Ehrenberg
2016/06/01 10:38:13
Maybe you could use the new %RunMicrotasks call, w
|
| + assertEquals(expectation, log); |
| + } catch (e) { |
| + print(e, e.stack); |
| + quit(1); |
| + } |
| + } |
| +} |
| + |
| +function listener(event, exec_state, event_data, data) { |
| + if (event != Debug.DebugEvent.Break) return; |
| + try { |
| + var p = Promise.resolve(); |
| + var q = p.then(LogX("then 1")); |
| + p.then(LogX("then 2")); |
| + q.then(LogX("then 3")); |
| + q.then(DebuggerStatement); |
| + var r = q.then(() => { throw 1; }); |
| + r.catch(LogX("catch")); |
| + listenerComplete = true; |
| + } catch (e) { |
| + exception = e; |
| + print("failure"); |
|
caitp (gmail)
2016/05/31 11:44:32
if we fail here, it would be helpful to print the
Yang
2016/06/01 08:55:21
Done.
|
| + quit(1); |
| + }; |
| +}; |
| + |
| +// Add the debug event listener. |
| +Debug.setListener(listener); |
| + |
| +DebuggerStatement(); |
| +LogX("start")(); |
| + |
| +// Make sure that the debug event listener was invoked. |
| +assertTrue(listenerComplete); |