[ MacOS iOS ] Layout Test storage/indexeddb/modern/opendatabase-after-storage-crash...
authorsihui_liu@apple.com <sihui_liu@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 21 Jul 2018 00:41:44 +0000 (00:41 +0000)
committersihui_liu@apple.com <sihui_liu@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 21 Jul 2018 00:41:44 +0000 (00:41 +0000)
https://bugs.webkit.org/show_bug.cgi?id=187648
<rdar://problem/42405935>

Reviewed by Brady Eidson.

Make test wait until requests finish to get correct result, because indexedDB operations are asynchronous.

* storage/indexeddb/modern/opendatabase-after-storage-crash-expected.txt:
* storage/indexeddb/modern/opendatabase-after-storage-crash.html:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@234077 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/platform/wk2/TestExpectations
LayoutTests/storage/indexeddb/modern/opendatabase-after-storage-crash-expected.txt
LayoutTests/storage/indexeddb/modern/opendatabase-after-storage-crash.html

index 3ff5d51..b4b701e 100644 (file)
@@ -1,3 +1,16 @@
+2018-07-20  Sihui Liu  <sihui_liu@apple.com>
+
+        [ MacOS iOS ] Layout Test storage/indexeddb/modern/opendatabase-after-storage-crash.html is flaky
+        https://bugs.webkit.org/show_bug.cgi?id=187648
+        <rdar://problem/42405935>
+
+        Reviewed by Brady Eidson.
+
+        Make test wait until requests finish to get correct result, because indexedDB operations are asynchronous.
+
+        * storage/indexeddb/modern/opendatabase-after-storage-crash-expected.txt:
+        * storage/indexeddb/modern/opendatabase-after-storage-crash.html:
+
 2018-07-19  Simon Fraser  <simon.fraser@apple.com>
 
         Remove completed animations from GraphicsLayer, thus avoiding excessive backing store allocation
index 5dca15a..eb17740 100644 (file)
@@ -736,7 +736,7 @@ http/tests/navigation/process-swap-window-open.html [ Pass ]
 http/wpt/cross-origin-resource-policy/ [ Pass ]
 
 http/tests/navigation/useragent-reload.php [ Pass ]
-webkit.org/b/187648 storage/indexeddb/modern/opendatabase-after-storage-crash.html [ Pass Failure ]
+storage/indexeddb/modern/opendatabase-after-storage-crash.html [ Pass ]
 
 
 ### END OF (5) Progressions, expected successes that are expected failures in WebKit1.
index 73cb336..44d73d4 100644 (file)
@@ -1,7 +1,7 @@
 <script src="../../../resources/js-test.js"></script>
 <script src="../resources/shared.js"></script>
 <body>
-If this test completes quickly instead of hanging indefinitely, it has passed.
+This test verifies when storage process crashes, indexedDB operation should not hang indefinitely.
 </body>
 <script>
 
@@ -12,66 +12,65 @@ function continueTest()
 {
        var request = window.indexedDB.open(dbname, 2);
        request.onupgradeneeded = function(e) {
-               document.body.innerHTML = "openDatabase call after storage process termination should not have resulted in upgradeneeded";
+               document.body.innerHTML = "Unexpected upgradeneeded after storage process termination. Database: name " + dbname + ", version 2.";
                if (window.testRunner)
                        testRunner.notifyDone();
-
        }
-       
+
        request.onerror = function(e) {
                // Good, we received an expected error.
                // Now reload to see if a new document connects successfully
                if (sessionStorage[storageKey]) {
-                       document.body.innerHTML = "Should not have reached this code twice!";
+                       document.body.innerHTML = "Received error more than once unexpectedly. Database: name " + dbname + ", version 2.";
                        if (window.testRunner)
                                testRunner.notifyDone();
                        return;
                }
-               
+
                sessionStorage[storageKey] = "Made it";
                location.reload();
        }
 
        request.onsuccess = function(e) {
-               document.body.innerHTML = "Unexpected success during the second database open after document load. SessionStorage value: " + sessionStorage[storageKey];
+               document.body.innerHTML = "Unexpected upgradeneeded after storage process termination. Database: name " + dbname + ", version 2. SessionStorage value: " + sessionStorage[storageKey] + ".";
                if (window.testRunner)
                        testRunner.notifyDone();
        }
 }
 
-var versionToOpen = sessionStorage.finishedFirstOpen ? 3 : 1;
+var versionToOpen = sessionStorage.doneFirstLoad ? 3 : 1;
 var request = window.indexedDB.open(dbname, versionToOpen);
+
 request.onupgradeneeded = function(e) {
-       if (sessionStorage.finishedFirstOpen) {
-               document.body.innerHTML = "";
-               if (sessionStorage[storageKey] != "Made it")
-                       document.body.innerHTML += "Expected error in the first pass of the test was NOT logged<br>";
-               document.body.innerHTML += "Successfully opened the database in a new document"
+       if (sessionStorage.doneFirstLoad) {
+               document.body.innerHTML = "Successfully opened database with version " + versionToOpen + ".";
+               shouldBeEqualToString('sessionStorage[storageKey]', 'Made it');
+
                if (window.testRunner)
                        testRunner.notifyDone();
        }
        
-       sessionStorage.finishedFirstOpen = true;
-       
-       if (window.testRunner)
-               testRunner.terminateStorageProcess();
+       sessionStorage.doneFirstLoad = true;
 
        // Set an error handler on the database connection so once the storage process terminates we know to continue the test
        e.target.result.onerror = function(e) {
                setTimeout(continueTest, 0);
        }
+
+       if (window.testRunner) {
+               testRunner.waitUntilDone();
+               testRunner.terminateStorageProcess();
+       }
 }
 
 request.onerror = function(e) {
-       document.body.innerHTML = "Unexpected error during the first database open on document load. Message: " + e.message + ". DB opening: " + dbname + ". Version opening: " + versionToOpen + ". SessionStorage value: " + sessionStorage[storageKey];
-       if (window.testRunner)
-               testRunner.notifyDone();
+       if (versionToOpen == 1)
+               document.body.innerHTML = "Error on opening reuqest for database version 1. (FAIL: test should stop at opening version 3.)"; 
 }
 
 request.onsuccess = function(e) {
-       document.body.innerHTML = "Unexpected success during the first database open on document load. DB opening: " + dbname + ". Version opening: " + versionToOpen + ". SessionStorage value: " + sessionStorage[storageKey];
-       if (window.testRunner)
-               testRunner.notifyDone();
+       if (versionToOpen == 1)
+               document.body.innerHTML = "Success on opening reuqest for database version 1. (FAIL: test should stop at opening version 3.)";
 }
 
 </script>