Title: [286198] trunk/LayoutTests
Revision
286198
Author
sihui_...@apple.com
Date
2021-11-28 12:34:35 -0800 (Sun, 28 Nov 2021)

Log Message

Convert error to string before passing to testFailed() in FileSystemAccess layout tests
https://bugs.webkit.org/show_bug.cgi?id=233241

Reviewed by Youenn Fablet.

testFailed() in js-test.js expects string, but finishTest() may receive Error object as parameter.

* storage/filesystemaccess/directory-handle-basics.html:
* storage/filesystemaccess/directory-handle-iteration.html:
* storage/filesystemaccess/file-handle-getfile.html:
* storage/filesystemaccess/handle-move.html:
* storage/filesystemaccess/resources/directory-handle-basics.js:
(getDirectory):
(finishTest): Deleted.
* storage/filesystemaccess/resources/directory-handle-iteration.js:
(finishTest): Deleted.
* storage/filesystemaccess/resources/file-handle-getfile.js:
(async read):
(async test):
(finishTest): Deleted.
* storage/filesystemaccess/resources/handle-move.js:
(async test):
(finishTest): Deleted.
* storage/filesystemaccess/resources/shared.js: Added. Move finishTest() function here so the code can be shared.
(finishTest):
* storage/filesystemaccess/resources/sync-access-handle-basics.js:
(getDirectory):
(finishTest): Deleted.
* storage/filesystemaccess/resources/sync-access-handle-close.js:
(finishTest): Deleted.
* storage/filesystemaccess/resources/sync-access-handle-read-write.js:
(async test):
(finishTest): Deleted.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (286197 => 286198)


--- trunk/LayoutTests/ChangeLog	2021-11-28 19:15:39 UTC (rev 286197)
+++ trunk/LayoutTests/ChangeLog	2021-11-28 20:34:35 UTC (rev 286198)
@@ -1,3 +1,39 @@
+2021-11-28  Sihui Liu  <sihui_...@apple.com>
+
+        Convert error to string before passing to testFailed() in FileSystemAccess layout tests
+        https://bugs.webkit.org/show_bug.cgi?id=233241
+
+        Reviewed by Youenn Fablet.
+
+        testFailed() in js-test.js expects string, but finishTest() may receive Error object as parameter.
+
+        * storage/filesystemaccess/directory-handle-basics.html:
+        * storage/filesystemaccess/directory-handle-iteration.html:
+        * storage/filesystemaccess/file-handle-getfile.html:
+        * storage/filesystemaccess/handle-move.html:
+        * storage/filesystemaccess/resources/directory-handle-basics.js:
+        (getDirectory):
+        (finishTest): Deleted.
+        * storage/filesystemaccess/resources/directory-handle-iteration.js:
+        (finishTest): Deleted.
+        * storage/filesystemaccess/resources/file-handle-getfile.js:
+        (async read):
+        (async test):
+        (finishTest): Deleted.
+        * storage/filesystemaccess/resources/handle-move.js:
+        (async test):
+        (finishTest): Deleted.
+        * storage/filesystemaccess/resources/shared.js: Added. Move finishTest() function here so the code can be shared.
+        (finishTest):
+        * storage/filesystemaccess/resources/sync-access-handle-basics.js:
+        (getDirectory):
+        (finishTest): Deleted.
+        * storage/filesystemaccess/resources/sync-access-handle-close.js:
+        (finishTest): Deleted.
+        * storage/filesystemaccess/resources/sync-access-handle-read-write.js:
+        (async test):
+        (finishTest): Deleted.
+
 2021-11-28  Sam Weinig  <wei...@apple.com>
 
         [CSS Color 5] Update color-mix() to latest spec (again)

Modified: trunk/LayoutTests/storage/filesystemaccess/directory-handle-basics.html (286197 => 286198)


--- trunk/LayoutTests/storage/filesystemaccess/directory-handle-basics.html	2021-11-28 19:15:39 UTC (rev 286197)
+++ trunk/LayoutTests/storage/filesystemaccess/directory-handle-basics.html	2021-11-28 20:34:35 UTC (rev 286198)
@@ -2,15 +2,9 @@
 <html>
 <head>
 <script src=""
+<script src=""
 </head>
 <body>
-<script>
-var jsTestIsAsync = true;
-
-if (!window.testRunner) {
-    finishTest("window.testRunner is not available");
-}
-</script>
 <script src=""
 </body>
 </html>

Modified: trunk/LayoutTests/storage/filesystemaccess/directory-handle-iteration.html (286197 => 286198)


