Title: [259650] trunk
Revision
259650
Author
[email protected]
Date
2020-04-07 11:37:44 -0700 (Tue, 07 Apr 2020)

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

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (259649 => 259650)


--- trunk/Source/WebCore/ChangeLog	2020-04-07 18:19:18 UTC (rev 259649)
+++ trunk/Source/WebCore/ChangeLog	2020-04-07 18:37:44 UTC (rev 259650)
@@ -1,3 +1,18 @@
+2020-04-07  Timothy Hatcher  <[email protected]>
+
+        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.
+
+        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.
+
 2020-04-07  Devin Rousso  <[email protected]>
 
         Web Inspector: unable to see cookies on pages that have subframes which have been denied access to cookies

Modified: trunk/Source/WebCore/page/Page.cpp (259649 => 259650)


--- trunk/Source/WebCore/page/Page.cpp	2020-04-07 18:19:18 UTC (rev 259649)
+++ trunk/Source/WebCore/page/Page.cpp	2020-04-07 18:37:44 UTC (rev 259650)
@@ -2479,10 +2479,13 @@
 
 void Page::notifyToInjectUserScripts()
 {
+    m_hasBeenNotifiedToInjectUserScripts = true;
+
     for (auto* frame = &mainFrame(); frame; frame = frame->tree().traverseNext()) {
         for (const auto& pair : m_userScriptsAwaitingNotification)
             frame->injectUserScriptImmediately(pair.first, pair.second.get());
     }
+
     m_userScriptsAwaitingNotification.clear();
 }
 

Modified: trunk/Tools/ChangeLog (259649 => 259650)


--- trunk/Tools/ChangeLog	2020-04-07 18:19:18 UTC (rev 259649)
+++ trunk/Tools/ChangeLog	2020-04-07 18:37:44 UTC (rev 259650)
@@ -1,3 +1,14 @@
+2020-04-07  Timothy Hatcher  <[email protected]>
+
+        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.
+
+        * TestWebKitAPI/Tests/WebKitCocoa/UserContentController.mm:
+        (TEST):
+
 2020-04-07  Ryosuke Niwa  <[email protected]>
 
         TextManipulationController fails to replace a paragraph that ends with a br

Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/UserContentController.mm (259649 => 259650)


--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/UserContentController.mm	2020-04-07 18:19:18 UTC (rev 259649)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/UserContentController.mm	2020-04-07 18:37:44 UTC (rev 259650)
@@ -843,4 +843,15 @@
     [webView2 loadTestPageNamed:@"simple"];
     EXPECT_WK_STREQ([delegate waitForAlert], "waited for notification");
     EXPECT_WK_STREQ([delegate waitForAlert], "document parsing ended");
+
+    TestWKWebView *webView3 = [[TestWKWebView new] autorelease];
+    EXPECT_TRUE(webView3._deferrableUserScriptsNeedNotification);
+    [webView3.configuration.userContentController addUserScript:waitsForNotification];
+    [webView3.configuration.userContentController addUserScript:documentEnd];
+    webView3.UIDelegate = delegate;
+    [webView3 loadTestPageNamed:@"simple"];
+    [webView3 _notifyUserScripts];
+    EXPECT_FALSE(webView3._deferrableUserScriptsNeedNotification);
+    EXPECT_WK_STREQ([delegate waitForAlert], "waited for notification");
+    EXPECT_WK_STREQ([delegate waitForAlert], "document parsing ended");
 }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to