2014-11-15 19:48:32 +00:00
|
|
|
// Copyright 2014 the V8 project authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
|
|
// found in the LICENSE file.
|
|
|
|
|
|
|
|
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
var Debug = debug.Debug
|
|
|
|
var done, stepCount;
|
2016-11-07 09:43:08 +00:00
|
|
|
var exception = null;
|
2014-11-15 19:48:32 +00:00
|
|
|
|
|
|
|
function listener(event, execState, eventData, data) {
|
2016-11-07 09:43:08 +00:00
|
|
|
if (event != Debug.DebugEvent.Break) return;
|
|
|
|
try {
|
2014-11-15 19:48:32 +00:00
|
|
|
if (!done) {
|
2015-12-16 08:39:39 +00:00
|
|
|
execState.prepareStep(Debug.StepAction.StepIn);
|
2014-11-15 19:48:32 +00:00
|
|
|
var s = execState.frame().sourceLineText();
|
|
|
|
assertTrue(s.indexOf('// ' + stepCount + '.') !== -1);
|
|
|
|
stepCount++;
|
|
|
|
}
|
2016-11-07 09:43:08 +00:00
|
|
|
} catch (e) {
|
|
|
|
exception = e;
|
2014-11-15 19:48:32 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
Debug.setListener(listener);
|
|
|
|
|
|
|
|
|
|
|
|
class Base {
|
2016-11-07 09:43:08 +00:00
|
|
|
constructor() {
|
|
|
|
var x = 1; // 1.
|
|
|
|
var y = 2; // 2.
|
|
|
|
done = true; // 3.
|
2014-11-15 19:48:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-11-07 09:43:08 +00:00
|
|
|
class Derived extends Base {} // 0.
|
2014-11-15 19:48:32 +00:00
|
|
|
|
|
|
|
|
|
|
|
(function TestBreakPointInConstructor() {
|
|
|
|
done = false;
|
|
|
|
stepCount = 1;
|
|
|
|
var bp = Debug.setBreakPoint(Base, 0);
|
|
|
|
|
|
|
|
new Base();
|
2016-11-07 09:43:08 +00:00
|
|
|
assertEquals(4, stepCount);
|
2014-11-15 19:48:32 +00:00
|
|
|
|
|
|
|
Debug.clearBreakPoint(bp);
|
|
|
|
})();
|
|
|
|
|
|
|
|
|
|
|
|
(function TestDefaultConstructor() {
|
|
|
|
done = false;
|
|
|
|
stepCount = 1;
|
|
|
|
|
|
|
|
var bp = Debug.setBreakPoint(Base, 0);
|
|
|
|
new Derived();
|
2016-11-07 09:43:08 +00:00
|
|
|
assertEquals(4, stepCount);
|
2014-11-15 19:48:32 +00:00
|
|
|
|
|
|
|
Debug.clearBreakPoint(bp);
|
|
|
|
})();
|
|
|
|
|
|
|
|
|
|
|
|
(function TestStepInto() {
|
|
|
|
done = false;
|
2016-11-07 09:43:08 +00:00
|
|
|
stepCount = -1;
|
2014-11-15 19:48:32 +00:00
|
|
|
|
|
|
|
function f() {
|
2016-11-07 09:43:08 +00:00
|
|
|
new Derived(); // -1.
|
2014-11-15 19:48:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
var bp = Debug.setBreakPoint(f, 0);
|
|
|
|
f();
|
2016-11-07 09:43:08 +00:00
|
|
|
assertEquals(4, stepCount);
|
2014-11-15 19:48:32 +00:00
|
|
|
|
|
|
|
Debug.clearBreakPoint(bp);
|
|
|
|
})();
|
|
|
|
|
|
|
|
|
|
|
|
(function TestExtraIndirection() {
|
|
|
|
done = false;
|
2016-11-07 09:43:08 +00:00
|
|
|
stepCount = -2;
|
2014-11-15 19:48:32 +00:00
|
|
|
|
2016-11-07 09:43:08 +00:00
|
|
|
class Derived2 extends Derived {} // -1.
|
2014-11-15 19:48:32 +00:00
|
|
|
|
|
|
|
function f() {
|
2016-11-07 09:43:08 +00:00
|
|
|
new Derived2(); // -2.
|
2014-11-15 19:48:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
var bp = Debug.setBreakPoint(f, 0);
|
|
|
|
f();
|
2016-11-07 09:43:08 +00:00
|
|
|
assertEquals(4, stepCount);
|
2014-11-15 19:48:32 +00:00
|
|
|
|
|
|
|
Debug.clearBreakPoint(bp);
|
|
|
|
})();
|
|
|
|
|
|
|
|
|
|
|
|
(function TestBoundClass() {
|
|
|
|
done = false;
|
2016-11-07 09:43:08 +00:00
|
|
|
stepCount = -1;
|
2014-11-15 19:48:32 +00:00
|
|
|
|
|
|
|
var bound = Derived.bind(null);
|
|
|
|
|
|
|
|
function f() {
|
2016-11-07 09:43:08 +00:00
|
|
|
new bound(); // -1.
|
2014-11-15 19:48:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
var bp = Debug.setBreakPoint(f, 0);
|
|
|
|
f();
|
2016-11-07 09:43:08 +00:00
|
|
|
assertEquals(4, stepCount);
|
2014-11-15 19:48:32 +00:00
|
|
|
|
|
|
|
Debug.clearBreakPoint(bp);
|
|
|
|
})();
|
|
|
|
|
|
|
|
|
|
|
|
Debug.setListener(null);
|
2016-11-07 09:43:08 +00:00
|
|
|
assertNull(exception);
|