Skip to content

Commit

Permalink
adjust tests
Browse files Browse the repository at this point in the history
  • Loading branch information
rbri committed Nov 19, 2022
1 parent 6e4055d commit 7d8faaa
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 10 deletions.
Expand Up @@ -37,6 +37,7 @@
import com.gargoylesoftware.htmlunit.html.HtmlPageTest;
import com.gargoylesoftware.htmlunit.junit.BrowserRunner;
import com.gargoylesoftware.htmlunit.junit.BrowserRunner.Alerts;
import com.gargoylesoftware.htmlunit.junit.BrowserRunner.HtmlUnitNYI;
import com.gargoylesoftware.htmlunit.util.MimeType;
import com.gargoylesoftware.htmlunit.util.NameValuePair;

Expand Down Expand Up @@ -169,6 +170,16 @@ public void domain() throws Exception {
"c2=2; path=/; domain=.htmlunit.org; sameSite=None",
"c3=3; path=/; domain=.host1.htmlunit.org; sameSite=None",
"c4=4; path=/; domain=.host1.htmlunit.org; sameSite=None"})
@HtmlUnitNYI(FF = {"c1=1; c2=2; c3=3; c4=4",
"c1=1; path=/; domain=.htmlunit.org",
"c2=2; path=/; domain=.htmlunit.org",
"c3=3; path=/; domain=.host1.htmlunit.org",
"c4=4; path=/; domain=.host1.htmlunit.org"},
FF_ESR = {"c1=1; c2=2; c3=3; c4=4",
"c1=1; path=/; domain=.htmlunit.org",
"c2=2; path=/; domain=.htmlunit.org",
"c3=3; path=/; domain=.host1.htmlunit.org",
"c4=4; path=/; domain=.host1.htmlunit.org"})
public void storedDomain1() throws Exception {
final List<NameValuePair> responseHeader = new ArrayList<>();
responseHeader.add(new NameValuePair("Set-Cookie", "c1=1; Domain=." + DOMAIN + "; Path=/"));
Expand Down Expand Up @@ -208,6 +219,8 @@ public void storedDomain1() throws Exception {
FF_ESR = {"c1=1; c2=2",
"c1=1; path=/; domain=.htmlunit.org; sameSite=None",
"c2=2; path=/; domain=.htmlunit.org; sameSite=None"})
@HtmlUnitNYI(FF = {"c1=1; c2=2", "c1=1; path=/; domain=.htmlunit.org", "c2=2; path=/; domain=.htmlunit.org"},
FF_ESR = {"c1=1; c2=2", "c1=1; path=/; domain=.htmlunit.org", "c2=2; path=/; domain=.htmlunit.org"})
public void storedDomain2() throws Exception {
final List<NameValuePair> responseHeader = new ArrayList<>();
responseHeader.add(new NameValuePair("Set-Cookie", "c1=1; Domain=." + DOMAIN + "; Path=/"));
Expand Down Expand Up @@ -245,6 +258,8 @@ public void storedDomain2() throws Exception {
FF_ESR = {"c1=1; c2=2",
"c1=1; path=/; domain=.htmlunit.org; sameSite=None",
"c2=2; path=/; domain=.htmlunit.org; sameSite=None"})
@HtmlUnitNYI(FF = {"c1=1; c2=2", "c1=1; path=/; domain=.htmlunit.org", "c2=2; path=/; domain=.htmlunit.org"},
FF_ESR = {"c1=1; c2=2", "c1=1; path=/; domain=.htmlunit.org", "c2=2; path=/; domain=.htmlunit.org"})
public void storedDomain3() throws Exception {
final List<NameValuePair> responseHeader = new ArrayList<>();
responseHeader.add(new NameValuePair("Set-Cookie", "c1=1; Domain=." + DOMAIN + "; Path=/"));
Expand Down Expand Up @@ -275,15 +290,16 @@ public void storedDomain3() throws Exception {
* @throws Exception if the test fails
*/
@Test
@Alerts(CHROME = {"c12=12", "c12=12; path=/; domain=htmlunit", "c11=11; path=/; domain=htmlunit"},
EDGE = {"c12=12", "c12=12; path=/; domain=htmlunit", "c11=11; path=/; domain=htmlunit"},
@Alerts(DEFAULT = {"c12=12", "c12=12; path=/; domain=htmlunit", "c11=11; path=/; domain=htmlunit"},
FF = {"c11=11; c12=12",
"c12=12; path=/; domain=htmlunit; sameSite=None",
"c11=11; path=/; domain=htmlunit; sameSite=None"},
FF_ESR = {"c11=11; c12=12",
"c12=12; path=/; domain=htmlunit; sameSite=None",
"c11=11; path=/; domain=htmlunit; sameSite=None"},
IE = {"c11=11; c12=12", "c12=12; path=/; domain=htmlunit", "c11=11; path=/; domain=htmlunit"})
@HtmlUnitNYI(FF = {"c11=11; c12=12", "c12=12; path=/; domain=htmlunit", "c11=11; path=/; domain=htmlunit"},
FF_ESR = {"c11=11; c12=12", "c12=12; path=/; domain=htmlunit", "c11=11; path=/; domain=htmlunit"})
public void storedDomain4() throws Exception {
final List<NameValuePair> responseHeader = new ArrayList<>();
responseHeader.add(new NameValuePair("Set-Cookie", "c1=1; Domain=." + DOMAIN + "; Path=/"));
Expand Down Expand Up @@ -326,6 +342,10 @@ public void storedDomain4() throws Exception {
"c2=2; path=/; domain=.htmlunit.org; sameSite=None",
"c3=3; path=/; domain=.host1.htmlunit.org; sameSite=None",
"c4=4; path=/; domain=.host1.htmlunit.org; sameSite=None"})
@HtmlUnitNYI(FF = {"c1=1; path=/; domain=.htmlunit.org", "c2=2; path=/; domain=.htmlunit.org",
"c3=3; path=/; domain=.host1.htmlunit.org", "c4=4; path=/; domain=.host1.htmlunit.org"},
FF_ESR = {"c1=1; path=/; domain=.htmlunit.org", "c2=2; path=/; domain=.htmlunit.org",
"c3=3; path=/; domain=.host1.htmlunit.org", "c4=4; path=/; domain=.host1.htmlunit.org"})
public void storedDomainFromJs1() throws Exception {
final String html = "<html>\n"
+ "<head>\n"
Expand Down Expand Up @@ -368,6 +388,8 @@ public void storedDomainFromJs1() throws Exception {
"c2=2; path=/; domain=.htmlunit.org; sameSite=None"},
FF_ESR = {"c1=1; path=/; domain=.htmlunit.org; sameSite=None",
"c2=2; path=/; domain=.htmlunit.org; sameSite=None"})
@HtmlUnitNYI(FF = {"c1=1; path=/; domain=.htmlunit.org", "c2=2; path=/; domain=.htmlunit.org"},
FF_ESR = {"c1=1; path=/; domain=.htmlunit.org", "c2=2; path=/; domain=.htmlunit.org"})
public void storedDomainFromJs2() throws Exception {
final String html = "<html>\n"
+ "<head>\n"
Expand Down Expand Up @@ -408,6 +430,8 @@ public void storedDomainFromJs2() throws Exception {
"c2=2; path=/; domain=.htmlunit.org; sameSite=None"},
FF_ESR = {"c1=1; path=/; domain=.htmlunit.org; sameSite=None",
"c2=2; path=/; domain=.htmlunit.org; sameSite=None"})
@HtmlUnitNYI(FF = {"c1=1; path=/; domain=.htmlunit.org", "c2=2; path=/; domain=.htmlunit.org"},
FF_ESR = {"c1=1; path=/; domain=.htmlunit.org", "c2=2; path=/; domain=.htmlunit.org"})
public void storedDomainFromJs3() throws Exception {
final String html = "<html>\n"
+ "<head>\n"
Expand Down Expand Up @@ -443,15 +467,16 @@ public void storedDomainFromJs3() throws Exception {
* @throws Exception if the test fails
*/
@Test
@Alerts(CHROME = {"1", "c12=12; path=/; domain=htmlunit"},
EDGE = {"1", "c12=12; path=/; domain=htmlunit"},
@Alerts(DEFAULT = {"1", "c12=12; path=/; domain=htmlunit"},
FF = {"2",
"c12=12; path=/; domain=htmlunit; sameSite=None",
"c11=11; path=/; domain=htmlunit; sameSite=None"},
FF_ESR = {"2",
"c12=12; path=/; domain=htmlunit; sameSite=None",
"c11=11; path=/; domain=htmlunit; sameSite=None"},
IE = {"2", "c12=12; path=/; domain=htmlunit", "c11=11; path=/; domain=htmlunit"})
@HtmlUnitNYI(FF = {"2", "c12=12; path=/; domain=htmlunit", "c11=11; path=/; domain=htmlunit"},
FF_ESR = {"2", "c12=12; path=/; domain=htmlunit", "c11=11; path=/; domain=htmlunit"})
public void storedDomainFromJs4() throws Exception {
final String html = "<html>\n"
+ "<head>\n"
Expand Down
18 changes: 12 additions & 6 deletions src/test/java/com/gargoylesoftware/htmlunit/CookieManagerTest.java
Expand Up @@ -321,9 +321,11 @@ public void setCookieExpired() throws Exception {
@Alerts({"cookies: first=1", "cookies: "})
public void setCookieTimeout() throws Exception {
final String html = HtmlPageTest.STANDARDS_MODE_PREFIX_
+ "<html><head><script>\n"
+ "<html><head>\n"
+ "<script>\n"
+ LOG_TITLE_FUNCTION
+ " function alertCookies() {\n"
+ " alert('cookies: ' + document.cookie);\n"
+ " log('cookies: ' + document.cookie);\n"
+ " }\n"

+ " function test() {\n"
Expand All @@ -338,7 +340,8 @@ public void setCookieTimeout() throws Exception {
responseHeader1.add(new NameValuePair("Set-Cookie", "first=1; expires=" + expires + ";"));
getMockWebConnection().setResponse(URL_FIRST, html, 200, "OK", MimeType.TEXT_HTML, responseHeader1);

loadPageWithAlerts2(URL_FIRST, 4_000);
loadPage2(URL_FIRST, StandardCharsets.ISO_8859_1);
verifyTitle2(DEFAULT_WAIT_TIME * 4, getWebDriver(), getExpectedAlerts());
}

/**
Expand Down Expand Up @@ -615,9 +618,11 @@ public void setCookieDifferentPathSlashAtEnd() throws Exception {
@HtmlUnitNYI(IE = {"cookies: first=1", "cookies: "})
public void setCookieDuring302() throws Exception {
final String html = HtmlPageTest.STANDARDS_MODE_PREFIX_
+ "<html><head><title>foo</title><script>\n"
+ "<html><head>\n"
+ "<script>\n"
+ LOG_TITLE_FUNCTION
+ " function alertCookies() {\n"
+ " alert('cookies: ' + document.cookie);\n"
+ " log('cookies: ' + document.cookie);\n"
+ " }\n"

+ " function test() {\n"
Expand All @@ -636,7 +641,8 @@ public void setCookieDuring302() throws Exception {
responseHeader1.add(new NameValuePair("Location", "/foo/content.html"));
getMockWebConnection().setResponse(firstUrl, "", 302, "Moved", MimeType.TEXT_HTML, responseHeader1);

loadPageWithAlerts2(firstUrl, 4_000);
loadPage2(firstUrl, StandardCharsets.ISO_8859_1);
verifyTitle2(DEFAULT_WAIT_TIME * 4, getWebDriver(), getExpectedAlerts());
}

/**
Expand Down

0 comments on commit 7d8faaa

Please sign in to comment.