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

Unified Diff: LayoutTests/fast/domurl/url-hostname.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
« no previous file with comments | « LayoutTests/fast/domurl/url-host-expected.txt ('k') | LayoutTests/fast/domurl/url-hostname-expected.txt » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: LayoutTests/fast/domurl/url-hostname.html
diff --git a/LayoutTests/fast/domurl/url-hostname.html b/LayoutTests/fast/domurl/url-hostname.html
new file mode 100644
index 0000000000000000000000000000000000000000..1350c66e7820186da488772a19c3a4fe93207838
--- /dev/null
+++ b/LayoutTests/fast/domurl/url-hostname.html
@@ -0,0 +1,74 @@
+<!DOCTYPE HTML>
+<link rel="help" href="http://url.spec.whatwg.org/#dom-url-hostname">
+<script src="../../resources/testharness.js"></script>
+<script src="../../resources/testharnessreport.js"></script>
+<script>
+
+test(function() {
+ var url = new URL('https://www.mydomain.com/path/');
+ assert_equals(url.hostname, 'www.mydomain.com');
+ url.hostname = 'www.otherdomain.com';
+ assert_equals(url.href, 'https://www.otherdomain.com/path/');
+}, 'Basic test');
+
+test(function() {
+ var url = new URL('https://www.mydomain.com/path/?key=value');
+ url.hostname = 'www.other?domain.com';
+ assert_equals(url.href, 'https://www.other%3Fdomain.com/path/?key=value');
+}, 'Set hostname with ? in it');
+
+test(function() {
+ var url = new URL('https://www.mydomain.com/path/');
+ url.hostname = null;
+ assert_equals(url.href, 'https://null/path/');
+}, 'Set hostname to null');
+
+test(function() {
+ var url = new URL('https://www.mydomain.com/path/');
+ url.hostname = '';
+ assert_equals(url.href, 'https://www.mydomain.com/path/');
+}, 'Set hostname to empty string');
+
+test(function() {
+ var url = new URL('file:///path/');
+ assert_equals(url.hostname, '');
+ url.hostname = 'mydomain.com';
+ assert_equals(url.href, 'file://mydomain.com/path/');
+}, 'Set hostname to URL with file: protocol');
+
+test(function() {
+ var url = new URL('https://www.mydomain.com/path/');
+ url.hostname = 'www.other\\dom/ain.com';
+ assert_equals(url.href, 'https://www.other%5Cdom%2Fain.com/path/');
+}, 'Set hostname containing slashes in it');
+
+test(function() {
+ var url = new URL('https:/\rww.my@domain.com/path/');
+ assert_equals(url.hostname, 'domain.com');
+ url.hostname = 'www.other!domain.com';
+ assert_equals(url.href, 'https://ww.my@www.other%21domain.com/path/');
+}, 'Set hostname to a malformed URL');
+
+test(function() {
+ var url = new URL('https://rwwmy@domain.com/purl..th/');
+ url.hostname = 'www.other!domain.com';
+ assert_equals(url.href, 'https://rwwmy@www.other%21domain.com/purl..th/');
+}, 'Set hostname to URL containing username and ..');
+
+test(function() {
+ var url = new URL('tel:+1-816-555-1212');
+ assert_equals(url.hostname, '');
+ url.hostname = '+1-800-555-1212';
+ assert_equals(url.href, 'tel:+1-816-555-1212');
+}, 'Set hostname to a URL with tel: protocol');
+
+test(function() {
+ var url = new URL('http://abc.de/path/file?query#fragment');
+ url.href = 'invalid';
+ assert_equals(url.hostname, '');
+ url.host = 'changed';
+ assert_equals(url.hostname, '');
+ assert_equals(url.href, 'invalid');
+}, 'hostname property invalid URL');
+
+</script>
« no previous file with comments | « LayoutTests/fast/domurl/url-host-expected.txt ('k') | LayoutTests/fast/domurl/url-hostname-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698