js/src/jit-test/tests/jaeger/propertyOptimize-3.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     2 // Properties cleared in the middle of a single function constructor.
     4 function foo(x, y) {
     5   this.f = 0;
     6   this.g = x + y;
     7   this.h = 2;
     8 }
    10 var called = false;
    11 var a = 0;
    12 var b = {valueOf: function() { Object.defineProperty(Object.prototype, 'g', {set: function() { called = true }}) }};
    13 var c = new foo(a, b);
    15 assertEq(called, true);
    16 assertEq(c.g, undefined);
    18 // Properties cleared in the middle of a constructor callee.
    20 function foo2(x, y) {
    21   this.a = 0;
    22   this.b = 1;
    23   bar2.call(this, x, y);
    24   this.c = 2;
    25 }
    26 function bar2(x, y) {
    27   this.d = x + y;
    28   this.e = 3;
    29 }
    31 var called2 = false;
    32 var xa = 0;
    33 var xb = {valueOf: function() { Object.defineProperty(Object.prototype, 'e', {set: function() { called2 = true }}) }};
    34 var xc = new foo2(xa, xb);
    36 assertEq(called2, true);
    37 assertEq(xc.e, undefined);
    38 assertEq(xc.c, 2);
    40 // Properties cleared after a constructor callee.
    42 function foo3() {
    43   this.aa = 0;
    44   this.bb = 1;
    45   bar3.call(this);
    46   this.cc = 2;
    47   baz();
    48   xbar3.call(this);
    49   this.dd = 3;
    50 }
    51 function bar3() {
    52   this.ee = 4;
    53 }
    54 function xbar3() {
    55   this.ff = 5;
    56 }
    57 function baz() {
    58   eval("xbar3.call = function() { called3 = true }");
    59 }
    61 var called3 = false;
    62 var c3 = new foo3();
    63 assertEq(c3.cc, 2);
    64 assertEq(c3.ee, 4);
    65 assertEq(c3.ff, undefined);
    66 assertEq(c3.dd, 3);
    67 assertEq(called3, true);

mercurial