Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(95)

Side by Side Diff: test/webkit/fast/js/string-link.js

Issue 21070002: Migrate more tests from blink repository. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 the V8 project authors. All rights reserved.
2 // Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. 2 // Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
3 // 3 //
4 // Redistribution and use in source and binary forms, with or without 4 // Redistribution and use in source and binary forms, with or without
5 // modification, are permitted provided that the following conditions 5 // modification, are permitted provided that the following conditions
6 // are met: 6 // are met:
7 // 1. Redistributions of source code must retain the above copyright 7 // 1. Redistributions of source code must retain the above copyright
8 // notice, this list of conditions and the following disclaimer. 8 // notice, this list of conditions and the following disclaimer.
9 // 2. Redistributions in binary form must reproduce the above copyright 9 // 2. Redistributions in binary form must reproduce the above copyright
10 // notice, this list of conditions and the following disclaimer in the 10 // notice, this list of conditions and the following disclaimer in the
11 // documentation and/or other materials provided with the distribution. 11 // documentation and/or other materials provided with the distribution.
12 // 12 //
13 // THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND AN Y 13 // THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND AN Y
14 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 14 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
15 // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 15 // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
16 // DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR AN Y 16 // DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR AN Y
17 // DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 17 // DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
18 // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 18 // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
19 // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND O N 19 // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND O N
20 // ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 20 // ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
21 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 21 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
22 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 22 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23 23
24 description( 24 description(
25 'This test checks break and continue behaviour in the presence of multiple label s.' 25 'This is a test case for String.prototype.link(href).'
26 ); 26 );
27 27
28 function test1() 28 // This test is based on http://mathias.html5.org/tests/javascript/string/.
29 {
30 var s = "";
31 29
32 a: 30 // Check that the quotation mark is correctly escaped.
33 b: 31 shouldBe("'_'.link('\"')", '"<a href=\\"&quot;\\">_</a>"');
34 for (var i = 1; i < 10; i++) {
35 if (i == 4)
36 continue a;
37 s += i;
38 }
39 32
40 return s; 33 // Simple case.
41 } 34 shouldBe("'_'.link('b')", '"<a href=\\"b\\">_</a>"');
42 35
43 shouldBe("test1()", "'12356789'"); 36 // Does not escape special characters in `this` value.
37 shouldBe("'<'.link('b')", '"<a href=\\"b\\"><</a>"');
44 38
45 function test2() 39 // First argument gets ToString()ed.
46 { 40 shouldBe("'_'.link(0x2A)", '"<a href=\\"42\\">_</a>"');
47 var s = "";
48 41
49 a: 42 // Check that the quotation mark is correctly escaped.
50 b: 43 shouldBe("'_'.link('\"')", '"<a href=\\"&quot;\\">_</a>"');
51 for (var i = 1; i < 10; i++) { 44 shouldBe("'_'.link('\" target=\"_blank')", '"<a href=\\"&quot; target=&quot;_bla nk\\">_</a>"');
52 if (i == 4)
53 break a;
54 s += i;
55 }
56 45
57 return s; 46 // Generic use on Number object.
58 } 47 shouldBe("String.prototype.link.call(0x2A, 0x2A)", '"<a href=\\"42\\">42</a>"');
59 48
60 shouldBe("test2()", "'123'"); 49 // Generic use on non-coercible object `undefined`.
50 shouldThrow("String.prototype.link.call(undefined)", '"TypeError: Type error"');
61 51
62 function test3() 52 // Generic use on non-coercible object `null`.
63 { 53 shouldThrow("String.prototype.link.call(null)", '"TypeError: Type error"');
64 var i;
65 for (i = 1; i < 10; i++) {
66 try {
67 continue;
68 } finally {
69 innerLoop:
70 while (1) {
71 break innerLoop;
72 }
73 }
74 }
75 54
76 return i; 55 // Check link.length.
77 } 56 shouldBe("String.prototype.link.length", "1");
78
79 shouldBe("test3()", "10");
80
81 function test4()
82 {
83 var i = 0;
84
85 a:
86 i++;
87 while (1) {
88 break;
89 }
90
91 return i;
92 }
93
94 shouldBe("test4()", "1");
95
96 function test5()
97 {
98 var i = 0;
99
100 switch (1) {
101 default:
102 while (1) {
103 break;
104 }
105 i++;
106 }
107
108 return i;
109 }
110
111 shouldBe("test5()", "1");
OLDNEW
« no previous file with comments | « test/webkit/fast/js/string-fontsize-expected.txt ('k') | test/webkit/fast/js/string-link-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698