Commit 8970ade1 authored by dslomov@chromium.org's avatar dslomov@chromium.org

Fix Context::declaration_context to account for script contexts.

R=rossberg@chromium.org
BUG=v8:3690
LOG=N

Review URL: https://codereview.chromium.org/715263003

Cr-Commit-Position: refs/heads/master@{#25303}
git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@25303 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent fd9a4df5
......@@ -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());
}
......
......@@ -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");
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment