From: <rb...@us...> - 2018-07-18 06:39:48
|
Revision: 15478 http://sourceforge.net/p/htmlunit/code/15478 Author: rbri Date: 2018-07-18 06:39:42 +0000 (Wed, 18 Jul 2018) Log Message: ----------- debug at the server Modified Paths: -------------- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/PrimitiveWebServer.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/WebClient7Test.java Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/PrimitiveWebServer.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/PrimitiveWebServer.java 2018-07-18 06:33:19 UTC (rev 15477) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/PrimitiveWebServer.java 2018-07-18 06:39:42 UTC (rev 15478) @@ -94,6 +94,7 @@ break; } } +System.out.println("req: " + requestString); final String response; if (requestString.contains("/favicon.ico")) { Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/WebClient7Test.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/WebClient7Test.java 2018-07-18 06:33:19 UTC (rev 15477) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/WebClient7Test.java 2018-07-18 06:39:42 UTC (rev 15478) @@ -51,111 +51,111 @@ shutDownAll(); } - /** - * Test that the path and query string are encoded to be valid. - * @throws Exception if something goes wrong - */ - @Test - @Alerts(DEFAULT = "/test.html?a=b%20c&d=%C3%A9%C3%A8", - IE = "/test.html?a=b%20c&d=\u00E9\u00E8") - @NotYetImplemented(IE) - public void loadPage_EncodeRequest() throws Exception { - // with query string not encoded - testRequestUrlEncoding("test.html?a=b c&d=\u00E9\u00E8"); - } +// /** +// * Test that the path and query string are encoded to be valid. +// * @throws Exception if something goes wrong +// */ +// @Test +// @Alerts(DEFAULT = "/test.html?a=b%20c&d=%C3%A9%C3%A8", +// IE = "/test.html?a=b%20c&d=\u00E9\u00E8") +// @NotYetImplemented(IE) +// public void loadPage_EncodeRequest() throws Exception { +// // with query string not encoded +// testRequestUrlEncoding("test.html?a=b c&d=\u00E9\u00E8"); +// } +// +// /** +// * Test that the path and query string are encoded to be valid. +// * @throws Exception if something goes wrong +// */ +// @Test +// @Alerts("/test.html?a=b%20c&d=%C3%A9%C3%A8") +// public void loadPage_EncodeRequest2() throws Exception { +// // with query string already encoded +// testRequestUrlEncoding("test.html?a=b%20c&d=%C3%A9%C3%A8"); +// } +// +// /** +// * Test that the path and query string are encoded to be valid. +// * @throws Exception if something goes wrong +// */ +// @Test +// @Alerts("/test.html?a=b%20c&d=e%20f") +// public void loadPage_EncodeRequest3() throws Exception { +// // with query string partially encoded +// testRequestUrlEncoding("test.html?a=b%20c&d=e f"); +// } +// +// /** +// * Test that the path and query string are encoded to be valid. +// * @throws Exception if something goes wrong +// */ +// @Test +// @Alerts("/test.html?a=b%20c") +// public void loadPage_EncodeRequest4() throws Exception { +// // with anchor +// testRequestUrlEncoding("test.html?a=b c#myAnchor"); +// } +// +// /** +// * Test that the path and query string are encoded to be valid. +// * @throws Exception if something goes wrong +// */ +// @Test +// @Alerts("/test.html?a=%26%3D%20%2C%24") +// public void loadPage_EncodeRequest5() throws Exception { +// // with query string containing encoded "&", "=", "+", ",", and "$" +// testRequestUrlEncoding("test.html?a=%26%3D%20%2C%24"); +// } +// +// /** +// * Test that the path and query string are encoded to be valid. +// * @throws Exception if something goes wrong +// */ +// @Test +// @Alerts("/page%201.html") +// public void loadPage_EncodeRequest6() throws Exception { +// // with character to encode in path +// testRequestUrlEncoding("page 1.html"); +// } +// +// /** +// * Test that the path and query string are encoded to be valid. +// * @throws Exception if something goes wrong +// */ +// @Test +// @Alerts(DEFAULT = "/test.html?param=%C2%A9%C2%A3", +// IE = "/test.html?param=\u00A9\u00A3") +// @NotYetImplemented(IE) +// public void loadPage_EncodeRequest7() throws Exception { +// // unicode +// testRequestUrlEncoding("test.html?param=\u00A9\u00A3"); +// } +// +// private void testRequestUrlEncoding(final String url) throws Exception { +// final String html = "<html>" +// + "<head><title>foo</title></head>" +// + "<body></body></html>"; +// +// final String response = "HTTP/1.1 200 OK\r\n" +// + "Content-Length: " + html.length() + "\r\n" +// + "Content-Type: text/html\r\n" +// + "\r\n" +// + html; +// +// primitiveWebServer_ = new PrimitiveWebServer(PORT, response); +// primitiveWebServer_.start(); +// +// final WebDriver driver = getWebDriver(); +// +// driver.get(new URL(URL_FIRST, url).toString()); +// String reqUrl = primitiveWebServer_.getRequests().get(0); +// reqUrl = reqUrl.substring(4, reqUrl.indexOf("HTTP/1.1") - 1); +// +// assertEquals(getExpectedAlerts()[0], reqUrl); +// } /** - * Test that the path and query string are encoded to be valid. - * @throws Exception if something goes wrong - */ - @Test - @Alerts("/test.html?a=b%20c&d=%C3%A9%C3%A8") - public void loadPage_EncodeRequest2() throws Exception { - // with query string already encoded - testRequestUrlEncoding("test.html?a=b%20c&d=%C3%A9%C3%A8"); - } - - /** - * Test that the path and query string are encoded to be valid. - * @throws Exception if something goes wrong - */ - @Test - @Alerts("/test.html?a=b%20c&d=e%20f") - public void loadPage_EncodeRequest3() throws Exception { - // with query string partially encoded - testRequestUrlEncoding("test.html?a=b%20c&d=e f"); - } - - /** - * Test that the path and query string are encoded to be valid. - * @throws Exception if something goes wrong - */ - @Test - @Alerts("/test.html?a=b%20c") - public void loadPage_EncodeRequest4() throws Exception { - // with anchor - testRequestUrlEncoding("test.html?a=b c#myAnchor"); - } - - /** - * Test that the path and query string are encoded to be valid. - * @throws Exception if something goes wrong - */ - @Test - @Alerts("/test.html?a=%26%3D%20%2C%24") - public void loadPage_EncodeRequest5() throws Exception { - // with query string containing encoded "&", "=", "+", ",", and "$" - testRequestUrlEncoding("test.html?a=%26%3D%20%2C%24"); - } - - /** - * Test that the path and query string are encoded to be valid. - * @throws Exception if something goes wrong - */ - @Test - @Alerts("/page%201.html") - public void loadPage_EncodeRequest6() throws Exception { - // with character to encode in path - testRequestUrlEncoding("page 1.html"); - } - - /** - * Test that the path and query string are encoded to be valid. - * @throws Exception if something goes wrong - */ - @Test - @Alerts(DEFAULT = "/test.html?param=%C2%A9%C2%A3", - IE = "/test.html?param=\u00A9\u00A3") - @NotYetImplemented(IE) - public void loadPage_EncodeRequest7() throws Exception { - // unicode - testRequestUrlEncoding("test.html?param=\u00A9\u00A3"); - } - - private void testRequestUrlEncoding(final String url) throws Exception { - final String html = "<html>" - + "<head><title>foo</title></head>" - + "<body></body></html>"; - - final String response = "HTTP/1.1 200 OK\r\n" - + "Content-Length: " + html.length() + "\r\n" - + "Content-Type: text/html\r\n" - + "\r\n" - + html; - - primitiveWebServer_ = new PrimitiveWebServer(PORT, response); - primitiveWebServer_.start(); - - final WebDriver driver = getWebDriver(); - - driver.get(new URL(URL_FIRST, url).toString()); - String reqUrl = primitiveWebServer_.getRequests().get(0); - reqUrl = reqUrl.substring(4, reqUrl.indexOf("HTTP/1.1") - 1); - - assertEquals(getExpectedAlerts()[0], reqUrl); - } - - /** * @throws Exception if the test fails */ @Test @@ -165,57 +165,57 @@ public void anchorUrlEncodingUTF8Header() throws Exception { urlEncoding(true, "UTF-8"); } +// +// /** +// * @throws Exception if the test fails +// */ +// @Test +// @Alerts(DEFAULT = "/test.html?k%C3%B6nig", +// IE = "/test.html?k\u00c3\u00b6nig") +// @NotYetImplemented(IE) +// public void anchorUrlEncodingUTF8Meta() throws Exception { +// urlEncoding(false, "UTF-8"); +// } +// +// /** +// * @throws Exception if the test fails +// */ +// @Test +// @Alerts(DEFAULT = "/test.html?k%F6nig", +// IE = "/test.html?k\u00f6nig") +// @NotYetImplemented(IE) +// public void anchorUrlEncodingISO8859_1Header() throws Exception { +// urlEncoding(true, "ISO-8859-1"); +// } +// +// /** +// * @throws Exception if the test fails +// */ +// @Test +// @Alerts(DEFAULT = "/test.html?k%F6nig", +// IE = "/test.html?k\u00f6nig") +// @NotYetImplemented(IE) +// public void anchorUrlEncodingISO8859_1Meta() throws Exception { +// urlEncoding(false, "ISO-8859-1"); +// } +// +// /** +// * @throws Exception if the test fails +// */ +// @Test +// @Alerts("/test.html?k?nig") +// public void anchorUrlEncodingWindows_1251Header() throws Exception { +// urlEncoding(true, "Windows-1251"); +// } +// /** +// * @throws Exception if the test fails +// */ +// @Test +// @Alerts("/test.html?k?nig") +// public void anchorUrlEncodingWindows_1251Meta() throws Exception { +// urlEncoding(false, "Windows-1251"); +// } - /** - * @throws Exception if the test fails - */ - @Test - @Alerts(DEFAULT = "/test.html?k%C3%B6nig", - IE = "/test.html?k\u00c3\u00b6nig") - @NotYetImplemented(IE) - public void anchorUrlEncodingUTF8Meta() throws Exception { - urlEncoding(false, "UTF-8"); - } - - /** - * @throws Exception if the test fails - */ - @Test - @Alerts(DEFAULT = "/test.html?k%F6nig", - IE = "/test.html?k\u00f6nig") - @NotYetImplemented(IE) - public void anchorUrlEncodingISO8859_1Header() throws Exception { - urlEncoding(true, "ISO-8859-1"); - } - - /** - * @throws Exception if the test fails - */ - @Test - @Alerts(DEFAULT = "/test.html?k%F6nig", - IE = "/test.html?k\u00f6nig") - @NotYetImplemented(IE) - public void anchorUrlEncodingISO8859_1Meta() throws Exception { - urlEncoding(false, "ISO-8859-1"); - } - - /** - * @throws Exception if the test fails - */ - @Test - @Alerts("/test.html?k?nig") - public void anchorUrlEncodingWindows_1251Header() throws Exception { - urlEncoding(true, "Windows-1251"); - } - /** - * @throws Exception if the test fails - */ - @Test - @Alerts("/test.html?k?nig") - public void anchorUrlEncodingWindows_1251Meta() throws Exception { - urlEncoding(false, "Windows-1251"); - } - private void urlEncoding(final boolean header, final String charset) throws Exception { String html = "<html>\n" + "<head><title>foo</title>\n"; @@ -260,180 +260,180 @@ assertEquals(getExpectedAlerts()[0], reqUrl); } - /** - * @throws Exception if the test fails - */ - @Test - @Alerts(DEFAULT = "/test.css?k%C3%B6nig", - IE = "/test.css?k\u00c3\u00b6nig") - @NotYetImplemented(IE) - public void linkUrlEncodingUTF8Header() throws Exception { - final String html = "<html>\n" - + "<head><title>foo</title>\n" - + " <link rel='stylesheet' type='text/css' href='test.css?k\u00F6nig'>" - + "</head>\n" - + "<body>\n" - + "</body></html>"; +// /** +// * @throws Exception if the test fails +// */ +// @Test +// @Alerts(DEFAULT = "/test.css?k%C3%B6nig", +// IE = "/test.css?k\u00c3\u00b6nig") +// @NotYetImplemented(IE) +// public void linkUrlEncodingUTF8Header() throws Exception { +// final String html = "<html>\n" +// + "<head><title>foo</title>\n" +// + " <link rel='stylesheet' type='text/css' href='test.css?k\u00F6nig'>" +// + "</head>\n" +// + "<body>\n" +// + "</body></html>"; +// +// final String firstResponse = "HTTP/1.1 200 OK\r\n" +// + "Content-Length: " + html.length() + "\r\n" +// + "Content-Type: text/html; charset=UTF-8\r\n" +// + "\r\n" +// + html; +// +// final String css = "p { color: red; }"; +// +// final String secondResponse = "HTTP/1.1 200 OK\r\n" +// + "Content-Length: " + css.length() + "\r\n" +// + "Content-Type: text/css\r\n" +// + "\r\n" +// + css; +// +// primitiveWebServer_ = new PrimitiveWebServer(PORT, firstResponse, secondResponse); +// primitiveWebServer_.setCharset(StandardCharsets.UTF_8); +// primitiveWebServer_.start(); +// +// final WebDriver driver = getWebDriver(); +// +// driver.get(URL_FIRST.toString()); +// +// String reqUrl = primitiveWebServer_.getRequests().get(1); +// reqUrl = reqUrl.substring(4, reqUrl.indexOf("HTTP/1.1") - 1); +// +// assertEquals(getExpectedAlerts()[0], reqUrl); +// } +// +// /** +// * @throws Exception if the test fails +// */ +// @Test +// @Alerts(DEFAULT = "/test.css?k%C3%B6nig", +// IE = "/test.css?k\u00c3\u00b6nig") +// @NotYetImplemented(IE) +// public void linkUrlEncodingUTF8Meta() throws Exception { +// final String html = "<html>\n" +// + "<head><title>foo</title>\n" +// + " <meta http-equiv='Content-Type' content='text/html; charset=UTF-8'>\n" +// + " <link rel='stylesheet' type='text/css' href='test.css?k\u00F6nig'>" +// + "</head>\n" +// + "<body>\n" +// + "</body></html>"; +// +// final String firstResponse = "HTTP/1.1 200 OK\r\n" +// + "Content-Length: " + html.length() + "\r\n" +// + "Content-Type: text/html\r\n" +// + "\r\n" +// + html; +// +// final String css = "p { color: red; }"; +// +// final String secondResponse = "HTTP/1.1 200 OK\r\n" +// + "Content-Length: " + css.length() + "\r\n" +// + "Content-Type: text/css\r\n" +// + "\r\n" +// + css; +// +// primitiveWebServer_ = new PrimitiveWebServer(PORT, firstResponse, secondResponse); +// primitiveWebServer_.setCharset(StandardCharsets.UTF_8); +// primitiveWebServer_.start(); +// +// final WebDriver driver = getWebDriver(); +// +// driver.get(URL_FIRST.toString()); +// +// String reqUrl = primitiveWebServer_.getRequests().get(1); +// reqUrl = reqUrl.substring(4, reqUrl.indexOf("HTTP/1.1") - 1); +// +// assertEquals(getExpectedAlerts()[0], reqUrl); +// } +// +// /** +// * @throws Exception if the test fails +// */ +// @Test +// @Alerts(DEFAULT = "/test.css?k%F6nig", +// IE = "/test.css?k\u00f6nig") +// @NotYetImplemented(IE) +// public void linkUrlEncodingISO8859_1Header() throws Exception { +// final String html = "<html>\n" +// + "<head><title>foo</title>\n" +// + " <link rel='stylesheet' type='text/css' href='test.css?k\u00F6nig'>" +// + "</head>\n" +// + "<body>\n" +// + "</body></html>"; +// +// final String firstResponse = "HTTP/1.1 200 OK\r\n" +// + "Content-Length: " + html.length() + "\r\n" +// + "Content-Type: text/html; charset=ISO-8859-1\r\n" +// + "\r\n" +// + html; +// +// final String css = "p { color: red; }"; +// +// final String secondResponse = "HTTP/1.1 200 OK\r\n" +// + "Content-Length: " + css.length() + "\r\n" +// + "Content-Type: text/css\r\n" +// + "\r\n" +// + css; +// +// primitiveWebServer_ = new PrimitiveWebServer(PORT, firstResponse, secondResponse); +// primitiveWebServer_.setCharset(StandardCharsets.ISO_8859_1); +// primitiveWebServer_.start(); +// +// final WebDriver driver = getWebDriver(); +// +// driver.get(URL_FIRST.toString()); +// +// String reqUrl = primitiveWebServer_.getRequests().get(1); +// reqUrl = reqUrl.substring(4, reqUrl.indexOf("HTTP/1.1") - 1); +// +// assertEquals(getExpectedAlerts()[0], reqUrl); +// } +// +// /** +// * @throws Exception if the test fails +// */ +// @Test +// @Alerts(DEFAULT = "/test.css?k%F6nig", +// IE = "/test.css?k\u00f6nig") +// @NotYetImplemented(IE) +// public void linkUrlEncodingISO8859_1Meta() throws Exception { +// final String html = "<html>\n" +// + "<head><title>foo</title>\n" +// + " <meta http-equiv='Content-Type' content='text/html; charset=ISO-8859-1'>\n" +// + " <link rel='stylesheet' type='text/css' href='test.css?k\u00F6nig'>" +// + "</head>\n" +// + "<body>\n" +// + "</body></html>"; +// +// final String firstResponse = "HTTP/1.1 200 OK\r\n" +// + "Content-Length: " + html.length() + "\r\n" +// + "Content-Type: text/html\r\n" +// + "\r\n" +// + html; +// +// final String css = "p { color: red; }"; +// +// final String secondResponse = "HTTP/1.1 200 OK\r\n" +// + "Content-Length: " + css.length() + "\r\n" +// + "Content-Type: text/css\r\n" +// + "\r\n" +// + css; +// +// primitiveWebServer_ = new PrimitiveWebServer(PORT, firstResponse, secondResponse); +// primitiveWebServer_.setCharset(StandardCharsets.ISO_8859_1); +// primitiveWebServer_.start(); +// +// final WebDriver driver = getWebDriver(); +// +// driver.get(URL_FIRST.toString()); +// +// String reqUrl = primitiveWebServer_.getRequests().get(1); +// reqUrl = reqUrl.substring(4, reqUrl.indexOf("HTTP/1.1") - 1); +// +// assertEquals(getExpectedAlerts()[0], reqUrl); +// } - final String firstResponse = "HTTP/1.1 200 OK\r\n" - + "Content-Length: " + html.length() + "\r\n" - + "Content-Type: text/html; charset=UTF-8\r\n" - + "\r\n" - + html; - - final String css = "p { color: red; }"; - - final String secondResponse = "HTTP/1.1 200 OK\r\n" - + "Content-Length: " + css.length() + "\r\n" - + "Content-Type: text/css\r\n" - + "\r\n" - + css; - - primitiveWebServer_ = new PrimitiveWebServer(PORT, firstResponse, secondResponse); - primitiveWebServer_.setCharset(StandardCharsets.UTF_8); - primitiveWebServer_.start(); - - final WebDriver driver = getWebDriver(); - - driver.get(URL_FIRST.toString()); - - String reqUrl = primitiveWebServer_.getRequests().get(1); - reqUrl = reqUrl.substring(4, reqUrl.indexOf("HTTP/1.1") - 1); - - assertEquals(getExpectedAlerts()[0], reqUrl); - } - - /** - * @throws Exception if the test fails - */ - @Test - @Alerts(DEFAULT = "/test.css?k%C3%B6nig", - IE = "/test.css?k\u00c3\u00b6nig") - @NotYetImplemented(IE) - public void linkUrlEncodingUTF8Meta() throws Exception { - final String html = "<html>\n" - + "<head><title>foo</title>\n" - + " <meta http-equiv='Content-Type' content='text/html; charset=UTF-8'>\n" - + " <link rel='stylesheet' type='text/css' href='test.css?k\u00F6nig'>" - + "</head>\n" - + "<body>\n" - + "</body></html>"; - - final String firstResponse = "HTTP/1.1 200 OK\r\n" - + "Content-Length: " + html.length() + "\r\n" - + "Content-Type: text/html\r\n" - + "\r\n" - + html; - - final String css = "p { color: red; }"; - - final String secondResponse = "HTTP/1.1 200 OK\r\n" - + "Content-Length: " + css.length() + "\r\n" - + "Content-Type: text/css\r\n" - + "\r\n" - + css; - - primitiveWebServer_ = new PrimitiveWebServer(PORT, firstResponse, secondResponse); - primitiveWebServer_.setCharset(StandardCharsets.UTF_8); - primitiveWebServer_.start(); - - final WebDriver driver = getWebDriver(); - - driver.get(URL_FIRST.toString()); - - String reqUrl = primitiveWebServer_.getRequests().get(1); - reqUrl = reqUrl.substring(4, reqUrl.indexOf("HTTP/1.1") - 1); - - assertEquals(getExpectedAlerts()[0], reqUrl); - } - - /** - * @throws Exception if the test fails - */ - @Test - @Alerts(DEFAULT = "/test.css?k%F6nig", - IE = "/test.css?k\u00f6nig") - @NotYetImplemented(IE) - public void linkUrlEncodingISO8859_1Header() throws Exception { - final String html = "<html>\n" - + "<head><title>foo</title>\n" - + " <link rel='stylesheet' type='text/css' href='test.css?k\u00F6nig'>" - + "</head>\n" - + "<body>\n" - + "</body></html>"; - - final String firstResponse = "HTTP/1.1 200 OK\r\n" - + "Content-Length: " + html.length() + "\r\n" - + "Content-Type: text/html; charset=ISO-8859-1\r\n" - + "\r\n" - + html; - - final String css = "p { color: red; }"; - - final String secondResponse = "HTTP/1.1 200 OK\r\n" - + "Content-Length: " + css.length() + "\r\n" - + "Content-Type: text/css\r\n" - + "\r\n" - + css; - - primitiveWebServer_ = new PrimitiveWebServer(PORT, firstResponse, secondResponse); - primitiveWebServer_.setCharset(StandardCharsets.ISO_8859_1); - primitiveWebServer_.start(); - - final WebDriver driver = getWebDriver(); - - driver.get(URL_FIRST.toString()); - - String reqUrl = primitiveWebServer_.getRequests().get(1); - reqUrl = reqUrl.substring(4, reqUrl.indexOf("HTTP/1.1") - 1); - - assertEquals(getExpectedAlerts()[0], reqUrl); - } - - /** - * @throws Exception if the test fails - */ - @Test - @Alerts(DEFAULT = "/test.css?k%F6nig", - IE = "/test.css?k\u00f6nig") - @NotYetImplemented(IE) - public void linkUrlEncodingISO8859_1Meta() throws Exception { - final String html = "<html>\n" - + "<head><title>foo</title>\n" - + " <meta http-equiv='Content-Type' content='text/html; charset=ISO-8859-1'>\n" - + " <link rel='stylesheet' type='text/css' href='test.css?k\u00F6nig'>" - + "</head>\n" - + "<body>\n" - + "</body></html>"; - - final String firstResponse = "HTTP/1.1 200 OK\r\n" - + "Content-Length: " + html.length() + "\r\n" - + "Content-Type: text/html\r\n" - + "\r\n" - + html; - - final String css = "p { color: red; }"; - - final String secondResponse = "HTTP/1.1 200 OK\r\n" - + "Content-Length: " + css.length() + "\r\n" - + "Content-Type: text/css\r\n" - + "\r\n" - + css; - - primitiveWebServer_ = new PrimitiveWebServer(PORT, firstResponse, secondResponse); - primitiveWebServer_.setCharset(StandardCharsets.ISO_8859_1); - primitiveWebServer_.start(); - - final WebDriver driver = getWebDriver(); - - driver.get(URL_FIRST.toString()); - - String reqUrl = primitiveWebServer_.getRequests().get(1); - reqUrl = reqUrl.substring(4, reqUrl.indexOf("HTTP/1.1") - 1); - - assertEquals(getExpectedAlerts()[0], reqUrl); - } - // BaseFrameElement.java (2 matches) // HtmlApplet.java // HtmlArea.java |