<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[259523] trunk</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/259523">259523</a></dd>
<dt>Author</dt> <dd>commit-queue@webkit.org</dd>
<dt>Date</dt> <dd>2020-04-03 17:44:31 -0700 (Fri, 03 Apr 2020)</dd>
</dl>

<h3>Log Message</h3>
<pre>Add SPI to make WKUserScripts wait for a notification
https://bugs.webkit.org/show_bug.cgi?id=209845
<rdar://problem/60342299>

Patch by Alex Christensen <achristensen@webkit.org> on 2020-04-03
Reviewed by Chris Dumez.

Source/WebCore:

There's also SPI on WKWebView to provide this notification, and on WKWebViewConfiguration to start out with this notification.

* dom/ExtensionStyleSheets.cpp:
(WebCore::ExtensionStyleSheets::updateInjectedStyleSheetCache const):
* html/ImageDocument.cpp:
(WebCore::ImageDocument::createDocumentStructure):
* html/MediaDocument.cpp:
(WebCore::MediaDocumentParser::createDocumentStructure):
* html/PluginDocument.cpp:
(WebCore::PluginDocumentParser::createDocumentStructure):
* html/parser/HTMLConstructionSite.cpp:
(WebCore::HTMLConstructionSite::dispatchDocumentElementAvailableIfNeeded):
* loader/FrameLoader.cpp:
(WebCore::FrameLoader::finishedParsing):
* page/Frame.cpp:
(WebCore::Frame::injectUserScripts):
(WebCore::Frame::injectUserScriptImmediately):
* page/Page.cpp:
(WebCore::m_deviceOrientationUpdateProvider):
(WebCore::Page::notifyToInjectUserScripts):
(WebCore::Page::addUserScriptAwaitingNotification):
(WebCore::Page::injectUserStyleSheet):
(WebCore::Page::removeInjectedUserStyleSheet):
* page/Page.h:
(WebCore::Page::hasBeenNotifiedToInjectUserScripts const):
* page/PageConfiguration.h:
* page/UserContentTypes.h:
(): Deleted.
* page/UserScript.h:
(WebCore::UserScript::UserScript):
(WebCore::UserScript::waitForNotificationBeforeInjecting const):
(WebCore::UserScript::encode const):
(WebCore::UserScript::decode):
* page/UserScriptTypes.h:
(): Deleted.
* page/UserStyleSheet.h:
(WebCore::UserStyleSheet::UserStyleSheet):
* xml/parser/XMLDocumentParserLibxml2.cpp:
(WebCore::XMLDocumentParser::startElementNs):

Source/WebKit:

* Shared/API/c/WKSharedAPICast.h:
(WebKit::toUserScriptInjectionTime):
(WebKit::toWKUserScriptInjectionTime):
(WebKit::toUserContentInjectedFrames):
* Shared/WebPageCreationParameters.cpp:
(WebKit::WebPageCreationParameters::encode const):
(WebKit::WebPageCreationParameters::decode):
* Shared/WebPageCreationParameters.h:
* Shared/WebUserContentControllerDataTypes.cpp:
(WebKit::WebUserScriptData::decode):
* UIProcess/API/APIPageConfiguration.h:
(API::PageConfiguration::userScriptsShouldWaitUntilNotification const):
(API::PageConfiguration::setUserScriptsShouldWaitUntilNotification):
* UIProcess/API/APIUserScript.h:
* UIProcess/API/C/WKPageGroup.cpp:
(WKPageGroupAddUserScript):
* UIProcess/API/C/WKUserScriptRef.cpp:
(WKUserScriptCreateWithSource):
(WKUserScriptGetMainFrameOnly):
* UIProcess/API/Cocoa/WKUserScript.mm:
(-[WKUserScript initWithSource:injectionTime:forMainFrameOnly:]):
(-[WKUserScript isForMainFrameOnly]):
(-[WKUserScript _initWithSource:injectionTime:forMainFrameOnly:legacyWhitelist:legacyBlacklist:userContentWorld:]):
(-[WKUserScript _initWithSource:injectionTime:forMainFrameOnly:legacyWhitelist:legacyBlacklist:associatedURL:userContentWorld:]):
(-[WKUserScript _initWithSource:injectionTime:forMainFrameOnly:legacyWhitelist:legacyBlacklist:contentWorld:]):
(-[WKUserScript _initWithSource:injectionTime:forMainFrameOnly:legacyWhitelist:legacyBlacklist:associatedURL:contentWorld:]):
(-[WKUserScript _initWithSource:injectionTime:forMainFrameOnly:legacyWhitelist:legacyBlacklist:associatedURL:contentWorld:waitForNotification:]):
* UIProcess/API/Cocoa/WKUserScriptInternal.h:
(API::toWebCoreUserScriptInjectionTime):
(API::toWKUserScriptInjectionTime):
* UIProcess/API/Cocoa/WKUserScriptPrivate.h:
* UIProcess/API/Cocoa/WKWebView.mm:
(-[WKWebView _notifyUserScripts]):
* UIProcess/API/Cocoa/WKWebViewConfiguration.mm:
(-[WKWebViewConfiguration _userScriptsShouldWaitUntilNotification]):
(-[WKWebViewConfiguration _setUserScriptsShouldWaitUntilNotification:]):
* UIProcess/API/Cocoa/WKWebViewConfigurationPrivate.h:
* UIProcess/API/Cocoa/WKWebViewPrivate.h:
* UIProcess/API/Cocoa/_WKUserStyleSheet.mm:
(-[_WKUserStyleSheet initWithSource:forMainFrameOnly:]):
(-[_WKUserStyleSheet initWithSource:forWKWebView:forMainFrameOnly:userContentWorld:]):
(-[_WKUserStyleSheet initWithSource:forMainFrameOnly:legacyWhitelist:legacyBlacklist:userContentWorld:]):
(-[_WKUserStyleSheet initWithSource:forMainFrameOnly:legacyWhitelist:legacyBlacklist:baseURL:userContentWorld:]):
(-[_WKUserStyleSheet isForMainFrameOnly]):
* UIProcess/WebPageProxy.cpp:
* UIProcess/WebPageProxy.h:
* WebProcess/UserContent/WebUserContentController.cpp:
(WebKit::WebUserContentController::addUserScriptInternal):
* WebProcess/WebPage/WebPage.cpp:
(WebKit::m_processDisplayName):
(WebKit::WebPage::notifyUserScripts):
(WebKit::WebPage::addUserScript):
* WebProcess/WebPage/WebPage.h:
* WebProcess/WebPage/WebPage.messages.in:

Source/WebKitLegacy/mac:

* WebView/WebView.mm:
(-[WebView _injectOutlookQuirksScript]):

Source/WebKitLegacy/win:

* WebView.cpp:
(WebView::addUserScriptToGroup):
(WebView::addUserStyleSheetToGroup):

Tools:

