js/src/tests/js1_8_5/extensions/findReferences-03.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 // Any copyright is dedicated to the Public Domain.
michael@0 2 // http://creativecommons.org/licenses/publicdomain/
michael@0 3 // Contributor: Jim Blandy
michael@0 4
michael@0 5 if (typeof findReferences == "function") {
michael@0 6
michael@0 7 function makeGenerator(c) { eval(c); yield function generatorClosure() { return x; }; }
michael@0 8 var generator = makeGenerator('var x = 42');
michael@0 9 var closure = generator.next();
michael@0 10 referencesVia(closure, 'parent; generator object', generator);
michael@0 11
michael@0 12 var o = {};
michael@0 13
michael@0 14 assertEq(function f() {
michael@0 15 return referencesVia(null, 'arguments', arguments) ||
michael@0 16 referencesVia(null, 'baseline-args-obj', arguments);
michael@0 17 }(), true);
michael@0 18
michael@0 19 var rvalueCorrect;
michael@0 20
michael@0 21 function finallyHoldsRval() {
michael@0 22 try {
michael@0 23 return o;
michael@0 24 } finally {
michael@0 25 rvalueCorrect = referencesVia(null, 'rval', o) ||
michael@0 26 referencesVia(null, 'baseline-rval', o);
michael@0 27 }
michael@0 28 }
michael@0 29 rvalueCorrect = false;
michael@0 30 finallyHoldsRval();
michael@0 31 assertEq(rvalueCorrect, true);
michael@0 32
michael@0 33 // Because we don't distinguish between JavaScript stack marking and C++
michael@0 34 // stack marking (both use the conservative scanner), we can't really write
michael@0 35 // the following tests meaningfully:
michael@0 36 // generator frame -> generator object
michael@0 37 // stack frame -> local variables
michael@0 38 // stack frame -> this
michael@0 39 // stack frame -> callee
michael@0 40 // for(... in x) loop's reference to x
michael@0 41
michael@0 42 reportCompare(true, true);
michael@0 43 } else {
michael@0 44 reportCompare(true, true, "test skipped: findReferences is not a function");
michael@0 45 }

mercurial