OLD | NEW |
| (Empty) |
1 // Copyright 2008 the V8 project authors. All rights reserved. | |
2 // Redistribution and use in source and binary forms, with or without | |
3 // modification, are permitted provided that the following conditions are | |
4 // met: | |
5 // | |
6 // * Redistributions of source code must retain the above copyright | |
7 // notice, this list of conditions and the following disclaimer. | |
8 // * Redistributions in binary form must reproduce the above | |
9 // copyright notice, this list of conditions and the following | |
10 // disclaimer in the documentation and/or other materials provided | |
11 // with the distribution. | |
12 // * Neither the name of Google Inc. nor the names of its | |
13 // contributors may be used to endorse or promote products derived | |
14 // from this software without specific prior written permission. | |
15 // | |
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | |
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | |
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | |
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
27 | |
28 // According to section 7.1 of EcmaScript-262 format control characters | |
29 // should be removed before parsing. We're following the discussion at | |
30 // https://bugs.webkit.org/show_bug.cgi?id=4931 in only removing the BOM. | |
31 // See also https://bugzilla.mozilla.org/show_bug.cgi?id=274152. | |
32 | |
33 // Ignores BOM (and only BOM) in string literals. | |
34 var format_controls = | |
35 eval('"\uFEFF\u200F\u200E\u00AD\u2062\u200D\u200C\u200B"'); | |
36 assertEquals('\u200F\u200E\u00AD\u2062\u200D\u200C\u200B', | |
37 format_controls); | |
38 | |
39 // Ignores BOM in identifiers. | |
40 eval('var x\uFEFFy = 7'); | |
41 assertEquals(7, xy); | |
42 | |
43 // Doesn't ignore non-BOM format control characters. | |
44 assertThrows('var y\u200Fx = 7'); | |
45 assertThrows('var y\u200Ex = 7'); | |
46 assertThrows('var y\u20ADx = 7'); | |
47 assertThrows('var y\u2062x = 7'); | |
48 assertThrows('var y\u200Dx = 7'); | |
49 assertThrows('var y\u200Cx = 7'); | |
50 assertThrows('var y\u200Bx = 7'); | |
OLD | NEW |