Title: [246012] trunk/Tools
Revision
246012
Author
sihui_...@apple.com
Date
2019-05-31 21:33:04 -0700 (Fri, 31 May 2019)

Log Message

TestWebKitAPI.WKWebView.LocalStorageProcessSuspends is flaky
https://bugs.webkit.org/show_bug.cgi?id=198450

Reviewed by Ryosuke Niwa.

In local-storage-process-suspends-2.html, we periodically checked local storage item and sent a message when the
item value was changed or times of check reached limit. We expected the message to be sent after network process
resumed from suspension, because that's when the item value should get updated. However, the limit we set seemed
to be not high enough, so that the message could be sent eariler than expected, when limit of check number was
reached.

We can solve this in different ways. To make the test robust, we can send the message on a storage event, which
notifies about changes in local storage.

* TestWebKitAPI/Tests/WebKitCocoa/LocalStoragePersistence.mm:
(TEST):
* TestWebKitAPI/Tests/WebKitCocoa/local-storage-process-suspends-2.html:

Modified Paths

Diff

Modified: trunk/Tools/ChangeLog (246011 => 246012)


--- trunk/Tools/ChangeLog	2019-06-01 04:16:40 UTC (rev 246011)
+++ trunk/Tools/ChangeLog	2019-06-01 04:33:04 UTC (rev 246012)
@@ -1,3 +1,23 @@
+2019-05-31  Sihui Liu  <sihui_...@apple.com>
+
+        TestWebKitAPI.WKWebView.LocalStorageProcessSuspends is flaky
+        https://bugs.webkit.org/show_bug.cgi?id=198450
+
+        Reviewed by Ryosuke Niwa.
+
+        In local-storage-process-suspends-2.html, we periodically checked local storage item and sent a message when the
+        item value was changed or times of check reached limit. We expected the message to be sent after network process
+        resumed from suspension, because that's when the item value should get updated. However, the limit we set seemed
+        to be not high enough, so that the message could be sent eariler than expected, when limit of check number was 
+        reached.
+
+        We can solve this in different ways. To make the test robust, we can send the message on a storage event, which
+        notifies about changes in local storage.
+
+        * TestWebKitAPI/Tests/WebKitCocoa/LocalStoragePersistence.mm:
+        (TEST):
+        * TestWebKitAPI/Tests/WebKitCocoa/local-storage-process-suspends-2.html:
+
 2019-05-31  Ryosuke Niwa  <rn...@webkit.org>
 
         DragAndDropTests.DragImageLocationForLinkInSubframe fails on some iPad

Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/LocalStoragePersistence.mm (246011 => 246012)


--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/LocalStoragePersistence.mm	2019-06-01 04:16:40 UTC (rev 246011)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/LocalStoragePersistence.mm	2019-06-01 04:33:04 UTC (rev 246012)
@@ -111,6 +111,7 @@
     [[configuration userContentController] addScriptMessageHandler:handler.get() name:@"testHandler"];
     RetainPtr<WKProcessPool> processPool = adoptNS([[WKProcessPool alloc] init]);
     [configuration setProcessPool:processPool.get()];
+    [configuration _setAllowUniversalAccessFromFileURLs:YES];
 
     RetainPtr<WKWebView> webView1 = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:configuration.get()]);
     NSURLRequest *request = [NSURLRequest requestWithURL:[[NSBundle mainBundle] URLForResource:@"local-storage-process-suspends-1" withExtension:@"html" subdirectory:@"TestWebKitAPI.resources"]];
@@ -138,7 +139,7 @@
     
     readyToContinue = false;
     [webView2 evaluateJavaScript:@"window.localStorage.getItem('key')" completionHandler:^(id result, NSError *) {
-        EXPECT_TRUE([@"value" isEqualToString:result]);
+        EXPECT_WK_STREQ(@"value", result);
         readyToContinue = true;
     }];
     TestWebKitAPI::Util::run(&readyToContinue);

Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/local-storage-process-suspends-2.html (246011 => 246012)


--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/local-storage-process-suspends-2.html	2019-06-01 04:16:40 UTC (rev 246011)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/local-storage-process-suspends-2.html	2019-06-01 04:33:04 UTC (rev 246012)
@@ -1,17 +1,11 @@
 <!DOCTYPE html>
 <script>
 
-var startValue = window.localStorage.getItem('key');
-window.webkit.messageHandlers.testHandler.postMessage(startValue);
+function checkLocalStorage(event) {
+    window.webkit.messageHandlers.testHandler.postMessage(window.localStorage.getItem('key'));
+}
 
-var tries = 10;
-var intervalID = setInterval(()=> {
-    var newValue = window.localStorage.getItem('key');
-    if (newValue != startValue || tries == 0) {
-        window.webkit.messageHandlers.testHandler.postMessage(newValue);
-        clearInterval(intervalID);
-    }
-    --tries;
-}, 100);
+checkLocalStorage();
+window.addEventListener("storage", checkLocalStorage);
 
-</script>
\ No newline at end of file
+</script>
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to