js/src/jit-test/tests/debug/Frame-this-04.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/js/src/jit-test/tests/debug/Frame-this-04.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,25 @@
     1.4 +// Debugger.Frame.prototype.this in functions, with object values
     1.5 +
     1.6 +function classOf(obj) {
     1.7 +    return Object.prototype.toString.call(obj).match(/^\[object (.*)\]$/)[1];
     1.8 +}
     1.9 +
    1.10 +var g = newGlobal();
    1.11 +var dbg = new Debugger(g);
    1.12 +var hits = 0;
    1.13 +dbg.onDebuggerStatement = function (frame) {
    1.14 +    hits++;
    1.15 +    assertEq(frame.this instanceof Debugger.Object, true);
    1.16 +    assertEq(frame.this.class, classOf(Object(g.v)));
    1.17 +};
    1.18 +
    1.19 +g.eval("function f() { debugger; }");
    1.20 +
    1.21 +g.eval("v = {}; f.call(v);");
    1.22 +g.eval("v.f = f; v.f();");
    1.23 +g.eval("v = new Date; f.call(v);");
    1.24 +g.eval("v.f = f; v.f();");
    1.25 +g.eval("v = []; f.call(v);");
    1.26 +g.eval("Object.prototype.f = f; v.f();");
    1.27 +g.eval("v = this; f();");
    1.28 +assertEq(hits, 7);

mercurial