| OLD | NEW |
| 1 <html> | 1 <html> |
| 2 <head> | 2 <head> |
| 3 <script src="../inspector-test.js"></script> | 3 <script src="../inspector-test.js"></script> |
| 4 <script> | 4 <script> |
| 5 function test() | 5 function test() |
| 6 { | 6 { |
| 7 function createNetworkRequestForURLAndDumpNameAndPath(url) | 7 /** |
| 8 * @param {string} url |
| 9 * @param {string=} targetUrl |
| 10 */ |
| 11 function createNetworkRequestForURLAndDumpNameAndPath(url, targetUrl) |
| 8 { | 12 { |
| 13 var mainTarget = WebInspector.targetManager.mainTarget(); |
| 14 var currentTargetURL = mainTarget.inspectedURL(); |
| 15 if (targetUrl) |
| 16 mainTarget.setInspectedURL(targetUrl); |
| 9 InspectorTest.addResult("Dumping request name and path for url: " + url)
; | 17 InspectorTest.addResult("Dumping request name and path for url: " + url)
; |
| 10 var request = new WebInspector.NetworkRequest(WebInspector.targetManager
.mainTarget(), 0, url); | 18 var request = new WebInspector.NetworkRequest(mainTarget, 0, url); |
| 11 InspectorTest.addResult(" name = " + request.name()); | 19 InspectorTest.addResult(" name = " + request.name()); |
| 12 InspectorTest.addResult(" path = " + request.path()); | 20 InspectorTest.addResult(" path = " + request.path()); |
| 21 InspectorTest.addResult(" targetUrl = " + (targetUrl ? targetUrl : cu
rrentTargetURL)); |
| 22 if (targetUrl !== currentTargetURL) |
| 23 mainTarget.setInspectedURL(currentTargetURL); |
| 13 } | 24 } |
| 14 | 25 |
| 26 // Save the target URL to ensure test works well with other tests. |
| 27 var mainTarget = WebInspector.targetManager.mainTarget(); |
| 28 var originalTargetURL = mainTarget.inspectedURL(); |
| 29 mainTarget.setInspectedURL("http://127.0.0.1/aFolder/aTest.html"); |
| 30 |
| 15 createNetworkRequestForURLAndDumpNameAndPath("http://www.example.com/foo/bar
/baz?key=value"); | 31 createNetworkRequestForURLAndDumpNameAndPath("http://www.example.com/foo/bar
/baz?key=value"); |
| 16 createNetworkRequestForURLAndDumpNameAndPath("http://www.example.com/foo/bar
/?key=value"); | 32 createNetworkRequestForURLAndDumpNameAndPath("http://www.example.com/foo/bar
/?key=value"); |
| 17 createNetworkRequestForURLAndDumpNameAndPath("http://www.example.com/foo/bar
/baz"); | 33 createNetworkRequestForURLAndDumpNameAndPath("http://www.example.com/foo/bar
/baz"); |
| 18 createNetworkRequestForURLAndDumpNameAndPath("http://www.example.com/foo/bar
/"); | 34 createNetworkRequestForURLAndDumpNameAndPath("http://www.example.com/foo/bar
/"); |
| 19 | 35 |
| 20 createNetworkRequestForURLAndDumpNameAndPath("http://www.example.com/baz?key
=value"); | 36 createNetworkRequestForURLAndDumpNameAndPath("http://www.example.com/baz?key
=value"); |
| 21 createNetworkRequestForURLAndDumpNameAndPath("http://www.example.com/?key=va
lue"); | 37 createNetworkRequestForURLAndDumpNameAndPath("http://www.example.com/?key=va
lue"); |
| 22 createNetworkRequestForURLAndDumpNameAndPath("http://www.example.com/baz"); | 38 createNetworkRequestForURLAndDumpNameAndPath("http://www.example.com/baz"); |
| 23 createNetworkRequestForURLAndDumpNameAndPath("http://www.example.com/"); | 39 createNetworkRequestForURLAndDumpNameAndPath("http://www.example.com/"); |
| 24 | 40 |
| 25 createNetworkRequestForURLAndDumpNameAndPath("http://127.0.0.1/foo/bar/baz?k
ey=value"); | 41 createNetworkRequestForURLAndDumpNameAndPath("http://127.0.0.1/foo/bar/baz?k
ey=value"); |
| 26 createNetworkRequestForURLAndDumpNameAndPath("http://127.0.0.1/foo/bar/?key=
value"); | 42 createNetworkRequestForURLAndDumpNameAndPath("http://127.0.0.1/foo/bar/?key=
value"); |
| 27 createNetworkRequestForURLAndDumpNameAndPath("http://127.0.0.1/foo/bar/baz")
; | 43 createNetworkRequestForURLAndDumpNameAndPath("http://127.0.0.1/foo/bar/baz")
; |
| 28 createNetworkRequestForURLAndDumpNameAndPath("http://127.0.0.1/foo/bar/"); | 44 createNetworkRequestForURLAndDumpNameAndPath("http://127.0.0.1/foo/bar/"); |
| 29 | 45 |
| 30 createNetworkRequestForURLAndDumpNameAndPath("http://127.0.0.1/baz?key=value
"); | 46 createNetworkRequestForURLAndDumpNameAndPath("http://127.0.0.1/baz?key=value
"); |
| 31 createNetworkRequestForURLAndDumpNameAndPath("http://127.0.0.1/?key=value"); | 47 createNetworkRequestForURLAndDumpNameAndPath("http://127.0.0.1/?key=value"); |
| 32 createNetworkRequestForURLAndDumpNameAndPath("http://127.0.0.1/baz"); | 48 createNetworkRequestForURLAndDumpNameAndPath("http://127.0.0.1/baz"); |
| 33 createNetworkRequestForURLAndDumpNameAndPath("http://127.0.0.1/"); | 49 createNetworkRequestForURLAndDumpNameAndPath("http://127.0.0.1/"); |
| 50 createNetworkRequestForURLAndDumpNameAndPath("http://127.0.0.1/", "data:text
/html,<html><body><img src=\"data:,foobar\" /></body></html>"); |
| 51 createNetworkRequestForURLAndDumpNameAndPath("data:text/html,<html><body><im
g src=\"data:,foobar\" /></body></html>", "data:text/html,<html><body><img src=\
"data:,foobar\" /></body></html>"); |
| 52 createNetworkRequestForURLAndDumpNameAndPath("data:text/html,<html><body><im
g src=\"data:,foobar\" /></body></html>", "http://127.0.0.1/"); |
| 53 |
| 54 // Restore the target URL to ensure test works well with other tests. |
| 55 mainTarget.setInspectedURL(originalTargetURL); |
| 34 | 56 |
| 35 InspectorTest.completeTest(); | 57 InspectorTest.completeTest(); |
| 36 } | 58 } |
| 37 | 59 |
| 38 </script> | 60 </script> |
| 39 </head> | 61 </head> |
| 40 <body onload="runTest()"> | 62 <body onload="runTest()"> |
| 41 <p>Tests name() and path() methods of NetworkRequest.</p> | 63 <p>Tests name() and path() methods of NetworkRequest.</p> |
| 42 <a href="https://bugs.webkit.org/show_bug.cgi?id=101064">Bug 101064</a> | 64 <a href="https://bugs.webkit.org/show_bug.cgi?id=101064">Bug 101064</a> |
| 43 </body> | 65 </body> |
| 44 </html> | 66 </html> |
| OLD | NEW |