File tree Expand file tree Collapse file tree
test/java/org/htmlunit/javascript/host Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1386,16 +1386,16 @@ private WebResponse makeWebResponseForDataUrl(final WebRequest webRequest) throw
13861386
13871387 private static WebResponse makeWebResponseForAboutUrl (final WebRequest webRequest ) throws MalformedURLException {
13881388 final URL url = webRequest .getUrl ();
1389- final String urlString = url .toExternalForm ();
1390- if (UrlUtils .ABOUT_BLANK .equalsIgnoreCase (urlString )) {
1391- return new StringWebResponse ("" , UrlUtils .URL_ABOUT_BLANK );
1389+ if (UrlUtils .ABOUT .equals (url .getProtocol ())) {
1390+ if ("blank" .equalsIgnoreCase (url .getPath ())) {
1391+ if (url .getRef () == null && url .getQuery () == null ) {
1392+ return new StringWebResponse ("" , UrlUtils .URL_ABOUT_BLANK );
1393+ }
1394+ return new StringWebResponse ("" , url );
1395+ }
13921396 }
13931397
1394- final String urlWithoutQuery = StringUtils .substringBefore (urlString , "?" );
1395- if (!"blank" .equalsIgnoreCase (StringUtils .substringAfter (urlWithoutQuery , UrlUtils .ABOUT_SCHEME ))) {
1396- throw new MalformedURLException (url + " is not supported, only about:blank is supported at the moment." );
1397- }
1398- return new StringWebResponse ("" , url );
1398+ throw new MalformedURLException (url + " is not supported, only about:blank is supported at the moment." );
13991399 }
14001400
14011401 /**
Original file line number Diff line number Diff line change @@ -405,6 +405,23 @@ public void setHashUpdatesPageUrl() throws Exception {
405405 assertEquals ("newHash" , page .getUrl ().getRef ());
406406 }
407407
408+ /**
409+ * @throws Exception if the test fails
410+ */
411+ @ Test
412+ public void setHashAboutBlank () throws Exception {
413+ try (WebClient webClient = new WebClient ()) {
414+ HtmlPage page = webClient .getPage ("about:blank" );
415+ assertNull (page .getUrl ().getRef ());
416+
417+ page .executeJavaScript ("location.hash = 'foo'" );
418+ assertEquals ("foo" , page .getUrl ().getRef ());
419+
420+ page = (HtmlPage ) page .refresh ();
421+ assertEquals ("foo" , page .getUrl ().getRef ());
422+ }
423+ }
424+
408425 /**
409426 * @throws Exception if an error occurs
410427 */
You can’t perform that action at this time.
0 commit comments