MCPcopy Create free account
hub / github.com/HtmlUnit/htmlunit / hash

Method hash

src/test/java/org/htmlunit/javascript/host/URLTest.java:399–447  ·  view source on GitHub ↗

@throws Exception if the test fails

()

Source from the content-addressed store, hash-verified

397 * @throws Exception if the test fails
398 */
399 @Test
400 @Alerts({"", "#abcd", "#bcd",
401 "#hash", "http://developer.mozilla.org/?a=b#hash",
402 "", "http://developer.mozilla.org/?a=b",
403 "#undefined", "http://developer.mozilla.org/#undefined",
404 "#null", "http://developer.mozilla.org/#null"})
405 public void hash() throws Exception {
406 final String html = DOCTYPE_HTML
407 + "<html>\n"
408 + "<head>\n"
409 + " <script>\n"
410 + LOG_TITLE_FUNCTION
411 + " function test() {\n"
412 + " if (typeof window.URL === 'function') {\n"
413 + " var u = new URL('http://developer.mozilla.org');\n"
414 + " log(u.hash);\n"
415
416 + " u = new URL('http://developer.mozilla.org#abcd');\n"
417 + " log(u.hash);\n"
418
419 + " u = new URL('http://developer.mozilla.org?a=b#bcd');\n"
420 + " log(u.hash);\n"
421
422 + " u.hash = 'hash';\n"
423 + " log(u.hash);\n"
424 + " log(u.toString());\n"
425
426 + " u.hash = '';\n"
427 + " log(u.hash);\n"
428 + " log(u.toString());\n"
429
430 + " u = new URL('http://developer.mozilla.org#bcd');\n"
431 + " u.hash = undefined;\n"
432 + " log(u.hash);\n"
433 + " log(u.toString());\n"
434
435 + " u = new URL('http://developer.mozilla.org#bcd');\n"
436 + " u.hash = null;\n"
437 + " log(u.hash);\n"
438 + " log(u.toString());\n"
439 + " }\n"
440 + " }\n"
441 + " </script>\n"
442 + "</head>\n"
443 + "<body onload='test()'>\n"
444 + "</body>\n"
445 + "</html>";
446 loadPageVerifyTitle2(html);
447 }
448
449 /**
450 * @throws Exception if the test fails

Callers 6

hashCodeMethod · 0.45
hashCodeMethod · 0.45
hashCodeMethod · 0.45
hashCodeMethod · 0.45
hashCodeMethod · 0.45
hashCodeMethod · 0.45

Calls 1

loadPageVerifyTitle2Method · 0.80

Tested by

no test coverage detected