This test is flaky. This unreviewed patch is my attempt to make it less so.
authorbeidson@apple.com <beidson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 6 Jul 2018 22:54:38 +0000 (22:54 +0000)
committerbeidson@apple.com <beidson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 6 Jul 2018 22:54:38 +0000 (22:54 +0000)
* storage/indexeddb/modern/opendatabase-after-storage-crash.html:

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

LayoutTests/ChangeLog
LayoutTests/storage/indexeddb/modern/opendatabase-after-storage-crash.html

index 90221cc..bd501fc 100644 (file)
@@ -1,3 +1,9 @@
+2018-07-06  Brady Eidson  <beidson@apple.com>
+
+        This test is flaky. This unreviewed patch is my attempt to make it less so.
+
+        * storage/indexeddb/modern/opendatabase-after-storage-crash.html:
+
 2018-07-06  David Fenton  <david_fenton@apple.com>
 
         Layout Test imported/w3c/web-platform-tests/IndexedDB/interfaces.any.worker.html is flaky.
index c22f1a9..0678da6 100644 (file)
@@ -11,11 +11,12 @@ 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 succeeded";
+               document.body.innerHTML = "openDatabase call after storage process termination should not have resulted in upgradeneeded";
                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
@@ -23,11 +24,18 @@ function continueTest()
                        document.body.innerHTML = "Should not have reached this code twice!";
                        if (window.testRunner)
                                testRunner.notifyDone();
+                       return;
                }
                
                sessionStorage[location.href] = "Made it";
                location.reload();
        }
+
+       request.onsuccess = function(e) {
+               document.body.innerHTML = "Unexpected success during the second database open after document load. " + sessionStorage[location.href];
+               if (window.testRunner)
+                       testRunner.notifyDone();
+       }
 }
 
 var request = window.indexedDB.open(dbname, 1);
@@ -43,18 +51,25 @@ request.onupgradeneeded = function(e) {
        
        sessionStorage.finishedFirstOpen = true;
        
-       if (window.testRunner) {
+       if (window.testRunner)
                testRunner.terminateStorageProcess();
-               // One spin of the runloop is *ALMOST* always enough delay here.
-               // Padding it makes this reliable.
-               setTimeout(continueTest, 10);
+
+       // 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);
        }
 }
 
 request.onerror = function(e) {
        document.body.innerHTML = "Unexpected error during the first database open on document load. " + sessionStorage[location.href];
        if (window.testRunner)
-               testRunner.notifyDone();        
+               testRunner.notifyDone();
+}
+
+request.onsuccess = function(e) {
+       document.body.innerHTML = "Unexpected success during the first database open on document load. " + sessionStorage[location.href];
+       if (window.testRunner)
+               testRunner.notifyDone();
 }
 
 </script>