Changeset 209143 in webkit
- Timestamp:
- Nov 30, 2016, 11:48:04 AM (9 years ago)
- Location:
- trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r209140 r209143 1 2016-11-30 Joseph Pecoraro <pecoraro@apple.com> 2 3 Web Inspector: Clicking on link in Web Inspector can cause UIProcess to crash 4 https://bugs.webkit.org/show_bug.cgi?id=165157 5 <rdar://problem/27896562> 6 7 Reviewed by Brian Burg. 8 9 * inspector/unit-tests/url-utilities-expected.txt: 10 * inspector/unit-tests/url-utilities.html: 11 Add some tests for expected valid and invalid parseURL cases. 12 Note some cases that we don't handle properly and would benefit 13 by switching to URL constructor which is a much larger change. 14 1 15 2016-11-30 Dave Hyatt <hyatt@apple.com> 2 16 -
trunk/LayoutTests/inspector/unit-tests/url-utilities-expected.txt
r196654 r209143 1 1 2 2 == Running test suite: URLUtilities 3 -- Running test case: parseURL 4 5 Test Invalid: a 6 PASS: Should not be a complete URL 7 PASS: URL constructor thinks this is invalid 8 9 Test Invalid: /http://example.com 10 PASS: Should not be a complete URL 11 PASS: URL constructor thinks this is invalid 12 13 Test Valid: http://example.com 14 PASS: scheme should be: 'http' 15 PASS: host should be: 'example.com' 16 PASS: port should be: 'null' 17 PASS: path should be: 'null' 18 PASS: queryString should be: 'null' 19 PASS: fragment should be: 'null' 20 PASS: lastPathComponent should be: 'null' 21 22 Test Valid: http://example.com/ 23 PASS: scheme should be: 'http' 24 PASS: host should be: 'example.com' 25 PASS: port should be: 'null' 26 PASS: path should be: '/' 27 PASS: queryString should be: 'null' 28 PASS: fragment should be: 'null' 29 PASS: lastPathComponent should be: 'null' 30 31 Test Valid: http://example.com:80/ 32 PASS: scheme should be: 'http' 33 PASS: host should be: 'example.com' 34 PASS: port should be: '80' 35 PASS: path should be: '/' 36 PASS: queryString should be: 'null' 37 PASS: fragment should be: 'null' 38 PASS: lastPathComponent should be: 'null' 39 40 Test Valid: http://example.com/path/to/page.html 41 PASS: scheme should be: 'http' 42 PASS: host should be: 'example.com' 43 PASS: port should be: 'null' 44 PASS: path should be: '/path/to/page.html' 45 PASS: queryString should be: 'null' 46 PASS: fragment should be: 'null' 47 PASS: lastPathComponent should be: 'page.html' 48 49 Test Valid: http://example.com/path/to/page.html? 50 PASS: scheme should be: 'http' 51 PASS: host should be: 'example.com' 52 PASS: port should be: 'null' 53 PASS: path should be: '/path/to/page.html' 54 PASS: queryString should be: '' 55 PASS: fragment should be: 'null' 56 PASS: lastPathComponent should be: 'page.html' 57 58 Test Valid: http://example.com/path/to/page.html?a=1 59 PASS: scheme should be: 'http' 60 PASS: host should be: 'example.com' 61 PASS: port should be: 'null' 62 PASS: path should be: '/path/to/page.html' 63 PASS: queryString should be: 'a=1' 64 PASS: fragment should be: 'null' 65 PASS: lastPathComponent should be: 'page.html' 66 67 Test Valid: http://example.com/path/to/page.html?a=1&b=2 68 PASS: scheme should be: 'http' 69 PASS: host should be: 'example.com' 70 PASS: port should be: 'null' 71 PASS: path should be: '/path/to/page.html' 72 PASS: queryString should be: 'a=1&b=2' 73 PASS: fragment should be: 'null' 74 PASS: lastPathComponent should be: 'page.html' 75 76 Test Valid: http://example.com/path/to/page.html?a=1&b=2#test 77 PASS: scheme should be: 'http' 78 PASS: host should be: 'example.com' 79 PASS: port should be: 'null' 80 PASS: path should be: '/path/to/page.html' 81 PASS: queryString should be: 'a=1&b=2' 82 PASS: fragment should be: 'test' 83 PASS: lastPathComponent should be: 'page.html' 84 85 Test Valid: http://example.com:123/path/to/page.html?a=1&b=2#test 86 PASS: scheme should be: 'http' 87 PASS: host should be: 'example.com' 88 PASS: port should be: '123' 89 PASS: path should be: '/path/to/page.html' 90 PASS: queryString should be: 'a=1&b=2' 91 PASS: fragment should be: 'test' 92 PASS: lastPathComponent should be: 'page.html' 93 94 Test Valid: http://example.com/path/to/page.html#test 95 PASS: scheme should be: 'http' 96 PASS: host should be: 'example.com' 97 PASS: port should be: 'null' 98 PASS: path should be: '/path/to/page.html' 99 PASS: queryString should be: 'null' 100 PASS: fragment should be: 'test' 101 PASS: lastPathComponent should be: 'page.html' 102 103 Test Valid: http://example.com#alpha/beta 104 PASS: scheme should be: 'http' 105 PASS: host should be: 'example.com' 106 PASS: port should be: 'null' 107 PASS: path should be: 'null' 108 PASS: queryString should be: 'null' 109 PASS: fragment should be: 'alpha/beta' 110 PASS: lastPathComponent should be: 'null' 111 112 Test Valid: app-specific://example.com 113 PASS: scheme should be: 'app-specific' 114 PASS: host should be: 'example.com' 115 PASS: port should be: 'null' 116 PASS: path should be: 'null' 117 PASS: queryString should be: 'null' 118 PASS: fragment should be: 'null' 119 PASS: lastPathComponent should be: 'null' 120 121 Test Valid: http://example 122 PASS: scheme should be: 'http' 123 PASS: host should be: 'example' 124 PASS: port should be: 'null' 125 PASS: path should be: 'null' 126 PASS: queryString should be: 'null' 127 PASS: fragment should be: 'null' 128 PASS: lastPathComponent should be: 'null' 129 130 Test Valid: http://my.example.com 131 PASS: scheme should be: 'http' 132 PASS: host should be: 'my.example.com' 133 PASS: port should be: 'null' 134 PASS: path should be: 'null' 135 PASS: queryString should be: 'null' 136 PASS: fragment should be: 'null' 137 PASS: lastPathComponent should be: 'null' 138 139 Test Valid: data:text/plain,test 140 PASS: scheme should be: 'data' 141 PASS: host should be: 'null' 142 PASS: port should be: 'null' 143 PASS: path should be: 'null' 144 PASS: queryString should be: 'null' 145 PASS: fragment should be: 'null' 146 PASS: lastPathComponent should be: 'null' 147 148 -- Known issues <https://webkit.org/b/165155> 149 150 Test Invalid: http:// 151 FAIL: Should not be a complete URL 152 Expected: truthy 153 Actual: false 154 PASS: URL constructor thinks this is invalid 155 156 Test Invalid: http://example.com:999999999 157 FAIL: Should not be a complete URL 158 Expected: truthy 159 Actual: false 160 PASS: URL constructor thinks this is invalid 161 162 Test Valid: http:example.com/ 163 FAIL: scheme should be: 'http' 164 Expected: "http" 165 Actual: null 166 FAIL: host should be: 'example.com' 167 Expected: "example.com" 168 Actual: null 169 PASS: port should be: 'null' 170 FAIL: path should be: '/' 171 Expected: "/" 172 Actual: null 173 PASS: queryString should be: 'null' 174 PASS: fragment should be: 'null' 175 PASS: lastPathComponent should be: 'null' 176 177 Test Valid: http:/example.com/ 178 FAIL: scheme should be: 'http' 179 Expected: "http" 180 Actual: null 181 FAIL: host should be: 'example.com' 182 Expected: "example.com" 183 Actual: null 184 PASS: port should be: 'null' 185 FAIL: path should be: '/' 186 Expected: "/" 187 Actual: null 188 PASS: queryString should be: 'null' 189 PASS: fragment should be: 'null' 190 PASS: lastPathComponent should be: 'null' 191 192 Test Valid: http://user@pass:example.com/ 193 FAIL: scheme should be: 'http' 194 Expected: "http" 195 Actual: null 196 FAIL: host should be: 'example.com' 197 Expected: "example.com" 198 Actual: null 199 PASS: port should be: 'null' 200 FAIL: path should be: '/' 201 Expected: "/" 202 Actual: null 203 PASS: queryString should be: 'null' 204 PASS: fragment should be: 'null' 205 PASS: lastPathComponent should be: 'null' 206 207 Test Valid: http://example.com?key=alpha/beta 208 PASS: scheme should be: 'http' 209 FAIL: host should be: 'example.com' 210 Expected: "example.com" 211 Actual: "example.com?key=alpha" 212 PASS: port should be: 'null' 213 FAIL: path should be: 'null' 214 Expected: null 215 Actual: "/beta" 216 FAIL: queryString should be: 'key=alpha/beta' 217 Expected: "key=alpha/beta" 218 Actual: null 219 PASS: fragment should be: 'null' 220 FAIL: lastPathComponent should be: 'null' 221 Expected: null 222 Actual: "beta" 223 3 224 -- Running test case: parseDataURL 4 Test: https://webkit.org 225 226 Test Invalid: https://webkit.org 5 227 PASS: Should not be a data URL 6 Test: data: 228 229 Test Invalid: data: 7 230 PASS: Should not be a data URL 8 Test: data:text/plain;test 231 232 Test Invalid: data:text/plain;test 9 233 PASS: Should not be a data URL 10 Test: data:text/plain;base64;test 234 235 Test Invalid: data:text/plain;base64;test 11 236 PASS: Should not be a data URL 12 237 13 Test: data:, 238 Test Valid: data:, 239 PASS: scheme should always be 'data' 14 240 PASS: mimeType should be: 'text/plain' 15 241 PASS: charset should be: 'US-ASCII' … … 18 244 PASS: Resolved content should be: '' 19 245 20 Test: data:,test 246 Test Valid: data:,test 247 PASS: scheme should always be 'data' 21 248 PASS: mimeType should be: 'text/plain' 22 249 PASS: charset should be: 'US-ASCII' … … 25 252 PASS: Resolved content should be: 'test' 26 253 27 Test: data:text/plain,test 254 Test Valid: data:text/plain,test 255 PASS: scheme should always be 'data' 28 256 PASS: mimeType should be: 'text/plain' 29 257 PASS: charset should be: 'US-ASCII' … … 32 260 PASS: Resolved content should be: 'test' 33 261 34 Test: data:text/plain;charset=TEST,test 262 Test Valid: data:text/plain;charset=TEST,test 263 PASS: scheme should always be 'data' 35 264 PASS: mimeType should be: 'text/plain' 36 265 PASS: charset should be: 'TEST' … … 39 268 PASS: Resolved content should be: 'test' 40 269 41 Test: data:application/json,{"name":"test","list":[1,2,3]} 270 Test Valid: data:application/json,{"name":"test","list":[1,2,3]} 271 PASS: scheme should always be 'data' 42 272 PASS: mimeType should be: 'application/json' 43 273 PASS: charset should be: 'US-ASCII' … … 46 276 PASS: Resolved content should be: '{"name":"test","list":[1,2,3]}' 47 277 48 Test: data:application/json,%7B%22name%22%3A%22test%22%2C%22list%22%3A%5B1%2C2%2C3%5D%7D 278 Test Valid: data:application/json,%7B%22name%22%3A%22test%22%2C%22list%22%3A%5B1%2C2%2C3%5D%7D 279 PASS: scheme should always be 'data' 49 280 PASS: mimeType should be: 'application/json' 50 281 PASS: charset should be: 'US-ASCII' … … 53 284 PASS: Resolved content should be: '{"name":"test","list":[1,2,3]}' 54 285 55 Test: data:application/json;base64,eyJuYW1lIjoidGVzdCIsImxpc3QiOlsxLDIsM119 286 Test Valid: data:application/json;base64,eyJuYW1lIjoidGVzdCIsImxpc3QiOlsxLDIsM119 287 PASS: scheme should always be 'data' 56 288 PASS: mimeType should be: 'application/json' 57 289 PASS: charset should be: 'US-ASCII' … … 60 292 PASS: Resolved content should be: '{"name":"test","list":[1,2,3]}' 61 293 62 Test: data:application/json;charset=utf-8;base64,eyJuYW1lIjoidGVzdCIsImxpc3QiOlsxLDIsM119 294 Test Valid: data:application/json;charset=utf-8;base64,eyJuYW1lIjoidGVzdCIsImxpc3QiOlsxLDIsM119 295 PASS: scheme should always be 'data' 63 296 PASS: mimeType should be: 'application/json' 64 297 PASS: charset should be: 'utf-8' … … 67 300 PASS: Resolved content should be: '{"name":"test","list":[1,2,3]}' 68 301 69 Test: data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg== 302 Test Valid: data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg== 303 PASS: scheme should always be 'data' 70 304 PASS: mimeType should be: 'image/png' 71 305 PASS: charset should be: 'US-ASCII' -
trunk/LayoutTests/inspector/unit-tests/url-utilities.html
r196654 r209143 9 9 10 10 suite.addTestCase({ 11 name: "parseURL", 12 test() { 13 function testInvalid(url) { 14 InspectorTest.log(""); 15 InspectorTest.log("Test Invalid: " + url); 16 InspectorTest.expectThat(parseURL(url).scheme === null, "Should not be a complete URL"); 17 18 try { 19 new URL(url); 20 InspectorTest.fail("URL constructor thinks this is valid"); 21 } catch (e) { 22 InspectorTest.pass("URL constructor thinks this is invalid"); 23 } 24 } 25 26 function testValid(url, expected) { 27 InspectorTest.log(""); 28 InspectorTest.log("Test Valid: " + url); 29 30 let {scheme: expectedScheme, host: expectedHost, port: expectedPort, path: expectedPath, queryString: expectedQueryString, fragment: expectedFragment, lastPathComponent: expectedLastPathComponent} = expected; 31 let {scheme: actualScheme, host: actualHost, port: actualPort, path: actualPath, queryString: actualQueryString, fragment: actualFragment, lastPathComponent: actualLastPathComponent} = parseURL(url); 32 33 InspectorTest.expectEqual(actualScheme, expectedScheme, `scheme should be: '${expectedScheme}'`); 34 InspectorTest.expectEqual(actualHost, expectedHost, `host should be: '${expectedHost}'`); 35 InspectorTest.expectEqual(actualPort, expectedPort, `port should be: '${expectedPort}'`); 36 InspectorTest.expectEqual(actualPath, expectedPath, `path should be: '${expectedPath}'`); 37 InspectorTest.expectEqual(actualQueryString, expectedQueryString, `queryString should be: '${expectedQueryString}'`); 38 InspectorTest.expectEqual(actualFragment, expectedFragment, `fragment should be: '${expectedFragment}'`); 39 InspectorTest.expectEqual(actualLastPathComponent, expectedLastPathComponent, `lastPathComponent should be: '${expectedLastPathComponent}'`); 40 } 41 42 testInvalid("a"); 43 testInvalid("/http://example.com"); 44 45 testValid("http://example.com", { 46 scheme: "http", 47 host: "example.com", 48 port: null, 49 path: null, 50 queryString: null, 51 fragment: null, 52 lastPathComponent: null, 53 }); 54 55 testValid("http://example.com/", { 56 scheme: "http", 57 host: "example.com", 58 port: null, 59 path: "/", 60 queryString: null, 61 fragment: null, 62 lastPathComponent: null, 63 }); 64 65 testValid("http://example.com:80/", { 66 scheme: "http", 67 host: "example.com", 68 port: 80, 69 path: "/", 70 queryString: null, 71 fragment: null, 72 lastPathComponent: null, 73 }); 74 75 testValid("http://example.com/path/to/page.html", { 76 scheme: "http", 77 host: "example.com", 78 port: null, 79 path: "/path/to/page.html", 80 queryString: null, 81 fragment: null, 82 lastPathComponent: "page.html", 83 }); 84 85 testValid("http://example.com/path/to/page.html?", { 86 scheme: "http", 87 host: "example.com", 88 port: null, 89 path: "/path/to/page.html", 90 queryString: "", 91 fragment: null, 92 lastPathComponent: "page.html", 93 }); 94 95 testValid("http://example.com/path/to/page.html?a=1", { 96 scheme: "http", 97 host: "example.com", 98 port: null, 99 path: "/path/to/page.html", 100 queryString: "a=1", 101 fragment: null, 102 lastPathComponent: "page.html", 103 }); 104 105 testValid("http://example.com/path/to/page.html?a=1&b=2", { 106 scheme: "http", 107 host: "example.com", 108 port: null, 109 path: "/path/to/page.html", 110 queryString: "a=1&b=2", 111 fragment: null, 112 lastPathComponent: "page.html", 113 }); 114 115 testValid("http://example.com/path/to/page.html?a=1&b=2#test", { 116 scheme: "http", 117 host: "example.com", 118 port: null, 119 path: "/path/to/page.html", 120 queryString: "a=1&b=2", 121 fragment: "test", 122 lastPathComponent: "page.html", 123 }); 124 125 testValid("http://example.com:123/path/to/page.html?a=1&b=2#test", { 126 scheme: "http", 127 host: "example.com", 128 port: 123, 129 path: "/path/to/page.html", 130 queryString: "a=1&b=2", 131 fragment: "test", 132 lastPathComponent: "page.html", 133 }); 134 135 testValid("http://example.com/path/to/page.html#test", { 136 scheme: "http", 137 host: "example.com", 138 port: null, 139 path: "/path/to/page.html", 140 queryString: null, 141 fragment: "test", 142 lastPathComponent: "page.html", 143 }); 144 145 testValid("http://example.com#alpha/beta", { 146 scheme: "http", 147 host: "example.com", 148 port: null, 149 path: null, 150 queryString: null, 151 fragment: "alpha/beta", 152 lastPathComponent: null, 153 }); 154 155 testValid("app-specific://example.com", { 156 scheme: "app-specific", 157 host: "example.com", 158 port: null, 159 path: null, 160 queryString: null, 161 fragment: null, 162 lastPathComponent: null, 163 }); 164 165 testValid("http://example", { 166 scheme: "http", 167 host: "example", 168 port: null, 169 path: null, 170 queryString: null, 171 fragment: null, 172 lastPathComponent: null, 173 }); 174 175 testValid("http://my.example.com", { 176 scheme: "http", 177 host: "my.example.com", 178 port: null, 179 path: null, 180 queryString: null, 181 fragment: null, 182 lastPathComponent: null, 183 }); 184 185 // Data URLs just spit back the scheme. 186 testValid("data:text/plain,test", { 187 scheme: "data", 188 host: null, 189 port: null, 190 path: null, 191 queryString: null, 192 fragment: null, 193 lastPathComponent: null, 194 }); 195 196 // FIXME: <https://webkit.org/b/165155> Web Inspector: Use URL constructor to better handle all kinds of URLs 197 InspectorTest.log(""); 198 InspectorTest.log("-- Known issues <https://webkit.org/b/165155>"); 199 200 testInvalid("http://"); 201 testInvalid("http://example.com:999999999"); 202 203 testValid("http:example.com/", { 204 scheme: "http", 205 host: "example.com", 206 port: null, 207 path: "/", 208 queryString: null, 209 fragment: null, 210 lastPathComponent: null, 211 }); 212 213 testValid("http:/example.com/", { 214 scheme: "http", 215 host: "example.com", 216 port: null, 217 path: "/", 218 queryString: null, 219 fragment: null, 220 lastPathComponent: null, 221 }); 222 223 testValid("http://user@pass:example.com/", { 224 scheme: "http", 225 host: "example.com", 226 port: null, 227 path: "/", 228 queryString: null, 229 fragment: null, 230 lastPathComponent: null, 231 }); 232 233 testValid("http://example.com?key=alpha/beta", { 234 scheme: "http", 235 host: "example.com", 236 port: null, 237 path: null, 238 queryString: "key=alpha/beta", 239 fragment: null, 240 lastPathComponent: null, 241 }); 242 243 return true; 244 } 245 }); 246 247 248 suite.addTestCase({ 11 249 name: "parseDataURL", 12 test : () =>{250 test() { 13 251 function testInvalid(url) { 14 InspectorTest.log("Test: " + url); 252 InspectorTest.log(""); 253 InspectorTest.log("Test Invalid: " + url); 15 254 InspectorTest.expectThat(parseDataURL(url) === null, "Should not be a data URL"); 16 255 } … … 18 257 function testValid(url, expected) { 19 258 InspectorTest.log(""); 20 InspectorTest.log("Test : " + url);259 InspectorTest.log("Test Valid: " + url); 21 260 22 261 let {mimeType: expectedMimeType, charset: expectedCharset, base64: expectedBase64, data: expectedData, content: expectedContent} = expected; … … 26 265 actualContent = atob(actualContent); 27 266 28 InspectorTest. assert(actualScheme ==="data", "scheme should always be 'data'");29 InspectorTest.expect That(actualMimeType ===expectedMimeType, `mimeType should be: '${expectedMimeType}'`);30 InspectorTest.expect That(actualCharset ===expectedCharset, `charset should be: '${expectedCharset}'`);31 InspectorTest.expect That(actualBase64 ===expectedBase64, `base64 should be: '${expectedBase64}'`);32 InspectorTest.expect That(actualData ===expectedData, `data should be: '${expectedData}'`);267 InspectorTest.expectEqual(actualScheme, "data", "scheme should always be 'data'"); 268 InspectorTest.expectEqual(actualMimeType, expectedMimeType, `mimeType should be: '${expectedMimeType}'`); 269 InspectorTest.expectEqual(actualCharset, expectedCharset, `charset should be: '${expectedCharset}'`); 270 InspectorTest.expectEqual(actualBase64, expectedBase64, `base64 should be: '${expectedBase64}'`); 271 InspectorTest.expectEqual(actualData, expectedData, `data should be: '${expectedData}'`); 33 272 if (expectedContent !== null) 34 273 InspectorTest.expectThat(actualContent === expectedContent, `Resolved content should be: '${expectedContent}'`); -
trunk/Source/WebInspectorUI/ChangeLog
r209115 r209143 1 2016-11-30 Joseph Pecoraro <pecoraro@apple.com> 2 3 Web Inspector: Clicking on link in Web Inspector can cause UIProcess to crash 4 https://bugs.webkit.org/show_bug.cgi?id=165157 5 <rdar://problem/27896562> 6 7 Reviewed by Brian Burg. 8 9 By correctly disallowing slashes in the scheme Web Inspector resolves 10 the correct absolute URL and doesn't end up trying to navigate to an 11 incorrect file URL. 12 13 * UserInterface/Base/URLUtilities.js: 14 (parseURL): 15 Disallow "/" characters in the scheme portion. (/http://example.com) 16 Allow path to be optional before a fragment portion. (http://example.com#frag) 17 1 18 2016-11-29 Joseph Pecoraro <pecoraro@apple.com> 2 19 -
trunk/Source/WebInspectorUI/UserInterface/Base/URLUtilities.js
r196654 r209143 24 24 */ 25 25 26 // FIXME: <https://webkit.org/b/165155> Web Inspector: Use URL constructor to better handle all kinds of URLs 27 26 28 function removeURLFragment(url) 27 29 { … … 97 99 return {scheme: "data", host: null, port: null, path: null, queryString: null, fragment: null, lastPathComponent: null}; 98 100 99 var match = url.match(/^([^ :]+):\/\/([^\/:]*)(?::([\d]+))?(?:(\/[^#]*)(?:#(.*))?)?$/i);101 var match = url.match(/^([^\/:]+):\/\/([^\/#:]*)(?::([\d]+))?(?:(\/[^#]*)?(?:#(.*))?)?$/i); 100 102 if (!match) 101 103 return {scheme: null, host: null, port: null, path: null, queryString: null, fragment: null, lastPathComponent: null};
Note:
See TracChangeset
for help on using the changeset viewer.