Title: [218299] trunk
Revision
218299
Author
[email protected]
Date
2017-06-14 17:39:21 -0700 (Wed, 14 Jun 2017)

Log Message

Unreviewed, rolling out r218285.
https://bugs.webkit.org/show_bug.cgi?id=173391

API test fails on iOS (Requested by alexchristensen on
#webkit).

Reverted changeset:

"Add SPI for immediate injection of user scripts"
https://bugs.webkit.org/show_bug.cgi?id=173342
http://trac.webkit.org/changeset/218285

Modified Paths

Removed Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (218298 => 218299)


--- trunk/Source/WebCore/ChangeLog	2017-06-15 00:36:46 UTC (rev 218298)
+++ trunk/Source/WebCore/ChangeLog	2017-06-15 00:39:21 UTC (rev 218299)
@@ -1,3 +1,17 @@
+2017-06-14  Commit Queue  <[email protected]>
+
+        Unreviewed, rolling out r218285.
+        https://bugs.webkit.org/show_bug.cgi?id=173391
+
+        API test fails on iOS (Requested by alexchristensen on
+        #webkit).
+
+        Reverted changeset:
+
+        "Add SPI for immediate injection of user scripts"
+        https://bugs.webkit.org/show_bug.cgi?id=173342
+        http://trac.webkit.org/changeset/218285
+
 2017-06-14  Jer Noble  <[email protected]>
 
         Video flashes black when switching back to a tab https://www.apple.com/homepod/

Modified: trunk/Source/WebCore/page/Frame.cpp (218298 => 218299)


--- trunk/Source/WebCore/page/Frame.cpp	2017-06-15 00:36:46 UTC (rev 218298)
+++ trunk/Source/WebCore/page/Frame.cpp	2017-06-15 00:39:21 UTC (rev 218299)
@@ -707,25 +707,20 @@
         return;
 
     m_page->userContentProvider().forEachUserScript([this, protectedThis = makeRef(*this), injectionTime](DOMWrapperWorld& world, const UserScript& script) {
-        if (script.injectionTime() == injectionTime)
-            injectUserScriptImmediately(world, script);
+        auto* document = this->document();
+        if (!document)
+            return;
+        if (script.injectedFrames() == InjectInTopFrameOnly && ownerElement())
+            return;
+
+        if (script.injectionTime() == injectionTime && UserContentURLPattern::matchesPatterns(document->url(), script.whitelist(), script.blacklist())) {
+            if (m_page)
+                m_page->setAsRunningUserScripts();
+            m_script->evaluateInWorld(ScriptSourceCode(script.source(), script.url()), world);
+        }
     });
 }
 
-void Frame::injectUserScriptImmediately(DOMWrapperWorld& world, const UserScript& script)
-{
-    auto* document = this->document();
-    if (!document)
-        return;
-    if (script.injectedFrames() == InjectInTopFrameOnly && !isMainFrame())
-        return;
-    if (!UserContentURLPattern::matchesPatterns(document->url(), script.whitelist(), script.blacklist()))
-        return;
-    if (m_page)
-        m_page->setAsRunningUserScripts();
-    m_script->evaluateInWorld(ScriptSourceCode(script.source(), script.url()), world);
-}
-
 RenderView* Frame::contentRenderer() const
 {
     return document() ? document()->renderView() : nullptr;

Modified: trunk/Source/WebCore/page/Frame.h (218298 => 218299)


--- trunk/Source/WebCore/page/Frame.h	2017-06-15 00:36:46 UTC (rev 218298)
+++ trunk/Source/WebCore/page/Frame.h	2017-06-15 00:39:21 UTC (rev 218299)
@@ -165,8 +165,7 @@
 
 // ======== All public functions below this point are candidates to move out of Frame into another class. ========
 
-    WEBCORE_EXPORT void injectUserScripts(UserScriptInjectionTime);
-    WEBCORE_EXPORT void injectUserScriptImmediately(DOMWrapperWorld&, const UserScript&);
+    void injectUserScripts(UserScriptInjectionTime);
     
     WEBCORE_EXPORT String layerTreeAsText(LayerTreeFlags = 0) const;
     WEBCORE_EXPORT String trackedRepaintRectsAsText() const;

Modified: trunk/Source/WebCore/page/Page.cpp (218298 => 218299)


--- trunk/Source/WebCore/page/Page.cpp	2017-06-15 00:36:46 UTC (rev 218298)
+++ trunk/Source/WebCore/page/Page.cpp	2017-06-15 00:39:21 UTC (rev 218299)
@@ -150,7 +150,7 @@
 
 DEFINE_DEBUG_ONLY_GLOBAL(WTF::RefCountedLeakCounter, pageCounter, ("Page"));
 
-void Page::forEachPage(Function<void(Page&)>&& function)
+void Page::forEachPage(std::function<void(Page&)> function)
 {
     if (!allPages)
         return;

Modified: trunk/Source/WebCore/page/Page.h (218298 => 218299)


--- trunk/Source/WebCore/page/Page.h	2017-06-15 00:36:46 UTC (rev 218298)
+++ trunk/Source/WebCore/page/Page.h	2017-06-15 00:39:21 UTC (rev 218299)
@@ -193,7 +193,7 @@
 
     PageGroup& group();
 
-    WEBCORE_EXPORT static void forEachPage(WTF::Function<void(Page&)>&&);
+    static void forEachPage(std::function<void(Page&)>);
 
     void incrementSubframeCount() { ++m_subframeCount; }
     void decrementSubframeCount() { ASSERT(m_subframeCount); --m_subframeCount; }
@@ -515,7 +515,7 @@
 
     PluginInfoProvider& pluginInfoProvider();
 
-    WEBCORE_EXPORT UserContentProvider& userContentProvider();
+    UserContentProvider& userContentProvider();
     WEBCORE_EXPORT void setUserContentProvider(Ref<UserContentProvider>&&);
 
     VisitedLinkStore& visitedLinkStore();

Modified: trunk/Source/WebKit2/ChangeLog (218298 => 218299)


--- trunk/Source/WebKit2/ChangeLog	2017-06-15 00:36:46 UTC (rev 218298)
+++ trunk/Source/WebKit2/ChangeLog	2017-06-15 00:39:21 UTC (rev 218299)
@@ -1,5 +1,19 @@
 2017-06-14  Commit Queue  <[email protected]>
 
+        Unreviewed, rolling out r218285.
+        https://bugs.webkit.org/show_bug.cgi?id=173391
+
+        API test fails on iOS (Requested by alexchristensen on
+        #webkit).
+
+        Reverted changeset:
+
+        "Add SPI for immediate injection of user scripts"
+        https://bugs.webkit.org/show_bug.cgi?id=173342
+        http://trac.webkit.org/changeset/218285
+
+2017-06-14  Commit Queue  <[email protected]>
+
         Unreviewed, rolling out r218267.
         https://bugs.webkit.org/show_bug.cgi?id=173390
 

Modified: trunk/Source/WebKit2/Shared/WebUserContentControllerDataTypes.h (218298 => 218299)


--- trunk/Source/WebKit2/Shared/WebUserContentControllerDataTypes.h	2017-06-15 00:36:46 UTC (rev 218298)
+++ trunk/Source/WebKit2/Shared/WebUserContentControllerDataTypes.h	2017-06-15 00:39:21 UTC (rev 218299)
@@ -23,7 +23,8 @@
  * THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#pragma once
+#ifndef WebUserContentControllerDataTypes_h
+#define WebUserContentControllerDataTypes_h
 
 #include <WebCore/UserScript.h>
 #include <WebCore/UserStyleSheet.h>
@@ -63,3 +64,5 @@
 };
 
 } // namespace WebKit
+
+#endif // WebUserContentControllerDataTypes_h

Modified: trunk/Source/WebKit2/UIProcess/API/C/WKPageGroup.cpp (218298 => 218299)


--- trunk/Source/WebKit2/UIProcess/API/C/WKPageGroup.cpp	2017-06-15 00:36:46 UTC (rev 218298)
+++ trunk/Source/WebKit2/UIProcess/API/C/WKPageGroup.cpp	2017-06-15 00:39:21 UTC (rev 218299)
@@ -31,11 +31,9 @@
 #include "APIUserContentWorld.h"
 #include "APIUserScript.h"
 #include "APIUserStyleSheet.h"
-#include "AddUserScriptImmediately.h"
 #include "WKAPICast.h"
 #include "WebPageGroup.h"
 #include "WebPreferences.h"
-#include "WebUserContentController.h"
 #include "WebUserContentControllerProxy.h"
 
 using namespace WebKit;
@@ -100,7 +98,7 @@
     
     auto url = "" ? WebCore::blankURL() : WebCore::URL(WebCore::URL(), baseURLString);
     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::UserContentWorld::normalWorld());
-    toImpl(pageGroupRef)->userContentController().addUserScript(userScript.get(), AddUserScriptImmediately::No);
+    toImpl(pageGroupRef)->userContentController().addUserScript(userScript.get());
 }
 
 void WKPageGroupRemoveAllUserScripts(WKPageGroupRef pageGroupRef)