* TestWebKitAPI/Tests/WebKitCocoa/UserContentController.mm:
(TEST):</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoredomExtensionStyleSheetscpp">trunk/Source/WebCore/dom/ExtensionStyleSheets.cpp</a></li>
<li><a href="#trunkSourceWebCorehtmlImageDocumentcpp">trunk/Source/WebCore/html/ImageDocument.cpp</a></li>
<li><a href="#trunkSourceWebCorehtmlMediaDocumentcpp">trunk/Source/WebCore/html/MediaDocument.cpp</a></li>
<li><a href="#trunkSourceWebCorehtmlPluginDocumentcpp">trunk/Source/WebCore/html/PluginDocument.cpp</a></li>
<li><a href="#trunkSourceWebCorehtmlparserHTMLConstructionSitecpp">trunk/Source/WebCore/html/parser/HTMLConstructionSite.cpp</a></li>
<li><a href="#trunkSourceWebCoreloaderFrameLoadercpp">trunk/Source/WebCore/loader/FrameLoader.cpp</a></li>
<li><a href="#trunkSourceWebCorepageFramecpp">trunk/Source/WebCore/page/Frame.cpp</a></li>
<li><a href="#trunkSourceWebCorepagePagecpp">trunk/Source/WebCore/page/Page.cpp</a></li>
<li><a href="#trunkSourceWebCorepagePageh">trunk/Source/WebCore/page/Page.h</a></li>
<li><a href="#trunkSourceWebCorepagePageConfigurationh">trunk/Source/WebCore/page/PageConfiguration.h</a></li>
<li><a href="#trunkSourceWebCorepageUserContentTypesh">trunk/Source/WebCore/page/UserContentTypes.h</a></li>
<li><a href="#trunkSourceWebCorepageUserScripth">trunk/Source/WebCore/page/UserScript.h</a></li>
<li><a href="#trunkSourceWebCorepageUserScriptTypesh">trunk/Source/WebCore/page/UserScriptTypes.h</a></li>
<li><a href="#trunkSourceWebCorepageUserStyleSheeth">trunk/Source/WebCore/page/UserStyleSheet.h</a></li>
<li><a href="#trunkSourceWebCorexmlparserXMLDocumentParserLibxml2cpp">trunk/Source/WebCore/xml/parser/XMLDocumentParserLibxml2.cpp</a></li>
<li><a href="#trunkSourceWebKitChangeLog">trunk/Source/WebKit/ChangeLog</a></li>
<li><a href="#trunkSourceWebKitSharedAPIcWKSharedAPICasth">trunk/Source/WebKit/Shared/API/c/WKSharedAPICast.h</a></li>
<li><a href="#trunkSourceWebKitSharedWebPageCreationParameterscpp">trunk/Source/WebKit/Shared/WebPageCreationParameters.cpp</a></li>
<li><a href="#trunkSourceWebKitSharedWebPageCreationParametersh">trunk/Source/WebKit/Shared/WebPageCreationParameters.h</a></li>
<li><a href="#trunkSourceWebKitSharedWebUserContentControllerDataTypescpp">trunk/Source/WebKit/Shared/WebUserContentControllerDataTypes.cpp</a></li>
<li><a href="#trunkSourceWebKitUIProcessAPIAPIPageConfigurationcpp">trunk/Source/WebKit/UIProcess/API/APIPageConfiguration.cpp</a></li>
<li><a href="#trunkSourceWebKitUIProcessAPIAPIPageConfigurationh">trunk/Source/WebKit/UIProcess/API/APIPageConfiguration.h</a></li>
<li><a href="#trunkSourceWebKitUIProcessAPIAPIUserScripth">trunk/Source/WebKit/UIProcess/API/APIUserScript.h</a></li>
<li><a href="#trunkSourceWebKitUIProcessAPICWKPageGroupcpp">trunk/Source/WebKit/UIProcess/API/C/WKPageGroup.cpp</a></li>
<li><a href="#trunkSourceWebKitUIProcessAPICWKUserScriptRefcpp">trunk/Source/WebKit/UIProcess/API/C/WKUserScriptRef.cpp</a></li>
<li><a href="#trunkSourceWebKitUIProcessAPICocoaWKUserScriptmm">trunk/Source/WebKit/UIProcess/API/Cocoa/WKUserScript.mm</a></li>
<li><a href="#trunkSourceWebKitUIProcessAPICocoaWKUserScriptInternalh">trunk/Source/WebKit/UIProcess/API/Cocoa/WKUserScriptInternal.h</a></li>
<li><a href="#trunkSourceWebKitUIProcessAPICocoaWKUserScriptPrivateh">trunk/Source/WebKit/UIProcess/API/Cocoa/WKUserScriptPrivate.h</a></li>
<li><a href="#trunkSourceWebKitUIProcessAPICocoaWKWebViewmm">trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm</a></li>
<li><a href="#trunkSourceWebKitUIProcessAPICocoaWKWebViewConfigurationmm">trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewConfiguration.mm</a></li>
<li><a href="#trunkSourceWebKitUIProcessAPICocoaWKWebViewConfigurationPrivateh">trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewConfigurationPrivate.h</a></li>
<li><a href="#trunkSourceWebKitUIProcessAPICocoaWKWebViewPrivateh">trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewPrivate.h</a></li>
<li><a href="#trunkSourceWebKitUIProcessAPICocoa_WKUserStyleSheetmm">trunk/Source/WebKit/UIProcess/API/Cocoa/_WKUserStyleSheet.mm</a></li>
<li><a href="#trunkSourceWebKitUIProcessAPIglibWebKitUserContentcpp">trunk/Source/WebKit/UIProcess/API/glib/WebKitUserContent.cpp</a></li>
<li><a href="#trunkSourceWebKitUIProcessWebPageProxycpp">trunk/Source/WebKit/UIProcess/WebPageProxy.cpp</a></li>
<li><a href="#trunkSourceWebKitUIProcessWebPageProxyh">trunk/Source/WebKit/UIProcess/WebPageProxy.h</a></li>
<li><a href="#trunkSourceWebKitWebProcessUserContentWebUserContentControllercpp">trunk/Source/WebKit/WebProcess/UserContent/WebUserContentController.cpp</a></li>
<li><a href="#trunkSourceWebKitWebProcessWebPageWebPagecpp">trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp</a></li>
<li><a href="#trunkSourceWebKitWebProcessWebPageWebPageh">trunk/Source/WebKit/WebProcess/WebPage/WebPage.h</a></li>
<li><a href="#trunkSourceWebKitWebProcessWebPageWebPagemessagesin">trunk/Source/WebKit/WebProcess/WebPage/WebPage.messages.in</a></li>
<li><a href="#trunkSourceWebKitLegacymacChangeLog">trunk/Source/WebKitLegacy/mac/ChangeLog</a></li>
<li><a href="#trunkSourceWebKitLegacymacWebViewWebViewmm">trunk/Source/WebKitLegacy/mac/WebView/WebView.mm</a></li>
<li><a href="#trunkSourceWebKitLegacywinChangeLog">trunk/Source/WebKitLegacy/win/ChangeLog</a></li>
<li><a href="#trunkSourceWebKitLegacywinWebViewcpp">trunk/Source/WebKitLegacy/win/WebView.cpp</a></li>
<li><a href="#trunkToolsChangeLog">trunk/Tools/ChangeLog</a></li>
<li><a href="#trunkToolsTestWebKitAPITestsWebKitCocoaUserContentControllermm">trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/UserContentController.mm</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (259522 => 259523)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog   2020-04-04 00:16:04 UTC (rev 259522)
+++ trunk/Source/WebCore/ChangeLog      2020-04-04 00:44:31 UTC (rev 259523)
</span><span class="lines">@@ -1,5 +1,53 @@
</span><span class="cx"> 2020-04-03  Alex Christensen  <achristensen@webkit.org>
</span><span class="cx"> 
</span><ins>+        Add SPI to make WKUserScripts wait for a notification
+        https://bugs.webkit.org/show_bug.cgi?id=209845
+        <rdar://problem/60342299>
+
+        Reviewed by Chris Dumez.
+
+        There's also SPI on WKWebView to provide this notification, and on WKWebViewConfiguration to start out with this notification.
+
+        * dom/ExtensionStyleSheets.cpp:
+        (WebCore::ExtensionStyleSheets::updateInjectedStyleSheetCache const):
+        * html/ImageDocument.cpp:
+        (WebCore::ImageDocument::createDocumentStructure):
+        * html/MediaDocument.cpp:
+        (WebCore::MediaDocumentParser::createDocumentStructure):
+        * html/PluginDocument.cpp:
+        (WebCore::PluginDocumentParser::createDocumentStructure):
+        * html/parser/HTMLConstructionSite.cpp:
+        (WebCore::HTMLConstructionSite::dispatchDocumentElementAvailableIfNeeded):
+        * loader/FrameLoader.cpp:
+        (WebCore::FrameLoader::finishedParsing):
+        * page/Frame.cpp:
+        (WebCore::Frame::injectUserScripts):
+        (WebCore::Frame::injectUserScriptImmediately):
+        * page/Page.cpp:
+        (WebCore::m_deviceOrientationUpdateProvider):
+        (WebCore::Page::notifyToInjectUserScripts):
+        (WebCore::Page::addUserScriptAwaitingNotification):
+        (WebCore::Page::injectUserStyleSheet):
+        (WebCore::Page::removeInjectedUserStyleSheet):
+        * page/Page.h:
+        (WebCore::Page::hasBeenNotifiedToInjectUserScripts const):
+        * page/PageConfiguration.h:
+        * page/UserContentTypes.h:
+        (): Deleted.
+        * page/UserScript.h:
+        (WebCore::UserScript::UserScript):
+        (WebCore::UserScript::waitForNotificationBeforeInjecting const):
+        (WebCore::UserScript::encode const):
+        (WebCore::UserScript::decode):
+        * page/UserScriptTypes.h:
+        (): Deleted.
+        * page/UserStyleSheet.h:
+        (WebCore::UserStyleSheet::UserStyleSheet):
+        * xml/parser/XMLDocumentParserLibxml2.cpp:
+        (WebCore::XMLDocumentParser::startElementNs):
+
+2020-04-03  Alex Christensen  <achristensen@webkit.org>
+
</ins><span class="cx">         Use-after-move of `formState` in WebCore::PolicyChecker::checkNavigationPolicy()
</span><span class="cx">         https://bugs.webkit.org/show_bug.cgi?id=209987
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoredomExtensionStyleSheetscpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/ExtensionStyleSheets.cpp (259522 => 259523)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/ExtensionStyleSheets.cpp        2020-04-04 00:16:04 UTC (rev 259522)
+++ trunk/Source/WebCore/dom/ExtensionStyleSheets.cpp   2020-04-04 00:44:31 UTC (rev 259523)
</span><span class="lines">@@ -138,7 +138,7 @@
</span><span class="cx">         if (userStyleSheet.pageID())
</span><span class="cx">             return;
</span><span class="cx"> 
</span><del>-        if (userStyleSheet.injectedFrames() == InjectInTopFrameOnly && m_document.ownerElement())
</del><ins>+        if (userStyleSheet.injectedFrames() == UserContentInjectedFrames::InjectInTopFrameOnly && m_document.ownerElement())
</ins><span class="cx">             return;
</span><span class="cx"> 
</span><span class="cx">         if (!UserContentURLPattern::matchesPatterns(m_document.url(), userStyleSheet.whitelist(), userStyleSheet.blacklist()))
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlImageDocumentcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/ImageDocument.cpp (259522 => 259523)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/ImageDocument.cpp      2020-04-04 00:16:04 UTC (rev 259522)
+++ trunk/Source/WebCore/html/ImageDocument.cpp 2020-04-04 00:44:31 UTC (rev 259523)
</span><span class="lines">@@ -221,7 +221,7 @@
</span><span class="cx">     appendChild(rootElement);
</span><span class="cx">     rootElement->insertedByParser();
</span><span class="cx"> 
</span><del>-    frame()->injectUserScripts(InjectAtDocumentStart);
</del><ins>+    frame()->injectUserScripts(UserScriptInjectionTime::DocumentStart);
</ins><span class="cx"> 
</span><span class="cx">     // We need a <head> so that the call to setTitle() later on actually has an <head> to append to <title> to.
</span><span class="cx">     auto head = HTMLHeadElement::create(*this);
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlMediaDocumentcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/MediaDocument.cpp (259522 => 259523)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/MediaDocument.cpp      2020-04-04 00:16:04 UTC (rev 259522)
+++ trunk/Source/WebCore/html/MediaDocument.cpp 2020-04-04 00:44:31 UTC (rev 259523)
</span><span class="lines">@@ -93,7 +93,7 @@
</span><span class="cx">     rootElement->insertedByParser();
</span><span class="cx"> 
</span><span class="cx">     if (document.frame())
</span><del>-        document.frame()->injectUserScripts(InjectAtDocumentStart);
</del><ins>+        document.frame()->injectUserScripts(UserScriptInjectionTime::DocumentStart);
</ins><span class="cx"> 
</span><span class="cx"> #if PLATFORM(IOS_FAMILY)
</span><span class="cx">     auto headElement = HTMLHeadElement::create(document);
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlPluginDocumentcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/PluginDocument.cpp (259522 => 259523)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/PluginDocument.cpp     2020-04-04 00:16:04 UTC (rev 259522)
+++ trunk/Source/WebCore/html/PluginDocument.cpp        2020-04-04 00:44:31 UTC (rev 259523)
</span><span class="lines">@@ -74,7 +74,7 @@
</span><span class="cx">     rootElement->insertedByParser();
</span><span class="cx"> 
</span><span class="cx">     if (document.frame())
</span><del>-        document.frame()->injectUserScripts(InjectAtDocumentStart);
</del><ins>+        document.frame()->injectUserScripts(UserScriptInjectionTime::DocumentStart);
</ins><span class="cx"> 
</span><span class="cx"> #if PLATFORM(IOS_FAMILY)
</span><span class="cx">     // Should not be able to zoom into standalone plug-in documents.
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlparserHTMLConstructionSitecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/parser/HTMLConstructionSite.cpp (259522 => 259523)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/parser/HTMLConstructionSite.cpp        2020-04-04 00:16:04 UTC (rev 259522)
+++ trunk/Source/WebCore/html/parser/HTMLConstructionSite.cpp   2020-04-04 00:44:31 UTC (rev 259523)
</span><span class="lines">@@ -270,7 +270,7 @@
</span><span class="cx">         return;
</span><span class="cx"> 
</span><span class="cx">     if (auto frame = makeRefPtr(m_document.frame()))
</span><del>-        frame->injectUserScripts(InjectAtDocumentStart);
</del><ins>+        frame->injectUserScripts(UserScriptInjectionTime::DocumentStart);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void HTMLConstructionSite::insertHTMLHtmlStartTagBeforeHTML(AtomicHTMLToken&& token)
</span></span></pre></div>
<a id="trunkSourceWebCoreloaderFrameLoadercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/loader/FrameLoader.cpp (259522 => 259523)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/loader/FrameLoader.cpp      2020-04-04 00:16:04 UTC (rev 259522)
+++ trunk/Source/WebCore/loader/FrameLoader.cpp 2020-04-04 00:44:31 UTC (rev 259523)
</span><span class="lines">@@ -793,7 +793,7 @@
</span><span class="cx"> {
</span><span class="cx">     LOG(Loading, "WebCoreLoading %s: Finished parsing", m_frame.tree().uniqueName().string().utf8().data());
</span><span class="cx"> 
</span><del>-    m_frame.injectUserScripts(InjectAtDocumentEnd);
</del><ins>+    m_frame.injectUserScripts(UserScriptInjectionTime::DocumentEnd);
</ins><span class="cx"> 
</span><span class="cx">     if (m_stateMachine.creatingInitialEmptyDocument())
</span><span class="cx">         return;
</span></span></pre></div>
<a id="trunkSourceWebCorepageFramecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/Frame.cpp (259522 => 259523)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/Frame.cpp      2020-04-04 00:16:04 UTC (rev 259522)
+++ trunk/Source/WebCore/page/Frame.cpp 2020-04-04 00:44:31 UTC (rev 259523)
</span><span class="lines">@@ -619,9 +619,14 @@
</span><span class="cx">     if (loader().stateMachine().creatingInitialEmptyDocument() && !settings().shouldInjectUserScriptsInInitialEmptyDocument())
</span><span class="cx">         return;
</span><span class="cx"> 
</span><del>-    m_page->userContentProvider().forEachUserScript([this, protectedThis = makeRef(*this), injectionTime](DOMWrapperWorld& world, const UserScript& script) {
-        if (script.injectionTime() == injectionTime)
-            injectUserScriptImmediately(world, script);
</del><ins>+    bool pageWasNotified = m_page->hasBeenNotifiedToInjectUserScripts();
+    m_page->userContentProvider().forEachUserScript([this, protectedThis = makeRef(*this), injectionTime, pageWasNotified] (DOMWrapperWorld& world, const UserScript& script) {
+        if (script.injectionTime() == injectionTime) {
+            if (script.waitForNotificationBeforeInjecting() == WaitForNotificationBeforeInjecting::Yes && !pageWasNotified)
+                m_page->addUserScriptAwaitingNotification(world, script);
+            else
+                injectUserScriptImmediately(world, script);
+        }
</ins><span class="cx">     });
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -637,7 +642,7 @@
</span><span class="cx">     auto* document = this->document();
</span><span class="cx">     if (!document)
</span><span class="cx">         return;
</span><del>-    if (script.injectedFrames() == InjectInTopFrameOnly && !isMainFrame())
</del><ins>+    if (script.injectedFrames() == UserContentInjectedFrames::InjectInTopFrameOnly && !isMainFrame())
</ins><span class="cx">         return;
</span><span class="cx">     if (!UserContentURLPattern::matchesPatterns(document->url(), script.whitelist(), script.blacklist()))
</span><span class="cx">         return;
</span></span></pre></div>
<a id="trunkSourceWebCorepagePagecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/Page.cpp (259522 => 259523)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/Page.cpp       2020-04-04 00:16:04 UTC (rev 259522)
+++ trunk/Source/WebCore/page/Page.cpp  2020-04-04 00:44:31 UTC (rev 259523)
</span><span class="lines">@@ -124,6 +124,7 @@
</span><span class="cx"> #include "UserContentProvider.h"
</span><span class="cx"> #include "UserContentURLPattern.h"
</span><span class="cx"> #include "UserInputBridge.h"
</span><ins>+#include "UserScript.h"
</ins><span class="cx"> #include "UserStyleSheet.h"
</span><span class="cx"> #include "ValidationMessageClient.h"
</span><span class="cx"> #include "VisitedLinkState.h"
</span><span class="lines">@@ -337,6 +338,9 @@
</span><span class="cx">             m_corsDisablingPatterns.uncheckedAppend(WTFMove(parsedPattern));
</span><span class="cx">     }
</span><span class="cx">     m_corsDisablingPatterns.shrinkToFit();
</span><ins>+    
+    if (!pageConfiguration.userScriptsShouldWaitUntilNotification)
+        m_hasBeenNotifiedToInjectUserScripts = true;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> Page::~Page()
</span><span class="lines">@@ -2473,6 +2477,20 @@
</span><span class="cx">     return m_userContentProvider;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void Page::notifyToInjectUserScripts()
+{
+    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();
+}
+
+void Page::addUserScriptAwaitingNotification(DOMWrapperWorld& world, const UserScript& script)
+{
+    m_userScriptsAwaitingNotification.append({ makeRef(world), makeUniqueRef<UserScript>(script) });
+}
+
</ins><span class="cx"> void Page::setUserContentProvider(Ref<UserContentProvider>&& userContentProvider)
</span><span class="cx"> {
</span><span class="cx">     m_userContentProvider->removePage(*this);
</span><span class="lines">@@ -3073,7 +3091,7 @@
</span><span class="cx">         return;
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    if (userStyleSheet.injectedFrames() == InjectInTopFrameOnly) {
</del><ins>+    if (userStyleSheet.injectedFrames() == UserContentInjectedFrames::InjectInTopFrameOnly) {
</ins><span class="cx">         if (auto* document = m_mainFrame->document())
</span><span class="cx">             document->extensionStyleSheets().injectPageSpecificUserStyleSheet(userStyleSheet);
</span><span class="cx">     } else {
</span><span class="lines">@@ -3092,7 +3110,7 @@
</span><span class="cx">         return;
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    if (userStyleSheet.injectedFrames() == InjectInTopFrameOnly) {
</del><ins>+    if (userStyleSheet.injectedFrames() == UserContentInjectedFrames::InjectInTopFrameOnly) {
</ins><span class="cx">         if (auto* document = m_mainFrame->document())
</span><span class="cx">             document->extensionStyleSheets().removePageSpecificUserStyleSheet(userStyleSheet);
</span><span class="cx">     } else {
</span></span></pre></div>
<a id="trunkSourceWebCorepagePageh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/Page.h (259522 => 259523)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/Page.h 2020-04-04 00:16:04 UTC (rev 259522)
+++ trunk/Source/WebCore/page/Page.h    2020-04-04 00:44:31 UTC (rev 259523)
</span><span class="lines">@@ -140,6 +140,7 @@
</span><span class="cx"> class UserContentProvider;
</span><span class="cx"> class UserContentURLPattern;
</span><span class="cx"> class UserInputBridge;
</span><ins>+class UserScript;
</ins><span class="cx"> class UserStyleSheet;
</span><span class="cx"> class ValidationMessageClient;
</span><span class="cx"> class VisibleSelection;
</span><span class="lines">@@ -734,6 +735,10 @@
</span><span class="cx">     bool shouldFireResizeEvents() const { return m_shouldFireResizeEvents; }
</span><span class="cx">     void setShouldFireResizeEvents(bool shouldFireResizeEvents) { m_shouldFireResizeEvents = shouldFireResizeEvents; }
</span><span class="cx"> 
</span><ins>+    bool hasBeenNotifiedToInjectUserScripts() const { return m_hasBeenNotifiedToInjectUserScripts; }
+    WEBCORE_EXPORT void notifyToInjectUserScripts();
+    void addUserScriptAwaitingNotification(DOMWrapperWorld&, const UserScript&);
+
</ins><span class="cx"> private:
</span><span class="cx">     struct Navigation {
</span><span class="cx">         RegistrableDomain domain;
</span><span class="lines">@@ -1015,6 +1020,8 @@
</span><span class="cx">     bool m_shouldFireResizeEvents { true };
</span><span class="cx">     bool m_loadsSubresources { true };
</span><span class="cx">     bool m_loadsFromNetwork { true };
</span><ins>+    bool m_hasBeenNotifiedToInjectUserScripts { false };
+    Vector<std::pair<Ref<DOMWrapperWorld>, UniqueRef<UserScript>>> m_userScriptsAwaitingNotification;
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> inline PageGroup& Page::group()
</span></span></pre></div>
<a id="trunkSourceWebCorepagePageConfigurationh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/PageConfiguration.h (259522 => 259523)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/PageConfiguration.h    2020-04-04 00:16:04 UTC (rev 259522)
+++ trunk/Source/WebCore/page/PageConfiguration.h       2020-04-04 00:44:31 UTC (rev 259523)
</span><span class="lines">@@ -129,6 +129,7 @@
</span><span class="cx">     UniqueRef<MediaRecorderProvider> mediaRecorderProvider;
</span><span class="cx">     bool loadsSubresources { true };
</span><span class="cx">     bool loadsFromNetwork { true };
</span><ins>+    bool userScriptsShouldWaitUntilNotification { true };
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCorepageUserContentTypesh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/UserContentTypes.h (259522 => 259523)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/UserContentTypes.h     2020-04-04 00:16:04 UTC (rev 259522)
+++ trunk/Source/WebCore/page/UserContentTypes.h        2020-04-04 00:44:31 UTC (rev 259523)
</span><span class="lines">@@ -27,6 +27,6 @@
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><del>-enum UserContentInjectedFrames { InjectInAllFrames, InjectInTopFrameOnly };
</del><ins>+enum class UserContentInjectedFrames : bool { InjectInAllFrames, InjectInTopFrameOnly };
</ins><span class="cx"> 
</span><span class="cx"> } // namespace WebCore
</span></span></pre></div>
<a id="trunkSourceWebCorepageUserScripth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/UserScript.h (259522 => 259523)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/UserScript.h   2020-04-04 00:16:04 UTC (rev 259522)
+++ trunk/Source/WebCore/page/UserScript.h      2020-04-04 00:44:31 UTC (rev 259523)
</span><span class="lines">@@ -35,10 +35,13 @@
</span><span class="cx"> class UserScript {
</span><span class="cx">     WTF_MAKE_FAST_ALLOCATED;
</span><span class="cx"> public:
</span><del>-    UserScript() = default;
</del><span class="cx">     ~UserScript() = default;
</span><ins>+    UserScript(const UserScript&) = default;
+    UserScript(UserScript&&) = default;
+    UserScript& operator=(const UserScript&) = default;
+    UserScript& operator=(UserScript&&) = default;
</ins><span class="cx"> 
</span><del>-    UserScript(String&& source, URL&& url, Vector<String>&& whitelist, Vector<String>&& blacklist, UserScriptInjectionTime injectionTime, UserContentInjectedFrames injectedFrames)
</del><ins>+    UserScript(String&& source, URL&& url, Vector<String>&& whitelist, Vector<String>&& blacklist, UserScriptInjectionTime injectionTime, UserContentInjectedFrames injectedFrames, WaitForNotificationBeforeInjecting waitForNotification)
</ins><span class="cx">         : m_source(WTFMove(source))
</span><span class="cx">         , m_url(WTFMove(url))
</span><span class="cx">         , m_whitelist(WTFMove(whitelist))
</span><span class="lines">@@ -45,6 +48,7 @@
</span><span class="cx">         , m_blacklist(WTFMove(blacklist))
</span><span class="cx">         , m_injectionTime(injectionTime)
</span><span class="cx">         , m_injectedFrames(injectedFrames)
</span><ins>+        , m_waitForNotificationBeforeInjecting(waitForNotification)
</ins><span class="cx">     {
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="lines">@@ -54,9 +58,10 @@
</span><span class="cx">     const Vector<String>& blacklist() const { return m_blacklist; }
</span><span class="cx">     UserScriptInjectionTime injectionTime() const { return m_injectionTime; }
</span><span class="cx">     UserContentInjectedFrames injectedFrames() const { return m_injectedFrames; }
</span><ins>+    WaitForNotificationBeforeInjecting waitForNotificationBeforeInjecting() const { return m_waitForNotificationBeforeInjecting; }
</ins><span class="cx"> 
</span><span class="cx">     template<class Encoder> void encode(Encoder&) const;
</span><del>-    template<class Decoder> static bool decode(Decoder&, UserScript&);
</del><ins>+    template<class Decoder> static Optional<UserScript> decode(Decoder&);
</ins><span class="cx"> 
</span><span class="cx"> private:
</span><span class="cx">     String m_source;
</span><span class="lines">@@ -63,8 +68,9 @@
</span><span class="cx">     URL m_url;
</span><span class="cx">     Vector<String> m_whitelist;
</span><span class="cx">     Vector<String> m_blacklist;
</span><del>-    UserScriptInjectionTime m_injectionTime { InjectAtDocumentStart };
-    UserContentInjectedFrames m_injectedFrames { InjectInAllFrames };
</del><ins>+    UserScriptInjectionTime m_injectionTime { UserScriptInjectionTime::DocumentStart };
+    UserContentInjectedFrames m_injectedFrames { UserContentInjectedFrames::InjectInAllFrames };
+    WaitForNotificationBeforeInjecting m_waitForNotificationBeforeInjecting { WaitForNotificationBeforeInjecting::No };
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> template<class Encoder>
</span><span class="lines">@@ -74,39 +80,58 @@
</span><span class="cx">     encoder << m_url;
</span><span class="cx">     encoder << m_whitelist;
</span><span class="cx">     encoder << m_blacklist;
</span><del>-    encoder.encodeEnum(m_injectionTime);
-    encoder.encodeEnum(m_injectedFrames);
</del><ins>+    encoder << m_injectionTime;
+    encoder << m_injectedFrames;
+    encoder << m_waitForNotificationBeforeInjecting;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> template<class Decoder>
</span><del>-bool UserScript::decode(Decoder& decoder, UserScript& userScript)
</del><ins>+Optional<UserScript> UserScript::decode(Decoder& decoder)
</ins><span class="cx"> {
</span><del>-    String source;
-    if (!decoder.decode(source))
-        return false;
</del><ins>+    Optional<String> source;
+    decoder >> source;
+    if (!source)
+        return WTF::nullopt;
</ins><span class="cx">     
</span><del>-    URL url;
-    if (!decoder.decode(url))
-        return false;
</del><ins>+    Optional<URL> url;
+    decoder >> url;
+    if (!url)
+        return WTF::nullopt;
</ins><span class="cx">     
</span><del>-    Vector<String> whitelist;
-    if (!decoder.decode(whitelist))
-        return false;
</del><ins>+    Optional<Vector<String>> whitelist;
+    decoder >> whitelist;
+    if (!whitelist)
+        return WTF::nullopt;
</ins><span class="cx">     
</span><del>-    Vector<String> blacklist;
-    if (!decoder.decode(blacklist))
-        return false;
</del><ins>+    Optional<Vector<String>> blacklist;
+    decoder >> blacklist;
+    if (!blacklist)
+        return WTF::nullopt;
</ins><span class="cx">     
</span><del>-    UserScriptInjectionTime injectionTime;
-    if (!decoder.decodeEnum(injectionTime))
-        return false;
</del><ins>+    Optional<UserScriptInjectionTime> injectionTime;
+    decoder >> injectionTime;
+    if (!injectionTime)
+        return WTF::nullopt;
</ins><span class="cx">     
</span><del>-    UserContentInjectedFrames injectedFrames;
-    if (!decoder.decodeEnum(injectedFrames))
-        return false;
</del><ins>+    Optional<UserContentInjectedFrames> injectedFrames;
+    decoder >> injectedFrames;
+    if (!injectedFrames)
+        return WTF::nullopt;
</ins><span class="cx">     
</span><del>-    userScript = { WTFMove(source), WTFMove(url), WTFMove(whitelist), WTFMove(blacklist), injectionTime, injectedFrames };
-    return true;
</del><ins>+    Optional<WaitForNotificationBeforeInjecting> waitForNotification;
+    decoder >> waitForNotification;
+    if (!waitForNotification)
+        return WTF::nullopt;
+    
+    return {{
+        WTFMove(*source),
+        WTFMove(*url),
+        WTFMove(*whitelist),
+        WTFMove(*blacklist),
+        WTFMove(*injectionTime),
+        WTFMove(*injectedFrames),
+        WTFMove(*waitForNotification)
+    }};
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> } // namespace WebCore
</span></span></pre></div>
<a id="trunkSourceWebCorepageUserScriptTypesh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/UserScriptTypes.h (259522 => 259523)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/UserScriptTypes.h      2020-04-04 00:16:04 UTC (rev 259522)
+++ trunk/Source/WebCore/page/UserScriptTypes.h 2020-04-04 00:44:31 UTC (rev 259523)
</span><span class="lines">@@ -30,7 +30,8 @@
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><del>-enum UserScriptInjectionTime { InjectAtDocumentStart, InjectAtDocumentEnd };
</del><ins>+enum class UserScriptInjectionTime : bool { DocumentStart, DocumentEnd };
+enum class WaitForNotificationBeforeInjecting : bool { No, Yes };
</ins><span class="cx"> 
</span><span class="cx"> class DOMWrapperWorld;
</span><span class="cx"> class UserScript;
</span></span></pre></div>
<a id="trunkSourceWebCorepageUserStyleSheeth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/UserStyleSheet.h (259522 => 259523)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/UserStyleSheet.h       2020-04-04 00:16:04 UTC (rev 259522)
+++ trunk/Source/WebCore/page/UserStyleSheet.h  2020-04-04 00:44:31 UTC (rev 259523)
</span><span class="lines">@@ -38,7 +38,7 @@
</span><span class="cx">     WTF_MAKE_FAST_ALLOCATED;
</span><span class="cx"> public:
</span><span class="cx">     UserStyleSheet()
</span><del>-        : m_injectedFrames(InjectInAllFrames)
</del><ins>+        : m_injectedFrames(UserContentInjectedFrames::InjectInAllFrames)
</ins><span class="cx">         , m_level(UserStyleUserLevel)
</span><span class="cx">     {
</span><span class="cx">     }
</span></span></pre></div>
<a id="trunkSourceWebCorexmlparserXMLDocumentParserLibxml2cpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/xml/parser/XMLDocumentParserLibxml2.cpp (259522 => 259523)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/xml/parser/XMLDocumentParserLibxml2.cpp     2020-04-04 00:16:04 UTC (rev 259522)
+++ trunk/Source/WebCore/xml/parser/XMLDocumentParserLibxml2.cpp        2020-04-04 00:44:31 UTC (rev 259523)
</span><span class="lines">@@ -813,7 +813,7 @@
</span><span class="cx">         downcast<HTMLHtmlElement>(newElement.get()).insertedByParser();
</span><span class="cx"> 
</span><span class="cx">     if (!m_parsingFragment && isFirstElement && document()->frame())
</span><del>-        document()->frame()->injectUserScripts(InjectAtDocumentStart);
</del><ins>+        document()->frame()->injectUserScripts(UserScriptInjectionTime::DocumentStart);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void XMLDocumentParser::endElementNs()
</span></span></pre></div>
<a id="trunkSourceWebKitChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/ChangeLog (259522 => 259523)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/ChangeLog    2020-04-04 00:16:04 UTC (rev 259522)
+++ trunk/Source/WebKit/ChangeLog       2020-04-04 00:44:31 UTC (rev 259523)
</span><span class="lines">@@ -1,5 +1,68 @@
</span><span class="cx"> 2020-04-03  Alex Christensen  <achristensen@webkit.org>
</span><span class="cx"> 
</span><ins>+        Add SPI to make WKUserScripts wait for a notification
+        https://bugs.webkit.org/show_bug.cgi?id=209845
+        <rdar://problem/60342299>
+
+        Reviewed by Chris Dumez.
+
+        * Shared/API/c/WKSharedAPICast.h:
+        (WebKit::toUserScriptInjectionTime):
+        (WebKit::toWKUserScriptInjectionTime):
+        (WebKit::toUserContentInjectedFrames):
+        * Shared/WebPageCreationParameters.cpp:
+        (WebKit::WebPageCreationParameters::encode const):
+        (WebKit::WebPageCreationParameters::decode):
+        * Shared/WebPageCreationParameters.h:
+        * Shared/WebUserContentControllerDataTypes.cpp:
+        (WebKit::WebUserScriptData::decode):
+        * UIProcess/API/APIPageConfiguration.h:
+        (API::PageConfiguration::userScriptsShouldWaitUntilNotification const):
+        (API::PageConfiguration::setUserScriptsShouldWaitUntilNotification):
+        * UIProcess/API/APIUserScript.h:
+        * UIProcess/API/C/WKPageGroup.cpp:
+        (WKPageGroupAddUserScript):
+        * UIProcess/API/C/WKUserScriptRef.cpp:
+        (WKUserScriptCreateWithSource):
+        (WKUserScriptGetMainFrameOnly):
+        * UIProcess/API/Cocoa/WKUserScript.mm:
+        (-[WKUserScript initWithSource:injectionTime:forMainFrameOnly:]):
+        (-[WKUserScript isForMainFrameOnly]):
+        (-[WKUserScript _initWithSource:injectionTime:forMainFrameOnly:legacyWhitelist:legacyBlacklist:userContentWorld:]):
+        (-[WKUserScript _initWithSource:injectionTime:forMainFrameOnly:legacyWhitelist:legacyBlacklist:associatedURL:userContentWorld:]):
+        (-[WKUserScript _initWithSource:injectionTime:forMainFrameOnly:legacyWhitelist:legacyBlacklist:contentWorld:]):
+        (-[WKUserScript _initWithSource:injectionTime:forMainFrameOnly:legacyWhitelist:legacyBlacklist:associatedURL:contentWorld:]):
+        (-[WKUserScript _initWithSource:injectionTime:forMainFrameOnly:legacyWhitelist:legacyBlacklist:associatedURL:contentWorld:waitForNotification:]):
+        * UIProcess/API/Cocoa/WKUserScriptInternal.h:
+        (API::toWebCoreUserScriptInjectionTime):
+        (API::toWKUserScriptInjectionTime):
+        * UIProcess/API/Cocoa/WKUserScriptPrivate.h:
+        * UIProcess/API/Cocoa/WKWebView.mm:
+        (-[WKWebView _notifyUserScripts]):
+        * UIProcess/API/Cocoa/WKWebViewConfiguration.mm:
+        (-[WKWebViewConfiguration _userScriptsShouldWaitUntilNotification]):
+        (-[WKWebViewConfiguration _setUserScriptsShouldWaitUntilNotification:]):
+        * UIProcess/API/Cocoa/WKWebViewConfigurationPrivate.h:
+        * UIProcess/API/Cocoa/WKWebViewPrivate.h:
+        * UIProcess/API/Cocoa/_WKUserStyleSheet.mm:
+        (-[_WKUserStyleSheet initWithSource:forMainFrameOnly:]):
+        (-[_WKUserStyleSheet initWithSource:forWKWebView:forMainFrameOnly:userContentWorld:]):
+        (-[_WKUserStyleSheet initWithSource:forMainFrameOnly:legacyWhitelist:legacyBlacklist:userContentWorld:]):
+        (-[_WKUserStyleSheet initWithSource:forMainFrameOnly:legacyWhitelist:legacyBlacklist:baseURL:userContentWorld:]):
+        (-[_WKUserStyleSheet isForMainFrameOnly]):
+        * UIProcess/WebPageProxy.cpp:
+        * UIProcess/WebPageProxy.h:
+        * WebProcess/UserContent/WebUserContentController.cpp:
+        (WebKit::WebUserContentController::addUserScriptInternal):
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::m_processDisplayName):
+        (WebKit::WebPage::notifyUserScripts):
+        (WebKit::WebPage::addUserScript):
+        * WebProcess/WebPage/WebPage.h:
+        * WebProcess/WebPage/WebPage.messages.in:
+
+2020-04-03  Alex Christensen  <achristensen@webkit.org>
+
</ins><span class="cx">         Use AuthenticationChallenge instead of AuthenticationChallengeProxy for ResourceLoadDelegate
</span><span class="cx">         https://bugs.webkit.org/show_bug.cgi?id=207639
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKitSharedAPIcWKSharedAPICasth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/Shared/API/c/WKSharedAPICast.h (259522 => 259523)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/Shared/API/c/WKSharedAPICast.h       2020-04-04 00:16:04 UTC (rev 259522)
+++ trunk/Source/WebKit/Shared/API/c/WKSharedAPICast.h  2020-04-04 00:44:31 UTC (rev 259523)
</span><span class="lines">@@ -993,21 +993,21 @@
</span><span class="cx"> {
</span><span class="cx">     switch (wkInjectedTime) {
</span><span class="cx">     case kWKInjectAtDocumentStart:
</span><del>-        return WebCore::InjectAtDocumentStart;
</del><ins>+        return WebCore::UserScriptInjectionTime::DocumentStart;
</ins><span class="cx">     case kWKInjectAtDocumentEnd:
</span><del>-        return WebCore::InjectAtDocumentEnd;
</del><ins>+        return WebCore::UserScriptInjectionTime::DocumentEnd;
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     ASSERT_NOT_REACHED();
</span><del>-    return WebCore::InjectAtDocumentStart;
</del><ins>+    return WebCore::UserScriptInjectionTime::DocumentStart;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> inline _WKUserScriptInjectionTime toWKUserScriptInjectionTime(WebCore::UserScriptInjectionTime injectedTime)
</span><span class="cx"> {
</span><span class="cx">     switch (injectedTime) {
</span><del>-    case WebCore::InjectAtDocumentStart:
</del><ins>+    case WebCore::UserScriptInjectionTime::DocumentStart:
</ins><span class="cx">         return kWKInjectAtDocumentStart;
</span><del>-    case WebCore::InjectAtDocumentEnd:
</del><ins>+    case WebCore::UserScriptInjectionTime::DocumentEnd:
</ins><span class="cx">         return kWKInjectAtDocumentEnd;
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="lines">@@ -1019,13 +1019,13 @@
</span><span class="cx"> {
</span><span class="cx">     switch (wkInjectedFrames) {
</span><span class="cx">     case kWKInjectInAllFrames:
</span><del>-        return WebCore::InjectInAllFrames;
</del><ins>+        return WebCore::UserContentInjectedFrames::InjectInAllFrames;
</ins><span class="cx">     case kWKInjectInTopFrameOnly:
</span><del>-        return WebCore::InjectInTopFrameOnly;
</del><ins>+        return WebCore::UserContentInjectedFrames::InjectInTopFrameOnly;
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     ASSERT_NOT_REACHED();
</span><del>-    return WebCore::InjectInAllFrames;
</del><ins>+    return WebCore::UserContentInjectedFrames::InjectInAllFrames;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> } // namespace WebKit
</span></span></pre></div>
<a id="trunkSourceWebKitSharedWebPageCreationParameterscpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/Shared/WebPageCreationParameters.cpp (259522 => 259523)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/Shared/WebPageCreationParameters.cpp 2020-04-04 00:16:04 UTC (rev 259522)
+++ trunk/Source/WebKit/Shared/WebPageCreationParameters.cpp    2020-04-04 00:44:31 UTC (rev 259523)
</span><span class="lines">@@ -135,6 +135,7 @@
</span><span class="cx">     encoder << corsDisablingPatterns;
</span><span class="cx">     encoder << loadsSubresources;
</span><span class="cx">     encoder << loadsFromNetwork;
</span><ins>+    encoder << userScriptsShouldWaitUntilNotification;
</ins><span class="cx">     encoder << crossOriginAccessControlCheckEnabled;
</span><span class="cx">     encoder << processDisplayName;
</span><span class="cx"> 
</span><span class="lines">@@ -430,6 +431,12 @@
</span><span class="cx">         return WTF::nullopt;
</span><span class="cx">     parameters.loadsFromNetwork = *loadsFromNetwork;
</span><span class="cx"> 
</span><ins>+    Optional<bool> userScriptsShouldWaitUntilNotification;
+    decoder >> userScriptsShouldWaitUntilNotification;
+    if (!userScriptsShouldWaitUntilNotification)
+        return WTF::nullopt;
+    parameters.userScriptsShouldWaitUntilNotification = *userScriptsShouldWaitUntilNotification;
+    
</ins><span class="cx">     Optional<bool> crossOriginAccessControlCheckEnabled;
</span><span class="cx">     decoder >> crossOriginAccessControlCheckEnabled;
</span><span class="cx">     if (!crossOriginAccessControlCheckEnabled)
</span></span></pre></div>
<a id="trunkSourceWebKitSharedWebPageCreationParametersh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/Shared/WebPageCreationParameters.h (259522 => 259523)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/Shared/WebPageCreationParameters.h   2020-04-04 00:16:04 UTC (rev 259522)
+++ trunk/Source/WebKit/Shared/WebPageCreationParameters.h      2020-04-04 00:44:31 UTC (rev 259523)
</span><span class="lines">@@ -202,6 +202,7 @@
</span><span class="cx"> 
</span><span class="cx">     String overriddenMediaType;
</span><span class="cx">     Vector<String> corsDisablingPatterns;
</span><ins>+    bool userScriptsShouldWaitUntilNotification { true };
</ins><span class="cx">     bool loadsSubresources { true };
</span><span class="cx">     bool loadsFromNetwork { true };
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKitSharedWebUserContentControllerDataTypescpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/Shared/WebUserContentControllerDataTypes.cpp (259522 => 259523)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/Shared/WebUserContentControllerDataTypes.cpp 2020-04-04 00:16:04 UTC (rev 259522)
+++ trunk/Source/WebKit/Shared/WebUserContentControllerDataTypes.cpp    2020-04-04 00:44:31 UTC (rev 259523)
</span><span class="lines">@@ -49,11 +49,12 @@
</span><span class="cx">     if (!worldIdentifier)
</span><span class="cx">         return WTF::nullopt;
</span><span class="cx">     
</span><del>-    WebCore::UserScript userScript;
-    if (!decoder.decode(userScript))
</del><ins>+    Optional<WebCore::UserScript> userScript;
+    decoder >> userScript;
+    if (!userScript)
</ins><span class="cx">         return WTF::nullopt;
</span><span class="cx">     
</span><del>-    return {{ WTFMove(*identifier), WTFMove(*worldIdentifier), WTFMove(userScript) }};
</del><ins>+    return {{ WTFMove(*identifier), WTFMove(*worldIdentifier), WTFMove(*userScript) }};
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WebUserStyleSheetData::encode(IPC::Encoder& encoder) const
</span></span></pre></div>
<a id="trunkSourceWebKitUIProcessAPIAPIPageConfigurationcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/UIProcess/API/APIPageConfiguration.cpp (259522 => 259523)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/UIProcess/API/APIPageConfiguration.cpp       2020-04-04 00:16:04 UTC (rev 259522)
+++ trunk/Source/WebKit/UIProcess/API/APIPageConfiguration.cpp  2020-04-04 00:44:31 UTC (rev 259523)
</span><span class="lines">@@ -90,6 +90,7 @@
</span><span class="cx">         copy->m_urlSchemeHandlers.set(pair.key, pair.value.copyRef());
</span><span class="cx">     copy->m_corsDisablingPatterns = this->m_corsDisablingPatterns;
</span><span class="cx">     copy->m_crossOriginAccessControlCheckEnabled = this->m_crossOriginAccessControlCheckEnabled;
</span><ins>+    copy->m_userScriptsShouldWaitUntilNotification = this->m_userScriptsShouldWaitUntilNotification;
</ins><span class="cx">     copy->m_webViewCategory = this->m_webViewCategory;
</span><span class="cx"> 
</span><span class="cx">     copy->m_processDisplayName = this->m_processDisplayName;
</span></span></pre></div>
<a id="trunkSourceWebKitUIProcessAPIAPIPageConfigurationh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/UIProcess/API/APIPageConfiguration.h (259522 => 259523)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/UIProcess/API/APIPageConfiguration.h 2020-04-04 00:16:04 UTC (rev 259522)
+++ trunk/Source/WebKit/UIProcess/API/APIPageConfiguration.h    2020-04-04 00:44:31 UTC (rev 259523)
</span><span class="lines">@@ -136,6 +136,9 @@
</span><span class="cx"> 
</span><span class="cx">     const Vector<WTF::String>& corsDisablingPatterns() const { return m_corsDisablingPatterns; }
</span><span class="cx">     void setCORSDisablingPatterns(Vector<WTF::String>&& patterns) { m_corsDisablingPatterns = WTFMove(patterns); }
</span><ins>+    
+    bool userScriptsShouldWaitUntilNotification() const { return m_userScriptsShouldWaitUntilNotification; }
+    void setUserScriptsShouldWaitUntilNotification(bool value) { m_userScriptsShouldWaitUntilNotification = value; }
</ins><span class="cx"> 
</span><span class="cx">     bool crossOriginAccessControlCheckEnabled() const { return m_crossOriginAccessControlCheckEnabled; }
</span><span class="cx">     void setCrossOriginAccessControlCheckEnabled(bool enabled) { m_crossOriginAccessControlCheckEnabled = enabled; }
</span><span class="lines">@@ -191,6 +194,7 @@
</span><span class="cx"> 
</span><span class="cx">     HashMap<WTF::String, Ref<WebKit::WebURLSchemeHandler>> m_urlSchemeHandlers;
</span><span class="cx">     Vector<WTF::String> m_corsDisablingPatterns;
</span><ins>+    bool m_userScriptsShouldWaitUntilNotification { true };
</ins><span class="cx">     bool m_crossOriginAccessControlCheckEnabled { true };
</span><span class="cx">     WTF::String m_processDisplayName;
</span><span class="cx">     WebKit::WebViewCategory m_webViewCategory { WebKit::WebViewCategory::AppBoundDomain };
</span></span></pre></div>
<a id="trunkSourceWebKitUIProcessAPIAPIUserScripth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/UIProcess/API/APIUserScript.h (259522 => 259523)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/UIProcess/API/APIUserScript.h        2020-04-04 00:16:04 UTC (rev 259522)
+++ trunk/Source/WebKit/UIProcess/API/APIUserScript.h   2020-04-04 00:44:31 UTC (rev 259523)
</span><span class="lines">@@ -36,7 +36,7 @@
</span><span class="cx"> public:
</span><span class="cx">     static WTF::URL generateUniqueURL();
</span><span class="cx"> 
</span><del>-    static Ref<UserScript> create(WebCore::UserScript userScript, API::ContentWorld& world)
</del><ins>+    static Ref<UserScript> create(WebCore::UserScript&& userScript, API::ContentWorld& world)
</ins><span class="cx">     {
</span><span class="cx">         return adoptRef(*new UserScript(WTFMove(userScript), world));
</span><span class="cx">     }
</span><span class="lines">@@ -43,8 +43,9 @@
</span><span class="cx"> 
</span><span class="cx">     UserScript(WebCore::UserScript, API::ContentWorld&);
</span><span class="cx"> 
</span><ins>+    WebCore::UserScript& userScript() { return m_userScript; }
</ins><span class="cx">     const WebCore::UserScript& userScript() const { return m_userScript; }
</span><del>-    
</del><ins>+
</ins><span class="cx">     ContentWorld& contentWorld() { return m_world; }
</span><span class="cx">     const ContentWorld& contentWorld() const { return m_world; }
</span><span class="cx">     
</span></span></pre></div>
<a id="trunkSourceWebKitUIProcessAPICWKPageGroupcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/UIProcess/API/C/WKPageGroup.cpp (259522 => 259523)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/UIProcess/API/C/WKPageGroup.cpp      2020-04-04 00:16:04 UTC (rev 259522)
+++ trunk/Source/WebKit/UIProcess/API/C/WKPageGroup.cpp 2020-04-04 00:44:31 UTC (rev 259523)
</span><span class="lines">@@ -99,7 +99,7 @@
</span><span class="cx">     auto blacklist = toImpl(blacklistedURLPatterns);
</span><span class="cx">     
</span><span class="cx">     auto url = baseURLString.isEmpty() ? aboutBlankURL() :  URL(URL(), baseURLString);
</span><del>-    Ref<API::UserScript> userScript = API::UserScript::create(WebCore::UserScript { WTFMove(source), WTFMove(url), whitelist ? whitelist->toStringVector() : Vector<String>(), blacklist ? blacklist->toStringVector() : Vector<String>(), toUserScriptInjectionTime(injectionTime), toUserContentInjectedFrames(injectedFrames) }, API::ContentWorld::pageContentWorld());
</del><ins>+    Ref<API::UserScript> userScript = API::UserScript::create(WebCore::UserScript { WTFMove(source), WTFMove(url), whitelist ? whitelist->toStringVector() : Vector<String>(), blacklist ? blacklist->toStringVector() : Vector<String>(), toUserScriptInjectionTime(injectionTime), toUserContentInjectedFrames(injectedFrames), WebCore::WaitForNotificationBeforeInjecting::No }, API::ContentWorld::pageContentWorld());
</ins><span class="cx">     toImpl(pageGroupRef)->userContentController().addUserScript(userScript.get(), InjectUserScriptImmediately::No);
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKitUIProcessAPICWKUserScriptRefcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/UIProcess/API/C/WKUserScriptRef.cpp (259522 => 259523)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/UIProcess/API/C/WKUserScriptRef.cpp  2020-04-04 00:16:04 UTC (rev 259522)
+++ trunk/Source/WebKit/UIProcess/API/C/WKUserScriptRef.cpp     2020-04-04 00:44:31 UTC (rev 259523)
</span><span class="lines">@@ -38,7 +38,7 @@
</span><span class="cx"> 
</span><span class="cx"> WKUserScriptRef WKUserScriptCreateWithSource(WKStringRef sourceRef, _WKUserScriptInjectionTime injectionTime, bool forMainFrameOnly)
</span><span class="cx"> {
</span><del>-    return toAPI(&API::UserScript::create(WebCore::UserScript { toWTFString(sourceRef), API::UserScript::generateUniqueURL(), { }, { }, toUserScriptInjectionTime(injectionTime), forMainFrameOnly ? WebCore::InjectInTopFrameOnly : WebCore::InjectInAllFrames }, API::ContentWorld::pageContentWorld()).leakRef());
</del><ins>+    return toAPI(&API::UserScript::create(WebCore::UserScript { toWTFString(sourceRef), API::UserScript::generateUniqueURL(), { }, { }, toUserScriptInjectionTime(injectionTime), forMainFrameOnly ? WebCore::UserContentInjectedFrames::InjectInTopFrameOnly : WebCore::UserContentInjectedFrames::InjectInAllFrames, WebCore::WaitForNotificationBeforeInjecting::No }, API::ContentWorld::pageContentWorld()).leakRef());
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> WKStringRef WKUserScriptCopySource(WKUserScriptRef userScriptRef)
</span><span class="lines">@@ -53,5 +53,5 @@
</span><span class="cx"> 
</span><span class="cx"> bool WKUserScriptGetMainFrameOnly(WKUserScriptRef userScriptRef)
</span><span class="cx"> {
</span><del>-    return toImpl(userScriptRef)->userScript().injectedFrames() == WebCore::InjectInTopFrameOnly;
</del><ins>+    return toImpl(userScriptRef)->userScript().injectedFrames() == WebCore::UserContentInjectedFrames::InjectInTopFrameOnly;
</ins><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebKitUIProcessAPICocoaWKUserScriptmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKUserScript.mm (259522 => 259523)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKUserScript.mm  2020-04-04 00:16:04 UTC (rev 259522)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKUserScript.mm     2020-04-04 00:44:31 UTC (rev 259523)
</span><span class="lines">@@ -35,7 +35,7 @@
</span><span class="cx">     if (!(self = [super init]))
</span><span class="cx">         return nil;
</span><span class="cx"> 
</span><del>-    API::Object::constructInWrapper<API::UserScript>(self, WebCore::UserScript { WTF::String(source), API::UserScript::generateUniqueURL(), { }, { }, API::toWebCoreUserScriptInjectionTime(injectionTime), forMainFrameOnly ? WebCore::InjectInTopFrameOnly : WebCore::InjectInAllFrames }, API::ContentWorld::pageContentWorld());
</del><ins>+    API::Object::constructInWrapper<API::UserScript>(self, WebCore::UserScript { WTF::String(source), API::UserScript::generateUniqueURL(), { }, { }, API::toWebCoreUserScriptInjectionTime(injectionTime), forMainFrameOnly ? WebCore::UserContentInjectedFrames::InjectInTopFrameOnly : WebCore::UserContentInjectedFrames::InjectInAllFrames, WebCore::WaitForNotificationBeforeInjecting::No }, API::ContentWorld::pageContentWorld());
</ins><span class="cx"> 
</span><span class="cx">     return self;
</span><span class="cx"> }
</span><span class="lines">@@ -59,7 +59,7 @@
</span><span class="cx"> 
</span><span class="cx"> - (BOOL)isForMainFrameOnly
</span><span class="cx"> {
</span><del>-    return _userScript->userScript().injectedFrames() == WebCore::InjectInTopFrameOnly;
</del><ins>+    return _userScript->userScript().injectedFrames() == WebCore::UserContentInjectedFrames::InjectInTopFrameOnly;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> - (id)copyWithZone:(NSZone *)zone
</span><span class="lines">@@ -84,7 +84,7 @@
</span><span class="cx">     if (!(self = [super init]))
</span><span class="cx">         return nil;
</span><span class="cx"> 
</span><del>-    API::Object::constructInWrapper<API::UserScript>(self, WebCore::UserScript { WTF::String(source), API::UserScript::generateUniqueURL(), API::toStringVector(legacyWhitelist), API::toStringVector(legacyBlacklist), API::toWebCoreUserScriptInjectionTime(injectionTime), forMainFrameOnly ? WebCore::InjectInTopFrameOnly : WebCore::InjectInAllFrames }, *userContentWorld->_contentWorld->_contentWorld);
</del><ins>+    API::Object::constructInWrapper<API::UserScript>(self, WebCore::UserScript { WTF::String(source), API::UserScript::generateUniqueURL(), API::toStringVector(legacyWhitelist), API::toStringVector(legacyBlacklist), API::toWebCoreUserScriptInjectionTime(injectionTime), forMainFrameOnly ? WebCore::UserContentInjectedFrames::InjectInTopFrameOnly : WebCore::UserContentInjectedFrames::InjectInAllFrames, WebCore::WaitForNotificationBeforeInjecting::No }, *userContentWorld->_contentWorld->_contentWorld);
</ins><span class="cx"> 
</span><span class="cx">     return self;
</span><span class="cx"> }
</span><span class="lines">@@ -94,7 +94,7 @@
</span><span class="cx">     if (!(self = [super init]))
</span><span class="cx">         return nil;
</span><span class="cx"> 
</span><del>-    API::Object::constructInWrapper<API::UserScript>(self, WebCore::UserScript { WTF::String(source), URL(associatedURL), API::toStringVector(legacyWhitelist), API::toStringVector(legacyBlacklist), API::toWebCoreUserScriptInjectionTime(injectionTime), forMainFrameOnly ? WebCore::InjectInTopFrameOnly : WebCore::InjectInAllFrames }, *userContentWorld->_contentWorld->_contentWorld);
</del><ins>+    API::Object::constructInWrapper<API::UserScript>(self, WebCore::UserScript { WTF::String(source), URL(associatedURL), API::toStringVector(legacyWhitelist), API::toStringVector(legacyBlacklist), API::toWebCoreUserScriptInjectionTime(injectionTime), forMainFrameOnly ? WebCore::UserContentInjectedFrames::InjectInTopFrameOnly : WebCore::UserContentInjectedFrames::InjectInAllFrames, WebCore::WaitForNotificationBeforeInjecting::No }, *userContentWorld->_contentWorld->_contentWorld);
</ins><span class="cx"> 
</span><span class="cx">     return self;
</span><span class="cx"> }
</span><span class="lines">@@ -110,7 +110,7 @@
</span><span class="cx">     if (!(self = [super init]))
</span><span class="cx">         return nil;
</span><span class="cx"> 
</span><del>-    API::Object::constructInWrapper<API::UserScript>(self, WebCore::UserScript { WTF::String(source), API::UserScript::generateUniqueURL(), API::toStringVector(legacyWhitelist), API::toStringVector(legacyBlacklist), API::toWebCoreUserScriptInjectionTime(injectionTime), forMainFrameOnly ? WebCore::InjectInTopFrameOnly : WebCore::InjectInAllFrames }, *contentWorld->_contentWorld);
</del><ins>+    API::Object::constructInWrapper<API::UserScript>(self, WebCore::UserScript { WTF::String(source), API::UserScript::generateUniqueURL(), API::toStringVector(legacyWhitelist), API::toStringVector(legacyBlacklist), API::toWebCoreUserScriptInjectionTime(injectionTime), forMainFrameOnly ? WebCore::UserContentInjectedFrames::InjectInTopFrameOnly : WebCore::UserContentInjectedFrames::InjectInAllFrames, WebCore::WaitForNotificationBeforeInjecting::No }, *contentWorld->_contentWorld);
</ins><span class="cx"> 
</span><span class="cx">     return self;
</span><span class="cx"> }
</span><span class="lines">@@ -120,11 +120,21 @@
</span><span class="cx">     if (!(self = [super init]))
</span><span class="cx">         return nil;
</span><span class="cx"> 
</span><del>-    API::Object::constructInWrapper<API::UserScript>(self, WebCore::UserScript { WTF::String(source), URL(associatedURL), API::toStringVector(legacyWhitelist), API::toStringVector(legacyBlacklist), API::toWebCoreUserScriptInjectionTime(injectionTime), forMainFrameOnly ? WebCore::InjectInTopFrameOnly : WebCore::InjectInAllFrames }, *contentWorld->_contentWorld);
</del><ins>+    API::Object::constructInWrapper<API::UserScript>(self, WebCore::UserScript { WTF::String(source), URL(associatedURL), API::toStringVector(legacyWhitelist), API::toStringVector(legacyBlacklist), API::toWebCoreUserScriptInjectionTime(injectionTime), forMainFrameOnly ? WebCore::UserContentInjectedFrames::InjectInTopFrameOnly : WebCore::UserContentInjectedFrames::InjectInAllFrames, WebCore::WaitForNotificationBeforeInjecting::No }, *contentWorld->_contentWorld);
</ins><span class="cx"> 
</span><span class="cx">     return self;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+- (instancetype)_initWithSource:(NSString *)source injectionTime:(WKUserScriptInjectionTime)injectionTime forMainFrameOnly:(BOOL)forMainFrameOnly legacyWhitelist:(NSArray<NSString *> *)legacyWhitelist legacyBlacklist:(NSArray<NSString *> *)legacyBlacklist associatedURL:(NSURL *)associatedURL contentWorld:(WKContentWorld *)contentWorld deferRunningUntilNotification:(BOOL)deferRunningUntilNotification
+{
+    if (!(self = [super init]))
+        return nil;
+
+    API::Object::constructInWrapper<API::UserScript>(self, WebCore::UserScript { WTF::String(source), URL(associatedURL), API::toStringVector(legacyWhitelist), API::toStringVector(legacyBlacklist), API::toWebCoreUserScriptInjectionTime(injectionTime), forMainFrameOnly ? WebCore::UserContentInjectedFrames::InjectInTopFrameOnly : WebCore::UserContentInjectedFrames::InjectInAllFrames, deferRunningUntilNotification ? WebCore::WaitForNotificationBeforeInjecting::Yes : WebCore::WaitForNotificationBeforeInjecting::No }, *contentWorld->_contentWorld);
+
+    return self;
+}
+
</ins><span class="cx"> - (WKContentWorld *)_contentWorld
</span><span class="cx"> {
</span><span class="cx">     return wrapper(_userScript->contentWorld());
</span></span></pre></div>
<a id="trunkSourceWebKitUIProcessAPICocoaWKUserScriptInternalh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKUserScriptInternal.h (259522 => 259523)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKUserScriptInternal.h   2020-04-04 00:16:04 UTC (rev 259522)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKUserScriptInternal.h      2020-04-04 00:44:31 UTC (rev 259523)
</span><span class="lines">@@ -41,23 +41,21 @@
</span><span class="cx"> {
</span><span class="cx">     switch (injectionTime) {
</span><span class="cx">     case WKUserScriptInjectionTimeAtDocumentStart:
</span><del>-        return WebCore::InjectAtDocumentStart;
-
</del><ins>+        return WebCore::UserScriptInjectionTime::DocumentStart;
</ins><span class="cx">     case WKUserScriptInjectionTimeAtDocumentEnd:
</span><del>-        return WebCore::InjectAtDocumentEnd;
</del><ins>+        return WebCore::UserScriptInjectionTime::DocumentEnd;
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     ASSERT_NOT_REACHED();
</span><del>-    return WebCore::InjectAtDocumentEnd;
</del><ins>+    return WebCore::UserScriptInjectionTime::DocumentEnd;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> inline WKUserScriptInjectionTime toWKUserScriptInjectionTime(WebCore::UserScriptInjectionTime injectionTime)
</span><span class="cx"> {
</span><span class="cx">     switch (injectionTime) {
</span><del>-    case WebCore::InjectAtDocumentStart:
</del><ins>+    case WebCore::UserScriptInjectionTime::DocumentStart:
</ins><span class="cx">         return WKUserScriptInjectionTimeAtDocumentStart;
</span><del>-
-    case WebCore::InjectAtDocumentEnd:
</del><ins>+    case WebCore::UserScriptInjectionTime::DocumentEnd:
</ins><span class="cx">         return WKUserScriptInjectionTimeAtDocumentEnd;
</span><span class="cx">     }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKitUIProcessAPICocoaWKUserScriptPrivateh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKUserScriptPrivate.h (259522 => 259523)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKUserScriptPrivate.h    2020-04-04 00:16:04 UTC (rev 259522)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKUserScriptPrivate.h       2020-04-04 00:44:31 UTC (rev 259523)
</span><span class="lines">@@ -38,6 +38,8 @@
</span><span class="cx"> - (instancetype)_initWithSource:(NSString *)source injectionTime:(WKUserScriptInjectionTime)injectionTime forMainFrameOnly:(BOOL)forMainFrameOnly legacyWhitelist:(NSArray<NSString *> *)legacyWhitelist legacyBlacklist:(NSArray<NSString *> *)legacyBlacklist contentWorld:(WKContentWorld *)contentWorld WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA));
</span><span class="cx"> - (instancetype)_initWithSource:(NSString *)source injectionTime:(WKUserScriptInjectionTime)injectionTime forMainFrameOnly:(BOOL)forMainFrameOnly legacyWhitelist:(NSArray<NSString *> *)legacyWhitelist legacyBlacklist:(NSArray<NSString *> *)legacyBlacklist associatedURL:(NSURL *)associatedURL contentWorld:(WKContentWorld *)contentWorld WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA));
</span><span class="cx"> 
</span><ins>+- (instancetype)_initWithSource:(NSString *)source injectionTime:(WKUserScriptInjectionTime)injectionTime forMainFrameOnly:(BOOL)forMainFrameOnly legacyWhitelist:(NSArray<NSString *> *)legacyWhitelist legacyBlacklist:(NSArray<NSString *> *)legacyBlacklist associatedURL:(NSURL *)associatedURL contentWorld:(WKContentWorld *)contentWorld deferRunningUntilNotification:(BOOL)deferRunningUntilNotification WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA));
+
</ins><span class="cx"> @property (nonatomic, readonly) _WKUserContentWorld *_userContentWorld WK_API_AVAILABLE(macos(10.12), ios(10.0));
</span><span class="cx"> @property (nonatomic, readonly) WKContentWorld *_contentWorld WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA));
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKitUIProcessAPICocoaWKWebViewmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm (259522 => 259523)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm     2020-04-04 00:16:04 UTC (rev 259522)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm        2020-04-04 00:44:31 UTC (rev 259523)
</span><span class="lines">@@ -2326,6 +2326,16 @@
</span><span class="cx">     _page->updateWebsitePolicies(WTFMove(data));
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+- (void)_notifyUserScripts
+{
+    _page->notifyUserScripts();
+}
+
+- (BOOL)_deferrableUserScriptsNeedNotification
+{
+    return _page->userScriptsNeedNotification();
+}
+
</ins><span class="cx"> - (BOOL)_allowsRemoteInspection
</span><span class="cx"> {
</span><span class="cx"> #if ENABLE(REMOTE_INSPECTOR)
</span></span></pre></div>
<a id="trunkSourceWebKitUIProcessAPICocoaWKWebViewConfigurationmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewConfiguration.mm (259522 => 259523)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewConfiguration.mm        2020-04-04 00:16:04 UTC (rev 259522)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewConfiguration.mm   2020-04-04 00:44:31 UTC (rev 259523)
</span><span class="lines">@@ -933,6 +933,16 @@
</span><span class="cx">     return _pageConfiguration->loadsSubresources();
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+- (BOOL)_deferrableUserScriptsShouldWaitUntilNotification
+{
+    return _pageConfiguration->userScriptsShouldWaitUntilNotification();
+}
+
+- (void)_setDeferrableUserScriptsShouldWaitUntilNotification:(BOOL)value
+{
+    _pageConfiguration->setUserScriptsShouldWaitUntilNotification(value);
+}
+
</ins><span class="cx"> - (void)_setCrossOriginAccessControlCheckEnabled:(BOOL)enabled
</span><span class="cx"> {
</span><span class="cx">     _pageConfiguration->setCrossOriginAccessControlCheckEnabled(enabled);
</span></span></pre></div>
<a id="trunkSourceWebKitUIProcessAPICocoaWKWebViewConfigurationPrivateh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewConfigurationPrivate.h (259522 => 259523)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewConfigurationPrivate.h  2020-04-04 00:16:04 UTC (rev 259522)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewConfigurationPrivate.h     2020-04-04 00:44:31 UTC (rev 259523)
</span><span class="lines">@@ -84,6 +84,7 @@
</span><span class="cx"> 
</span><span class="cx"> @property (nonatomic, readonly) WKWebsiteDataStore *_websiteDataStoreIfExists WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA));
</span><span class="cx"> @property (nonatomic, copy, setter=_setCORSDisablingPatterns:) NSArray<NSString *> *_corsDisablingPatterns WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA));
</span><ins>+@property (nonatomic, setter=_setDeferrableUserScriptsShouldWaitUntilNotification:) BOOL _deferrableUserScriptsShouldWaitUntilNotification WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA));
</ins><span class="cx"> @property (nonatomic, setter=_setCrossOriginAccessControlCheckEnabled:) BOOL _crossOriginAccessControlCheckEnabled WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA));
</span><span class="cx"> 
</span><span class="cx"> @property (nonatomic, setter=_setLoadsFromNetwork:) BOOL _loadsFromNetwork WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA));
</span></span></pre></div>
<a id="trunkSourceWebKitUIProcessAPICocoaWKWebViewPrivateh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewPrivate.h (259522 => 259523)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewPrivate.h       2020-04-04 00:16:04 UTC (rev 259522)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewPrivate.h  2020-04-04 00:44:31 UTC (rev 259523)
</span><span class="lines">@@ -207,6 +207,8 @@
</span><span class="cx"> 
</span><span class="cx"> - (void)_updateWebsitePolicies:(_WKWebsitePolicies *)websitePolicies WK_API_DEPRECATED_WITH_REPLACEMENT("-_updateWebpagePreferences:", macos(10.13, WK_MAC_TBA), ios(11.3, WK_IOS_TBA));
</span><span class="cx"> - (void)_updateWebpagePreferences:(WKWebpagePreferences *)webpagePreferences WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA));
</span><ins>+- (void)_notifyUserScripts WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA));
+@property (nonatomic, readonly) BOOL _deferrableUserScriptsNeedNotification WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA));
</ins><span class="cx"> 
</span><span class="cx"> - (void)_evaluateJavaScriptWithoutUserGesture:(NSString *)javaScriptString completionHandler:(void (^)(id, NSError *))completionHandler WK_API_AVAILABLE(macos(10.13), ios(11.0));
</span><span class="cx"> - (void)_evaluateJavaScript:(NSString *)javaScriptString inFrame:(WKFrameInfo *)frame inContentWorld:(WKContentWorld *)contentWorld completionHandler:(void (^)(id, NSError * error))completionHandler WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA));
</span></span></pre></div>
<a id="trunkSourceWebKitUIProcessAPICocoa_WKUserStyleSheetmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/_WKUserStyleSheet.mm (259522 => 259523)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/UIProcess/API/Cocoa/_WKUserStyleSheet.mm     2020-04-04 00:16:04 UTC (rev 259522)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/_WKUserStyleSheet.mm        2020-04-04 00:44:31 UTC (rev 259523)
</span><span class="lines">@@ -44,7 +44,7 @@
</span><span class="cx">     // FIXME: In the API test, we can use generateUniqueURL below before the API::Object constructor has done this... where should this really be?
</span><span class="cx">     WebKit::InitializeWebKit2();
</span><span class="cx"> 
</span><del>-    API::Object::constructInWrapper<API::UserStyleSheet>(self, WebCore::UserStyleSheet { WTF::String(source), API::UserStyleSheet::generateUniqueURL(), { }, { }, forMainFrameOnly ? WebCore::InjectInTopFrameOnly : WebCore::InjectInAllFrames, WebCore::UserStyleUserLevel }, API::ContentWorld::pageContentWorld());
</del><ins>+    API::Object::constructInWrapper<API::UserStyleSheet>(self, WebCore::UserStyleSheet { WTF::String(source), API::UserStyleSheet::generateUniqueURL(), { }, { }, forMainFrameOnly ? WebCore::UserContentInjectedFrames::InjectInTopFrameOnly : WebCore::UserContentInjectedFrames::InjectInAllFrames, WebCore::UserStyleUserLevel }, API::ContentWorld::pageContentWorld());
</ins><span class="cx"> 
</span><span class="cx">     return self;
</span><span class="cx"> }
</span><span class="lines">@@ -58,7 +58,7 @@
</span><span class="cx">     // FIXME: In the API test, we can use generateUniqueURL below before the API::Object constructor has done this... where should this really be?
</span><span class="cx">     WebKit::InitializeWebKit2();
</span><span class="cx"> 
</span><del>-    API::Object::constructInWrapper<API::UserStyleSheet>(self, WebCore::UserStyleSheet { WTF::String(source), API::UserStyleSheet::generateUniqueURL(), { },  { }, forMainFrameOnly ? WebCore::InjectInTopFrameOnly : WebCore::InjectInAllFrames, WebCore::UserStyleUserLevel, [webView _page]->webPageID() }, *userContentWorld->_contentWorld->_contentWorld);
</del><ins>+    API::Object::constructInWrapper<API::UserStyleSheet>(self, WebCore::UserStyleSheet { WTF::String(source), API::UserStyleSheet::generateUniqueURL(), { },  { }, forMainFrameOnly ? WebCore::UserContentInjectedFrames::InjectInTopFrameOnly : WebCore::UserContentInjectedFrames::InjectInAllFrames, WebCore::UserStyleUserLevel, [webView _page]->webPageID() }, *userContentWorld->_contentWorld->_contentWorld);
</ins><span class="cx"> 
</span><span class="cx">     return self;
</span><span class="cx"> }
</span><span class="lines">@@ -71,7 +71,7 @@
</span><span class="cx">     // FIXME: In the API test, we can use generateUniqueURL below before the API::Object constructor has done this... where should this really be?
</span><span class="cx">     WebKit::InitializeWebKit2();
</span><span class="cx"> 
</span><del>-    API::Object::constructInWrapper<API::UserStyleSheet>(self, WebCore::UserStyleSheet { WTF::String(source), API::UserStyleSheet::generateUniqueURL(), API::toStringVector(legacyWhitelist), API::toStringVector(legacyBlacklist), forMainFrameOnly ? WebCore::InjectInTopFrameOnly : WebCore::InjectInAllFrames, WebCore::UserStyleUserLevel }, *userContentWorld->_contentWorld->_contentWorld);
</del><ins>+    API::Object::constructInWrapper<API::UserStyleSheet>(self, WebCore::UserStyleSheet { WTF::String(source), API::UserStyleSheet::generateUniqueURL(), API::toStringVector(legacyWhitelist), API::toStringVector(legacyBlacklist), forMainFrameOnly ? WebCore::UserContentInjectedFrames::InjectInTopFrameOnly : WebCore::UserContentInjectedFrames::InjectInAllFrames, WebCore::UserStyleUserLevel }, *userContentWorld->_contentWorld->_contentWorld);
</ins><span class="cx"> 
</span><span class="cx">     return self;
</span><span class="cx"> }
</span><span class="lines">@@ -84,7 +84,7 @@
</span><span class="cx">     // FIXME: In the API test, we can use generateUniqueURL below before the API::Object constructor has done this... where should this really be?
</span><span class="cx">     WebKit::InitializeWebKit2();
</span><span class="cx"> 
</span><del>-    API::Object::constructInWrapper<API::UserStyleSheet>(self, WebCore::UserStyleSheet { WTF::String(source), {  URL(), WTF::String([baseURL _web_originalDataAsWTFString]) }, API::toStringVector(legacyWhitelist), API::toStringVector(legacyBlacklist), forMainFrameOnly ? WebCore::InjectInTopFrameOnly : WebCore::InjectInAllFrames, WebCore::UserStyleUserLevel }, *userContentWorld->_contentWorld->_contentWorld);
</del><ins>+    API::Object::constructInWrapper<API::UserStyleSheet>(self, WebCore::UserStyleSheet { WTF::String(source), {  URL(), WTF::String([baseURL _web_originalDataAsWTFString]) }, API::toStringVector(legacyWhitelist), API::toStringVector(legacyBlacklist), forMainFrameOnly ? WebCore::UserContentInjectedFrames::InjectInTopFrameOnly : WebCore::UserContentInjectedFrames::InjectInAllFrames, WebCore::UserStyleUserLevel }, *userContentWorld->_contentWorld->_contentWorld);
</ins><span class="cx"> 
</span><span class="cx">     return self;
</span><span class="cx"> }
</span><span class="lines">@@ -109,7 +109,7 @@
</span><span class="cx"> 
</span><span class="cx"> - (BOOL)isForMainFrameOnly
</span><span class="cx"> {
</span><del>-    return _userStyleSheet->userStyleSheet().injectedFrames() == WebCore::InjectInTopFrameOnly;
</del><ins>+    return _userStyleSheet->userStyleSheet().injectedFrames() == WebCore::UserContentInjectedFrames::InjectInTopFrameOnly;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> - (id)copyWithZone:(NSZone *)zone
</span></span></pre></div>
<a id="trunkSourceWebKitUIProcessAPIglibWebKitUserContentcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/UIProcess/API/glib/WebKitUserContent.cpp (259522 => 259523)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/UIProcess/API/glib/WebKitUserContent.cpp     2020-04-04 00:16:04 UTC (rev 259522)
+++ trunk/Source/WebKit/UIProcess/API/glib/WebKitUserContent.cpp        2020-04-04 00:44:31 UTC (rev 259523)
</span><span class="lines">@@ -50,12 +50,12 @@
</span><span class="cx"> {
</span><span class="cx">     switch (injectedFrames) {
</span><span class="cx">     case WEBKIT_USER_CONTENT_INJECT_TOP_FRAME:
</span><del>-        return InjectInTopFrameOnly;
</del><ins>+        return UserContentInjectedFrames::InjectInTopFrameOnly;
</ins><span class="cx">     case WEBKIT_USER_CONTENT_INJECT_ALL_FRAMES:
</span><del>-        return InjectInAllFrames;
</del><ins>+        return UserContentInjectedFrames::InjectInAllFrames;
</ins><span class="cx">     default:
</span><span class="cx">         ASSERT_NOT_REACHED();
</span><del>-        return InjectInAllFrames;
</del><ins>+        return UserContentInjectedFrames::InjectInAllFrames;
</ins><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -76,12 +76,12 @@
</span><span class="cx"> {
</span><span class="cx">     switch (injectionTime) {
</span><span class="cx">     case WEBKIT_USER_SCRIPT_INJECT_AT_DOCUMENT_START:
</span><del>-        return InjectAtDocumentStart;
</del><ins>+        return UserScriptInjectionTime::DocumentStart;
</ins><span class="cx">     case WEBKIT_USER_SCRIPT_INJECT_AT_DOCUMENT_END:
</span><del>-        return InjectAtDocumentEnd;
</del><ins>+        return UserScriptInjectionTime::DocumentEnd;
</ins><span class="cx">     default:
</span><span class="cx">         ASSERT_NOT_REACHED();
</span><del>-        return InjectAtDocumentStart;
</del><ins>+        return UserScriptInjectionTime::DocumentStart;
</ins><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -214,7 +214,7 @@
</span><span class="cx">             String::fromUTF8(source), URL { },
</span><span class="cx">             toStringVector(whitelist), toStringVector(blacklist),
</span><span class="cx">             toUserScriptInjectionTime(injectionTime),
</span><del>-            toUserContentInjectedFrames(injectedFrames) }, world)))
</del><ins>+            toUserContentInjectedFrames(injectedFrames), WebCore::WaitForNotificationBeforeInjecting::No }, world)))
</ins><span class="cx">         , referenceCount(1)
</span><span class="cx">     {
</span><span class="cx">     }
</span></span></pre></div>
<a id="trunkSourceWebKitUIProcessWebPageProxycpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.cpp (259522 => 259523)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/UIProcess/WebPageProxy.cpp   2020-04-04 00:16:04 UTC (rev 259522)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.cpp      2020-04-04 00:44:31 UTC (rev 259523)
</span><span class="lines">@@ -7768,6 +7768,7 @@
</span><span class="cx"> 
</span><span class="cx">     parameters.overriddenMediaType = m_overriddenMediaType;
</span><span class="cx">     parameters.corsDisablingPatterns = m_configuration->corsDisablingPatterns();
</span><ins>+    parameters.userScriptsShouldWaitUntilNotification = m_configuration->userScriptsShouldWaitUntilNotification();
</ins><span class="cx">     parameters.loadsFromNetwork = m_configuration->loadsFromNetwork();
</span><span class="cx">     parameters.loadsSubresources = m_configuration->loadsSubresources();
</span><span class="cx">     parameters.crossOriginAccessControlCheckEnabled = m_configuration->crossOriginAccessControlCheckEnabled();
</span><span class="lines">@@ -8191,6 +8192,19 @@
</span><span class="cx">     send(Messages::WebPage::UpdateWebsitePolicies(websitePolicies));
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void WebPageProxy::notifyUserScripts()
+{
+    m_userScriptsNotified = true;
+    send(Messages::WebPage::NotifyUserScripts());
+}
+
+bool WebPageProxy::userScriptsNeedNotification() const
+{
+    if (!m_configuration->userScriptsShouldWaitUntilNotification())
+        return false;
+    return !m_userScriptsNotified;
+}
+
</ins><span class="cx"> void WebPageProxy::didFinishLoadingDataForCustomContentProvider(const String& suggestedFilename, const IPC::DataReference& dataReference)
</span><span class="cx"> {
</span><span class="cx">     pageClient().didFinishLoadingDataForCustomContentProvider(ResourceResponseBase::sanitizeSuggestedFilename(suggestedFilename), dataReference);
</span></span></pre></div>
<a id="trunkSourceWebKitUIProcessWebPageProxyh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.h (259522 => 259523)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/UIProcess/WebPageProxy.h     2020-04-04 00:16:04 UTC (rev 259522)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.h        2020-04-04 00:44:31 UTC (rev 259523)
</span><span class="lines">@@ -611,6 +611,8 @@
</span><span class="cx">     bool willHandleHorizontalScrollEvents() const;
</span><span class="cx"> 
</span><span class="cx">     void updateWebsitePolicies(WebsitePoliciesData&&);
</span><ins>+    void notifyUserScripts();
+    bool userScriptsNeedNotification() const;
</ins><span class="cx"> 
</span><span class="cx">     bool canShowMIMEType(const String& mimeType);
</span><span class="cx"> 
</span><span class="lines">@@ -2772,6 +2774,7 @@
</span><span class="cx">     NavigatingToAppBoundDomain m_isNavigatingToAppBoundDomain { NavigatingToAppBoundDomain::No };
</span><span class="cx">     NavigatedAwayFromAppBoundDomain m_hasNavigatedAwayFromAppBoundDomain { NavigatedAwayFromAppBoundDomain::No };
</span><span class="cx">     bool m_ignoresAppBoundDomains { false };
</span><ins>+    bool m_userScriptsNotified { false };
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> } // namespace WebKit
</span></span></pre></div>
<a id="trunkSourceWebKitWebProcessUserContentWebUserContentControllercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/WebProcess/UserContent/WebUserContentController.cpp (259522 => 259523)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/WebProcess/UserContent/WebUserContentController.cpp  2020-04-04 00:16:04 UTC (rev 259522)
+++ trunk/Source/WebKit/WebProcess/UserContent/WebUserContentController.cpp     2020-04-04 00:44:31 UTC (rev 259523)
</span><span class="lines">@@ -392,7 +392,7 @@
</span><span class="cx">                 return;
</span><span class="cx"> 
</span><span class="cx">             auto& mainFrame = page.mainFrame();
</span><del>-            if (userScript.injectedFrames() == InjectInTopFrameOnly) {
</del><ins>+            if (userScript.injectedFrames() == UserContentInjectedFrames::InjectInTopFrameOnly) {
</ins><span class="cx">                 mainFrame.injectUserScriptImmediately(world.coreWorld(), userScript);
</span><span class="cx">                 return;
</span><span class="cx">             }
</span></span></pre></div>
<a id="trunkSourceWebKitWebProcessWebPageWebPagecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp (259522 => 259523)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp       2020-04-04 00:16:04 UTC (rev 259522)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp  2020-04-04 00:44:31 UTC (rev 259523)
</span><span class="lines">@@ -529,6 +529,7 @@
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx">     pageConfiguration.corsDisablingPatterns = WTFMove(parameters.corsDisablingPatterns);
</span><ins>+    pageConfiguration.userScriptsShouldWaitUntilNotification = parameters.userScriptsShouldWaitUntilNotification;
</ins><span class="cx">     pageConfiguration.loadsSubresources = parameters.loadsSubresources;
</span><span class="cx">     pageConfiguration.loadsFromNetwork = parameters.loadsFromNetwork;
</span><span class="cx"> 
</span><span class="lines">@@ -6284,6 +6285,14 @@
</span><span class="cx"> #endif
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void WebPage::notifyUserScripts()
+{
+    if (!m_page)
+        return;
+
+    m_page->notifyToInjectUserScripts();
+}
+
</ins><span class="cx"> unsigned WebPage::extendIncrementalRenderingSuppression()
</span><span class="cx"> {
</span><span class="cx">     unsigned token = m_maximumRenderingSuppressionToken + 1;
</span><span class="lines">@@ -6436,7 +6445,7 @@
</span><span class="cx"> 
</span><span class="cx"> void WebPage::addUserScript(String&& source, InjectedBundleScriptWorld& world, WebCore::UserContentInjectedFrames injectedFrames, WebCore::UserScriptInjectionTime injectionTime)
</span><span class="cx"> {
</span><del>-    WebCore::UserScript userScript { WTFMove(source), URL(aboutBlankURL()), Vector<String>(), Vector<String>(), injectionTime, injectedFrames };
</del><ins>+    WebCore::UserScript userScript { WTFMove(source), URL(aboutBlankURL()), Vector<String>(), Vector<String>(), injectionTime, injectedFrames, WebCore::WaitForNotificationBeforeInjecting::No };
</ins><span class="cx"> 
</span><span class="cx">     m_userContentController->addUserScript(world, WTFMove(userScript));
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebKitWebProcessWebPageWebPageh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.h (259522 => 259523)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.h 2020-04-04 00:16:04 UTC (rev 259522)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.h    2020-04-04 00:44:31 UTC (rev 259523)
</span><span class="lines">@@ -1615,6 +1615,7 @@
</span><span class="cx">     void reportUsedFeatures();
</span><span class="cx"> 
</span><span class="cx">     void updateWebsitePolicies(WebsitePoliciesData&&);
</span><ins>+    void notifyUserScripts();
</ins><span class="cx"> 
</span><span class="cx">     void changeFont(WebCore::FontChanges&&);
</span><span class="cx">     void changeFontAttributes(WebCore::FontAttributeChanges&&);
</span></span></pre></div>
<a id="trunkSourceWebKitWebProcessWebPageWebPagemessagesin"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.messages.in (259522 => 259523)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.messages.in       2020-04-04 00:16:04 UTC (rev 259522)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.messages.in  2020-04-04 00:44:31 UTC (rev 259523)
</span><span class="lines">@@ -186,6 +186,7 @@
</span><span class="cx">     DidRemoveBackForwardItem(struct WebCore::BackForwardItemIdentifier backForwardItemID)
</span><span class="cx"> 
</span><span class="cx">     UpdateWebsitePolicies(struct WebKit::WebsitePoliciesData websitePolicies)
</span><ins>+    NotifyUserScripts()
</ins><span class="cx">     DidReceivePolicyDecision(WebCore::FrameIdentifier frameID, uint64_t listenerID, struct WebKit::PolicyDecision policyDecision)
</span><span class="cx"> 
</span><span class="cx">     ContinueWillSubmitForm(WebCore::FrameIdentifier frameID, uint64_t listenerID)
</span></span></pre></div>
<a id="trunkSourceWebKitLegacymacChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKitLegacy/mac/ChangeLog (259522 => 259523)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKitLegacy/mac/ChangeLog  2020-04-04 00:16:04 UTC (rev 259522)
+++ trunk/Source/WebKitLegacy/mac/ChangeLog     2020-04-04 00:44:31 UTC (rev 259523)
</span><span class="lines">@@ -1,3 +1,14 @@
</span><ins>+2020-04-03  Alex Christensen  <achristensen@webkit.org>
+
+        Add SPI to make WKUserScripts wait for a notification
+        https://bugs.webkit.org/show_bug.cgi?id=209845
+        <rdar://problem/60342299>
+
+        Reviewed by Chris Dumez.
+
+        * WebView/WebView.mm:
+        (-[WebView _injectOutlookQuirksScript]):
+
</ins><span class="cx"> 2020-04-03  Tim Horton  <timothy_horton@apple.com>
</span><span class="cx"> 
</span><span class="cx">         Add a visual debug indicator for locating and identifying all kinds of WebViews
</span></span></pre></div>
<a id="trunkSourceWebKitLegacymacWebViewWebViewmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKitLegacy/mac/WebView/WebView.mm (259522 => 259523)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKitLegacy/mac/WebView/WebView.mm 2020-04-04 00:16:04 UTC (rev 259522)
+++ trunk/Source/WebKitLegacy/mac/WebView/WebView.mm    2020-04-04 00:44:31 UTC (rev 259523)
</span><span class="lines">@@ -1228,7 +1228,7 @@
</span><span class="cx"> -(void)_injectOutlookQuirksScript
</span><span class="cx"> {
</span><span class="cx">     static NSString *outlookQuirksScriptContents = leakOutlookQuirksUserScriptContents();
</span><del>-    _private->group->userContentController().addUserScript(*core([WebScriptWorld world]), makeUnique<WebCore::UserScript>(outlookQuirksScriptContents, URL(), Vector<String>(), Vector<String>(), WebCore::InjectAtDocumentEnd, WebCore::InjectInAllFrames));
</del><ins>+    _private->group->userContentController().addUserScript(*core([WebScriptWorld world]), makeUnique<WebCore::UserScript>(outlookQuirksScriptContents, URL(), Vector<String>(), Vector<String>(), WebCore::UserScriptInjectionTime::DocumentEnd, WebCore::UserContentInjectedFrames::InjectInAllFrames, WebCore::WaitForNotificationBeforeInjecting::No));
</ins><span class="cx"> 
</span><span class="cx"> }
</span><span class="cx"> #endif
</span><span class="lines">@@ -4681,7 +4681,7 @@
</span><span class="cx">     if (!world)
</span><span class="cx">         return;
</span><span class="cx"> 
</span><del>-    auto userScript = makeUnique<WebCore::UserScript>(source, url, toStringVector(whitelist), toStringVector(blacklist), injectionTime == WebInjectAtDocumentStart ? WebCore::InjectAtDocumentStart : WebCore::InjectAtDocumentEnd, injectedFrames == WebInjectInAllFrames ? WebCore::InjectInAllFrames : WebCore::InjectInTopFrameOnly);
</del><ins>+    auto userScript = makeUnique<WebCore::UserScript>(source, url, toStringVector(whitelist), toStringVector(blacklist), injectionTime == WebInjectAtDocumentStart ? WebCore::UserScriptInjectionTime::DocumentStart : WebCore::UserScriptInjectionTime::DocumentEnd, injectedFrames == WebInjectInAllFrames ? WebCore::UserContentInjectedFrames::InjectInAllFrames : WebCore::UserContentInjectedFrames::InjectInTopFrameOnly, WebCore::WaitForNotificationBeforeInjecting::No);
</ins><span class="cx">     viewGroup->userContentController().addUserScript(*core(world), WTFMove(userScript));
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -4704,7 +4704,7 @@
</span><span class="cx">     if (!world)
</span><span class="cx">         return;
</span><span class="cx"> 
</span><del>-    auto styleSheet = makeUnique<WebCore::UserStyleSheet>(source, url, toStringVector(whitelist), toStringVector(blacklist), injectedFrames == WebInjectInAllFrames ? WebCore::InjectInAllFrames : WebCore::InjectInTopFrameOnly, WebCore::UserStyleUserLevel);
</del><ins>+    auto styleSheet = makeUnique<WebCore::UserStyleSheet>(source, url, toStringVector(whitelist), toStringVector(blacklist), injectedFrames == WebInjectInAllFrames ? WebCore::UserContentInjectedFrames::InjectInAllFrames : WebCore::UserContentInjectedFrames::InjectInTopFrameOnly, WebCore::UserStyleUserLevel);
</ins><span class="cx">     viewGroup->userContentController().addUserStyleSheet(*core(world), WTFMove(styleSheet), WebCore::InjectInExistingDocuments);
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKitLegacywinChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKitLegacy/win/ChangeLog (259522 => 259523)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKitLegacy/win/ChangeLog  2020-04-04 00:16:04 UTC (rev 259522)
+++ trunk/Source/WebKitLegacy/win/ChangeLog     2020-04-04 00:44:31 UTC (rev 259523)
</span><span class="lines">@@ -1,3 +1,15 @@
</span><ins>+2020-04-03  Alex Christensen  <achristensen@webkit.org>
+
+        Add SPI to make WKUserScripts wait for a notification
+        https://bugs.webkit.org/show_bug.cgi?id=209845
+        <rdar://problem/60342299>
+
+        Reviewed by Chris Dumez.
+
+        * WebView.cpp:
+        (WebView::addUserScriptToGroup):
+        (WebView::addUserStyleSheetToGroup):
+
</ins><span class="cx"> 2020-04-01  Darin Adler  <darin@apple.com>
</span><span class="cx"> 
</span><span class="cx">         Remove all uses of live ranges from TextIterator
</span></span></pre></div>
<a id="trunkSourceWebKitLegacywinWebViewcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKitLegacy/win/WebView.cpp (259522 => 259523)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKitLegacy/win/WebView.cpp        2020-04-04 00:16:04 UTC (rev 259522)
+++ trunk/Source/WebKitLegacy/win/WebView.cpp   2020-04-04 00:44:31 UTC (rev 259523)
</span><span class="lines">@@ -7006,8 +7006,8 @@
</span><span class="cx"> 
</span><span class="cx">     WebScriptWorld* world = reinterpret_cast<WebScriptWorld*>(iWorld);
</span><span class="cx">     auto userScript = makeUnique<UserScript>(source, toURL(url), toStringVector(whitelist, whitelistCount),
</span><del>-        toStringVector(blacklist, blacklistCount), injectionTime == WebInjectAtDocumentStart ? InjectAtDocumentStart : InjectAtDocumentEnd,
-        injectedFrames == WebInjectInAllFrames ? InjectInAllFrames : InjectInTopFrameOnly);
</del><ins>+        toStringVector(blacklist, blacklistCount), injectionTime == WebInjectAtDocumentStart ? UserScriptInjectionTime::DocumentStart : UserScriptInjectionTime::DocumentEnd,
+        injectedFrames == WebInjectInAllFrames ? UserContentInjectedFrames::InjectInAllFrames : UserContentInjectedFrames::InjectInTopFrameOnly, WaitForNotificationBeforeInjecting::No);
</ins><span class="cx">     viewGroup->userContentController().addUserScript(world->world(), WTFMove(userScript));
</span><span class="cx">     return S_OK;
</span><span class="cx"> }
</span><span class="lines">@@ -7033,7 +7033,7 @@
</span><span class="cx"> 
</span><span class="cx">     WebScriptWorld* world = reinterpret_cast<WebScriptWorld*>(iWorld);
</span><span class="cx">     auto styleSheet = makeUnique<UserStyleSheet>(source, toURL(url), toStringVector(whitelist, whitelistCount), toStringVector(blacklist, blacklistCount),
</span><del>-        injectedFrames == WebInjectInAllFrames ? InjectInAllFrames : InjectInTopFrameOnly, UserStyleUserLevel);
</del><ins>+        injectedFrames == WebInjectInAllFrames ? UserContentInjectedFrames::InjectInAllFrames : UserContentInjectedFrames::InjectInTopFrameOnly, UserStyleUserLevel);
</ins><span class="cx">     viewGroup->userContentController().addUserStyleSheet(world->world(), WTFMove(styleSheet), InjectInExistingDocuments);
</span><span class="cx">     return S_OK;
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkToolsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Tools/ChangeLog (259522 => 259523)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/ChangeLog    2020-04-04 00:16:04 UTC (rev 259522)
+++ trunk/Tools/ChangeLog       2020-04-04 00:44:31 UTC (rev 259523)
</span><span class="lines">@@ -1,3 +1,14 @@
</span><ins>+2020-04-03  Alex Christensen  <achristensen@webkit.org>
+
+        Add SPI to make WKUserScripts wait for a notification
+        https://bugs.webkit.org/show_bug.cgi?id=209845
+        <rdar://problem/60342299>
+
+        Reviewed by Chris Dumez.
+
+        * TestWebKitAPI/Tests/WebKitCocoa/UserContentController.mm:
+        (TEST):
+
</ins><span class="cx"> 2020-04-03  Kate Cheney  <katherine_cheney@apple.com>
</span><span class="cx"> 
</span><span class="cx">         Prevent non app-bound domain cookies from being read or set using API calls
</span></span></pre></div>
<a id="trunkToolsTestWebKitAPITestsWebKitCocoaUserContentControllermm"></a>
<div class="modfile"><h4>Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/UserContentController.mm (259522 => 259523)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/UserContentController.mm     2020-04-04 00:16:04 UTC (rev 259522)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/UserContentController.mm        2020-04-04 00:44:31 UTC (rev 259523)
</span><span class="lines">@@ -28,10 +28,13 @@
</span><span class="cx"> #import "PlatformUtilities.h"
</span><span class="cx"> #import "Test.h"
</span><span class="cx"> #import "TestNavigationDelegate.h"
</span><ins>+#import "TestUIDelegate.h"
+#import "TestWKWebView.h"
</ins><span class="cx"> #import <WebKit/WKProcessPoolPrivate.h>
</span><span class="cx"> #import <WebKit/WKUserContentControllerPrivate.h>
</span><span class="cx"> #import <WebKit/WKUserScript.h>
</span><span class="cx"> #import <WebKit/WKUserScriptPrivate.h>
</span><ins>+#import <WebKit/WKWebViewConfigurationPrivate.h>
</ins><span class="cx"> #import <WebKit/WebKit.h>
</span><span class="cx"> #import <WebKit/_WKProcessPoolConfiguration.h>
</span><span class="cx"> #import <WebKit/_WKUserContentWorld.h>
</span><span class="lines">@@ -811,3 +814,33 @@
</span><span class="cx">     waitForMessages(6);
</span><span class="cx">     compareMessages({"start all", "start all", "end main", "start all", "end main", "start all"});
</span><span class="cx"> }
</span><ins>+
+TEST(WKUserContentController, UserScriptNotification)
+{
+    WKUserScript *waitsForNotification = [[[WKUserScript alloc] _initWithSource:@"alert('waited for notification')" injectionTime:WKUserScriptInjectionTimeAtDocumentStart forMainFrameOnly:YES legacyWhitelist:[NSArray array] legacyBlacklist:[NSArray array] associatedURL:[NSURL URLWithString:@"test:///script"] contentWorld:[WKContentWorld defaultClientWorld] deferRunningUntilNotification:YES] autorelease];
+    WKUserScript *documentEnd = [[[WKUserScript alloc] initWithSource:@"alert('document parsing ended')" injectionTime:WKUserScriptInjectionTimeAtDocumentEnd forMainFrameOnly:YES] autorelease];
+
+    TestWKWebView *webView1 = [[TestWKWebView new] autorelease];
+    EXPECT_TRUE(webView1._deferrableUserScriptsNeedNotification);
+    [webView1.configuration.userContentController addUserScript:waitsForNotification];
+    [webView1.configuration.userContentController addUserScript:documentEnd];
+    TestUIDelegate *delegate = [[TestUIDelegate new] autorelease];
+    webView1.UIDelegate = delegate;
+    [webView1 loadTestPageNamed:@"simple"];
+    EXPECT_WK_STREQ([delegate waitForAlert], "document parsing ended");
+    [webView1 _notifyUserScripts];
+    EXPECT_FALSE(webView1._deferrableUserScriptsNeedNotification);
+    EXPECT_WK_STREQ([delegate waitForAlert], "waited for notification");
+
+    WKWebViewConfiguration *configuration = [[WKWebViewConfiguration new] autorelease];
+    EXPECT_TRUE(configuration._deferrableUserScriptsShouldWaitUntilNotification);
+    configuration._deferrableUserScriptsShouldWaitUntilNotification = NO;
+    TestWKWebView *webView2 = [[[TestWKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:configuration] autorelease];
+    EXPECT_FALSE(webView2._deferrableUserScriptsNeedNotification);
+    [webView2.configuration.userContentController addUserScript:waitsForNotification];
+    [webView2.configuration.userContentController addUserScript:documentEnd];
+    webView2.UIDelegate = delegate;
+    [webView2 loadTestPageNamed:@"simple"];
+    EXPECT_WK_STREQ([delegate waitForAlert], "waited for notification");
+    EXPECT_WK_STREQ([delegate waitForAlert], "document parsing ended");
+}
</ins></span></pre>
</div>
</div>

</body>
</html>