Add SPI for immediate injection of user scripts
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 14 Jun 2017 19:51:00 +0000 (19:51 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 14 Jun 2017 19:51:00 +0000 (19:51 +0000)
commitd9374493fd6aad3f003f342787c973d3c07b3fd3
tree7b782358199864b35bc497cfebc3bb9a3a45dfaa
parent68285e3bd90b909978275498c1be976f072a8238
Add SPI for immediate injection of user scripts
https://bugs.webkit.org/show_bug.cgi?id=173342
<rdar://problem/29202285>

Patch by Alex Christensen <achristensen@webkit.org> on 2017-06-14
Reviewed by Brady Eidson.

Source/WebCore:

The new SPI is WKUserContentController._addUserScriptImmediately.
It is covered by new API tests.

* page/Frame.cpp:
(WebCore::Frame::injectUserScripts):
(WebCore::Frame::injectUserScriptImmediately):
Move injection functionality to allow us to call it directly from the new SPI.
* page/Frame.h:
* page/Page.cpp:
(WebCore::Page::forEachPage):
* page/Page.h:

Source/WebKit2:

* UIProcess/API/C/WKPageGroup.cpp:
(WKPageGroupAddUserScript):
* UIProcess/API/C/WKUserContentControllerRef.cpp:
(WKUserContentControllerAddUserScript):
* UIProcess/API/Cocoa/WKUserContentController.mm:
(-[WKUserContentController addUserScript:]):
(-[WKUserContentController _addUserScriptImmediately:]):
* UIProcess/API/Cocoa/WKUserContentControllerPrivate.h:
* UIProcess/UserContent/WebUserContentControllerProxy.cpp:
(WebKit::WebUserContentControllerProxy::addUserScript):
* UIProcess/UserContent/WebUserContentControllerProxy.h:
* WebProcess/UserContent/WebUserContentController.cpp:
(WebKit::WebUserContentController::addUserScripts):
(WebKit::WebUserContentController::addUserScriptInternal):
If we are to inject the script internally, inject it into the appropriate pages.
If we're injecting into the top frame only, there's no need to traverse the frame tree.
(WebKit::WebUserContentController::addUserScript):
* WebProcess/UserContent/WebUserContentController.h:
* WebProcess/UserContent/WebUserContentController.messages.in:
* WebProcess/WebPage/WebPage.cpp:
(WebKit::m_cpuLimit):

Tools:

* TestWebKitAPI/Tests/WebKit2Cocoa/UserContentController.mm:
(waitForMessage):
(TEST):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@218285 268f45cc-cd09-0410-ab3c-d52691b4dbfc
22 files changed:
Source/WebCore/ChangeLog
Source/WebCore/page/Frame.cpp
Source/WebCore/page/Frame.h
Source/WebCore/page/Page.cpp
Source/WebCore/page/Page.h
Source/WebKit2/ChangeLog
Source/WebKit2/Shared/WebUserContentControllerDataTypes.h
Source/WebKit2/UIProcess/API/C/WKPageGroup.cpp
Source/WebKit2/UIProcess/API/C/WKUserContentControllerRef.cpp
Source/WebKit2/UIProcess/API/Cocoa/WKUserContentController.mm
Source/WebKit2/UIProcess/API/Cocoa/WKUserContentControllerPrivate.h
Source/WebKit2/UIProcess/API/gtk/WebKitUserContentManager.cpp
Source/WebKit2/UIProcess/UserContent/WebUserContentControllerProxy.cpp
Source/WebKit2/UIProcess/UserContent/WebUserContentControllerProxy.h
Source/WebKit2/WebKit2.xcodeproj/project.pbxproj
Source/WebKit2/WebProcess/UserContent/AddUserScriptImmediately.h [new file with mode: 0644]
Source/WebKit2/WebProcess/UserContent/WebUserContentController.cpp
Source/WebKit2/WebProcess/UserContent/WebUserContentController.h
Source/WebKit2/WebProcess/UserContent/WebUserContentController.messages.in
Source/WebKit2/WebProcess/WebPage/WebPage.cpp
Tools/ChangeLog
Tools/TestWebKitAPI/Tests/WebKit2Cocoa/UserContentController.mm