Modified: trunk/Source/WebKit2/UIProcess/API/C/WKUserContentControllerRef.cpp (218298 => 218299)


--- trunk/Source/WebKit2/UIProcess/API/C/WKUserContentControllerRef.cpp	2017-06-15 00:36:46 UTC (rev 218298)
+++ trunk/Source/WebKit2/UIProcess/API/C/WKUserContentControllerRef.cpp	2017-06-15 00:39:21 UTC (rev 218299)
@@ -29,7 +29,6 @@
 #include "APIArray.h"
 #include "APIContentRuleList.h"
 #include "APIUserScript.h"
-#include "AddUserScriptImmediately.h"
 #include "WKAPICast.h"
 #include "WebUserContentControllerProxy.h"
 
@@ -53,7 +52,7 @@
 
 void WKUserContentControllerAddUserScript(WKUserContentControllerRef userContentControllerRef, WKUserScriptRef userScriptRef)
 {
-    toImpl(userContentControllerRef)->addUserScript(*toImpl(userScriptRef), AddUserScriptImmediately::No);
+    toImpl(userContentControllerRef)->addUserScript(*toImpl(userScriptRef));
 }
 
 void WKUserContentControllerRemoveAllUserScripts(WKUserContentControllerRef userContentControllerRef)

Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/WKUserContentController.mm (218298 => 218299)


