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

Changeset 259650 in webkit


Ignore:
Timestamp:
Apr 7, 2020, 11:37:44 AM (6 years ago)
Author:
timothy@apple.com
Message:

WKUserScripts deferred from injection are not injected if -[WKWebView _notifyUserScripts] is called early.
https://bugs.webkit.org/show_bug.cgi?id=210131
rdar://problem/61368446

Reviewed by Brady Eidson.

Source/WebCore:

If Page::notifyToInjectUserScripts() is called early, before Frame::injectUserScripts() happens,
m_hasBeenNotifiedToInjectUserScripts will be false, allowing scripts to build up in m_userScriptsAwaitingNotification
and never being injected (since Page::notifyToInjectUserScripts() will not be called again).

  • page/Page.cpp:

(WebCore::Page::notifyToInjectUserScripts): Set m_hasBeenNotifiedToInjectUserScripts to true when called.

Tools:

  • TestWebKitAPI/Tests/WebKitCocoa/UserContentController.mm:

(TEST):

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r259649 r259650  
     12020-04-07  Timothy Hatcher  <timothy@apple.com>
     2
     3        WKUserScripts deferred from injection are not injected if -[WKWebView _notifyUserScripts] is called early.
     4        https://bugs.webkit.org/show_bug.cgi?id=210131
     5        rdar://problem/61368446
     6
     7        Reviewed by Brady Eidson.
     8
     9        If Page::notifyToInjectUserScripts() is called early, before Frame::injectUserScripts() happens,
     10        m_hasBeenNotifiedToInjectUserScripts will be false, allowing scripts to build up in m_userScriptsAwaitingNotification
     11        and never being injected (since Page::notifyToInjectUserScripts() will not be called again).
     12
     13        * page/Page.cpp:
     14        (WebCore::Page::notifyToInjectUserScripts): Set m_hasBeenNotifiedToInjectUserScripts to true when called.
     15
    1162020-04-07  Devin Rousso  <drousso@apple.com>
    217
  • trunk/Source/WebCore/page/Page.cpp

    r259523 r259650  
    24802480void Page::notifyToInjectUserScripts()
    24812481{
     2482    m_hasBeenNotifiedToInjectUserScripts = true;
     2483
    24822484    for (auto* frame = &mainFrame(); frame; frame = frame->tree().traverseNext()) {
    24832485        for (const auto& pair : m_userScriptsAwaitingNotification)
    24842486            frame->injectUserScriptImmediately(pair.first, pair.second.get());
    24852487    }
     2488
    24862489    m_userScriptsAwaitingNotification.clear();
    24872490}
  • trunk/Tools/ChangeLog

    r259647 r259650  
     12020-04-07  Timothy Hatcher  <timothy@apple.com>
     2
     3        WKUserScripts deferred from injection are not injected if -[WKWebView _notifyUserScripts] is called early.
     4        https://bugs.webkit.org/show_bug.cgi?id=210131
     5        rdar://problem/61368446
     6
     7        Reviewed by Brady Eidson.
     8
     9        * TestWebKitAPI/Tests/WebKitCocoa/UserContentController.mm:
     10        (TEST):
     11
    1122020-04-07  Ryosuke Niwa  <rniwa@webkit.org>
    213
  • trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/UserContentController.mm

    r259569 r259650  
    844844    EXPECT_WK_STREQ([delegate waitForAlert], "waited for notification");
    845845    EXPECT_WK_STREQ([delegate waitForAlert], "document parsing ended");
    846 }
     846
     847    TestWKWebView *webView3 = [[TestWKWebView new] autorelease];
     848    EXPECT_TRUE(webView3._deferrableUserScriptsNeedNotification);
     849    [webView3.configuration.userContentController addUserScript:waitsForNotification];
     850    [webView3.configuration.userContentController addUserScript:documentEnd];
     851    webView3.UIDelegate = delegate;
     852    [webView3 loadTestPageNamed:@"simple"];
     853    [webView3 _notifyUserScripts];
     854    EXPECT_FALSE(webView3._deferrableUserScriptsNeedNotification);
     855    EXPECT_WK_STREQ([delegate waitForAlert], "waited for notification");
     856    EXPECT_WK_STREQ([delegate waitForAlert], "document parsing ended");
     857}
Note: See TracChangeset for help on using the changeset viewer.