Chromium Code Reviews| Index: test/mjsunit/debug-stepout-scope-part4.js |
| diff --git a/test/mjsunit/harmony/debug-evaluate-blockscopes.js b/test/mjsunit/debug-stepout-scope-part4.js |
| similarity index 56% |
| copy from test/mjsunit/harmony/debug-evaluate-blockscopes.js |
| copy to test/mjsunit/debug-stepout-scope-part4.js |
| index d6ce8b2b6a8c8050e1769297f865d06cf007bc6b..a55969462a00167f48b313fa5109c63abeb869ff 100644 |
| --- a/test/mjsunit/harmony/debug-evaluate-blockscopes.js |
| +++ b/test/mjsunit/debug-stepout-scope-part4.js |
| @@ -25,46 +25,55 @@ |
| // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| -// Flags: --expose-debug-as debug --harmony-scoping |
| +// Flags: --expose-debug-as debug --expose-natives-as=builtins |
| -// Test debug evaluation for functions without local context, but with |
| -// nested catch contexts. |
| +// Check that the ScopeIterator can properly recreate the scope at |
| +// every point when stepping through functions. |
| -// TODO(ES6): properly activate extended mode |
| -"use strict"; |
| +var Debug = debug.Debug; |
| -var x; |
| -var result; |
| +function listener(event, exec_state, event_data, data) { |
| + if (event == Debug.DebugEvent.Break) { |
| + // Access scope details. |
| + var scope_count = exec_state.frame().scopeCount(); |
| + for (var i = 0; i < scope_count; i++) { |
| + var scope = exec_state.frame().scope(i); |
| + // assertTrue(scope.isScope()); |
| + scope.scopeType(); |
| + scope.scopeObject(); |
| + } |
| -function f() { |
| - { // Line 1. |
| - let i = 1; // Line 2. |
| - try { // Line 3. |
| - throw 'stuff'; // Line 4. |
| - } catch (e) { // Line 5. |
| - x = 2; // Line 6. |
| + // Do steps until we reach the global scope again. |
| + if (true) { |
| + exec_state.prepareStep(Debug.StepAction.StepInMin, 1); |
| } |
| } |
| -}; |
| +} |
| -// Get the Debug object exposed from the debug context global object. |
| -var Debug = debug.Debug |
| -// Set breakpoint on line 6. |
| -var bp = Debug.setBreakPoint(f, 6); |
| +Debug.setListener(listener); |
| -function listener(event, exec_state, event_data, data) { |
| - if (event == Debug.DebugEvent.Break) { |
| - result = exec_state.frame().evaluate("i").value(); |
| - } |
| -}; |
| +var q = 42; |
| +var prefixes = [ "debugger; ", |
| + "if (false) { try { throw 0; } catch(x) { return x; } }; debugger; " ]; |
|
Yang
2012/09/24 11:14:40
ditto.
Jakob Kummerow
2012/09/24 11:18:34
Done.
|
| +var bodies = [ "1", |
| + "1 ", |
| + "1;", |
| + "1; ", |
| + "q", |
| + "q ", |
| + "q;", |
| + "q; ", |
| + "try { throw 'stuff' } catch (e) { e = 1; }", |
| + "try { throw 'stuff' } catch (e) { e = 1; } ", |
| + "try { throw 'stuff' } catch (e) { e = 1; };", |
| + "try { throw 'stuff' } catch (e) { e = 1; }; " ]; |
| -// Add the debug event listener. |
| -Debug.setListener(listener); |
| -result = -1; |
| -f(); |
| -assertEquals(1, result); |
| -// Clear breakpoint. |
| -Debug.clearBreakPoint(bp); |
| -// Get rid of the debug event listener. |
| -Debug.setListener(null); |
| +// Test global eval and function constructor. |
| +for (var i = 0; i < prefixes.length; ++i) { |
| + var pre = prefixes[i]; |
| + for (var j = 0; j < bodies.length; ++j) { |
| + var body = bodies[j]; |
| + eval(pre + body); |
| + } |
| +} |