Commit b06c4ce5 authored by jgruber's avatar jgruber Committed by Commit bot

[debug-wrapper] Further extend the debug wrapper

This CL further extends the debug wrapper, migrates around 60 tests, and
removes a few tests that use functionality we will not support anymore.

In more detail:

* Removed tests that use:
  * enable/disable individual breakpoints
  * invocationText()
  * the ScriptCollected event
  * showBreakPoints
  * evalFromScript (and similar)
  * mirror.constructedBy and mirror.referencedBy
  * event_data.promise()
* Some frame.evaluate uses were adapted since due to differences between
  remote objects (inspector) and mirrors. For instance, exceptions are
  currently not recreated exactly, since the inspector protocol does not
  give us the stack and message separately. Other objects (such as
  'this' in debug-evaluate-receiver-before-super) need to be explicitly
  converted to a string before the test works correctly.
* Ensure that inspector stores the script before sending ScriptParsed and
  ScriptFailedToParse events in order to be able to use the script from
  within those events.
* Better remote object reconstruction (e.g. for undefined and arrays).
* New functionality in wrapper:
  * debuggerFlags().breakPointsActive.setValue()
  * scripts()
  * execState.setVariableValue()
  * execState.scopeObject().value()
  * execState.scopeObject().property()
  * execState.frame().allScopes()
  * eventData.exception()
  * eventData.script()
  * setBreakPointsActive()

BUG=v8:5530

