Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(101)

Side by Side Diff: test/cctest/test-debug.cc

Issue 726643002: harmony-scoping: Implement debugger support for script scope. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Minor nits Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 7613 matching lines...) Expand 10 before | Expand all | Expand 10 after
7624 const v8::Debug::EventDetails& event_details) { 7624 const v8::Debug::EventDetails& event_details) {
7625 v8::DebugEvent event = event_details.GetEvent(); 7625 v8::DebugEvent event = event_details.GetEvent();
7626 if (event != v8::Break) return; 7626 if (event != v8::Break) return;
7627 7627
7628 int break_id = CcTest::i_isolate()->debug()->break_id(); 7628 int break_id = CcTest::i_isolate()->debug()->break_id();
7629 7629
7630 char script[128]; 7630 char script[128];
7631 i::Vector<char> script_vector(script, sizeof(script)); 7631 i::Vector<char> script_vector(script, sizeof(script));
7632 SNPrintF(script_vector, "%%GetFrameCount(%d)", break_id); 7632 SNPrintF(script_vector, "%%GetFrameCount(%d)", break_id);
7633 v8::Local<v8::Value> result = CompileRun(script); 7633 v8::Local<v8::Value> result = CompileRun(script);
7634 CHECK_EQ(1, result->Int32Value());
aandrey 2014/11/14 15:58:47 nit: you can use ExpectInt32() here and below
Dmitry Lomov (no reviews) 2014/11/14 16:37:26 Done.
7634 7635
7636 SNPrintF(script_vector, "var frame = new FrameMirror(%d, 0);", break_id);
7637 CompileRun(script);
7638 result = CompileRun("frame.evaluate('x').value_");
7635 CHECK_EQ(1, result->Int32Value()); 7639 CHECK_EQ(1, result->Int32Value());
7640 result = CompileRun("frame.evaluate('y').value_");
7641 CHECK_EQ(2, result->Int32Value());
7642
7643 CompileRun("var allScopes = frame.allScopes()");
7644 result = CompileRun("allScopes.length");
7645 CHECK_EQ(2, result->Int32Value());
7646
7647 result = CompileRun("allScopes[0].scopeType() === ScopeType.Script");
7648 CHECK(result->IsTrue());
7649
7650 result = CompileRun("allScopes[0].scopeObject().value_.x");
7651 CHECK_EQ(1, result->Int32Value());
7652
7653 result = CompileRun("allScopes[0].scopeObject().value_.y");
7654 CHECK_EQ(2, result->Int32Value());
7655
7656 CompileRun("allScopes[0].setVariableValue('x', 5);");
7657 CompileRun("allScopes[0].setVariableValue('y', 6);");
7658 result = CompileRun("frame.evaluate('x + y').value_");
7659 CHECK_EQ(11, result->Int32Value());
7636 } 7660 }
7637 7661
7638 7662
7639 TEST(DebugBreakInLexicalScopes) { 7663 TEST(DebugBreakInLexicalScopes) {
7640 i::FLAG_harmony_scoping = true; 7664 i::FLAG_harmony_scoping = true;
7641 i::FLAG_allow_natives_syntax = true; 7665 i::FLAG_allow_natives_syntax = true;
7642 7666
7643 DebugLocalContext env; 7667 DebugLocalContext env;
7644 v8::Isolate* isolate = env->GetIsolate(); 7668 v8::Isolate* isolate = env->GetIsolate();
7645 v8::HandleScope scope(isolate); 7669 v8::HandleScope scope(isolate);
7646 v8::Debug::SetDebugEventListener(DebugHarmonyScopingListener); 7670 v8::Debug::SetDebugEventListener(DebugHarmonyScopingListener);
7647 7671
7648 CompileRun( 7672 CompileRun(
7649 "'use strict'; \n" 7673 "'use strict'; \n"
7650 "let x = 1; \n"); 7674 "let x = 1; \n");
7651 CompileRun( 7675 v8::Local<v8::Value> result = CompileRun(
7652 "'use strict'; \n" 7676 "'use strict'; \n"
7653 "let y = 1; \n" 7677 "let y = 2; \n"
7654 "debugger \n"); 7678 "debugger; \n"
7679 "x * y");
7680 CHECK_EQ(30, result->Int32Value());
7681
7682 result = CompileRun(
7683 "x = 1; y = 2; \n"
7684 "debugger;"
7685 "x * y");
7686 CHECK_EQ(30, result->Int32Value());
7655 } 7687 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698