Block all plugins smaller than 5x5px
authordino@apple.com <dino@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 13 Mar 2019 23:37:32 +0000 (23:37 +0000)
committerdino@apple.com <dino@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 13 Mar 2019 23:37:32 +0000 (23:37 +0000)
commitdd5809da43515b42c74f00d873882438c3318723
tree7f45b64b0e63970a74b1706c0ea07bdd4b58f9bb
parent0c75ecc360bdce81a3cabb6342214f8d385c57be
Block all plugins smaller than 5x5px
https://bugs.webkit.org/show_bug.cgi?id=195702
<rdar://problem/28435204>

Reviewed by Sam Weinig.

Source/WebCore:

Block all plugins that are smaller than a threshold, in this case
5px x 5px. Other browsers have implemented this for a while, and now
that we have Intersection Observers, small plugins are no longer
necessary.

Test: plugins/small-plugin-blocked.html

* en.lproj/Localizable.strings: New message for a small plugin.
* platform/LocalizedStrings.cpp:
(WebCore::pluginTooSmallText):
* platform/LocalizedStrings.h:

* html/HTMLPlugInElement.cpp: Helper function for Internals testing.
(WebCore::HTMLPlugInElement::isBelowSizeThreshold const):
* html/HTMLPlugInElement.h:

* loader/EmptyClients.cpp: Removed an unused function.
(WebCore::EmptyFrameLoaderClient::recreatePlugin): Deleted.
* loader/EmptyFrameLoaderClient.h:
* loader/FrameLoaderClient.h:

* page/Settings.yaml: Add flag for new feature.

* rendering/RenderEmbeddedObject.cpp: New unavailability reason for
embedded objects.
(WebCore::unavailablePluginReplacementText):
* rendering/RenderEmbeddedObject.h:
(WebCore::RenderEmbeddedObject::pluginUnavailabilityReason const):

* testing/Internals.cpp: Helper function for testing.
(WebCore::Internals::pluginIsBelowSizeThreshold):
* testing/Internals.h:
* testing/Internals.idl:

Source/WebKit:

Block all plugins that are smaller than a threshold, in this case
5x5px. Other browsers have implemented this for a while, and now
that we have Intersection Observers, small plugins are no longer
necessary.

* Shared/WebPreferences.yaml: New setting for this feature.

* UIProcess/WebPageProxy.cpp: Handle new unavailability type.
(WebKit::WebPageProxy::unavailablePluginButtonClicked):
* WebProcess/WebCoreSupport/WebChromeClient.cpp:
(WebKit::WebChromeClient::shouldUnavailablePluginMessageBeButton const):

* WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp: Removed this function
as it was never being called.
(WebKit::WebFrameLoaderClient::recreatePlugin): Deleted.
* WebProcess/WebCoreSupport/WebFrameLoaderClient.h:

* WebProcess/WebPage/WebPage.cpp:
(WebKit::pluginIsSmall): Checks the size of the plugin.
(WebKit::WebPage::createPlugin): If the plugin is too small, stop it from
launching.

Source/WebKitLegacy/mac:

Removed a function that was never being called.

* WebCoreSupport/WebFrameLoaderClient.h:
* WebCoreSupport/WebFrameLoaderClient.mm:
(WebFrameLoaderClient::recreatePlugin): Deleted.

LayoutTests:

New test for some small plugins. Updated existing tests
to create plugins bigger than a threshold if necessary.

* plugins/clicking-missing-plugin-fires-delegate.html:
* plugins/destroy-stream-twice.html:
* plugins/npruntime/npruntime.html:
* plugins/object-embed-plugin-scripting.html:
* plugins/small-plugin-blocked-expected.txt: Added.
* plugins/small-plugin-blocked.html: Added.
* platform/mac-wk1/TestExpectations: Skip new test on WK1.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@242920 268f45cc-cd09-0410-ab3c-d52691b4dbfc
33 files changed:
LayoutTests/ChangeLog
LayoutTests/platform/mac-wk1/TestExpectations
LayoutTests/plugins/clicking-missing-plugin-fires-delegate.html
LayoutTests/plugins/destroy-stream-twice.html
LayoutTests/plugins/npruntime/npruntime.html
LayoutTests/plugins/object-embed-plugin-scripting.html
LayoutTests/plugins/small-plugin-blocked-expected.txt [new file with mode: 0644]
LayoutTests/plugins/small-plugin-blocked.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/en.lproj/Localizable.strings
Source/WebCore/html/HTMLPlugInElement.cpp
Source/WebCore/html/HTMLPlugInElement.h
Source/WebCore/loader/EmptyClients.cpp
Source/WebCore/loader/EmptyFrameLoaderClient.h
Source/WebCore/loader/FrameLoaderClient.h
Source/WebCore/page/Settings.yaml
Source/WebCore/platform/LocalizedStrings.cpp
Source/WebCore/platform/LocalizedStrings.h
Source/WebCore/rendering/RenderEmbeddedObject.cpp
Source/WebCore/rendering/RenderEmbeddedObject.h
Source/WebCore/testing/Internals.cpp
Source/WebCore/testing/Internals.h
Source/WebCore/testing/Internals.idl
Source/WebKit/ChangeLog
Source/WebKit/Shared/WebPreferences.yaml
Source/WebKit/UIProcess/WebPageProxy.cpp
Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.cpp
Source/WebKit/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp
Source/WebKit/WebProcess/WebCoreSupport/WebFrameLoaderClient.h
Source/WebKit/WebProcess/WebPage/WebPage.cpp
Source/WebKitLegacy/mac/ChangeLog
Source/WebKitLegacy/mac/WebCoreSupport/WebFrameLoaderClient.h
Source/WebKitLegacy/mac/WebCoreSupport/WebFrameLoaderClient.mm