diff -r 000000000000 -r 6474c204b198 js/src/tests/js1_8_1/extensions/regress-520572.js --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/js/src/tests/js1_8_1/extensions/regress-520572.js Wed Dec 31 06:09:35 2014 +0100 @@ -0,0 +1,41 @@ +/* -*- Mode: java; tab-width:8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/licenses/publicdomain/ + * Contributor: Blake Kaplan + */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 520572; +var summary = 'watch should innerize the object being watched'; +var actual = 0; +var expect = 2; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + if ("evalcx" in this) { + // shell + let s = evalcx("lazy"); + s.n = 0; + evalcx('this.watch("x", function(){ n++; }); this.x = 4; x = 6', s); + actual = s.n; + reportCompare(expect, actual, summary); + } else { + // browser + this.watch('x', function(){ actual++; }); + this.x = 4; + x = 6; + reportCompare(expect, actual, summary); + } + + exitFunc ('test'); +}