|
1 /* |
|
2 * Any copyright is dedicated to the Public Domain. |
|
3 * http://creativecommons.org/licenses/publicdomain/ |
|
4 */ |
|
5 |
|
6 var hitCount; |
|
7 function watcher(p,o,n) { hitCount++; return n; } |
|
8 |
|
9 var a = [1]; |
|
10 a.watch('length', watcher); |
|
11 hitCount = 0; |
|
12 a.length = 0; |
|
13 reportCompare(1, hitCount, "lenient; configurable: watchpoint hit"); |
|
14 |
|
15 var b = Object.defineProperty([1],'0',{configurable:false}); |
|
16 b.watch('length', watcher); |
|
17 hitCount = 0; |
|
18 var result; |
|
19 try { |
|
20 b.length = 0; |
|
21 result = "no error"; |
|
22 } catch (x) { |
|
23 result = x.toString(); |
|
24 } |
|
25 reportCompare(1, hitCount, "lenient; non-configurable: watchpoint hit"); |
|
26 reportCompare(1, b.length, "lenient; non-configurable: length unchanged"); |
|
27 reportCompare("no error", result, "lenient; non-configurable: no error thrown"); |
|
28 |
|
29 var c = Object.defineProperty([1],'0',{configurable:false}); |
|
30 c.watch('length', watcher); |
|
31 hitCount = 0; |
|
32 var threwTypeError; |
|
33 try { |
|
34 (function(){'use strict'; c.length = 0;})(); |
|
35 threwTypeError = false; |
|
36 } catch (x) { |
|
37 threwTypeError = x instanceof TypeError; |
|
38 } |
|
39 reportCompare(1, hitCount, "strict; non-configurable: watchpoint hit"); |
|
40 reportCompare(1, c.length, "strict; non-configurable: length unchanged"); |
|
41 reportCompare(true, threwTypeError, "strict; non-configurable: TypeError thrown"); |