Review-Url: https://codereview.chromium.org/2497973002
Cr-Commit-Position: refs/heads/master@{#41019}
parent 41a06267
......@@ -1033,25 +1033,31 @@ void V8DebuggerAgentImpl::didParseSource(
String16 scriptId = script->scriptId();
String16 scriptURL = script->sourceURL();
Maybe<String16> sourceMapURLParam = script->sourceMappingURL();
m_scripts[scriptId] = std::move(script);
ScriptsMap::iterator scriptIterator = m_scripts.find(scriptId);
DCHECK(scriptIterator != m_scripts.end());
V8DebuggerScript* scriptRef = scriptIterator->second.get();
Maybe<String16> sourceMapURLParam = scriptRef->sourceMappingURL();
Maybe<protocol::DictionaryValue> executionContextAuxDataParam(
std::move(executionContextAuxData));
const bool* isLiveEditParam = isLiveEdit ? &isLiveEdit : nullptr;
const bool* hasSourceURLParam = hasSourceURL ? &hasSourceURL : nullptr;
if (success)
m_frontend.scriptParsed(
scriptId, scriptURL, script->startLine(), script->startColumn(),
script->endLine(), script->endColumn(), script->executionContextId(),
script->hash(), std::move(executionContextAuxDataParam),
isLiveEditParam, std::move(sourceMapURLParam), hasSourceURLParam);
scriptId, scriptURL, scriptRef->startLine(), scriptRef->startColumn(),
scriptRef->endLine(), scriptRef->endColumn(),
scriptRef->executionContextId(), scriptRef->hash(),
std::move(executionContextAuxDataParam), isLiveEditParam,
std::move(sourceMapURLParam), hasSourceURLParam);
else
m_frontend.scriptFailedToParse(
scriptId, scriptURL, script->startLine(), script->startColumn(),
script->endLine(), script->endColumn(), script->executionContextId(),
script->hash(), std::move(executionContextAuxDataParam),
std::move(sourceMapURLParam), hasSourceURLParam);
m_scripts[scriptId] = std::move(script);
scriptId, scriptURL, scriptRef->startLine(), scriptRef->startColumn(),
scriptRef->endLine(), scriptRef->endColumn(),
scriptRef->executionContextId(), scriptRef->hash(),
std::move(executionContextAuxDataParam), std::move(sourceMapURLParam),
hasSourceURLParam);
if (scriptURL.isEmpty() || !success) return;
......
......@@ -2,7 +2,6 @@
// 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 --allow-natives-syntax
// Test debug event catch prediction for thrown exceptions. We distinguish
// between "caught" and "uncaught" based on the following assumptions:
......
......@@ -2,7 +2,6 @@
// 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
Debug = debug.Debug
var exception = null;
......@@ -28,7 +27,6 @@ function f(x) {
Debug.setBreakPoint(f, 0, 0); // break
Debug.scripts(); // break
debug.MakeMirror(f); // break
new Error("123").stack; // break
Math.sin(0); // break
......
......@@ -25,8 +25,6 @@
// (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
// Get the Debug object exposed from the debug context global object.
Debug = debug.Debug
Debug.setListener(function() {});
......@@ -120,106 +118,3 @@ Debug.clearBreakPoint(bp3);
// b=2;
// }
assertTrue(Debug.showBreakPoints(g).indexOf("[B0]") < 0);
// Tests for setting break points by script id and position.
function setBreakpointByPosition(f, position, opt_position_alignment)
{
var break_point = Debug.setBreakPointByScriptIdAndPosition(
Debug.findScript(f).id,
position + Debug.sourcePosition(f),
"",
true, opt_position_alignment);
return break_point.number();
}
bp = setBreakpointByPosition(f, 0);
assertEquals("() {[B0]a=1;b=2}", Debug.showBreakPoints(f));
Debug.clearBreakPoint(bp);
assertEquals("() {a=1;b=2}", Debug.showBreakPoints(f));
bp1 = setBreakpointByPosition(f, 8);
assertEquals("() {a=1;[B0]b=2}", Debug.showBreakPoints(f));
bp2 = setBreakpointByPosition(f, 4);
assertEquals("() {[B0]a=1;[B1]b=2}", Debug.showBreakPoints(f));
bp3 = setBreakpointByPosition(f, 11);
assertEquals("() {[B0]a=1;[B1]b=2[B2]}", Debug.showBreakPoints(f));
Debug.clearBreakPoint(bp1);
assertEquals("() {[B0]a=1;b=2[B1]}", Debug.showBreakPoints(f));
Debug.clearBreakPoint(bp2);
assertEquals("() {a=1;b=2[B0]}", Debug.showBreakPoints(f));
Debug.clearBreakPoint(bp3);
assertEquals("() {a=1;b=2}", Debug.showBreakPoints(f));
bp = setBreakpointByPosition(g, 0);
//function g() {
//[B0]a=1;
//b=2;
//}
assertTrue(Debug.showBreakPoints(g).indexOf("[B0]a=1;") > 0);
Debug.clearBreakPoint(bp);
//function g() {
//a=1;
//b=2;
//}
assertTrue(Debug.showBreakPoints(g).indexOf("[B0]") < 0);
//Second test set and clear breakpoints on lines 1, 2 and 3 (column = 0).
bp1 = setBreakpointByPosition(g, 12);
//function g() {
//a=1;
//[B0]b=2;
//}
assertTrue(Debug.showBreakPoints(g).indexOf("[B0]b=2;") > 0);
bp2 = setBreakpointByPosition(g, 5);
//function g() {
//[B0]a=1;
//[B1]b=2;
//}
assertTrue(Debug.showBreakPoints(g).indexOf("[B0]a=1;") > 0);
assertTrue(Debug.showBreakPoints(g).indexOf("[B1]b=2;") > 0);
bp3 = setBreakpointByPosition(g, 19);
//function g() {
//[B0]a=1;
//[B1]b=2;
//}[B2]
assertTrue(Debug.showBreakPoints(g).indexOf("[B0]a=1;") > 0);
assertTrue(Debug.showBreakPoints(g).indexOf("[B1]b=2;") > 0);
assertTrue(Debug.showBreakPoints(g).indexOf("[B2]}") > 0);
Debug.clearBreakPoint(bp1);
//function g() {
//[B0]a=1;
//b=2;
//}[B1]
assertTrue(Debug.showBreakPoints(g).indexOf("[B0]a=1;") > 0);
assertTrue(Debug.showBreakPoints(g).indexOf("[B1]}") > 0);
assertTrue(Debug.showBreakPoints(g).indexOf("[B2]") < 0);
Debug.clearBreakPoint(bp2);
//function g() {
//a=1;
//b=2;
//}[B0]
assertTrue(Debug.showBreakPoints(g).indexOf("[B0]}") > 0);
assertTrue(Debug.showBreakPoints(g).indexOf("[B1]") < 0);
Debug.clearBreakPoint(bp3);
//function g() {
//a=1;
//b=2;
//}
assertTrue(Debug.showBreakPoints(g).indexOf("[B0]") < 0);
// Tests for setting break points without statement aligment.
// (This may be sensitive to compiler break position map generation).
function h() {a=f(f2(1,2),f3())+f3();b=f3();}
var scenario = [
[6, "{a=[B0]f("],
[7, "{a=f([B0]f2("],
[16, "f2(1,2),[B0]f3()"],
[22, "+[B0]f3()"]
];
for(var i = 0; i < scenario.length; i++) {
bp1 = setBreakpointByPosition(h, scenario[i][0],
Debug.BreakPositionAlignment.BreakPosition);
assertTrue(Debug.showBreakPoints(h, undefined,
Debug.BreakPositionAlignment.BreakPosition).indexOf(scenario[i][1]) > 0);
Debug.clearBreakPoint(bp1);
}
......@@ -25,18 +25,13 @@
// (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
// Get the Debug object exposed from the debug context global object.
Debug = debug.Debug
var exception = false; // Exception in debug event listener.
var before_compile_count = 0;
var after_compile_count = 0;
var compile_error_count = 0;
var current_source = ''; // Current source being compiled.
var source_count = 0; // Total number of scources compiled.
var host_compilations = 0; // Number of scources compiled through the API.
var eval_compilations = 0; // Number of scources compiled through eval.
var mute_listener = false;
function compileSource(source) {
......@@ -64,19 +59,9 @@ function listener(event, exec_state, event_data, data) {
event == Debug.DebugEvent.AfterCompile ||
event == Debug.DebugEvent.CompileError) {
// Count the events.
if (event == Debug.DebugEvent.BeforeCompile) {
before_compile_count++;
} else if (event == Debug.DebugEvent.AfterCompile) {
if (event == Debug.DebugEvent.AfterCompile) {
after_compile_count++;
switch (event_data.script().compilationType()) {
case Debug.ScriptCompilationType.Host:
host_compilations++;
break;
case Debug.ScriptCompilationType.Eval:
eval_compilations++;
break;
}
} else {
} else if (event == Debug.DebugEvent.CompileError) {
compile_error_count++;
}
......@@ -91,10 +76,6 @@ function listener(event, exec_state, event_data, data) {
// exact source.
assertEquals(current_source, event_data.script().source());
}
// Check that script context is included into the event message.
var json = event_data.toJSONProtocol();
var msg = safeEval(json);
assertTrue('context' in msg.body.script);
// Check that we pick script name from //# sourceURL, iff present
if (event == Debug.DebugEvent.AfterCompile) {
......@@ -132,13 +113,10 @@ try {
assertFalse(exception, "exception in listener")
// Number of before and after + error events should be the same.
assertEquals(before_compile_count, after_compile_count + compile_error_count);
assertEquals(compile_error_count, 1);
// Check the actual number of events (no compilation through the API as all
// source compiled through eval).
assertEquals(source_count, after_compile_count);
assertEquals(0, host_compilations);
assertEquals(source_count, eval_compilations);
Debug.setListener(null);
......@@ -25,8 +25,6 @@
// (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
// Get the Debug object exposed from the debug context global object.
Debug = debug.Debug
// Simple debug event handler which just counts the number of break points hit.
......@@ -53,53 +51,12 @@ bp1 = Debug.setBreakPoint(f);
f();
assertEquals(1, break_point_hit_count);
// Disable the breakpoint.
Debug.disableBreakPoint(bp1);
f();
assertEquals(1, break_point_hit_count);
// Enable the breakpoint.
Debug.enableBreakPoint(bp1);
f();
assertEquals(2, break_point_hit_count);
// Set another breakpoint in f at the same place.
bp2 = Debug.setBreakPoint(f);
f();
assertEquals(3, break_point_hit_count);
// Disable the second breakpoint.
Debug.disableBreakPoint(bp2);
f();
assertEquals(4, break_point_hit_count);
// Disable the first breakpoint.
Debug.disableBreakPoint(bp1);
f();
assertEquals(4, break_point_hit_count);
// Enable both breakpoints.
Debug.enableBreakPoint(bp1);
Debug.enableBreakPoint(bp2);
f();
assertEquals(5, break_point_hit_count);
// Disable the first breakpoint.
Debug.disableBreakPoint(bp1);
f();
assertEquals(6, break_point_hit_count);
// Deactivate all breakpoints.
Debug.debuggerFlags().breakPointsActive.setValue(false);
f();
assertEquals(6, break_point_hit_count);
// Enable the first breakpoint.
Debug.enableBreakPoint(bp1);
f();
assertEquals(6, break_point_hit_count);
assertEquals(1, break_point_hit_count);
// Activate all breakpoints.
Debug.debuggerFlags().breakPointsActive.setValue(true);
f();
assertEquals(7, break_point_hit_count);
assertEquals(2, break_point_hit_count);
......@@ -2,7 +2,6 @@
// 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
// Test we break at every assignment in a var-statement with multiple
// variable declarations.
......
......@@ -2,13 +2,11 @@
// 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
// Get the Debug object exposed from the debug context global object.
Debug = debug.Debug;
Debug.disable();
assertThrows("Debug.scripts()");
Debug.setListener(function(){});
Debug.enable();
assertDoesNotThrow("Debug.scripts()");
Debug.setListener(null);
......@@ -2,20 +2,25 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
Debug = new DebugWrapper();
Debug.enable();
Debug = debug.Debug
// Simple debug event handler which performs 100 steps and then retrieves
// the resulting value of "i" in f().
// Simple debug event handler which first time hit will perform 1000 steps and
// second time hit will evaluate and store the value of "i". If requires that
// the global property "state" is initially zero.
var bp1, bp2;
function listener(event, exec_state, event_data, data) {
if (event == Debug.DebugEvent.Break) {
if (step_count > 0) {
Debug.stepInto();
exec_state.prepareStep(Debug.StepAction.StepIn);
step_count--;
} else {
const frameid = exec_state.frames[0].callFrameId;
result = Debug.evaluate(frameid, "i").value;
result = exec_state.frame().evaluate("i").value();
// Clear the break point on line 2 if set.
if (bp2) {
Debug.clearBreakPoint(bp2);
}
}
}
};
......@@ -25,19 +30,18 @@ Debug.setListener(listener);
// Test debug event for break point.
function f() {
var i; // Line 1.
for (i = 0; i < 100; i++) { // Line 2.
x = 1; // Line 3.
var i; // Line 1.
for (i = 0; i < 1000; i++) { // Line 2.
x = 1; // Line 3.
}
};
// Set a breakpoint on the for statement (line 1).
Debug.setBreakPoint(f, 1);
// Check that performing 100 steps will make i 33.
let step_count = 100;
let result = -1;
bp1 = Debug.setBreakPoint(f, 1);
// Check that performing 1000 steps will make i 333.
var step_count = 1000;
result = -1;
f();
assertEquals(33, result);
assertEquals(333, result);
Debug.setListener(null);
......@@ -2,7 +2,6 @@
// 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
// Test that debug-evaluate can find the correct this value for an arrow
// function, if "this" is referenced within the arrow function scope.
......@@ -17,7 +16,7 @@ function listener(event, exec_state, event_data, data) {
try {
for (var i = 0; i < exec_state.frameCount() - 1; i++) {
var frame = exec_state.frame(i);
var this_value = frame.evaluate("this").value();
var this_value = frame.evaluate("'' + this").value();
var expected = frame.sourceLineText().match(/\/\/ (.*$)/)[1];
print(expected, this_value, frame.sourceLineText());
assertEquals(String(expected), String(this_value));
......
......@@ -25,7 +25,6 @@
// (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
// Test debug evaluation for functions without local context, but with
// nested catch contexts.
......@@ -46,7 +45,6 @@ function f() {
}
};
// Get the Debug object exposed from the debug context global object.
var Debug = debug.Debug
function listener(event, exec_state, event_data, data) {
......
......@@ -2,7 +2,6 @@
// 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
// Test that debug-evaluate doesn't crash when this is used before super() call
// in constructor.
......@@ -28,7 +27,7 @@ class A { constructor () { this.a = 239; } }
class B extends A {
constructor () {
debugger;
assertEquals("Cannot read property 'a' of undefined", result);
assertTrue(result.indexOf("Cannot read property 'a' of undefined") >= 0);
super();
debugger;
assertEquals(239, result);
......
......@@ -2,7 +2,6 @@
// 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
Debug = debug.Debug
......
......@@ -2,7 +2,6 @@
// 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 --allow-natives-syntax
// Test debug events when we only listen to uncaught exceptions and a
// Promise p3 created by Promise.all has no catch handler, and is rejected
......@@ -22,10 +21,8 @@ function listener(event, exec_state, event_data, data) {
expected_events--;
assertTrue(expected_events >= 0);
assertEquals("uncaught", event_data.exception().message);
assertTrue(event_data.promise() instanceof Promise);
// Assert that the debug event is triggered at the throw site.
assertTrue(exec_state.frame(0).sourceLineText().indexOf("// event") > 0);
assertEquals("p2", event_data.promise().name);
assertTrue(event_data.uncaught());
} catch (e) {
%AbortJS(e + "\n" + e.stack);
......
......@@ -2,7 +2,6 @@
// 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 --allow-natives-syntax
// Test debug events when we only listen to uncaught exceptions and a
// Promise p3 created by Promise.race has no catch handler, and is rejected
......@@ -22,10 +21,8 @@ function listener(event, exec_state, event_data, data) {
expected_events--;
assertTrue(expected_events >= 0);
assertEquals("uncaught", event_data.exception().message);
assertTrue(event_data.promise() instanceof Promise);
// Assert that the debug event is triggered at the throw site.
assertTrue(exec_state.frame(0).sourceLineText().indexOf("// event") > 0);
assertEquals("p2", event_data.promise().name);
assertTrue(event_data.uncaught());
} catch (e) {
%AbortJS(e + "\n" + e.stack);
......
......@@ -2,7 +2,6 @@
// 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 --allow-natives-syntax
// Test debug events when we listen to all exceptions and
// there is a catch handler for the to-be-rejected Promise.
......@@ -36,7 +35,6 @@ function listener(event, exec_state, event_data, data) {
expected_events--;
assertTrue(expected_events >= 0);
assertEquals("reject", event_data.exception().message);
assertSame(q, event_data.promise());
assertFalse(event_data.uncaught());
}
} catch (e) {
......
......@@ -2,7 +2,6 @@
// 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 --allow-natives-syntax
// Test debug events when we only listen to uncaught exceptions and
// there is only a default reject handler for the to-be-rejected Promise.
......@@ -42,10 +41,8 @@ function listener(event, exec_state, event_data, data) {
expected_events--;
assertTrue(expected_events >= 0);
assertTrue(event_data.uncaught());
assertTrue(event_data.promise() instanceof Promise);
// p1 is rejected, uncaught, with the error from the Promise.reject line
assertNotNull(event_data.sourceLineText().match("Promise.reject"));
assertSame(p1, event_data.promise());
}
} catch (e) {
%AbortJS(e + "\n" + e.stack);
......
......@@ -2,7 +2,6 @@
// 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
// Test debug events when we only listen to uncaught exceptions and
// the Promise is rejected in the Promise constructor.
......@@ -18,7 +17,6 @@ function listener(event, exec_state, event_data, data) {
if (event == Debug.DebugEvent.Exception) {
steps++;
assertEquals("uncaught", event_data.exception().message);
assertTrue(event_data.promise() instanceof Promise);
assertTrue(event_data.uncaught());
// Assert that the debug event is triggered at the throw site.
assertTrue(exec_state.frame(0).sourceLineText().indexOf("// event") > 0);
......
......@@ -2,7 +2,6 @@
// 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 --allow-natives-syntax
// Test debug events when we listen to all exceptions and
// there is a catch handler for the to-be-rejected Promise.
......@@ -30,8 +29,6 @@ function listener(event, exec_state, event_data, data) {
expected_events--;
assertTrue(expected_events >= 0);
assertEquals("uncaught reject", event_data.exception().message);
assertTrue(event_data.promise() instanceof Promise);
assertSame(q, event_data.promise());
assertTrue(event_data.uncaught());
// The frame comes from the Promise.reject call
assertNotNull(/Promise\.reject/.exec(event_data.sourceLineText()));
......
......@@ -2,7 +2,6 @@
// 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 --allow-natives-syntax
// Test debug events when we only listen to uncaught exceptions and
// there is a catch handler for the to-be-rejected Promise.
......@@ -37,8 +36,6 @@ function listener(event, exec_state, event_data, data) {
expected_events--;
assertTrue(expected_events >= 0);
assertEquals("uncaught reject p", event_data.exception().message);
assertTrue(event_data.promise() instanceof Promise);
assertSame(p, event_data.promise());
assertTrue(event_data.uncaught());
// Assert that the debug event is triggered at the throw site.
assertTrue(exec_state.frame(0).sourceLineText().indexOf("// event") > 0);
......
......@@ -2,7 +2,6 @@
// 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 --allow-natives-syntax
// Test debug events when we only listen to uncaught exceptions and
// there is no catch handler for the to-be-rejected Promise.
......@@ -30,8 +29,6 @@ function listener(event, exec_state, event_data, data) {
expected_events--;
assertTrue(expected_events >= 0);
assertEquals("uncaught reject", event_data.exception().message);
assertTrue(event_data.promise() instanceof Promise);
assertSame(q, event_data.promise());
assertTrue(event_data.uncaught());
// The JavaScript frame is from the Promise rejection
assertTrue(/Promise\.reject/.test(event_data.sourceLineText()));
......
......@@ -2,7 +2,6 @@
// 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 --allow-natives-syntax
// Test debug events when we listen to all exceptions and
// there is a catch handler for the exception thrown in a Promise.
......@@ -35,7 +34,6 @@ function listener(event, exec_state, event_data, data) {
expected_events--;
assertTrue(expected_events >= 0);
assertEquals("caught", event_data.exception().message);
assertSame(q, event_data.promise());
assertFalse(event_data.uncaught());
}
} catch (e) {
......
......@@ -2,7 +2,6 @@
// 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 --allow-natives-syntax
// Test debug events when we only listen to uncaught exceptions and
// there is only a default reject handler for the to-be-rejected Promise.
......@@ -42,11 +41,9 @@ function listener(event, exec_state, event_data, data) {
expected_events--;
assertTrue(expected_events >= 0);
assertTrue(event_data.uncaught());
assertTrue(event_data.promise() instanceof Promise);
// p1 is rejected, uncaught except for its default reject handler.
assertTrue(
exec_state.frame(0).sourceLineText().indexOf("// event") > 0);
assertSame(p1, event_data.promise());
}
} catch (e) {
%AbortJS(e + "\n" + e.stack);
......
......@@ -2,7 +2,6 @@
// 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 --allow-natives-syntax
// Test debug events when we listen to all exceptions and
// there is a catch handler for the exception thrown in a Promise, first
......@@ -39,7 +38,6 @@ function listener(event, exec_state, event_data, data) {
expected_events--;
assertTrue(expected_events >= 0);
assertEquals("caught", event_data.exception().message);
assertSame(q, event_data.promise());
assertFalse(event_data.uncaught());
}
} catch (e) {
......
......@@ -2,7 +2,6 @@
// 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
// Test debug events when we only listen to uncaught exceptions and
// an exception is thrown in the Promise constructor.
......@@ -18,7 +17,6 @@ function listener(event, exec_state, event_data, data) {
if (event == Debug.DebugEvent.Exception) {
assertEquals(0, step);
assertEquals("uncaught", event_data.exception().message);
assertTrue(event_data.promise() instanceof Promise);
assertTrue(event_data.uncaught());
// Assert that the debug event is triggered at the throw site.
assertTrue(exec_state.frame(0).sourceLineText().indexOf("// event") > 0);
......
......@@ -2,7 +2,6 @@
// 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 --allow-natives-syntax
// Test debug events when we listen to all exceptions and
// there is no catch handler for the exception thrown in a Promise.
......@@ -31,8 +30,6 @@ function listener(event, exec_state, event_data, data) {
expected_events--;
assertTrue(expected_events >= 0);
assertEquals("uncaught", event_data.exception().message);
assertTrue(event_data.promise() instanceof Promise);
assertSame(q, event_data.promise());
assertTrue(event_data.uncaught());
// Assert that the debug event is triggered at the throw site.
assertTrue(exec_state.frame(0).sourceLineText().indexOf("// event") > 0);
......
......@@ -2,7 +2,6 @@
// 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 --allow-natives-syntax
// Test debug events when we only listen to uncaught exceptions and
// there is a catch handler for the exception thrown in a Promise.
......@@ -31,8 +30,6 @@ function listener(event, exec_state, event_data, data) {
expected_events--;
assertTrue(expected_events >= 0);
assertEquals("uncaught", event_data.exception().message);
assertTrue(event_data.promise() instanceof Promise);
assertSame(q, event_data.promise());
assertTrue(event_data.uncaught());
// Assert that the debug event is triggered at the throw site.
assertTrue(exec_state.frame(0).sourceLineText().indexOf("// event") > 0);
......
......@@ -2,7 +2,6 @@
// 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 --allow-natives-syntax
// Test debug events when an exception is thrown inside a Promise, which is
// caught by a custom promise, which throws a new exception in its reject
......@@ -52,7 +51,6 @@ function listener(event, exec_state, event_data, data) {
} else {
assertUnreachable();
}
assertSame(q, event_data.promise());
assertTrue(exec_state.frame(0).sourceLineText().indexOf('// event') > 0);
}
} catch (e) {
......
......@@ -2,7 +2,6 @@
// 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
// Test debug events when we only listen to uncaught exceptions and
// the Promise is rejected within a try-catch in the Promise constructor.
......@@ -18,7 +17,6 @@ function listener(event, exec_state, event_data, data) {
if (event == Debug.DebugEvent.Exception) {
assertEquals(0, step);
assertEquals("uncaught", event_data.exception().message);
assertTrue(event_data.promise() instanceof Promise);
assertTrue(event_data.uncaught());
// Assert that the debug event is triggered at the throw site.
assertTrue(exec_state.frame(0).sourceLineText().indexOf("// event") > 0);
......
......@@ -2,7 +2,6 @@
// 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
// Test debug events when we only listen to uncaught exceptions and
// an exception is thrown in the Promise constructor, but caught in an
......@@ -19,7 +18,6 @@ function listener(event, exec_state, event_data, data) {
if (event == Debug.DebugEvent.Exception) {
assertEquals(0, step);
assertEquals("uncaught", event_data.exception().message);
assertTrue(event_data.promise() instanceof Promise);
assertTrue(event_data.uncaught());
// Assert that the debug event is triggered at the throw site.
assertTrue(exec_state.frame(0).sourceLineText().indexOf("// event") > 0);
......
......@@ -2,7 +2,6 @@
// 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
Debug = debug.Debug
......
......@@ -2,7 +2,6 @@
// 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
Debug = debug.Debug
......
......@@ -2,7 +2,6 @@
// 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
Debug = debug.Debug
......
......@@ -2,7 +2,7 @@
// 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 --harmony
// Flags: --harmony
Debug = debug.Debug;
var break_count = 0
......
......@@ -2,9 +2,7 @@
// 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
// Get the Debug object exposed from the debug context global object.
Debug = debug.Debug
listenerComplete = false;
......
......@@ -2,7 +2,6 @@
// 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
Debug = debug.Debug
var exception = null;
......
......@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flags: --harmony-async-await --expose-debug-as debug
// Flags: --harmony-async-await
var Debug = debug.Debug;
var breakPointCount = 0;
......
......@@ -2,7 +2,6 @@
// 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
Debug = debug.Debug
......
......@@ -2,7 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flags: --allow-natives-syntax --expose-debug-as debug
// Test that PC in optimized frame would correctly translate into
// unoptimized frame when retrieving frame information in the debugger.
......
......@@ -25,7 +25,6 @@
// (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
// Test that the break point is set before initializing the loop variable
// so that we break before any iteration has been run.
......
......@@ -25,10 +25,10 @@
// (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
var Debug = debug.Debug;
function listener(event, exec_state, event_data, data) {
if (event != Debug.DebugEvent.Break) return;
for (var i = 0, n = exec_state.frameCount(); i < n; i++) {
exec_state.frame().scopeCount(i);
}
......
......@@ -25,7 +25,6 @@
// (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
Debug = debug.Debug;
......@@ -42,11 +41,7 @@ function listener(event, exec_state, event_data, data) {
assertEquals(4, lookup("f"));
assertEquals(1, lookup("a"));
try {
assertEquals(2, lookup("b"));
} catch (e) {
assertEquals("ReferenceError: b is not defined", e.toString());
}
assertThrows(() => lookup("b"), ReferenceError);
}
} catch (e) {
exception = e.toString() + e.stack;
......
......@@ -25,7 +25,6 @@
// (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
Debug = debug.Debug
......
......@@ -2,7 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flags: --allow-natives-syntax
// Test that setting break point works correctly when the debugger is
// activated late, which leads to duplicate shared function infos.
......
......@@ -2,7 +2,6 @@
// 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 --allow-natives-syntax
var Debug = debug.Debug;
......
......@@ -2,7 +2,6 @@
// 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 failure = null;
var args;
......
......@@ -2,7 +2,6 @@
// 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
function f() {
print(1);
......
......@@ -25,7 +25,6 @@
// (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
Debug = debug.Debug
......
......@@ -25,7 +25,6 @@
// (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
Debug = debug.Debug
......
......@@ -2,7 +2,6 @@
// 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
function f() {
var a = 1;
......
......@@ -2,7 +2,6 @@
// 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 exception = null;
......
......@@ -25,7 +25,6 @@
// (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 --allow-natives-syntax
Debug = debug.Debug;
......
......@@ -30,6 +30,7 @@
# TODO(jarin/mstarzinger): Investigate debugger issues with TurboFan.
'debug/debug-evaluate-closure': [FAIL],
'debug/es6/debug-evaluate-blockscopes': [FAIL],
}], # variant == turbofan_opt
##############################################################################
......
This diff is collapsed.
// Copyright 2012 the V8 project authors. All rights reserved.
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following
// disclaimer in the documentation and/or other materials provided
// with the distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (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 --expose-gc
// If one callback causes a GC then the other callbacks don't take place.
var f = eval("(function f() { return 42; })");
var f2 = eval("(function f2() { return 43; })");
Debug = debug.Debug;
var called = 0;
function listener(event, exec_state, event_data, data) {
if (event == Debug.DebugEvent.ScriptCollected) {
if (called != 2) {
called++;
gc();
}
}
};
Debug.scripts();
Debug.setListener(listener);
f = void 0;
f2 = void 0;
gc();
assertTrue(called == 2);
......@@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flags: --allow-natives-syntax --expose-debug-as debug
var Debug = debug.Debug;
......
// Copyright 2008 the V8 project authors. All rights reserved.
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following
// disclaimer in the documentation and/or other materials provided
// with the distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (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
// The functions used for testing backtraces.
function Point(x, y) {
this.x = x;
this.y = y;
};
Point.prototype.distanceTo = function(p) {
debugger;
return Math.sqrt(Math.pow(Math.abs(this.x - p.x), 2) +
Math.pow(Math.abs(this.y - p.y), 2))
}
p1 = new Point(1,1);
p2 = new Point(2,2);
p1.distanceTo = function(p) {
return p.distanceTo(this);
}
function distance(p, q) {
return p.distanceTo(q);
}
function createPoint(x, y) {
return new Point(x, y);
}
a=[1,2,distance];
// Get the Debug object exposed from the debug context global object.
Debug = debug.Debug
what = 'constructor'; // Flag to control which part of the test is run.
listenerCalled = false;
exception = false;
function safeEval(code) {
try {
return eval('(' + code + ')');
} catch (e) {
return undefined;
}
}
function listener(event, exec_state, event_data, data) {
try {
if (event == Debug.DebugEvent.Break) {
if (what == 'constructor') {
// The expected backtrace is
// 0: Call distance on Point where distance is a prototype property
// 1: Call distance on Point where distance is a direct property
// 2: Call on function an array element 2
// 3: [anonymous]
assertEquals("#<Point>.distanceTo(p=#<Point>)",
exec_state.frame(0).invocationText());
assertEquals("#<Point>.distanceTo(p=#<Point>)",
exec_state.frame(1).invocationText());
assertEquals("#<Array>[2](aka distance)(p=#<Point>, q=#<Point>)",
exec_state.frame(2).invocationText());
assertEquals("[anonymous]()", exec_state.frame(3).invocationText());
listenerCalled = true;
} else if (what == 'breakpoint') {
// The expected backtrace is
// 0: Call Point constructor
// 1: Call on global function createPoint
// 2: [anonymous]
assertEquals("new Point(x=0, y=0)",
exec_state.frame(0).invocationText());
assertEquals("createPoint(x=0, y=0)",
exec_state.frame(1).invocationText());
assertEquals("[anonymous]()", exec_state.frame(2).invocationText());
listenerCalled = true;
} else if (what == 'symbol') {
// The expected backtrace is
// 0: Call Point constructor
// 1: Call on symbol method
// 2: [anonymous]
assertEquals("new Point(x=0, y=0)",
exec_state.frame(0).invocationText());
assertEquals("#<Object>[Symbol(Das Symbol)](x=0, y=0)",
exec_state.frame(1).invocationText());
assertEquals("[anonymous]()", exec_state.frame(2).invocationText());
listenerCalled = true;
} else {
assertUnreachable();
}
}
} catch (e) {
exception = e
};
};
// Add the debug event listener.
Debug.setListener(listener);
// Set a break point and call to invoke the debug event listener.
a[2](p1, p2)
// Make sure that the debug event listener vas invoked.
assertTrue(listenerCalled);
assertFalse(exception, "exception in listener")
// Set a break point and call to invoke the debug event listener.
what = 'breakpoint';
listenerCalled = false;
Debug.setBreakPoint(Point, 0, 0);
createPoint(0, 0);
// Make sure that the debug event listener vas invoked (again).
assertTrue(listenerCalled);
assertFalse(exception, "exception in listener")
what = 'symbol';
listenerCalled = false;
var S = Symbol('Das Symbol');
var o = { [S](x, y) { return new Point(x, y); } };
Debug.setBreakPoint(Point, 0, 0);
o[S](0, 0);
assertTrue(listenerCalled);
assertFalse(exception, "exception in listener")
// Copyright 2010 the V8 project authors. All rights reserved.
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following
// disclaimer in the documentation and/or other materials provided
// with the distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (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
// Get the Debug object exposed from the debug context global object.
Debug = debug.Debug
var exception = null; // Exception in debug event listener.
function listener(event, exec_state, event_data, data) {
try {
if (event == Debug.DebugEvent.AfterCompile) {
assertEquals(Debug.ScriptCompilationType.Eval,
event_data.script().compilationType(),
'Wrong compilationType');
var evalFromScript = event_data.script().evalFromScript();
assertTrue(!!evalFromScript, ' evalFromScript ');
assertFalse(evalFromScript.isUndefined(), 'evalFromScript.isUndefined()');
assertTrue(/debug-compile-event-newfunction.js$/.test(
evalFromScript.name()),
'Wrong eval from script name.');
var evalFromLocation = event_data.script().evalFromLocation();
assertTrue(!!evalFromLocation, 'evalFromLocation is undefined');
assertEquals(63, evalFromLocation.line);
// Check that the event can be serialized without exceptions.
var json = event_data.toJSONProtocol();
}
} catch (e) {
exception = e
}
};
// Add the debug event listener.
Debug.setListener(listener);
// Create a function from its body text. It will lead to an eval.
new Function('arg1', 'return arg1 + 1;');
assertNull(exception, "exception in listener");
Debug.setListener(null);
// Copyright 2008 the V8 project authors. All rights reserved.
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following
// disclaimer in the documentation and/or other materials provided
// with the distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (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
// Get the Debug object exposed from the debug context global object.
Debug = debug.Debug
// Simple constructor.
function Point(x,y) {}
// Create mirror for the constructor.
var ctor = debug.MakeMirror(Point);
// Initially no instances.
assertEquals(0, ctor.constructedBy().length);
assertEquals(0, ctor.constructedBy(0).length);
assertEquals(0, ctor.constructedBy(1).length);
assertEquals(0, ctor.constructedBy(10).length);
// Create an instance.
var p = new Point();
assertEquals(1, ctor.constructedBy().length);
assertEquals(1, ctor.constructedBy(0).length);
assertEquals(1, ctor.constructedBy(1).length);
assertEquals(1, ctor.constructedBy(10).length);
// Create 10 more instances making for 11.
ps = [];
for (var i = 0; i < 10; i++) {
ps.push(new Point());
}
assertEquals(11, ctor.constructedBy().length);
assertEquals(11, ctor.constructedBy(0).length);
assertEquals(1, ctor.constructedBy(1).length);
assertEquals(10, ctor.constructedBy(10).length);
// Copyright 2008 the V8 project authors. All rights reserved.
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following
// disclaimer in the documentation and/or other materials provided
// with the distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (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
// Get the Debug object exposed from the debug context global object.
Debug = debug.Debug
// Simple object.
var a = {};
// Create mirror for the object.
var mirror = debug.MakeMirror(a);
// Initially one reference from the global object.
assertEquals(1, mirror.referencedBy().length);
assertEquals(1, mirror.referencedBy(0).length);
assertEquals(1, mirror.referencedBy(1).length);
assertEquals(1, mirror.referencedBy(10).length);
// Add some more references from simple objects and arrays.
var b = {}
b.a = a;
assertEquals(2, mirror.referencedBy().length);
var c = {}
c.a = a;
c.aa = a;
c.aaa = a;
assertEquals(3, mirror.referencedBy().length);
function d(){};
d.a = a
assertEquals(4, mirror.referencedBy().length);
e = [a,b,c,d];
assertEquals(5, mirror.referencedBy().length);
// Simple closure.
function closure_simple(p) {
return function() { p = null; };
}
// This adds a reference (function context).
f = closure_simple(a);
assertEquals(6, mirror.referencedBy().length);
// This clears the reference (in function context).
f()
assertEquals(5, mirror.referencedBy().length);
// Use closure with eval - creates arguments array.
function closure_eval(p, s) {
if (s) {
eval(s);
}
return function e(s) { eval(s); };
}
// This adds a references (function context).
g = closure_eval(a);
assertEquals(6, mirror.referencedBy().length);
// Dynamically create a variable. This should create a context extension.
h = closure_eval(null, "var x_");
assertEquals(6, mirror.referencedBy().length);
// Adds a reference when set.
h("x_ = a");
var x = mirror.referencedBy();
assertEquals(7, mirror.referencedBy().length);
// Removes a reference when cleared.
h("x_ = null");
assertEquals(6, mirror.referencedBy().length);
// Check circular references.
x = {}
mirror = debug.MakeMirror(x);
assertEquals(1, mirror.referencedBy().length);
x.x = x;
assertEquals(2, mirror.referencedBy().length);
x = null;
assertEquals(0, mirror.referencedBy().length);
// Check many references.
y = {}
mirror = debug.MakeMirror(y);
refs = [];
for (var i = 0; i < 200; i++) {
refs[i] = {'y': y};
}
y = null;
assertEquals(200, mirror.referencedBy().length);
......@@ -619,7 +619,6 @@
'debug-evaluate-locals': [FAIL],
'debug-set-variable-value': [FAIL],
'debug-liveedit-double-call': [FAIL],
'es6/debug-evaluate-blockscopes': [FAIL],
# TODO(jgruber): Fails in --turbo --always-opt mode.
'regress/regress-105': [FAIL],
......
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