OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Include test fixture. | 5 // Include test fixture. |
6 GEN_INCLUDE(['net_internals_test.js']); | 6 GEN_INCLUDE(['net_internals_test.js']); |
7 | 7 |
8 // Anonymous namespace | 8 // Anonymous namespace |
9 (function() { | 9 (function() { |
10 | 10 |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 // information. | 90 // information. |
91 expectNotEquals(stripped, entry); | 91 expectNotEquals(stripped, entry); |
92 if (expectation[1] == null) { | 92 if (expectation[1] == null) { |
93 expectEquals(expectation[0], stripped.params.headers[position]); | 93 expectEquals(expectation[0], stripped.params.headers[position]); |
94 } else { | 94 } else { |
95 expectEquals(expectation[1], stripped.params.headers[position]); | 95 expectEquals(expectation[1], stripped.params.headers[position]); |
96 } | 96 } |
97 } | 97 } |
98 } | 98 } |
99 | 99 |
100 // Test with SPDY request headers, which use an object rather than an array. | 100 // Test with HTTP/2 request headers, which use an object rather than an array. |
101 var spdyRequestHeadersEntry = { | 101 var spdyRequestHeadersEntry = { |
102 'params': { | 102 'params': { |
103 'headers': { | 103 'headers': { |
104 ':host': 'clients1.google.com', | 104 ':host': 'clients1.google.com', |
105 ':method': 'GET', | 105 ':method': 'GET', |
106 ':path': '/cute/cat/pictures/', | 106 ':path': '/cute/cat/pictures/', |
107 'cookie': 'blah' | 107 'cookie': 'blah' |
108 }, | 108 }, |
109 'line': 'GET / HTTP/1.1\r\n' | 109 'line': 'GET / HTTP/1.1\r\n' |
110 }, | 110 }, |
111 'phase': EventPhase.PHASE_BEGIN, | 111 'phase': EventPhase.PHASE_BEGIN, |
112 'source': {'id': 329, 'type': EventSourceType.URL_REQUEST}, | 112 'source': {'id': 329, 'type': EventSourceType.URL_REQUEST}, |
113 'time': '22468349', | 113 'time': '22468349', |
114 'type': EventSourceType.HTTP_TRANSACTION_SPDY_SEND_REQUEST_HEADERS | 114 'type': EventSourceType.HTTP_TRANSACTION_HTTP2_SEND_REQUEST_HEADERS |
115 }; | 115 }; |
116 var strippedSpdyRequestHeadersEntry = | 116 var strippedSpdyRequestHeadersEntry = |
117 stripCookiesAndLoginInfo(spdyRequestHeadersEntry); | 117 stripCookiesAndLoginInfo(spdyRequestHeadersEntry); |
118 expectEquals('cookie: [4 bytes were stripped]', | 118 expectEquals('cookie: [4 bytes were stripped]', |
119 strippedSpdyRequestHeadersEntry.params.headers[3]); | 119 strippedSpdyRequestHeadersEntry.params.headers[3]); |
120 | 120 |
121 testDone(); | 121 testDone(); |
122 }); | 122 }); |
123 | 123 |
124 /** | 124 /** |
(...skipping 1625 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1750 */ | 1750 */ |
1751 function painterTestStripCookiesURLRequest() { | 1751 function painterTestStripCookiesURLRequest() { |
1752 var testCase = painterTestDontStripCookiesURLRequest(); | 1752 var testCase = painterTestDontStripCookiesURLRequest(); |
1753 testCase.privacyStripping = true; | 1753 testCase.privacyStripping = true; |
1754 testCase.expectedText = | 1754 testCase.expectedText = |
1755 testCase.expectedText.replace(/MyMagicPony/g, '[11 bytes were stripped]'); | 1755 testCase.expectedText.replace(/MyMagicPony/g, '[11 bytes were stripped]'); |
1756 return testCase; | 1756 return testCase; |
1757 } | 1757 } |
1758 | 1758 |
1759 /** | 1759 /** |
1760 * Tests that cookies are NOT stripped from SPDY sessions when stripping is not | 1760 * Tests that cookies are NOT stripped from HTTP/2 sessions when stripping is |
1761 * enabled. This test data was pieced together in order to get a "cookie" and | 1761 * not enabled. This test data was pieced together in order to get a "cookie" |
1762 * "set-cookie" header. | 1762 * and "set-cookie" header. |
1763 */ | 1763 */ |
1764 function painterTestDontStripCookiesSPDYSession() { | 1764 function painterTestDontStripCookiesSPDYSession() { |
1765 var testCase = {}; | 1765 var testCase = {}; |
1766 testCase.tickOffset = '1337911097783'; | 1766 testCase.tickOffset = '1337911097783'; |
1767 | 1767 |
1768 testCase.logEntries = [ | 1768 testCase.logEntries = [ |
1769 { | 1769 { |
1770 'params': { | 1770 'params': { |
1771 'flags': 1, | 1771 'flags': 1, |
1772 'headers': [ | 1772 'headers': [ |
1773 ':host: mail.google.com', | 1773 ':host: mail.google.com', |
1774 ':method: GET', | 1774 ':method: GET', |
1775 ':path: /a/google.com', | 1775 ':path: /a/google.com', |
1776 ':scheme: https', | 1776 ':scheme: https', |
1777 ':version: HTTP/1.1', | 1777 ':version: HTTP/1.1', |
1778 'accept: text/html', | 1778 'accept: text/html', |
1779 'accept-charset: ISO-8859-1', | 1779 'accept-charset: ISO-8859-1', |
1780 'accept-encoding: gzip,deflate,sdch', | 1780 'accept-encoding: gzip,deflate,sdch', |
1781 'accept-language: en-US,en;q=0.8', | 1781 'accept-language: en-US,en;q=0.8', |
1782 'cookie: MyMagicPony', | 1782 'cookie: MyMagicPony', |
1783 'user-agent: Mozilla/5.0' | 1783 'user-agent: Mozilla/5.0' |
1784 ], | 1784 ], |
1785 'stream_id': 1 | 1785 'stream_id': 1 |
1786 }, | 1786 }, |
1787 'phase': EventPhase.PHASE_NONE, | 1787 'phase': EventPhase.PHASE_NONE, |
1788 'source': { | 1788 'source': { |
1789 'id': 153, | 1789 'id': 153, |
1790 'type': EventSourceType.SPDY_SESSION | 1790 'type': EventSourceType.HTTP2_SESSION |
1791 }, | 1791 }, |
1792 'time': '1012984638', | 1792 'time': '1012984638', |
1793 'type': EventType.SPDY_SESSION_SYN_STREAM | 1793 'type': EventType.HTTP2_SESSION_SYN_STREAM |
1794 }, | 1794 }, |
1795 { | 1795 { |
1796 'params': { | 1796 'params': { |
1797 'flags': 0, | 1797 'flags': 0, |
1798 'headers': [ | 1798 'headers': [ |
1799 ':status: 204 No Content', | 1799 ':status: 204 No Content', |
1800 ':version: HTTP/1.1', | 1800 ':version: HTTP/1.1', |
1801 'date: Tue, 05 Jun 2012 19:21:30 GMT', | 1801 'date: Tue, 05 Jun 2012 19:21:30 GMT', |
1802 'server: GSE', | 1802 'server: GSE', |
1803 'set-cookie: MyMagicPony', | 1803 'set-cookie: MyMagicPony', |
1804 'x-random-header: sup' | 1804 'x-random-header: sup' |
1805 ], | 1805 ], |
1806 'stream_id': 5 | 1806 'stream_id': 5 |
1807 }, | 1807 }, |
1808 'phase': EventPhase.PHASE_NONE, | 1808 'phase': EventPhase.PHASE_NONE, |
1809 'source': { | 1809 'source': { |
1810 'id': 153, | 1810 'id': 153, |
1811 'type': EventSourceType.SPDY_SESSION | 1811 'type': EventSourceType.HTTP2_SESSION |
1812 }, | 1812 }, |
1813 'time': '1012992266', | 1813 'time': '1012992266', |
1814 'type': EventType.SPDY_SESSION_SYN_REPLY | 1814 'type': EventType.HTTP2_SESSION_SYN_REPLY |
1815 } | 1815 } |
1816 ]; | 1816 ]; |
1817 | 1817 |
1818 testCase.expectedText = | 1818 testCase.expectedText = |
1819 't=1338924082421 [st= 0] SPDY_SESSION_SYN_STREAM\n' + | 1819 't=1338924082421 [st= 0] HTTP2_SESSION_SYN_STREAM\n' + |
1820 ' --> flags = 1\n' + | 1820 ' --> flags = 1\n' + |
1821 ' --> :host: mail.google.com\n' + | 1821 ' --> :host: mail.google.com\n' + |
1822 ' :method: GET\n' + | 1822 ' :method: GET\n' + |
1823 ' :path: /a/google.com\n' + | 1823 ' :path: /a/google.com\n' + |
1824 ' :scheme: https\n' + | 1824 ' :scheme: https\n' + |
1825 ' :version: HTTP/1.1\n' + | 1825 ' :version: HTTP/1.1\n' + |
1826 ' accept: text/html\n' + | 1826 ' accept: text/html\n' + |
1827 ' accept-charset: ISO-8859-1\n' + | 1827 ' accept-charset: ISO-8859-1\n' + |
1828 ' accept-encoding: gzip,deflate,sdch\n' + | 1828 ' accept-encoding: gzip,deflate,sdch\n' + |
1829 ' accept-language: en-US,en;q=0.8\n' + | 1829 ' accept-language: en-US,en;q=0.8\n' + |
1830 ' cookie: MyMagicPony\n' + | 1830 ' cookie: MyMagicPony\n' + |
1831 ' user-agent: Mozilla/5.0\n' + | 1831 ' user-agent: Mozilla/5.0\n' + |
1832 ' --> stream_id = 1\n' + | 1832 ' --> stream_id = 1\n' + |
1833 't=1338924090049 [st=7628] SPDY_SESSION_SYN_REPLY\n' + | 1833 't=1338924090049 [st=7628] HTTP2_SESSION_SYN_REPLY\n' + |
1834 ' --> flags = 0\n' + | 1834 ' --> flags = 0\n' + |
1835 ' --> :status: 204 No Content\n' + | 1835 ' --> :status: 204 No Content\n' + |
1836 ' :version: HTTP/1.1\n' + | 1836 ' :version: HTTP/1.1\n' + |
1837 ' date: Tue, 05 Jun 2012 19:21:30 GMT\n' + | 1837 ' date: Tue, 05 Jun 2012 19:21:30 GMT\n' + |
1838 ' server: GSE\n' + | 1838 ' server: GSE\n' + |
1839 ' set-cookie: MyMagicPony\n' + | 1839 ' set-cookie: MyMagicPony\n' + |
1840 ' x-random-header: sup\n' + | 1840 ' x-random-header: sup\n' + |
1841 ' --> stream_id = 5'; | 1841 ' --> stream_id = 5'; |
1842 | 1842 |
1843 return testCase; | 1843 return testCase; |
1844 } | 1844 } |
1845 | 1845 |
1846 /** | 1846 /** |
1847 * Tests that cookies are stripped from SPDY sessions when stripping is enabled. | 1847 * Tests that cookies are stripped from HTTP/2 sessions when stripping is |
| 1848 * enabled. |
1848 */ | 1849 */ |
1849 function painterTestStripCookiesSPDYSession() { | 1850 function painterTestStripCookiesSPDYSession() { |
1850 var testCase = painterTestDontStripCookiesSPDYSession(); | 1851 var testCase = painterTestDontStripCookiesSPDYSession(); |
1851 testCase.privacyStripping = true; | 1852 testCase.privacyStripping = true; |
1852 testCase.expectedText = | 1853 testCase.expectedText = |
1853 testCase.expectedText.replace(/MyMagicPony/g, '[11 bytes were stripped]'); | 1854 testCase.expectedText.replace(/MyMagicPony/g, '[11 bytes were stripped]'); |
1854 return testCase; | 1855 return testCase; |
1855 } | 1856 } |
1856 | 1857 |
1857 /** | 1858 /** |
1858 * Tests that cookies are NOT stripped from SPDY URL request headers when | 1859 * Tests that cookies are NOT stripped from HTTP/2 URL request headers when |
1859 * stripping is not enabled. The difference from the above requests is that SPDY | 1860 * stripping is not enabled. The difference from the above requests is that |
1860 * URL request headers use dictionaries rather than lists. | 1861 * HTTP/2 URL request headers use dictionaries rather than lists. |
1861 */ | 1862 */ |
1862 function painterTestSpdyURLRequestDontStripCookies() { | 1863 function painterTestSpdyURLRequestDontStripCookies() { |
1863 var testCase = {}; | 1864 var testCase = {}; |
1864 testCase.tickOffset = '1337911098481'; | 1865 testCase.tickOffset = '1337911098481'; |
1865 | 1866 |
1866 testCase.logEntries = [ | 1867 testCase.logEntries = [ |
1867 { | 1868 { |
1868 'params': { | 1869 'params': { |
1869 'headers': { | 1870 'headers': { |
1870 ':host': 'www.google.com', | 1871 ':host': 'www.google.com', |
1871 ':method': 'GET', | 1872 ':method': 'GET', |
1872 ':path': '/', | 1873 ':path': '/', |
1873 ':scheme': 'https', | 1874 ':scheme': 'https', |
1874 ':version': 'HTTP/1.1', | 1875 ':version': 'HTTP/1.1', |
1875 'cookie': 'MyMagicPony'}, | 1876 'cookie': 'MyMagicPony'}, |
1876 }, | 1877 }, |
1877 'phase': EventPhase.PHASE_NONE, | 1878 'phase': EventPhase.PHASE_NONE, |
1878 'source': {'id': 329, 'type': EventSourceType.URL_REQUEST}, | 1879 'source': {'id': 329, 'type': EventSourceType.URL_REQUEST}, |
1879 'time': '954124663', | 1880 'time': '954124663', |
1880 'type': EventType.HTTP_TRANSACTION_SPDY_SEND_REQUEST_HEADERS | 1881 'type': EventType.HTTP_TRANSACTION_HTTP2_SEND_REQUEST_HEADERS |
1881 } | 1882 } |
1882 ]; | 1883 ]; |
1883 | 1884 |
1884 testCase.expectedText = | 1885 testCase.expectedText = |
1885 't=1338865223144 [st=0] HTTP_TRANSACTION_SPDY_SEND_REQUEST_HEADERS\n' + | 1886 't=1338865223144 [st=0] HTTP_TRANSACTION_HTTP2_SEND_REQUEST_HEADERS\n' + |
1886 ' --> :host: www.google.com\n' + | 1887 ' --> :host: www.google.com\n' + |
1887 ' :method: GET\n' + | 1888 ' :method: GET\n' + |
1888 ' :path: /\n' + | 1889 ' :path: /\n' + |
1889 ' :scheme: https\n' + | 1890 ' :scheme: https\n' + |
1890 ' :version: HTTP/1.1\n' + | 1891 ' :version: HTTP/1.1\n' + |
1891 ' cookie: MyMagicPony'; | 1892 ' cookie: MyMagicPony'; |
1892 return testCase; | 1893 return testCase; |
1893 } | 1894 } |
1894 | 1895 |
1895 /** | 1896 /** |
1896 * Tests that cookies are NOT stripped from SPDY URL request headers when | 1897 * Tests that cookies are NOT stripped from HTTP/2 URL request headers when |
1897 * stripping is not enabled. The difference from the above requests is that | 1898 * stripping is not enabled. The difference from the above requests is that |
1898 */ | 1899 */ |
1899 function painterTestSpdyURLRequestStripCookies() { | 1900 function painterTestSpdyURLRequestStripCookies() { |
1900 var testCase = painterTestSpdyURLRequestDontStripCookies(); | 1901 var testCase = painterTestSpdyURLRequestDontStripCookies(); |
1901 testCase.privacyStripping = true; | 1902 testCase.privacyStripping = true; |
1902 testCase.expectedText = | 1903 testCase.expectedText = |
1903 testCase.expectedText.replace(/MyMagicPony/g, '[11 bytes were stripped]'); | 1904 testCase.expectedText.replace(/MyMagicPony/g, '[11 bytes were stripped]'); |
1904 return testCase; | 1905 return testCase; |
1905 } | 1906 } |
1906 | 1907 |
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2162 | 2163 |
2163 testCase.expectedText = | 2164 testCase.expectedText = |
2164 't= 2 [st= 0] +REQUEST_ALIVE [dt=789+]\n' + | 2165 't= 2 [st= 0] +REQUEST_ALIVE [dt=789+]\n' + |
2165 't=152 [st=150] HTTP_STREAM_REQUEST [dt=1]\n' + | 2166 't=152 [st=150] HTTP_STREAM_REQUEST [dt=1]\n' + |
2166 't=791 [st=789]'; | 2167 't=791 [st=789]'; |
2167 | 2168 |
2168 return testCase; | 2169 return testCase; |
2169 } | 2170 } |
2170 | 2171 |
2171 })(); // Anonymous namespace | 2172 })(); // Anonymous namespace |
OLD | NEW |