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

Side by Side Diff: LayoutTests/fast/domurl/url-constructor.html

Issue 331313011: Switch URL and URLUtils interfaces over to use ScalarValueString. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 6 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
« no previous file with comments | « no previous file | LayoutTests/fast/domurl/url-hash.html » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 <!DOCTYPE HTML> 1 <!DOCTYPE HTML>
2 <link rel="help" href="http://url.spec.whatwg.org/#dom-url"> 2 <link rel="help" href="http://url.spec.whatwg.org/#dom-url">
3 <script src="../../resources/testharness.js"></script> 3 <script src="../../resources/testharness.js"></script>
4 <script src="../../resources/testharnessreport.js"></script> 4 <script src="../../resources/testharnessreport.js"></script>
5 <script> 5 <script>
6 6
7 function assertThrows(func, expected) { 7 function assertThrows(func, expected) {
8 try { 8 try {
9 func(); 9 func();
10 } catch (ex) { 10 } catch (ex) {
11 assert_equals(String(ex), expected); 11 assert_equals(String(ex), expected);
12 return; 12 return;
13 } 13 }
14 assert_true(false, 'Expected an exception with string: ' + expected); 14 assert_true(false, 'Expected an exception with string: ' + expected);
15 } 15 }
16 16
17 var encodedReplacementCharacter = encodeURIComponent('\ufffd');
arv (Not doing code reviews) 2014/06/23 16:12:01 Since this is only used in one place, consider mov
sof 2014/06/23 19:02:48 Certainly; moved it next to its use.
18
17 test(function() { 19 test(function() {
18 assert_equals(new URL('http://www.domain.com/a/b').toString(), 'http://www.d omain.com/a/b'); 20 assert_equals(new URL('http://www.domain.com/a/b').toString(), 'http://www.d omain.com/a/b');
19 assert_equals(new URL('/c/d', 'http://www.domain.com/a/b').toString(), 'http ://www.domain.com/c/d'); 21 assert_equals(new URL('/c/d', 'http://www.domain.com/a/b').toString(), 'http ://www.domain.com/c/d');
20 assert_equals(new URL('b/c', 'http://www.domain.com/a/b').toString(), 'http: //www.domain.com/a/b/c'); 22 assert_equals(new URL('b/c', 'http://www.domain.com/a/b').toString(), 'http: //www.domain.com/a/b/c');
21 23
22 var base = new URL('http://www.domain.com/a/b'); 24 var base = new URL('http://www.domain.com/a/b');
23 assert_equals(new URL('b/c', base).toString(), 'http://www.domain.com/a/b/c' ); 25 assert_equals(new URL('b/c', base).toString(), 'http://www.domain.com/a/b/c' );
26
27 // Unmatched surrogate handling
28 assert_equals(new URL('b/c', 'http://www.domain.com/\ud801/b').toString(), ' http://www.domain.com/' + encodedReplacementCharacter + '/b/c');
24 }, 'Valid URLs'); 29 }, 'Valid URLs');
25 30
26 test(function() { 31 test(function() {
27 assertThrows(function() { 32 assertThrows(function() {
28 new URL(); 33 new URL();
29 }, 'TypeError: Failed to construct \'URL\': 1 argument required, but only 0 present.'); 34 }, 'TypeError: Failed to construct \'URL\': 1 argument required, but only 0 present.');
30 assertThrows(function() { 35 assertThrows(function() {
31 new URL('abc'); 36 new URL('abc');
32 }, 'SyntaxError: Failed to construct \'URL\': Invalid URL'); 37 }, 'SyntaxError: Failed to construct \'URL\': Invalid URL');
33 assertThrows(function() { 38 assertThrows(function() {
34 new URL('//abc'); 39 new URL('//abc');
35 }, 'SyntaxError: Failed to construct \'URL\': Invalid URL'); 40 }, 'SyntaxError: Failed to construct \'URL\': Invalid URL');
36 assertThrows(function() { 41 assertThrows(function() {
37 new URL('http:///www.domain.com/', 'abc'); 42 new URL('http:///www.domain.com/', 'abc');
38 }, 'SyntaxError: Failed to construct \'URL\': Invalid base URL'); 43 }, 'SyntaxError: Failed to construct \'URL\': Invalid base URL');
39 assertThrows(function() { 44 assertThrows(function() {
40 new URL('http:///www.domain.com/', null); 45 new URL('http:///www.domain.com/', null);
41 }, 'SyntaxError: Failed to construct \'URL\': Invalid base URL'); 46 }, 'SyntaxError: Failed to construct \'URL\': Invalid base URL');
42 }, 'Invalid URL parameters'); 47 }, 'Invalid URL parameters');
43 48
44 </script> 49 </script>
OLDNEW
« no previous file with comments | « no previous file | LayoutTests/fast/domurl/url-hash.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698