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 | load(libdir + "asserts.js"); |
michael@0 | 2 | |
michael@0 | 3 | var valid_strict_funs = [ |
michael@0 | 4 | // directive ends on next line |
michael@0 | 5 | function () { |
michael@0 | 6 | "use strict" |
michael@0 | 7 | ; |
michael@0 | 8 | }, |
michael@0 | 9 | function () { |
michael@0 | 10 | "use strict" |
michael@0 | 11 | }, |
michael@0 | 12 | // directive ends on same line |
michael@0 | 13 | function () { "use strict"; }, |
michael@0 | 14 | function () { "use strict" }, |
michael@0 | 15 | ]; |
michael@0 | 16 | |
michael@0 | 17 | for (var f of valid_strict_funs) { |
michael@0 | 18 | assertThrowsInstanceOf(function() { f.caller }, TypeError); |
michael@0 | 19 | } |
michael@0 | 20 | |
michael@0 | 21 | |
michael@0 | 22 | var binary_ops = [ |
michael@0 | 23 | "||", "&&", |
michael@0 | 24 | "|", "^", "&", |
michael@0 | 25 | "==", "!=", "===", "!==", |
michael@0 | 26 | "<", "<=", ">", ">=", "in", "instanceof", |
michael@0 | 27 | "<<", ">>", ">>>", |
michael@0 | 28 | "+", "-", |
michael@0 | 29 | "*", "/", "%", |
michael@0 | 30 | ]; |
michael@0 | 31 | |
michael@0 | 32 | var invalid_strict_funs = [ |
michael@0 | 33 | function () { |
michael@0 | 34 | "use strict" |
michael@0 | 35 | , "not"; |
michael@0 | 36 | }, |
michael@0 | 37 | function () { |
michael@0 | 38 | "use strict" |
michael@0 | 39 | ? 1 : 0; |
michael@0 | 40 | }, |
michael@0 | 41 | function () { |
michael@0 | 42 | "use strict" |
michael@0 | 43 | .length; |
michael@0 | 44 | }, |
michael@0 | 45 | function () { |
michael@0 | 46 | "use strict" |
michael@0 | 47 | [0]; |
michael@0 | 48 | }, |
michael@0 | 49 | function () { |
michael@0 | 50 | "use strict" |
michael@0 | 51 | (); |
michael@0 | 52 | }, |
michael@0 | 53 | ...([]), |
michael@0 | 54 | ...[Function("'use strict'\n " + op + " 'not'") for (op of binary_ops)], |
michael@0 | 55 | ]; |
michael@0 | 56 | |
michael@0 | 57 | for (var f of invalid_strict_funs) { |
michael@0 | 58 | f.caller; |
michael@0 | 59 | } |
michael@0 | 60 | |
michael@0 | 61 | |
michael@0 | 62 | var assignment_ops = [ |
michael@0 | 63 | "=", "+=", "-=", |
michael@0 | 64 | "|=", "^=", "&=", |
michael@0 | 65 | "<<=", ">>=", ">>>=", |
michael@0 | 66 | "*=", "/=", "%=", |
michael@0 | 67 | ]; |
michael@0 | 68 | |
michael@0 | 69 | var invalid_strict_funs_referror = [ |
michael@0 | 70 | ...[("'use strict'\n " + op + " 'not'") for (op of assignment_ops)], |
michael@0 | 71 | ]; |
michael@0 | 72 | |
michael@0 | 73 | // assignment with string literal as LHS is an early error, therefore we |
michael@0 | 74 | // can only test for ReferenceError |
michael@0 | 75 | for (var f of invalid_strict_funs_referror) { |
michael@0 | 76 | assertThrowsInstanceOf(function() { Function(f) }, ReferenceError); |
michael@0 | 77 | } |