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

Changeset 259696 in webkit


Ignore:
Timestamp:
Apr 7, 2020, 5:43:15 PM (6 years ago)
Author:
Russell Epstein
Message:

Cherry-pick r259650. rdar://problem/61419505

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):

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

Location:
branches/safari-610.1.9-branch
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/safari-610.1.9-branch/Source/WebCore/ChangeLog

    r259544 r259696  
     12020-04-07  Alan Coon  <alancoon@apple.com>
     2
     3        Cherry-pick r259650. rdar://problem/61419505
     4
     5    WKUserScripts deferred from injection are not injected if -[WKWebView _notifyUserScripts] is called early.
     6    https://bugs.webkit.org/show_bug.cgi?id=210131
     7    rdar://problem/61368446
     8   
     9    Reviewed by Brady Eidson.
     10   
     11    Source/WebCore:
     12   
     13    If Page::notifyToInjectUserScripts() is called early, before Frame::injectUserScripts() happens,
     14    m_hasBeenNotifiedToInjectUserScripts will be false, allowing scripts to build up in m_userScriptsAwaitingNotification
     15    and never being injected (since Page::notifyToInjectUserScripts() will not be called again).
     16   
     17    * page/Page.cpp:
     18    (WebCore::Page::notifyToInjectUserScripts): Set m_hasBeenNotifiedToInjectUserScripts to true when called.
     19   
     20    Tools:
     21   
     22    * TestWebKitAPI/Tests/WebKitCocoa/UserContentController.mm:
     23    (TEST):
     24   
     25   
     26    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@259650 268f45cc-cd09-0410-ab3c-d52691b4dbfc
     27
     28    2020-04-07  Timothy Hatcher  <timothy@apple.com>
     29
     30            WKUserScripts deferred from injection are not injected if -[WKWebView _notifyUserScripts] is called early.
     31            https://bugs.webkit.org/show_bug.cgi?id=210131
     32            rdar://problem/61368446
     33
     34            Reviewed by Brady Eidson.
     35
     36            If Page::notifyToInjectUserScripts() is called early, before Frame::injectUserScripts() happens,
     37            m_hasBeenNotifiedToInjectUserScripts will be false, allowing scripts to build up in m_userScriptsAwaitingNotification
     38            and never being injected (since Page::notifyToInjectUserScripts() will not be called again).
     39
     40            * page/Page.cpp:
     41            (WebCore::Page::notifyToInjectUserScripts): Set m_hasBeenNotifiedToInjectUserScripts to true when called.
     42
    1432020-04-04  Rob Buis  <rbuis@igalia.com>
    244
  • branches/safari-610.1.9-branch/Source/WebCore/page/Page.cpp

    r259523 r259696  
    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}
  • branches/safari-610.1.9-branch/Tools/ChangeLog

    r259541 r259696  
     12020-04-07  Alan Coon  <alancoon@apple.com>
     2
     3        Cherry-pick r259650. rdar://problem/61419505
     4
     5    WKUserScripts deferred from injection are not injected if -[WKWebView _notifyUserScripts] is called early.
     6    https://bugs.webkit.org/show_bug.cgi?id=210131
     7    rdar://problem/61368446
     8   
     9    Reviewed by Brady Eidson.
     10   
     11    Source/WebCore:
     12   
     13    If Page::notifyToInjectUserScripts() is called early, before Frame::injectUserScripts() happens,
     14    m_hasBeenNotifiedToInjectUserScripts will be false, allowing scripts to build up in m_userScriptsAwaitingNotification
     15    and never being injected (since Page::notifyToInjectUserScripts() will not be called again).
     16   
     17    * page/Page.cpp:
     18    (WebCore::Page::notifyToInjectUserScripts): Set m_hasBeenNotifiedToInjectUserScripts to true when called.
     19   
     20    Tools:
     21   
     22    * TestWebKitAPI/Tests/WebKitCocoa/UserContentController.mm:
     23    (TEST):
     24   
     25   
     26    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@259650 268f45cc-cd09-0410-ab3c-d52691b4dbfc
     27
     28    2020-04-07  Timothy Hatcher  <timothy@apple.com>
     29
     30            WKUserScripts deferred from injection are not injected if -[WKWebView _notifyUserScripts] is called early.
     31            https://bugs.webkit.org/show_bug.cgi?id=210131
     32            rdar://problem/61368446
     33
     34            Reviewed by Brady Eidson.
     35
     36            * TestWebKitAPI/Tests/WebKitCocoa/UserContentController.mm:
     37            (TEST):
     38
    1392020-04-04  Wenson Hsieh  <wenson_hsieh@apple.com>
    240
  • branches/safari-610.1.9-branch/Tools/TestWebKitAPI/Tests/WebKitCocoa/UserContentController.mm

    r259523 r259696  
    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.