Reviewers: rossberg,
Message:
PTAL
Description:
Fix Context::declaration_context to account for script contexts.
[email protected]
BUG=v8:3690
LOG=N
Please review this at https://codereview.chromium.org/715263003/
Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Affected files (+37, -1 lines):
M src/contexts.cc
M test/cctest/test-debug.cc
Index: src/contexts.cc
diff --git a/src/contexts.cc b/src/contexts.cc
index
54cbb3e2bb4e1150e90eee4c6d62af1796fbaf32..3da6191a77c98c70f6c872d02027e7f9828aa2b2
100644
--- a/src/contexts.cc
+++ b/src/contexts.cc
@@ -55,7 +55,8 @@ bool
ScriptContextTable::Lookup(Handle<ScriptContextTable> table,
Context* Context::declaration_context() {
Context* current = this;
- while (!current->IsFunctionContext() && !current->IsNativeContext()) {
+ while (!current->IsFunctionContext() && !current->IsNativeContext() &&
+ !current->IsScriptContext()) {
current = current->previous();
DCHECK(current->closure() == closure());
}
Index: test/cctest/test-debug.cc
diff --git a/test/cctest/test-debug.cc b/test/cctest/test-debug.cc
index
677a2926989a3869d2ab6d74e5443fb214c9a1d4..4b41a65451205f04ddd9dca3a24347eaabcf641c
100644
--- a/test/cctest/test-debug.cc
+++ b/test/cctest/test-debug.cc
@@ -7618,3 +7618,38 @@ TEST(DebugBreakOnExceptionInObserveCallback) {
CHECK(CompileRun("callbackRan")->BooleanValue());
CHECK_EQ(1, exception_event_counter);
}
+
+
+static void DebugHarmonyScopingListener(
+ const v8::Debug::EventDetails& event_details) {
+ v8::DebugEvent event = event_details.GetEvent();
+ if (event != v8::Break) return;
+
+ int break_id = CcTest::i_isolate()->debug()->break_id();
+
+ char script[128];
+ i::Vector<char> script_vector(script, sizeof(script));
+ SNPrintF(script_vector, "%%GetFrameCount(%d)", break_id);
+ v8::Local<v8::Value> result = CompileRun(script);
+
+ CHECK_EQ(1, result->Int32Value());
+}
+
+
+TEST(DebugBreakInLexicalScopes) {
+ i::FLAG_harmony_scoping = true;
+ i::FLAG_allow_natives_syntax = true;
+
+ DebugLocalContext env;
+ v8::Isolate* isolate = env->GetIsolate();
+ v8::HandleScope scope(isolate);
+ v8::Debug::SetDebugEventListener(DebugHarmonyScopingListener);
+
+ CompileRun(
+ "'use strict'; \n"
+ "let x = 1; \n"
+ CompileRun(
+ "'use strict'; \n"
+ "let y = 1; \n"
+ "debugger \n");
+}
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.