--- trunk/LayoutTests/storage/filesystemaccess/directory-handle-iteration.html	2021-11-28 19:15:39 UTC (rev 286197)
+++ trunk/LayoutTests/storage/filesystemaccess/directory-handle-iteration.html	2021-11-28 20:34:35 UTC (rev 286198)
@@ -2,15 +2,9 @@
 <html>
 <head>
 <script src=""
+<script src=""
 </head>
 <body>
-<script>
-var jsTestIsAsync = true;
-
-if (!window.testRunner) {
-    finishTest("window.testRunner is not available");
-}
-</script>
 <script src=""
 </body>
 </html>

Modified: trunk/LayoutTests/storage/filesystemaccess/file-handle-getfile.html (286197 => 286198)


--- trunk/LayoutTests/storage/filesystemaccess/file-handle-getfile.html	2021-11-28 19:15:39 UTC (rev 286197)
+++ trunk/LayoutTests/storage/filesystemaccess/file-handle-getfile.html	2021-11-28 20:34:35 UTC (rev 286198)
@@ -2,15 +2,9 @@
 <html>
 <head>
 <script src=""
+<script src=""
 </head>
 <body>
-<script>
-var jsTestIsAsync = true;
-
-if (!window.testRunner) {
-    finishTest("window.testRunner is not available");
-}
-</script>
 <script src=""
 </body>
 </html>

Modified: trunk/LayoutTests/storage/filesystemaccess/handle-move.html (286197 => 286198)


--- trunk/LayoutTests/storage/filesystemaccess/handle-move.html	2021-11-28 19:15:39 UTC (rev 286197)
+++ trunk/LayoutTests/storage/filesystemaccess/handle-move.html	2021-11-28 20:34:35 UTC (rev 286198)
@@ -2,15 +2,9 @@
 <html>
 <head>
 <script src=""
+<script src=""
 </head>
 <body>
-<script>
-var jsTestIsAsync = true;
-
-if (!window.testRunner) {
-    finishTest("window.testRunner is not available");
-}
-</script>
 <script src=""
 </body>
 </html>

Modified: trunk/LayoutTests/storage/filesystemaccess/resources/directory-handle-basics.js (286197 => 286198)


--- trunk/LayoutTests/storage/filesystemaccess/resources/directory-handle-basics.js	2021-11-28 19:15:39 UTC (rev 286197)
+++ trunk/LayoutTests/storage/filesystemaccess/resources/directory-handle-basics.js	2021-11-28 20:34:35 UTC (rev 286198)
@@ -1,5 +1,6 @@
 if (this.importScripts) {
     importScripts('../../../resources/js-test.js');
+    importScripts('shared.js');
 }
 
 description("This test checks basic funtionalities of FileSystemDirectoryHandle.");
@@ -6,15 +7,8 @@
 
 var rootHandle, dirHandle, fileHandle, isSameEntry, handleNames, createError;
 
-function finishTest(error)
+function getDirectory() 
 {
-    if (error) {
-        testFailed(error);
-    }
-    finishJSTest();
-}
-
-function getDirectory() {
     navigator.storage.getDirectory().then((handle) => {
         rootHandle = handle;
         shouldBeEqualToString("rootHandle.name", "");
@@ -25,7 +19,8 @@
     });
 }
 
