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 | /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
michael@0 | 2 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 5 | |
michael@0 | 6 | /* |
michael@0 | 7 | * |
michael@0 | 8 | * Date: 17 February 2003 |
michael@0 | 9 | * SUMMARY: Testing access to function name from inside function |
michael@0 | 10 | * |
michael@0 | 11 | * See http://bugzilla.mozilla.org/show_bug.cgi?id=193555 |
michael@0 | 12 | * |
michael@0 | 13 | */ |
michael@0 | 14 | //----------------------------------------------------------------------------- |
michael@0 | 15 | var UBound = 0; |
michael@0 | 16 | var BUGNUMBER = 193555; |
michael@0 | 17 | var summary = 'Testing access to function name from inside function'; |
michael@0 | 18 | var status = ''; |
michael@0 | 19 | var statusitems = []; |
michael@0 | 20 | var actual = ''; |
michael@0 | 21 | var actualvalues = []; |
michael@0 | 22 | var expect= ''; |
michael@0 | 23 | var expectedvalues = []; |
michael@0 | 24 | |
michael@0 | 25 | |
michael@0 | 26 | // test via function statement |
michael@0 | 27 | status = inSection(1); |
michael@0 | 28 | function f() {return f.toString();}; |
michael@0 | 29 | actual = f(); |
michael@0 | 30 | expect = f.toString(); |
michael@0 | 31 | addThis(); |
michael@0 | 32 | |
michael@0 | 33 | // test via function expression |
michael@0 | 34 | status = inSection(2); |
michael@0 | 35 | var x = function g() {return g.toString();}; |
michael@0 | 36 | actual = x(); |
michael@0 | 37 | expect = x.toString(); |
michael@0 | 38 | addThis(); |
michael@0 | 39 | |
michael@0 | 40 | // test via eval() outside function |
michael@0 | 41 | status = inSection(3); |
michael@0 | 42 | eval ('function a() {return a.toString();}'); |
michael@0 | 43 | actual = a(); |
michael@0 | 44 | expect = a.toString(); |
michael@0 | 45 | addThis(); |
michael@0 | 46 | |
michael@0 | 47 | status = inSection(4); |
michael@0 | 48 | eval ('var y = function b() {return b.toString();}'); |
michael@0 | 49 | actual = y(); |
michael@0 | 50 | expect = y.toString(); |
michael@0 | 51 | addThis(); |
michael@0 | 52 | |
michael@0 | 53 | // test via eval() inside function |
michael@0 | 54 | status = inSection(5); |
michael@0 | 55 | function c() {return eval('c').toString();}; |
michael@0 | 56 | actual = c(); |
michael@0 | 57 | expect = c.toString(); |
michael@0 | 58 | addThis(); |
michael@0 | 59 | |
michael@0 | 60 | status = inSection(6); |
michael@0 | 61 | var z = function d() {return eval('d').toString();}; |
michael@0 | 62 | actual = z(); |
michael@0 | 63 | expect = z.toString(); |
michael@0 | 64 | addThis(); |
michael@0 | 65 | |
michael@0 | 66 | // test via two evals! |
michael@0 | 67 | status = inSection(7); |
michael@0 | 68 | eval('var w = function e() {return eval("e").toString();}'); |
michael@0 | 69 | actual = w(); |
michael@0 | 70 | expect = w.toString(); |
michael@0 | 71 | addThis(); |
michael@0 | 72 | |
michael@0 | 73 | |
michael@0 | 74 | |
michael@0 | 75 | //----------------------------------------------------------------------------- |
michael@0 | 76 | test(); |
michael@0 | 77 | //----------------------------------------------------------------------------- |
michael@0 | 78 | |
michael@0 | 79 | |
michael@0 | 80 | |
michael@0 | 81 | function addThis() |
michael@0 | 82 | { |
michael@0 | 83 | statusitems[UBound] = status; |
michael@0 | 84 | actualvalues[UBound] = actual; |
michael@0 | 85 | expectedvalues[UBound] = expect; |
michael@0 | 86 | UBound++; |
michael@0 | 87 | } |
michael@0 | 88 | |
michael@0 | 89 | |
michael@0 | 90 | function test() |
michael@0 | 91 | { |
michael@0 | 92 | enterFunc('test'); |
michael@0 | 93 | printBugNumber(BUGNUMBER); |
michael@0 | 94 | printStatus(summary); |
michael@0 | 95 | |
michael@0 | 96 | for (var i=0; i<UBound; i++) |
michael@0 | 97 | { |
michael@0 | 98 | reportCompare(expectedvalues[i], actualvalues[i], statusitems[i]); |
michael@0 | 99 | } |
michael@0 | 100 | |
michael@0 | 101 | exitFunc ('test'); |
michael@0 | 102 | } |