--- trunk/Source/WebKit2/UIProcess/API/Cocoa/WKUserContentController.mm	2017-06-15 00:36:46 UTC (rev 218298)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/WKUserContentController.mm	2017-06-15 00:39:21 UTC (rev 218299)
@@ -30,7 +30,6 @@
 
 #import "APISerializedScriptValue.h"
 #import "APIUserContentWorld.h"
-#import "AddUserScriptImmediately.h"
 #import "WKContentRuleListInternal.h"
 #import "WKFrameInfoInternal.h"
 #import "WKNSArray.h"
@@ -85,7 +84,7 @@
 
 - (void)addUserScript:(WKUserScript *)userScript
 {
-    _userContentControllerProxy->addUserScript(*userScript->_userScript, WebKit::AddUserScriptImmediately::No);
+    _userContentControllerProxy->addUserScript(*userScript->_userScript);
 }
 
 - (void)removeAllUserScripts
@@ -173,11 +172,6 @@
     _userContentControllerProxy->removeAllUserScripts(*userContentWorld->_userContentWorld);
 }
 
-- (void)_addUserScriptImmediately:(WKUserScript *)userScript
-{
-    _userContentControllerProxy->addUserScript(*userScript->_userScript, WebKit::AddUserScriptImmediately::Yes);
-}
-
 - (void)_addUserContentFilter:(_WKUserContentFilter *)userContentFilter
 {
 #if ENABLE(CONTENT_EXTENSIONS)

Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/WKUserContentControllerPrivate.h (218298 => 218299)


--- trunk/Source/WebKit2/UIProcess/API/Cocoa/WKUserContentControllerPrivate.h	2017-06-15 00:36:46 UTC (rev 218298)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/WKUserContentControllerPrivate.h	2017-06-15 00:39:21 UTC (rev 218299)
@@ -36,7 +36,6 @@
 
 - (void)_removeUserScript:(WKUserScript *)userScript WK_API_AVAILABLE(macosx(10.12), ios(10.0));
 - (void)_removeAllUserScriptsAssociatedWithUserContentWorld:(_WKUserContentWorld *)userContentWorld WK_API_AVAILABLE(macosx(10.12), ios(10.0));
-- (void)_addUserScriptImmediately:(WKUserScript *)userScript WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA));
 
 - (void)_addUserContentFilter:(_WKUserContentFilter *)userContentFilter WK_API_AVAILABLE(macosx(10.11), ios(9.0));
 - (void)_removeUserContentFilter:(NSString *)userContentFilterName WK_API_AVAILABLE(macosx(10.11), ios(9.0));

