js/src/tests/ecma_5/extensions/watch-array-length.js

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

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");

mercurial