Title: [232417] trunk/LayoutTests
Revision
232417
Author
[email protected]
Date
2018-06-01 14:28:40 -0700 (Fri, 01 Jun 2018)

Log Message

Some tests for webkitdirectory API fail when tests are in an APFS file system
https://bugs.webkit.org/show_bug.cgi?id=186184

Reviewed by Chris Dumez.

On an APFS volume, files may not be listed in the lexicologically order and the size of a directory
may defer from that of HFS+. To make the test results consistent on either file systems,
sort file entries lexicologically by the name and list two possible directory sizes as the expectation.

Added a new helper function, shouldBeOneOfValues, which takes an array of values as the expectation.

* editing/pasteboard/entries-api/datatransfer-items-drop-directoryReader.html:
* editing/pasteboard/entries-api/datatransfer-items-drop-getAsEntry-expected.txt:
* editing/pasteboard/entries-api/datatransfer-items-drop-getAsEntry.html:
* fast/forms/file/entries-api/drag-folder-webkitEntries-expected.txt:
* fast/forms/file/entries-api/drag-folder-webkitEntries.html:
* fast/forms/file/entries-api/webkitdirectory-drag-folder.html:
* resources/js-test.js:
(shouldBeOneOfValues): Added.

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (232416 => 232417)


--- trunk/LayoutTests/ChangeLog	2018-06-01 20:58:27 UTC (rev 232416)
+++ trunk/LayoutTests/ChangeLog	2018-06-01 21:28:40 UTC (rev 232417)
@@ -1,3 +1,25 @@
+2018-05-31  Ryosuke Niwa  <[email protected]>
+
+        Some tests for webkitdirectory API fail when tests are in an APFS file system
+        https://bugs.webkit.org/show_bug.cgi?id=186184
+
+        Reviewed by Chris Dumez.
+
+        On an APFS volume, files may not be listed in the lexicologically order and the size of a directory
+        may defer from that of HFS+. To make the test results consistent on either file systems,
+        sort file entries lexicologically by the name and list two possible directory sizes as the expectation.
+
+        Added a new helper function, shouldBeOneOfValues, which takes an array of values as the expectation.
+
+        * editing/pasteboard/entries-api/datatransfer-items-drop-directoryReader.html:
+        * editing/pasteboard/entries-api/datatransfer-items-drop-getAsEntry-expected.txt:
+        * editing/pasteboard/entries-api/datatransfer-items-drop-getAsEntry.html:
+        * fast/forms/file/entries-api/drag-folder-webkitEntries-expected.txt:
+        * fast/forms/file/entries-api/drag-folder-webkitEntries.html:
+        * fast/forms/file/entries-api/webkitdirectory-drag-folder.html:
+        * resources/js-test.js:
+        (shouldBeOneOfValues): Added.
+
 2018-06-01  Daniel Bates  <[email protected]>
 
         http/tests/inspector/network/har/har-page.html should actually sort dumped cookies by name

Modified: trunk/LayoutTests/editing/pasteboard/entries-api/datatransfer-items-drop-directoryReader.html (232416 => 232417)


--- trunk/LayoutTests/editing/pasteboard/entries-api/datatransfer-items-drop-directoryReader.html	2018-06-01 20:58:27 UTC (rev 232416)
+++ trunk/LayoutTests/editing/pasteboard/entries-api/datatransfer-items-drop-directoryReader.html	2018-06-01 21:28:40 UTC (rev 232417)
@@ -20,7 +20,13 @@
                 entries.forEach(e => result.push(e));
                 doBatch();
             } else {
-                resolve(result);
+                resolve(result.sort(function (a, b) {
+                    if (a.name > b.name)
+                        return 1;
+                    else if (a.name < b.name)
+                        return -1;
+                    return 0;
+                }));
             }
         }, reject);
     };

Modified: trunk/LayoutTests/editing/pasteboard/entries-api/datatransfer-items-drop-getAsEntry-expected.txt (232416 => 232417)


--- trunk/LayoutTests/editing/pasteboard/entries-api/datatransfer-items-drop-getAsEntry-expected.txt	2018-06-01 20:58:27 UTC (rev 232416)
+++ trunk/LayoutTests/editing/pasteboard/entries-api/datatransfer-items-drop-getAsEntry-expected.txt	2018-06-01 21:28:40 UTC (rev 232417)
@@ -16,7 +16,7 @@
 PASS secondDataTransferItem.kind is "file"
 PASS secondDataTransferItem.type is ""
 PASS secondFile.name is "testFiles"
-PASS secondFile.size is 272
+PASS secondFile.size is one of `272`, and `256`
 PASS secondFile.type is ""
 PASS secondEntry.isDirectory is true
 PASS secondEntry.isFile is false

Modified: trunk/LayoutTests/editing/pasteboard/entries-api/datatransfer-items-drop-getAsEntry.html (232416 => 232417)


--- trunk/LayoutTests/editing/pasteboard/entries-api/datatransfer-items-drop-getAsEntry.html	2018-06-01 20:58:27 UTC (rev 232416)
+++ trunk/LayoutTests/editing/pasteboard/entries-api/datatransfer-items-drop-getAsEntry.html	2018-06-01 21:28:40 UTC (rev 232417)
@@ -37,7 +37,7 @@
     shouldBeEqualToString("secondDataTransferItem.type", "");
     secondFile = secondDataTransferItem.getAsFile();
     shouldBeEqualToString("secondFile.name", "testFiles");
