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

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

Issue 143313002: Implement URLSearchParams. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebased Created 6 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
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 src="resources/testharness-extras.js"></script>
5 <script> 6 <script>
6
7 function assertThrows(func, expected) {
8 try {
9 func();
10 } catch (ex) {
11 assert_equals(String(ex), expected);
12 return;
13 }
14 assert_true(false, 'Expected an exception with string: ' + expected);
15 }
16
17 test(function() { 7 test(function() {
18 assert_equals(new URL('http://www.domain.com/a/b').toString(), 'http://www.d omain.com/a/b'); 8 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'); 9 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'); 10 assert_equals(new URL('b/c', 'http://www.domain.com/a/b').toString(), 'http: //www.domain.com/a/b/c');
21 11
22 var base = new URL('http://www.domain.com/a/b'); 12 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' ); 13 assert_equals(new URL('b/c', base).toString(), 'http://www.domain.com/a/b/c' );
24 14
25 // Unmatched surrogate handling 15 // Unmatched surrogate handling
26 var encodedReplacementCharacter = encodeURIComponent('\ufffd'); 16 var encodedReplacementCharacter = encodeURIComponent('\ufffd');
27 assert_equals(new URL('b/c', 'http://www.domain.com/\ud801/b').toString(), ' http://www.domain.com/' + encodedReplacementCharacter + '/b/c'); 17 assert_equals(new URL('b/c', 'http://www.domain.com/\ud801/b').toString(), ' http://www.domain.com/' + encodedReplacementCharacter + '/b/c');
28 }, 'Valid URLs'); 18 }, 'Valid URLs');
29 19
30 test(function() { 20 test(function() {
31 assertThrows(function() { 21 assert_throws_message(function() {new URL();},
32 new URL(); 22 'TypeError: Failed to construct \'URL\': 1 argument required, but only 0 present.', 'TypeError');
33 }, 'TypeError: Failed to construct \'URL\': 1 argument required, but only 0 present.'); 23 assert_throws_message(function() { new URL('abc'); },
34 assertThrows(function() { 24 'SyntaxError: Failed to construct \'URL\': Invalid URL');
35 new URL('abc'); 25 assert_throws_message(function() { new URL('//abc'); },
36 }, 'SyntaxError: Failed to construct \'URL\': Invalid URL'); 26 'SyntaxError: Failed to construct \'URL\': Invalid URL');
37 assertThrows(function() { 27 assert_throws_message(function() { new URL('http:///www.domain.com/', 'abc') ; },
38 new URL('//abc'); 28 'SyntaxError: Failed to construct \'URL\': Invalid base URL');
39 }, 'SyntaxError: Failed to construct \'URL\': Invalid URL'); 29 assert_throws_message(function() { new URL('http:///www.domain.com/', null); },
40 assertThrows(function() { 30 'SyntaxError: Failed to construct \'URL\': Invalid base URL');
41 new URL('http:///www.domain.com/', 'abc');
42 }, 'SyntaxError: Failed to construct \'URL\': Invalid base URL');
43 assertThrows(function() {
44 new URL('http:///www.domain.com/', null);
45 }, 'SyntaxError: Failed to construct \'URL\': Invalid base URL');
46 }, 'Invalid URL parameters'); 31 }, 'Invalid URL parameters');
47 32
48 </script> 33 </script>
OLDNEW
« no previous file with comments | « LayoutTests/fast/domurl/resources/testharness-extras.js ('k') | LayoutTests/fast/domurl/url-search.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698