Modified: trunk/Source/WebKit2/UIProcess/API/gtk/WebKitUserContentManager.cpp (218298 => 218299)


--- trunk/Source/WebKit2/UIProcess/API/gtk/WebKitUserContentManager.cpp	2017-06-15 00:36:46 UTC (rev 218298)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/WebKitUserContentManager.cpp	2017-06-15 00:39:21 UTC (rev 218299)
@@ -21,7 +21,6 @@
 #include "WebKitUserContentManager.h"
 
 #include "APISerializedScriptValue.h"
-#include "AddUserScriptImmediately.h"
 #include "WebKitJavascriptResultPrivate.h"
 #include "WebKitPrivate.h"
 #include "WebKitUserContentManagerPrivate.h"
@@ -160,7 +159,7 @@
 {
     g_return_if_fail(WEBKIT_IS_USER_CONTENT_MANAGER(manager));
     g_return_if_fail(script);
-    manager->priv->userContentController->addUserScript(webkitUserScriptGetUserScript(script), AddUserScriptImmediately::No);
+    manager->priv->userContentController->addUserScript(webkitUserScriptGetUserScript(script));
 }
 
 /**

Modified: trunk/Source/WebKit2/UIProcess/UserContent/WebUserContentControllerProxy.cpp (218298 => 218299)


--- trunk/Source/WebKit2/UIProcess/UserContent/WebUserContentControllerProxy.cpp	2017-06-15 00:36:46 UTC (rev 218298)
+++ trunk/Source/WebKit2/UIProcess/UserContent/WebUserContentControllerProxy.cpp	2017-06-15 00:39:21 UTC (rev 218299)
@@ -30,7 +30,6 @@
 #include "APIUserContentWorld.h"
 #include "APIUserScript.h"
 #include "APIUserStyleSheet.h"
-#include "AddUserScriptImmediately.h"
 #include "DataReference.h"
 #include "WebPageCreationParameters.h"
 #include "WebProcessProxy.h"
@@ -155,7 +154,7 @@
         process->send(Messages::WebUserContentController::RemoveUserContentWorlds(worldsToRemove), m_identifier);
 }
 
-void WebUserContentControllerProxy::addUserScript(API::UserScript& userScript, AddUserScriptImmediately immediately)
+void WebUserContentControllerProxy::addUserScript(API::UserScript& userScript)
 {
     Ref<API::UserContentWorld> world = userScript.userContentWorld();
 
@@ -164,7 +163,7 @@
     m_userScripts->elements().append(&userScript);
 
     for (WebProcessProxy* process : m_processes)
-        process->send(Messages::WebUserContentController::AddUserScripts({ { userScript.identifier(), world->identifier(), userScript.userScript() } }, immediately), m_identifier);
+        process->send(Messages::WebUserContentController::AddUserScripts({ { userScript.identifier(), world->identifier(), userScript.userScript() } }), m_identifier);
 }
 
 void WebUserContentControllerProxy::removeUserScript(API::UserScript& userScript)

Modified: trunk/Source/WebKit2/UIProcess/UserContent/WebUserContentControllerProxy.h (218298 => 218299)


--- trunk/Source/WebKit2/UIProcess/UserContent/WebUserContentControllerProxy.h	2017-06-15 00:36:46 UTC (rev 218298)
+++ trunk/Source/WebKit2/UIProcess/UserContent/WebUserContentControllerProxy.h	2017-06-15 00:39:21 UTC (rev 218299)
@@ -57,7 +57,6 @@
 class WebScriptMessageHandler;
 struct FrameInfoData;
 struct WebPageCreationParameters;
-enum class AddUserScriptImmediately;
 
 class WebUserContentControllerProxy : public API::ObjectImpl<API::Object::Type::UserContentController>, private IPC::MessageReceiver {
 public:
@@ -74,7 +73,7 @@
     void removeProcess(WebProcessProxy&);
 
     API::Array& userScripts() { return m_userScripts.get(); }
-    void addUserScript(API::UserScript&, AddUserScriptImmediately);
+    void addUserScript(API::UserScript&);
     void removeUserScript(API::UserScript&);
     void removeAllUserScripts(API::UserContentWorld&);
     void removeAllUserScripts();

Modified: trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj (218298 => 218299)


--- trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj	2017-06-15 00:36:46 UTC (rev 218298)
+++ trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj	2017-06-15 00:39:21 UTC (rev 218299)
@@ -3444,7 +3444,6 @@
 		5C7706731D111D8B0012700F /* WebSocketProvider.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = WebSocketProvider.cpp; path = Network/WebSocketProvider.cpp; sourceTree = "<group>"; };
 		5C7C88DC1D0F41A0009D2F6D /* WebSocketProvider.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WebSocketProvider.h; path = Network/WebSocketProvider.h; sourceTree = "<group>"; };
 		5C85C7861C3F23C50061A4FA /* PendingDownload.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = PendingDownload.cpp; path = NetworkProcess/Downloads/PendingDownload.cpp; sourceTree = "<group>"; };
-		5C92412D1EF1A67A005AF897 /* AddUserScriptImmediately.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AddUserScriptImmediately.h; sourceTree = "<group>"; };
 		5C9E567F1DF7930900C9EE33 /* WebsitePolicies.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebsitePolicies.h; sourceTree = "<group>"; };
 		5C9E56801DF7F05500C9EE33 /* WKWebsitePolicies.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WKWebsitePolicies.cpp; sourceTree = "<group>"; };
 		5C9E56811DF7F05500C9EE33 /* WKWebsitePolicies.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKWebsitePolicies.h; sourceTree = "<group>"; };
@@ -5095,7 +5094,6 @@
 		1AAF08AA1926930B00B6390C /* UserContent */ = {
 			isa = PBXGroup;
 			children = (
-				5C92412D1EF1A67A005AF897 /* AddUserScriptImmediately.h */,
 				1AAF08AB1926936700B6390C /* WebUserContentController.cpp */,
 				1AAF08AC1926936700B6390C /* WebUserContentController.h */,
 				1AAF08B419269E2400B6390C /* WebUserContentController.messages.in */,

Deleted: trunk/Source/WebKit2/WebProcess/UserContent/AddUserScriptImmediately.h (218298 => 218299)


--- trunk/Source/WebKit2/WebProcess/UserContent/AddUserScriptImmediately.h	2017-06-15 00:36:46 UTC (rev 218298)
+++ trunk/Source/WebKit2/WebProcess/UserContent/AddUserScriptImmediately.h	2017-06-15 00:39:21 UTC (rev 218299)
@@ -1,46 +0,0 @@
-/*
- * Copyright (C) 2017 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#pragma once
-
-#include <wtf/EnumTraits.h>
-
-namespace WebKit {
-    
-enum class AddUserScriptImmediately { No, Yes };
-    
-}
-
-namespace WTF {
-
-template<> struct EnumTraits<WebKit::AddUserScriptImmediately> {
-    using values = EnumValues<
-    WebKit::AddUserScriptImmediately,
-    WebKit::AddUserScriptImmediately::No,
-    WebKit::AddUserScriptImmediately::Yes
-    >;
-};
-
-}

Modified: trunk/Source/WebKit2/WebProcess/UserContent/WebUserContentController.cpp (218298 => 218299)


--- trunk/Source/WebKit2/WebProcess/UserContent/WebUserContentController.cpp	2017-06-15 00:36:46 UTC (rev 218298)
+++ trunk/Source/WebKit2/WebProcess/UserContent/WebUserContentController.cpp	2017-06-15 00:39:21 UTC (rev 218299)
@@ -26,7 +26,6 @@
 #include "config.h"
 #include "WebUserContentController.h"
 
-#include "AddUserScriptImmediately.h"
 #include "DataReference.h"
 #include "FrameInfoData.h"
 #include "InjectedBundleScriptWorld.h"
@@ -37,7 +36,6 @@
 #include "WebUserContentControllerMessages.h"
 #include "WebUserContentControllerProxyMessages.h"
 #include <WebCore/DOMWrapperWorld.h>
-#include <WebCore/MainFrame.h>
 #include <WebCore/SecurityOriginData.h>
 #include <WebCore/SerializedScriptValue.h>
 #include <WebCore/UserStyleSheet.h>
@@ -124,7 +122,7 @@
     }
 }
 
-void WebUserContentController::addUserScripts(Vector<WebUserScriptData>&& userScripts, AddUserScriptImmediately immediately)
+void WebUserContentController::addUserScripts(const Vector<WebUserScriptData>& userScripts)
 {
     for (const auto& userScriptData : userScripts) {
         auto it = worldMap().find(userScriptData.worldIdentifier);
@@ -134,7 +132,7 @@
         }
 
         UserScript script = userScriptData.userScript;
-        addUserScriptInternal(*it->value.first, userScriptData.identifier, WTFMove(script), immediately);
+        addUserScriptInternal(*it->value.first, userScriptData.identifier, WTFMove(script));
     }
 }
 
@@ -362,24 +360,8 @@
 }
 #endif
 
-void WebUserContentController::addUserScriptInternal(InjectedBundleScriptWorld& world, uint64_t userScriptIdentifier, UserScript&& userScript, AddUserScriptImmediately immediately)
+void WebUserContentController::addUserScriptInternal(InjectedBundleScriptWorld& world, uint64_t userScriptIdentifier, UserScript&& userScript)
 {
-    if (immediately == AddUserScriptImmediately::Yes) {
-        Page::forEachPage([&] (Page& page) {
-            if (&page.userContentProvider() != this)
-                return;
-            
-            auto& mainFrame = page.mainFrame();
-            if (userScript.injectedFrames() == InjectInTopFrameOnly) {
-                mainFrame.injectUserScriptImmediately(world.coreWorld(), userScript);
-                return;
-            }
-
-            for (Frame* frame = &mainFrame; frame; frame = frame->tree().traverseNext(&mainFrame))
-                frame->injectUserScriptImmediately(world.coreWorld(), userScript);
-        });
-    }
-
     auto& scriptsInWorld = m_userScripts.ensure(&world, [] { return Vector<std::pair<uint64_t, WebCore::UserScript>>(); }).iterator->value;
     scriptsInWorld.append(std::make_pair(userScriptIdentifier, WTFMove(userScript)));
 }
@@ -386,7 +368,7 @@
 
 void WebUserContentController::addUserScript(InjectedBundleScriptWorld& world, UserScript&& userScript)
 {
-    addUserScriptInternal(world, 0, WTFMove(userScript), AddUserScriptImmediately::No);
+    addUserScriptInternal(world, 0, WTFMove(userScript));
 }
 
 void WebUserContentController::removeUserScriptWithURL(InjectedBundleScriptWorld& world, const URL& url)

Modified: trunk/Source/WebKit2/WebProcess/UserContent/WebUserContentController.h (218298 => 218299)


--- trunk/Source/WebKit2/WebProcess/UserContent/WebUserContentController.h	2017-06-15 00:36:46 UTC (rev 218298)
+++ trunk/Source/WebKit2/WebProcess/UserContent/WebUserContentController.h	2017-06-15 00:39:21 UTC (rev 218299)
@@ -46,7 +46,6 @@
 class InjectedBundleScriptWorld;
 class WebCompiledContentRuleListData;
 class WebUserMessageHandlerDescriptorProxy;
-enum class AddUserScriptImmediately;
 
 class WebUserContentController final : public WebCore::UserContentProvider, private IPC::MessageReceiver {
 public:
@@ -64,7 +63,7 @@
     void removeAllUserContent();
 
     void addUserContentWorlds(const Vector<std::pair<uint64_t, String>>&);
-    void addUserScripts(Vector<WebUserScriptData>&&, AddUserScriptImmediately);
+    void addUserScripts(const Vector<WebUserScriptData>&);
     void addUserStyleSheets(const Vector<WebUserStyleSheetData>&);
     void addUserScriptMessageHandlers(const Vector<WebScriptMessageHandlerData>&);
 #if ENABLE(CONTENT_EXTENSIONS)
@@ -103,7 +102,7 @@
     void removeAllContentRuleLists();
 #endif
 
-    void addUserScriptInternal(InjectedBundleScriptWorld&, uint64_t userScriptIdentifier, WebCore::UserScript&&, AddUserScriptImmediately);
+    void addUserScriptInternal(InjectedBundleScriptWorld&, uint64_t userScriptIdentifier, WebCore::UserScript&&);
     void removeUserScriptInternal(InjectedBundleScriptWorld&, uint64_t userScriptIdentifier);
     void addUserStyleSheetInternal(InjectedBundleScriptWorld&, uint64_t userStyleSheetIdentifier, WebCore::UserStyleSheet&&);
     void removeUserStyleSheetInternal(InjectedBundleScriptWorld&, uint64_t userStyleSheetIdentifier);

Modified: trunk/Source/WebKit2/WebProcess/UserContent/WebUserContentController.messages.in (218298 => 218299)


--- trunk/Source/WebKit2/WebProcess/UserContent/WebUserContentController.messages.in	2017-06-15 00:36:46 UTC (rev 218298)
+++ trunk/Source/WebKit2/WebProcess/UserContent/WebUserContentController.messages.in	2017-06-15 00:39:21 UTC (rev 218299)
@@ -27,7 +27,7 @@
     AddUserContentWorlds(Vector<std::pair<uint64_t, String>> worlds);
     RemoveUserContentWorlds(Vector<uint64_t> worldIdentifiers);
 
-    AddUserScripts(Vector<struct WebKit::WebUserScriptData> userScripts, enum WebKit::AddUserScriptImmediately immediately);
+    AddUserScripts(Vector<struct WebKit::WebUserScriptData> userScripts);
     RemoveUserScript(uint64_t worldIdentifier, uint64_t identifier);
     RemoveAllUserScripts(Vector<uint64_t> worldIdentifiers);
 

Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp (218298 => 218299)


--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp	2017-06-15 00:36:46 UTC (rev 218298)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp	2017-06-15 00:39:21 UTC (rev 218299)
@@ -31,7 +31,6 @@
 #include "APIArray.h"
 #include "APIGeometry.h"
 #include "APIWebsitePolicies.h"
-#include "AddUserScriptImmediately.h"
 #include "AssistedNodeInformation.h"
 #include "DataReference.h"
 #include "DragControllerAction.h"
@@ -565,7 +564,7 @@
         registerURLSchemeHandler(iterator.value, iterator.key);
 
     m_userContentController->addUserContentWorlds(parameters.userContentWorlds);
-    m_userContentController->addUserScripts(WTFMove(parameters.userScripts), AddUserScriptImmediately::No);
+    m_userContentController->addUserScripts(parameters.userScripts);
     m_userContentController->addUserStyleSheets(parameters.userStyleSheets);
     m_userContentController->addUserScriptMessageHandlers(parameters.messageHandlers);
 #if ENABLE(CONTENT_EXTENSIONS)

Modified: trunk/Tools/ChangeLog (218298 => 218299)


--- trunk/Tools/ChangeLog	2017-06-15 00:36:46 UTC (rev 218298)
+++ trunk/Tools/ChangeLog	2017-06-15 00:39:21 UTC (rev 218299)
@@ -1,3 +1,17 @@
+2017-06-14  Commit Queue  <[email protected]>
+
+        Unreviewed, rolling out r218285.
+        https://bugs.webkit.org/show_bug.cgi?id=173391
+
+        API test fails on iOS (Requested by alexchristensen on
+        #webkit).
+
+        Reverted changeset:
+
+        "Add SPI for immediate injection of user scripts"
+        https://bugs.webkit.org/show_bug.cgi?id=173342
+        http://trac.webkit.org/changeset/218285
+
 2017-06-14  Chris Dumez  <[email protected]>
 
         WebKit falsely reports that a web process is unresponsive if you close a page shortly after stopping a load

Modified: trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/UserContentController.mm (218298 => 218299)


--- trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/UserContentController.mm	2017-06-15 00:36:46 UTC (rev 218298)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/UserContentController.mm	2017-06-15 00:39:21 UTC (rev 218299)
@@ -140,47 +140,6 @@
     EXPECT_WK_STREQ(@"PASS", resultValue);
 }
 
-static void waitForMessage(const char* expectedMessage)
-{
-    TestWebKitAPI::Util::run(&receivedScriptMessage);
-    receivedScriptMessage = false;
-    EXPECT_STREQ(expectedMessage, [(NSString *)[lastScriptMessage body] UTF8String]);
-}
-
-TEST(WKUserContentController, AddUserScriptImmediately)
-{
-    RetainPtr<ScriptMessageHandler> handler = adoptNS([[ScriptMessageHandler alloc] init]);
-    RetainPtr<WKUserScript> startAllFrames = adoptNS([[WKUserScript alloc] initWithSource:@"window.webkit.messageHandlers.testHandler.postMessage('start all')" injectionTime:WKUserScriptInjectionTimeAtDocumentStart forMainFrameOnly:NO]);
-    RetainPtr<WKUserScript> endMainFrameOnly = adoptNS([[WKUserScript alloc] initWithSource:@"window.webkit.messageHandlers.testHandler.postMessage('end main')" injectionTime:WKUserScriptInjectionTimeAtDocumentEnd forMainFrameOnly:YES]);
-    
-    RetainPtr<WKWebViewConfiguration> configuration = adoptNS([[WKWebViewConfiguration alloc] init]);
-    [[configuration userContentController] addScriptMessageHandler:handler.get() name:@"testHandler"];
-    
-    RetainPtr<WKWebView> webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:configuration.get()]);
-    
-    RetainPtr<SimpleNavigationDelegate> delegate = adoptNS([[SimpleNavigationDelegate alloc] init]);
-    [webView setNavigationDelegate:delegate.get()];
-    
-    NSURLRequest *request = [NSURLRequest requestWithURL:[[NSBundle mainBundle] URLForResource:@"simple-iframe" withExtension:@"html" subdirectory:@"TestWebKitAPI.resources"]];
-    
-    isDoneWithNavigation = false;
-    [webView loadRequest:request];
-    TestWebKitAPI::Util::run(&isDoneWithNavigation);
-    
-    receivedScriptMessage = false;
-    [[configuration userContentController] _addUserScriptImmediately:startAllFrames.get()];
-    // simple-iframe.html has a main frame and one iframe.
-    waitForMessage("start all");
-    waitForMessage("start all");
-    [[configuration userContentController] _addUserScriptImmediately:endMainFrameOnly.get()];
-    waitForMessage("end main");
-    [webView reload];
-    waitForMessage("start all");
-    waitForMessage("end main");
-    // When reloading, an iframe doesn't exist before the document has started to load.
-    waitForMessage("start all");
-}
-
 TEST(WKUserContentController, ScriptMessageHandlerBasicRemove)
 {
     RetainPtr<ScriptMessageHandler> handler = adoptNS([[ScriptMessageHandler alloc] init]);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to