⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 246012 in webkit


Ignore:
Timestamp:
May 31, 2019, 9:33:04 PM (7 years ago)
Author:
sihui_liu@apple.com
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:
Location:
trunk/Tools
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Tools/ChangeLog

    r246010 r246012  
     12019-05-31  Sihui Liu  <sihui_liu@apple.com>
     2
     3        TestWebKitAPI.WKWebView.LocalStorageProcessSuspends is flaky
     4        https://bugs.webkit.org/show_bug.cgi?id=198450
     5
     6        Reviewed by Ryosuke Niwa.
     7
     8        In local-storage-process-suspends-2.html, we periodically checked local storage item and sent a message when the
     9        item value was changed or times of check reached limit. We expected the message to be sent after network process
     10        resumed from suspension, because that's when the item value should get updated. However, the limit we set seemed
     11        to be not high enough, so that the message could be sent eariler than expected, when limit of check number was
     12        reached.
     13
     14        We can solve this in different ways. To make the test robust, we can send the message on a storage event, which
     15        notifies about changes in local storage.
     16
     17        * TestWebKitAPI/Tests/WebKitCocoa/LocalStoragePersistence.mm:
     18        (TEST):
     19        * TestWebKitAPI/Tests/WebKitCocoa/local-storage-process-suspends-2.html:
     20
    1212019-05-31  Ryosuke Niwa  <rniwa@webkit.org>
    222
  • trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/LocalStoragePersistence.mm

    r245904 r246012  
    112112    RetainPtr<WKProcessPool> processPool = adoptNS([[WKProcessPool alloc] init]);
    113113    [configuration setProcessPool:processPool.get()];
     114    [configuration _setAllowUniversalAccessFromFileURLs:YES];
    114115
    115116    RetainPtr<WKWebView> webView1 = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:configuration.get()]);
     
    139140    readyToContinue = false;
    140141    [webView2 evaluateJavaScript:@"window.localStorage.getItem('key')" completionHandler:^(id result, NSError *) {
    141         EXPECT_TRUE([@"value" isEqualToString:result]);
     142        EXPECT_WK_STREQ(@"value", result);
    142143        readyToContinue = true;
    143144    }];
  • trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/local-storage-process-suspends-2.html

    r245904 r246012  
    22<script>
    33
    4 var startValue = window.localStorage.getItem('key');
    5 window.webkit.messageHandlers.testHandler.postMessage(startValue);
     4function checkLocalStorage(event) {
     5    window.webkit.messageHandlers.testHandler.postMessage(window.localStorage.getItem('key'));
     6}
    67
    7 var tries = 10;
    8 var intervalID = setInterval(()=> {
    9     var newValue = window.localStorage.getItem('key');
    10     if (newValue != startValue || tries == 0) {
    11         window.webkit.messageHandlers.testHandler.postMessage(newValue);
    12         clearInterval(intervalID);
    13     }
    14     --tries;
    15 }, 100);
     8checkLocalStorage();
     9window.addEventListener("storage", checkLocalStorage);
    1610
    1711</script>
Note: See TracChangeset for help on using the changeset viewer.