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 | File Name: 6-1.js |
michael@0 | 9 | ECMA Section: Source Text |
michael@0 | 10 | Description: |
michael@0 | 11 | |
michael@0 | 12 | ECMAScript source text is represented as a sequence of characters |
michael@0 | 13 | representable using the Unicode version 2.0 character encoding. |
michael@0 | 14 | |
michael@0 | 15 | SourceCharacter :: |
michael@0 | 16 | any Unicode character |
michael@0 | 17 | |
michael@0 | 18 | However, it is possible to represent every ECMAScript program using |
michael@0 | 19 | only ASCII characters (which are equivalent to the first 128 Unicode |
michael@0 | 20 | characters). Non-ASCII Unicode characters may appear only within comments |
michael@0 | 21 | and string literals. In string literals, any Unicode character may also be |
michael@0 | 22 | expressed as a Unicode escape sequence consisting of six ASCII characters, |
michael@0 | 23 | namely \u plus four hexadecimal digits. Within a comment, such an escape |
michael@0 | 24 | sequence is effectively ignored as part of the comment. Within a string |
michael@0 | 25 | literal, the Unicode escape sequence contributes one character to the string |
michael@0 | 26 | value of the literal. |
michael@0 | 27 | |
michael@0 | 28 | Note that ECMAScript differs from the Java programming language in the |
michael@0 | 29 | behavior of Unicode escape sequences. In a Java program, if the Unicode escape |
michael@0 | 30 | sequence \u000A, for example, occurs within a single-line comment, it is |
michael@0 | 31 | interpreted as a line terminator (Unicode character 000A is line feed) and |
michael@0 | 32 | therefore the next character is not part of the comment. Similarly, if the |
michael@0 | 33 | Unicode escape sequence \u000A occurs within a string literal in a Java |
michael@0 | 34 | program, it is likewise interpreted as a line terminator, which is not |
michael@0 | 35 | allowed within a string literal-one must write \n instead of \u000A to |
michael@0 | 36 | cause a line feed to be part of the string value of a string literal. In |
michael@0 | 37 | an ECMAScript program, a Unicode escape sequence occurring within a comment |
michael@0 | 38 | is never interpreted and therefore cannot contribute to termination of the |
michael@0 | 39 | comment. Similarly, a Unicode escape sequence occurring within a string literal |
michael@0 | 40 | in an ECMAScript program always contributes a character to the string value of |
michael@0 | 41 | the literal and is never interpreted as a line terminator or as a quote mark |
michael@0 | 42 | that might terminate the string literal. |
michael@0 | 43 | |
michael@0 | 44 | Author: christine@netscape.com |
michael@0 | 45 | Date: 12 november 1997 |
michael@0 | 46 | */ |
michael@0 | 47 | |
michael@0 | 48 | var SECTION = "6-1"; |
michael@0 | 49 | var VERSION = "ECMA_1"; |
michael@0 | 50 | startTest(); |
michael@0 | 51 | var TITLE = "Source Text"; |
michael@0 | 52 | |
michael@0 | 53 | writeHeaderToLog( SECTION + " "+ TITLE); |
michael@0 | 54 | |
michael@0 | 55 | // encoded quotes should not end a quote |
michael@0 | 56 | |
michael@0 | 57 | new TestCase( SECTION, |
michael@0 | 58 | "var s = 'PAS\\u0022SED'; s", |
michael@0 | 59 | "PAS\"SED", |
michael@0 | 60 | eval("var s = 'PAS\\u0022SED'; s") ); |
michael@0 | 61 | |
michael@0 | 62 | new TestCase( SECTION, |
michael@0 | 63 | 'var s = "PAS\\u0022SED"; s', |
michael@0 | 64 | "PAS\"SED", |
michael@0 | 65 | eval('var s = "PAS\\u0022SED"; s') ); |
michael@0 | 66 | |
michael@0 | 67 | |
michael@0 | 68 | new TestCase( SECTION, |
michael@0 | 69 | "var s = 'PAS\\u0027SED'; s", |
michael@0 | 70 | "PAS\'SED", |
michael@0 | 71 | eval("var s = 'PAS\\u0027SED'; s") ); |
michael@0 | 72 | |
michael@0 | 73 | |
michael@0 | 74 | new TestCase( SECTION, |
michael@0 | 75 | 'var s = "PAS\\u0027SED"; s', |
michael@0 | 76 | "PAS\'SED", |
michael@0 | 77 | eval('var s = "PAS\\u0027SED"; s') ); |
michael@0 | 78 | |
michael@0 | 79 | var testcase = new TestCase( SECTION, |
michael@0 | 80 | 'var s="PAS\\u0027SED"; s', |
michael@0 | 81 | "PAS\'SED", |
michael@0 | 82 | "" ); |
michael@0 | 83 | var s = "PAS\u0027SED"; |
michael@0 | 84 | |
michael@0 | 85 | testcase.actual = s; |
michael@0 | 86 | |
michael@0 | 87 | testcase = new TestCase( SECTION, |
michael@0 | 88 | 'var s = "PAS\\u0022SED"; s', |
michael@0 | 89 | "PAS\"SED", |
michael@0 | 90 | "" ); |
michael@0 | 91 | var s = "PAS\u0022SED"; |
michael@0 | 92 | |
michael@0 | 93 | testcase.actual = s; |
michael@0 | 94 | |
michael@0 | 95 | |
michael@0 | 96 | test(); |
michael@0 | 97 |