michael@0: /* michael@0: * Any copyright is dedicated to the Public Domain. michael@0: * http://creativecommons.org/licenses/publicdomain/ michael@0: */ michael@0: michael@0: var hitCount; michael@0: function watcher(p,o,n) { hitCount++; return n; } michael@0: michael@0: var a = [1]; michael@0: a.watch('length', watcher); michael@0: hitCount = 0; michael@0: a.length = 0; michael@0: reportCompare(1, hitCount, "lenient; configurable: watchpoint hit"); michael@0: michael@0: var b = Object.defineProperty([1],'0',{configurable:false}); michael@0: b.watch('length', watcher); michael@0: hitCount = 0; michael@0: var result; michael@0: try { michael@0: b.length = 0; michael@0: result = "no error"; michael@0: } catch (x) { michael@0: result = x.toString(); michael@0: } michael@0: reportCompare(1, hitCount, "lenient; non-configurable: watchpoint hit"); michael@0: reportCompare(1, b.length, "lenient; non-configurable: length unchanged"); michael@0: reportCompare("no error", result, "lenient; non-configurable: no error thrown"); michael@0: michael@0: var c = Object.defineProperty([1],'0',{configurable:false}); michael@0: c.watch('length', watcher); michael@0: hitCount = 0; michael@0: var threwTypeError; michael@0: try { michael@0: (function(){'use strict'; c.length = 0;})(); michael@0: threwTypeError = false; michael@0: } catch (x) { michael@0: threwTypeError = x instanceof TypeError; michael@0: } michael@0: reportCompare(1, hitCount, "strict; non-configurable: watchpoint hit"); michael@0: reportCompare(1, c.length, "strict; non-configurable: length unchanged"); michael@0: reportCompare(true, threwTypeError, "strict; non-configurable: TypeError thrown");