-function createDirectoryHandle(fromHandle) {
+function createDirectoryHandle(fromHandle) 
+{
     fromHandle.getDirectoryHandle("dir", { "create" : true }).then((handle) => {
         dirHandle = handle;
         shouldBeEqualToString("dirHandle.name", "dir");
@@ -47,7 +42,8 @@
     });
 }
 
-function createFileHandle(fromHandle, create) {
+function createFileHandle(fromHandle, create) 
+{
     let options = { "create" : create };
     fromHandle.getFileHandle("file", options).then((handle) => {
         fileHandle = handle;
@@ -65,7 +61,8 @@
     });
 }
 
-function resolvePath() {
+function resolvePath() 
+{
     rootHandle.resolve(fileHandle).then((result) => {
         handleNames = result;
         shouldBe("handleNames.length", "2");
@@ -77,7 +74,8 @@
     });
 }
 
-function removeEntry(fromHandle, name) {
+function removeEntry(fromHandle, name) 
+{
     fromHandle.removeEntry(name).then((result) => {
         // No error means it is removed.
         createFileHandle(dirHandle, false);

Modified: trunk/LayoutTests/storage/filesystemaccess/resources/directory-handle-iteration.js (286197 => 286198)


--- trunk/LayoutTests/storage/filesystemaccess/resources/directory-handle-iteration.js	2021-11-28 19:15:39 UTC (rev 286197)
+++ trunk/LayoutTests/storage/filesystemaccess/resources/directory-handle-iteration.js	2021-11-28 20:34:35 UTC (rev 286198)
@@ -1,5 +1,6 @@
 if (this.importScripts) {
     importScripts('../../../resources/js-test.js');
+    importScripts('shared.js');
 }
 
 description('This test checks iteration on FileSystemDirectoryHandle.');
@@ -8,14 +9,6 @@
 const handleNames = ['dir1', 'dir2', 'file1', 'file2'];
 var index, isEqual, iterator, prototype, descriptor, resultKeys, resultValuesName, resultValuesType, resultEntries, nextResults, expectedResults, nextResultsEnd;
 
-function finishTest(error)
-{
-    if (error) {
-        testFailed(error);
-    }
-    finishJSTest();
-}
-
 function testPrototype(it)
 {
     iterator = it;

Modified: trunk/LayoutTests/storage/filesystemaccess/resources/file-handle-getfile.js (286197 => 286198)


--- trunk/LayoutTests/storage/filesystemaccess/resources/file-handle-getfile.js	2021-11-28 19:15:39 UTC (rev 286197)
+++ trunk/LayoutTests/storage/filesystemaccess/resources/file-handle-getfile.js	2021-11-28 20:34:35 UTC (rev 286198)
@@ -1,5 +1,6 @@
 if (this.importScripts) {
     importScripts('../../../resources/js-test.js');
+    importScripts('shared.js');
 }
 
 description("This test checks getFile() of FileSystemFileHandle.");
@@ -6,15 +7,8 @@
 
 var rootHandle, fileHandle, fileObject, writeSize, writeBuffer, fileContent;
 
-function finishTest(error)
+async function read(file) 
 {
-    if (error) {
-        testFailed(error);
-    }
-    finishJSTest();
-}
-
-async function read(file) {
     return new Promise((resolve, reject) => {
         var reader = new FileReader();
         reader.readAsText(file);
@@ -27,7 +21,8 @@
     });
 }
 
-async function test() {
+async function test() 
+{
     try {
         var rootHandle = await navigator.storage.getDirectory();
         // Create a new file for this test.

Modified: trunk/LayoutTests/storage/filesystemaccess/resources/handle-move.js (286197 => 286198)


--- trunk/LayoutTests/storage/filesystemaccess/resources/handle-move.js	2021-11-28 19:15:39 UTC (rev 286197)
+++ trunk/LayoutTests/storage/filesystemaccess/resources/handle-move.js	2021-11-28 20:34:35 UTC (rev 286198)
@@ -1,5 +1,6 @@
 if (this.importScripts) {
     importScripts('../../../resources/js-test.js');
+    importScripts('shared.js');
 }
 
 description("This test checks move() of FileSystemHandle.");
@@ -6,15 +7,8 @@
 
 var rootHandle, dirHandle1, dirHandle2, fileHandle, fileHandle2, testError, getFileHandleError, moveFileError;
 
-function finishTest(error)
+async function test() 
 {
-    if (error) {
-        testFailed(error);
-    }
-    finishJSTest();
-}
-
-async function test() {
     try {
         var rootHandle = await navigator.storage.getDirectory();
         // Create two new folders for this test.

Added: trunk/LayoutTests/storage/filesystemaccess/resources/shared.js (0 => 286198)


--- trunk/LayoutTests/storage/filesystemaccess/resources/shared.js	                        (rev 0)
+++ trunk/LayoutTests/storage/filesystemaccess/resources/shared.js	2021-11-28 20:34:35 UTC (rev 286198)
@@ -0,0 +1,16 @@
+var jsTestIsAsync = true;
+
+function finishTest(error)
+{
+    if (error) {
+        if (error.toString)
+            error = error.toString();
+
+        if (typeof error === 'string')
+            testFailed(error);
+        else
+            debug("WARN: cannot print error because it is not a string");
+    }
+
+    finishJSTest();
+}
\ No newline at end of file

Modified: trunk/LayoutTests/storage/filesystemaccess/resources/sync-access-handle-basics.js (286197 => 286198)


--- trunk/LayoutTests/storage/filesystemaccess/resources/sync-access-handle-basics.js	2021-11-28 19:15:39 UTC (rev 286197)
+++ trunk/LayoutTests/storage/filesystemaccess/resources/sync-access-handle-basics.js	2021-11-28 20:34:35 UTC (rev 286198)
@@ -1,5 +1,6 @@
 if (this.importScripts) {
     importScripts('../../../resources/js-test.js');
+    importScripts('shared.js');
 }
 
 description("This test checks basic funtionalities of FileSystemSyncAccessHandle.");
@@ -6,15 +7,8 @@
 
 var rootHandle, fileHandle, accessHandle1, accessHandle2, createError;
 
-function finishTest(error)
+function getDirectory() 
 {
-    if (error) {
-        testFailed(error);
-    }
-    finishJSTest();
-}
-
-function getDirectory() {
     navigator.storage.getDirectory().then((handle) => {
         rootHandle = handle;
         rootHandle.removeEntry("sync-access-handle.txt").then(() => {
@@ -27,7 +21,8 @@
     });
 }
 
-function createFileHandle(fromHandle) {
+function createFileHandle(fromHandle) 
+{
     fromHandle.getFileHandle("sync-access-handle.txt", { "create" : true }).then((handle) => {
         fileHandle = handle;
         shouldBeEqualToString("fileHandle.name", "sync-access-handle.txt");
@@ -38,7 +33,8 @@
     });
 }
 
-function createSyncAccessHandle(fromHandle) {
+function createSyncAccessHandle(fromHandle) 
+{
     fromHandle.createSyncAccessHandle().then((handle) => {
         accessHandle1 = handle;
         debug("accessHandle1 is created");
@@ -48,7 +44,8 @@
     });
 }
 
-function getSize(accessHandle) {
+function getSize(accessHandle) 
+{
     accessHandle.getSize().then((result) => {
         size = result;
         shouldBe("size", "0");
@@ -58,7 +55,8 @@
     });
 }
 
-function createSecondSyncAcessHandle(fromHandle) {
+function createSecondSyncAcessHandle(fromHandle) 
+{
     fromHandle.createSyncAccessHandle().then((handle) => {
         accessHandle2 = handle;
         // Second creation should succeed.
@@ -73,7 +71,8 @@
     });
 }
 
-function close() {
+function close() 
+{
     accessHandle1.close().then((result) => {
         debug("accessHandle1 is closed");
         createSecondSyncAcessHandle(fileHandle);

Modified: trunk/LayoutTests/storage/filesystemaccess/resources/sync-access-handle-close.js (286197 => 286198)


--- trunk/LayoutTests/storage/filesystemaccess/resources/sync-access-handle-close.js	2021-11-28 19:15:39 UTC (rev 286197)
+++ trunk/LayoutTests/storage/filesystemaccess/resources/sync-access-handle-close.js	2021-11-28 20:34:35 UTC (rev 286198)
@@ -1,5 +1,6 @@
 if (this.importScripts) {
     importScripts('../../../resources/js-test.js');
+    importScripts('shared.js');
 }
 
 description("This test checks close() of FileSystemSyncAccessHandle");
@@ -14,14 +15,6 @@
     { name : "write", args : [buffer, options], sync : true },
 ];
 
-function finishTest(error)
-{
-    if (error) {
-        testFailed(error);
-    }
-    finishJSTest();
-}
-
 function testSyncFunction(currentFunction)
 {
     try {

Modified: trunk/LayoutTests/storage/filesystemaccess/resources/sync-access-handle-read-write.js (286197 => 286198)


--- trunk/LayoutTests/storage/filesystemaccess/resources/sync-access-handle-read-write.js	2021-11-28 19:15:39 UTC (rev 286197)
+++ trunk/LayoutTests/storage/filesystemaccess/resources/sync-access-handle-read-write.js	2021-11-28 20:34:35 UTC (rev 286198)
@@ -1,5 +1,6 @@
 if (this.importScripts) {
     importScripts('../../../resources/js-test.js');
+    importScripts('shared.js');
 }
 
 description("This test checks read and write capabilities of FileSystemSyncAccessHandle.");
@@ -7,16 +8,6 @@
 var accessHandle, fileSize, writeBuffer, writeSize, readBuffer, readSize, readText, readError;
 var totalReadSize = 0, totalWriteSize = 0;
 
-var testString;
-
-function finishTest(error)
-{
-    if (error) {
-        testFailed(error);
-    }
-    finishJSTest();
-}
-
 function arrayBufferToString(buffer)
 {
     const decoder = new TextDecoder();
@@ -50,7 +41,8 @@
     return readSize;
 }
 
-async function test() {
+async function test() 
+{
     try {
         var rootHandle = await navigator.storage.getDirectory();
         // Create a new file for this test.
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to