Changeset 223135 in webkit
- Timestamp:
- Oct 10, 2017 11:42:34 AM (7 years ago)
- Location:
- trunk
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r223134 r223135 1 2017-10-10 Chris Dumez <cdumez@apple.com> 2 3 Entries API should recognize path starting with 2 slashes as valid absolute path 4 https://bugs.webkit.org/show_bug.cgi?id=178135 5 6 Reviewed by Ryosuke Niwa. 7 8 Add layout test coverage. 9 10 * editing/pasteboard/entries-api/datatransfer-items-drop-getDirectory-expected.txt: 11 * editing/pasteboard/entries-api/datatransfer-items-drop-getDirectory.html: 12 * editing/pasteboard/entries-api/datatransfer-items-drop-getFile-expected.txt: 13 * editing/pasteboard/entries-api/datatransfer-items-drop-getFile.html: 14 1 15 2017-10-10 Matt Lewis <jlewis3@apple.com> 2 16 -
trunk/LayoutTests/editing/pasteboard/entries-api/datatransfer-items-drop-getDirectory-expected.txt
r223118 r223135 63 63 PASS testFilesEntry.name is "testFiles" 64 64 PASS testFilesEntry.fullPath is "/testFiles" 65 * Edge case: calling getDirectory() with path starting with 2 slashes 66 PASS testFilesEntry.isFile is false 67 PASS testFilesEntry.isDirectory is true 68 PASS testFilesEntry.name is "subfolder1" 69 PASS testFilesEntry.fullPath is "/testFiles/subfolder1" 70 * Edge case: calling getDirectory() with path starting with 2 slashes and containing 2 following slashes 71 PASS testFilesEntry.isFile is false 72 PASS testFilesEntry.isDirectory is true 73 PASS testFilesEntry.name is "subfolder1" 74 PASS testFilesEntry.fullPath is "/testFiles/subfolder1" 65 75 PASS successfullyParsed is true 66 76 -
trunk/LayoutTests/editing/pasteboard/entries-api/datatransfer-items-drop-getDirectory.html
r223118 r223135 201 201 }, e => { 202 202 testFailed("getDirectory('.') should succeed"); 203 }); 204 } 205 206 function test17() { 207 debug("* Edge case: calling getDirectory() with path starting with 2 slashes"); 208 return getDirectoryAsPromise(directoryEntry, '//testFiles/subfolder1', {}).then(entry => { 209 testFilesEntry = entry; 210 shouldBeFalse("testFilesEntry.isFile"); 211 shouldBeTrue("testFilesEntry.isDirectory"); 212 shouldBeEqualToString("testFilesEntry.name", "subfolder1"); 213 shouldBeEqualToString("testFilesEntry.fullPath", "/testFiles/subfolder1"); 214 }, e => { 215 testFailed("getDirectory('//testFiles/subfolder1') should succeed"); 216 }); 217 } 218 219 function test18() { 220 debug("* Edge case: calling getDirectory() with path starting with 2 slashes and containing 2 following slashes"); 221 return getDirectoryAsPromise(directoryEntry, '//testFiles//subfolder1', {}).then(entry => { 222 testFilesEntry = entry; 223 shouldBeFalse("testFilesEntry.isFile"); 224 shouldBeTrue("testFilesEntry.isDirectory"); 225 shouldBeEqualToString("testFilesEntry.name", "subfolder1"); 226 shouldBeEqualToString("testFilesEntry.fullPath", "/testFiles/subfolder1"); 227 }, e => { 228 testFailed("getDirectory('//testFiles//subfolder1') should succeed"); 203 229 }); 204 230 } … … 228 254 .then(test15) 229 255 .then(test16) 256 .then(test17) 257 .then(test18) 230 258 .then(finishJSTest); 231 259 }; -
trunk/LayoutTests/editing/pasteboard/entries-api/datatransfer-items-drop-getFile-expected.txt
r221556 r223135 43 43 * Error case: calling getFile() with empty path 44 44 PASS ex.name is "TypeMismatchError" 45 * Edge case: calling getFile() with absolute path starting with 2 slashes 46 PASS file1Entry.name is "file1.txt" 47 PASS file1Entry.fullPath is "/testFiles/file1.txt" 48 PASS file1Entry.isFile is true 49 * Edge case: calling getFile() with absolute path starting with 2 slashes and containing 2 following slashes 50 PASS file1Entry.name is "file1.txt" 51 PASS file1Entry.fullPath is "/testFiles/file1.txt" 52 PASS file1Entry.isFile is true 45 53 PASS successfullyParsed is true 46 54 -
trunk/LayoutTests/editing/pasteboard/entries-api/datatransfer-items-drop-getFile.html
r221556 r223135 157 157 ex = e; 158 158 shouldBeEqualToString("ex.name", "TypeMismatchError"); 159 }); 160 } 161 162 function test14() { 163 debug("* Edge case: calling getFile() with absolute path starting with 2 slashes"); 164 return getFileAsPromise(directoryEntry, "//testFiles/file1.txt", {}).then(entry => { 165 file1Entry = entry; 166 shouldBeEqualToString("file1Entry.name", "file1.txt"); 167 shouldBeEqualToString("file1Entry.fullPath", "/testFiles/file1.txt"); 168 shouldBeTrue("file1Entry.isFile"); 169 }, e => { 170 testFailed("getFile('//testFiles/file1.txt') should succeed"); 171 }); 172 } 173 174 function test15() { 175 debug("* Edge case: calling getFile() with absolute path starting with 2 slashes and containing 2 following slashes"); 176 return getFileAsPromise(directoryEntry, "//testFiles//file1.txt", {}).then(entry => { 177 file1Entry = entry; 178 shouldBeEqualToString("file1Entry.name", "file1.txt"); 179 shouldBeEqualToString("file1Entry.fullPath", "/testFiles/file1.txt"); 180 shouldBeTrue("file1Entry.isFile"); 181 }, e => { 182 testFailed("getFile('//testFiles//file1.txt') should succeed"); 159 183 }); 160 184 } … … 181 205 .then(test12) 182 206 .then(test13) 207 .then(test14) 208 .then(test15) 183 209 .then(finishJSTest); 184 210 }; -
trunk/Source/WebCore/ChangeLog
r223134 r223135 1 2017-10-10 Chris Dumez <cdumez@apple.com> 2 3 Entries API should recognize path starting with 2 slashes as valid absolute path 4 https://bugs.webkit.org/show_bug.cgi?id=178135 5 6 Reviewed by Ryosuke Niwa. 7 8 Entries API should recognize paths starting with 2 slashes as valid absolute paths to match Chrome's behavior. 9 See https://github.com/WICG/entries-api/commit/990454758005a6039655835503d551015e346d9d 10 11 This was causing us to fail some manual web-platform-tests. 12 13 No new tests, updated existing tests. 14 15 * Modules/entriesapi/DOMFileSystem.cpp: 16 (WebCore::isValidPathSegment): 17 (WebCore::isZeroOrMorePathSegmentsSeparatedBySlashes): 18 (WebCore::isValidRelativeVirtualPath): 19 (WebCore::isValidVirtualPath): 20 1 21 2017-10-10 Matt Lewis <jlewis3@apple.com> 2 22 -
trunk/Source/WebCore/Modules/entriesapi/DOMFileSystem.cpp
r223118 r223135 97 97 static bool isValidPathSegment(StringView segment) 98 98 { 99 ASSERT(!segment.isEmpty()); 100 if (segment == "." || segment == "..") 99 if (segment.isEmpty() || segment == "." || segment == "..") 101 100 return true; 102 101 … … 108 107 } 109 108 110 // https://wicg.github.io/entries-api/#relative-path 111 static bool isValidRelativeVirtualPath(StringView virtualPath) 112 { 113 if (virtualPath.isEmpty()) 114 return false; 115 116 if (virtualPath[0] == '/') 117 return false; 118 119 auto segments = virtualPath.split('/'); 109 static bool isZeroOrMorePathSegmentsSeparatedBySlashes(StringView string) 110 { 111 auto segments = string.split('/'); 120 112 for (auto segment : segments) { 121 113 if (!isValidPathSegment(segment)) … … 125 117 } 126 118 119 // https://wicg.github.io/entries-api/#relative-path 120 static bool isValidRelativeVirtualPath(StringView virtualPath) 121 { 122 if (virtualPath.isEmpty()) 123 return false; 124 125 if (virtualPath[0] == '/') 126 return false; 127 128 return isZeroOrMorePathSegmentsSeparatedBySlashes(virtualPath); 129 } 130 127 131 // https://wicg.github.io/entries-api/#valid-path 128 132 static bool isValidVirtualPath(StringView virtualPath) … … 130 134 if (virtualPath.isEmpty()) 131 135 return true; 132 if (virtualPath[0] == '/') 133 return virtualPath.length() == 1 || isValidRelativeVirtualPath(virtualPath.substring(1)); 136 if (virtualPath[0] == '/') { 137 // An absolute path is a string consisting of '/' (U+002F SOLIDUS) followed by one or more path segments joined by '/' (U+002F SOLIDUS). 138 return isZeroOrMorePathSegmentsSeparatedBySlashes(virtualPath.substring(1)); 139 } 134 140 return isValidRelativeVirtualPath(virtualPath); 135 141 }
Note: See TracChangeset
for help on using the changeset viewer.