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

Unified Diff: LayoutTests/fast/domurl/url-constructor.html

Issue 24066010: Implement URLUtils and URL interface (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: updates based on code review comments Created 7 years, 2 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 side-by-side diff with in-line comments
Download patch
Index: LayoutTests/fast/domurl/url-constructor.html
diff --git a/LayoutTests/fast/domurl/url-constructor.html b/LayoutTests/fast/domurl/url-constructor.html
new file mode 100644
index 0000000000000000000000000000000000000000..0205a12c3016bcaeed307e30334ac3eddb0b243a
--- /dev/null
+++ b/LayoutTests/fast/domurl/url-constructor.html
@@ -0,0 +1,44 @@
+<!DOCTYPE HTML>
+<link rel="help" href="http://url.spec.whatwg.org/#dom-url">
+<script src="../../resources/testharness.js"></script>
+<script src="../../resources/testharnessreport.js"></script>
+<script>
+
+function assertThrows(func, expected) {
+ try {
+ func();
+ } catch (ex) {
+ assert_equals(String(ex), expected);
+ return;
+ }
+ assert_true(false, 'Expected an exception with string: ' + expected);
+}
+
+test(function() {
+ assert_equals(new URL('http://www.domain.com/a/b').toString(), 'http://www.domain.com/a/b');
+ assert_equals(new URL('/c/d', 'http://www.domain.com/a/b').toString(), 'http://www.domain.com/c/d');
+ assert_equals(new URL('b/c', 'http://www.domain.com/a/b').toString(), 'http://www.domain.com/a/b/c');
+
+ var base = new URL('http://www.domain.com/a/b');
+ assert_equals(new URL('b/c', base).toString(), 'http://www.domain.com/a/b/c');
+}, 'Valid URLs');
+
+test(function() {
+ assertThrows(function() {
+ new URL();
+ }, 'TypeError: Failed to construct \'URL\': 1 argument required, but only 0 present.');
+ assertThrows(function() {
+ new URL('abc');
+ }, 'SyntaxError: Failed to construct \'URL\': Invalid URL');
+ assertThrows(function() {
+ new URL('//abc');
+ }, 'SyntaxError: Failed to construct \'URL\': Invalid URL');
+ assertThrows(function() {
+ new URL('http:///www.domain.com/', 'abc');
+ }, 'SyntaxError: Failed to construct \'URL\': Invalid base URL');
+ assertThrows(function() {
+ new URL('http:///www.domain.com/', null);
+ }, 'SyntaxError: Failed to construct \'URL\': Invalid base URL');
+}, 'Invalid URL parameters');
+
+</script>

Powered by Google App Engine
This is Rietveld 408576698