-    shouldBe("secondFile.size", "272"); // Chrome returns folder size, Firefox returns 0.
+    shouldBeOneOfValues("secondFile.size", [272, 256]); // Chrome returns folder size, Firefox returns 0. 256 in APFS, 272 in HFS+ 
     shouldBeEqualToString("secondFile.type", "");
 
     secondEntry = secondDataTransferItem.webkitGetAsEntry();

Modified: trunk/LayoutTests/fast/forms/file/entries-api/drag-folder-webkitEntries-expected.txt (232416 => 232417)


--- trunk/LayoutTests/fast/forms/file/entries-api/drag-folder-webkitEntries-expected.txt	2018-06-01 20:58:27 UTC (rev 232416)
+++ trunk/LayoutTests/fast/forms/file/entries-api/drag-folder-webkitEntries-expected.txt	2018-06-01 21:28:40 UTC (rev 232417)
@@ -16,7 +16,7 @@
 PASS files[0].size is 5
 PASS files[0].type is "text/plain"
 PASS files[1].name is "testFiles"
-PASS files[1].size is 272
+PASS files[1].size is one of `272`, and `256`
 PASS files[1].type is ""
 PASS successfullyParsed is true
 

Modified: trunk/LayoutTests/fast/forms/file/entries-api/drag-folder-webkitEntries.html (232416 => 232417)


--- trunk/LayoutTests/fast/forms/file/entries-api/drag-folder-webkitEntries.html	2018-06-01 20:58:27 UTC (rev 232416)
+++ trunk/LayoutTests/fast/forms/file/entries-api/drag-folder-webkitEntries.html	2018-06-01 21:28:40 UTC (rev 232417)
@@ -48,7 +48,7 @@
     shouldBeEqualToString("files[0].type", "text/plain");
 
     shouldBeEqualToString("files[1].name", "testFiles");
-    shouldBe("files[1].size", "272");
+    shouldBeOneOfValues("files[1].size", [272, 256]);
     shouldBeEqualToString("files[1].type", "");
 
     finishJSTest();

Modified: trunk/LayoutTests/fast/forms/file/entries-api/webkitdirectory-drag-folder.html (232416 => 232417)


--- trunk/LayoutTests/fast/forms/file/entries-api/webkitdirectory-drag-folder.html	2018-06-01 20:58:27 UTC (rev 232416)
+++ trunk/LayoutTests/fast/forms/file/entries-api/webkitdirectory-drag-folder.html	2018-06-01 21:28:40 UTC (rev 232417)
@@ -31,7 +31,13 @@
 
 function changed(event)
 {
-    fileList = event.target.files;
+    fileList = Array.from(event.target.files).sort(function (a, b) {
+        if (a.name > b.name)
+            return 1;
+        else if (a.name < b.name)
+            return -1;
+        return 0;
+    });
     shouldBe("fileList.length", "5");
     shouldBeEqualToString("fileList[0].name", "file1.txt");
     shouldBeEqualToString("fileList[0].webkitRelativePath", "testFiles/file1.txt");

Modified: trunk/LayoutTests/resources/js-test.js (232416 => 232417)


--- trunk/LayoutTests/resources/js-test.js	2018-06-01 20:58:27 UTC (rev 232416)
+++ trunk/LayoutTests/resources/js-test.js	2018-06-01 21:28:40 UTC (rev 232417)
@@ -284,6 +284,45 @@
         testFailed(_a + " should be " + stringify(_bv) + " (of type " + typeof _bv + "). Was " + _av + " (of type " + typeof _av + ").");
 }
 
+function shouldBeOneOfValues(_a, _values)
+{
+    if ((typeof _a != "function" && typeof _a != "string"))
+        debug("WARN: shouldBeOneOfValues() expects the first argument to be a function or a string");
+    if (!Array.isArray(_values)) {
+        testFailed("The second argument to shouldBeOneOfValues() must be an array of values");
+        return;
+    }
+
+    var _exception;
+    var _av;
+    try {
+        _av = (typeof _a == "function" ? _a() : eval(_a));
+    } catch (e) {
+        _exception = e;
+    }
+
+    var stringifiedValues = '';
+    for (var i = 0; i < _values.length; ++i) {
+        if (i) {
+            if (i + 1 == _values.length)
+                stringifiedValues += ', and ';
+            else
+                stringifiedValues += ','
+        }
+        stringifiedValues += "`" + stringify(_values[i]) + "`";
+    }
+    if (_exception)
+        testFailed(_a + " should be one of " + stringifiedValues + ". Threw exception " + _exception);
+    else {
+        var matchedValue = _values.find(function (value) { return isResultCorrect(_av, value); });
+        if (matchedValue) {
+            testPassed(_a + " is one of " + stringifiedValues);
+        } else {
+            testFailed(_a + " should be one of " + stringifiedValues + ". Was " + stringify(_av) + ".");
+        }
+    }
+}
+
 // Execute condition every 5 milliseconds until it succeeds.
 function _waitForCondition(condition, completionHandler)
 {
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to