@@ -293,6 +293,15 @@ public void ShouldBeAbleToSetDomainToTheCurrentDomain()
293
293
return ;
294
294
}
295
295
296
+ // Cookies cannot be set on domain names with less than 2 dots, so
297
+ // localhost is out. If we are in that boat, bail the test.
298
+ string hostName = EnvironmentManager . Instance . UrlBuilder . HostName ;
299
+ string [ ] hostNameParts = hostName . Split ( new char [ ] { '.' } ) ;
300
+ if ( hostNameParts . Length < 3 )
301
+ {
302
+ Assert . Ignore ( "Skipping test: Cookies can only be set on fully-qualified domain names." ) ;
303
+ }
304
+
296
305
Uri url = new Uri ( driver . Url ) ;
297
306
String host = url . Host + ":" + url . Port . ToString ( ) ;
298
307
@@ -353,6 +362,15 @@ public void ShouldIgnoreThePortNumberOfTheHostWhenSettingTheCookie()
353
362
return ;
354
363
}
355
364
365
+ // Cookies cannot be set on domain names with less than 2 dots, so
366
+ // localhost is out. If we are in that boat, bail the test.
367
+ string hostName = EnvironmentManager . Instance . UrlBuilder . HostName ;
368
+ string [ ] hostNameParts = hostName . Split ( new char [ ] { '.' } ) ;
369
+ if ( hostNameParts . Length < 3 )
370
+ {
371
+ Assert . Ignore ( "Skipping test: Cookies can only be set on fully-qualified domain names." ) ;
372
+ }
373
+
356
374
Uri uri = new Uri ( driver . Url ) ;
357
375
string host = string . Format ( "{0}:{1}" , uri . Host , uri . Port ) ;
358
376
string cookieName = "name" ;
@@ -627,6 +645,15 @@ public void ShouldNotShowCookieAddedToDifferentPath()
627
645
return ;
628
646
}
629
647
648
+ // Cookies cannot be set on domain names with less than 2 dots, so
649
+ // localhost is out. If we are in that boat, bail the test.
650
+ string hostName = EnvironmentManager . Instance . UrlBuilder . HostName ;
651
+ string [ ] hostNameParts = hostName . Split ( new char [ ] { '.' } ) ;
652
+ if ( hostNameParts . Length < 3 )
653
+ {
654
+ Assert . Ignore ( "Skipping test: Cookies can only be set on fully-qualified domain names." ) ;
655
+ }
656
+
630
657
driver . Url = macbethPage ;
631
658
IOptions options = driver . Manage ( ) ;
632
659
Cookie cookie = new Cookie ( "Lisa" , "Simpson" , EnvironmentManager . Instance . UrlBuilder . HostName , "/" + EnvironmentManager . Instance . UrlBuilder . Path + "IDoNotExist" , null ) ;
@@ -767,7 +794,13 @@ private bool IsValidHostNameForCookieTests(string hostname)
767
794
// Reenable this when we have a better solution per DanielWagnerHall.
768
795
// ChromeDriver2 has trouble with localhost. IE and Firefox don't.
769
796
// return !IsIpv4Address(hostname) && "localhost" != hostname;
770
- return ! IsIpv4Address ( hostname ) && ( "localhost" != hostname && TestUtilities . IsChrome ( driver ) ) ;
797
+ bool isLocalHostOkay = true ;
798
+ if ( "localhost" == hostname && TestUtilities . IsChrome ( driver ) )
799
+ {
800
+ isLocalHostOkay = false ;
801
+ }
802
+
803
+ return ! IsIpv4Address ( hostname ) && isLocalHostOkay ;
771
804
}
772
805
773
806
private static bool IsIpv4Address ( string addrString )
0 commit comments