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