REGRESSION (r230843): Flash doesn't work; Produces blue box on page
authoryouenn@apple.com <youenn@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 6 Jul 2018 05:50:17 +0000 (05:50 +0000)
committeryouenn@apple.com <youenn@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 6 Jul 2018 05:50:17 +0000 (05:50 +0000)
https://bugs.webkit.org/show_bug.cgi?id=187346
<rdar://problem/41773974>

Reviewed by Ryosuke Niwa.

Source/WebCore:

Introduce clearPagesPluginData used by WebProcess when a plugin policy changes.
Add a new internals API to get the plugin count as navigator.plugin is filtering plugins.

Test: http/tests/plugins/plugin-allow-then-reload.html

* plugins/PluginData.h:
* plugins/PluginInfoProvider.cpp:
(WebCore::PluginInfoProvider::clearPagesPluginData):
* plugins/PluginInfoProvider.h:
* testing/Internals.cpp:
(WebCore::Internals::pluginCount):
* testing/Internals.h:
* testing/Internals.idl:

Source/WebKit:

Reset page plugins when the load client policies are updated.
This will ensure that pages will rebuild their plugin lists based on the new policies.

* WebProcess/Plugins/WebPluginInfoProvider.cpp:
(WebKit::WebPluginInfoProvider::setPluginLoadClientPolicy):
(WebKit::WebPluginInfoProvider::clearPluginClientPolicies):

Tools:

* WebKitTestRunner/TestController.cpp:
(WTR::TestController::resetStateToConsistentValues):
(WTR::TestController::setBlockAllPlugins):
When not blocked, set the load policy to allow once.
* WebKitTestRunner/TestController.h:

LayoutTests:

Skip new test on WK1 since it does not have the ability to block plugins.

* http/tests/plugins/plugin-allow-then-reload-expected.txt: Added.
* http/tests/plugins/plugin-allow-then-reload.html: Added.
* platform/mac-wk1/TestExpectations:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@233563 268f45cc-cd09-0410-ab3c-d52691b4dbfc

16 files changed:
LayoutTests/ChangeLog
LayoutTests/http/tests/plugins/plugin-allow-then-reload-expected.txt [new file with mode: 0644]
LayoutTests/http/tests/plugins/plugin-allow-then-reload.html [new file with mode: 0644]
LayoutTests/platform/mac-wk1/TestExpectations
Source/WebCore/ChangeLog
Source/WebCore/plugins/PluginData.h
Source/WebCore/plugins/PluginInfoProvider.cpp
Source/WebCore/plugins/PluginInfoProvider.h
Source/WebCore/testing/Internals.cpp
Source/WebCore/testing/Internals.h
Source/WebCore/testing/Internals.idl
Source/WebKit/ChangeLog
Source/WebKit/WebProcess/Plugins/WebPluginInfoProvider.cpp
Tools/ChangeLog
Tools/WebKitTestRunner/TestController.cpp
Tools/WebKitTestRunner/TestController.h

index a6dd775..ac9335a 100644 (file)
@@ -1,3 +1,17 @@
+2018-07-05  Youenn Fablet  <youenn@apple.com>
+
+        REGRESSION (r230843): Flash doesn't work; Produces blue box on page
+        https://bugs.webkit.org/show_bug.cgi?id=187346
+        <rdar://problem/41773974>
+
+        Reviewed by Ryosuke Niwa.
+
+        Skip new test on WK1 since it does not have the ability to block plugins.
+
+        * http/tests/plugins/plugin-allow-then-reload-expected.txt: Added.
+        * http/tests/plugins/plugin-allow-then-reload.html: Added.
+        * platform/mac-wk1/TestExpectations:
+
 2018-07-05  Brady Eidson  <beidson@apple.com>
 
         IndexedDB operations in a Page fail after a StorageProcess crash.
diff --git a/LayoutTests/http/tests/plugins/plugin-allow-then-reload-expected.txt b/LayoutTests/http/tests/plugins/plugin-allow-then-reload-expected.txt
new file mode 100644 (file)
index 0000000..e7d7c80
--- /dev/null
@@ -0,0 +1,3 @@
+number of plugins decreased after blocking: PASS
+number of plugins increased after allowing: PASS
+PASS
diff --git a/LayoutTests/http/tests/plugins/plugin-allow-then-reload.html b/LayoutTests/http/tests/plugins/plugin-allow-then-reload.html
new file mode 100644 (file)
index 0000000..c75dc2e
--- /dev/null
@@ -0,0 +1,47 @@
+<html>
+<body>
+<script>
+function doTest()
+{
+    if (!window.testRunner || !window.internals) {
+        document.body.innerHTML = "FAIL: requires internals API";
+        return;
+    }
+    if (!window.localStorage.step) {
+        testRunner.waitUntilDone();
+        testRunner.dumpAsText();
+
+        window.localStorage.step = 1;
+        window.localStorage.step0Value = window.internals.pluginCount();
+
+        testRunner.setBlockAllPlugins(true);
+
+        window.location.reload();
+        return;
+    }
+    if (window.localStorage.step == 1) {
+        window.localStorage.step = 2;
+        window.localStorage.step1Value = window.internals.pluginCount();
+
+        testRunner.setBlockAllPlugins(false);
+
+        window.location.reload();
+        return;
+    }
+    window.localStorage.step2Value = window.internals.pluginCount();
+    var test1 = window.localStorage.step0Value > window.localStorage.step1Value;
+    var test2 = window.localStorage.step2Value > window.localStorage.step1Value;
+
+    var message = "number of plugins decreased after blocking: " + (test1 ? "PASS" : "FAIL");
+    message += "<br>";
+    message += "number of plugins increased after allowing: " + (test2 ? "PASS" : "FAIL");
+    message += "<br>";
+    message += test1 && test2 ? "PASS" : "FAIL";
+    document.body.innerHTML = message;
+
+    testRunner.notifyDone();
+}
+doTest();
+</script>
+</body>
+</html>
index 73129cf..3bed687 100644 (file)
@@ -111,6 +111,7 @@ editing/secure-input/reset-state-on-navigation.html [ Failure ]
 
 # Plug-in blocking callback doesn't exist in WebKit1.
 plugins/unavailable-plugin-indicator-obscurity.html
+http/tests/plugins/plugin-allow-then-reload.html [ Skip ]
 
 http/tests/plugins/nounsupported-plugin.html [ Skip ]
 http/tests/plugins/supported-plugin-all-origin-visibility.html [ Skip ]
index 54203b8..3379546 100644 (file)
@@ -1,3 +1,25 @@
+2018-07-05  Youenn Fablet  <youenn@apple.com>
+
+        REGRESSION (r230843): Flash doesn't work; Produces blue box on page
+        https://bugs.webkit.org/show_bug.cgi?id=187346
+        <rdar://problem/41773974>
+
+        Reviewed by Ryosuke Niwa.
+
+        Introduce clearPagesPluginData used by WebProcess when a plugin policy changes.
+        Add a new internals API to get the plugin count as navigator.plugin is filtering plugins.
+
+        Test: http/tests/plugins/plugin-allow-then-reload.html
+
+        * plugins/PluginData.h:
+        * plugins/PluginInfoProvider.cpp:
+        (WebCore::PluginInfoProvider::clearPagesPluginData):
+        * plugins/PluginInfoProvider.h:
+        * testing/Internals.cpp:
+        (WebCore::Internals::pluginCount):
+        * testing/Internals.h:
+        * testing/Internals.idl:
+
 2018-07-05  Brady Eidson  <beidson@apple.com>
 
         IndexedDB operations in a Page fail after a StorageProcess crash.
index 44500fa..0b6c42e 100644 (file)
@@ -102,7 +102,7 @@ public:
     static Ref<PluginData> create(Page& page) { return adoptRef(*new PluginData(page)); }
 
     const Vector<PluginInfo>& plugins() const { return m_plugins; }
-    const Vector<PluginInfo>& webVisiblePlugins() const;
+    WEBCORE_EXPORT const Vector<PluginInfo>& webVisiblePlugins() const;
     Vector<PluginInfo> publiclyVisiblePlugins() const;
     WEBCORE_EXPORT void getWebVisibleMimesAndPluginIndices(Vector<MimeClassInfo>&, Vector<size_t>&) const;
 
index 862c98a..aa8d773 100644 (file)
@@ -38,6 +38,12 @@ PluginInfoProvider::~PluginInfoProvider()
     ASSERT(m_pages.isEmpty());
 }
 
+void PluginInfoProvider::clearPagesPluginData()
+{
+    for (auto& page : m_pages)
+        page->clearPluginData();
+}
+
 void PluginInfoProvider::refresh(bool reloadPages)
 {
     refreshPlugins();
index b4ab462..f4707b7 100644 (file)
@@ -38,6 +38,7 @@ public:
 
     void addPage(Page&);
     void removePage(Page&);
+    void clearPagesPluginData();
 
     virtual Vector<PluginInfo> pluginInfo(Page&, std::optional<Vector<SupportedPluginIdentifier>>&) = 0;
     virtual Vector<PluginInfo> webVisiblePluginInfo(Page&, const URL&) = 0;
index 7ae04af..88feb66 100644 (file)
 #include "PathUtilities.h"
 #include "PlatformMediaSessionManager.h"
 #include "PlatformStrategies.h"
+#include "PluginData.h"
 #include "PrintContext.h"
 #include "PseudoElement.h"
 #include "Range.h"
@@ -4637,4 +4638,12 @@ void Internals::setUseSystemAppearance(bool value)
     contextDocument()->page()->setUseSystemAppearance(value);
 }
 
+size_t Internals::pluginCount()
+{
+    if (!contextDocument() || !contextDocument()->page())
+        return 0;
+
+    return contextDocument()->page()->pluginData().webVisiblePlugins().size();
+}
+
 } // namespace WebCore
index ad4d0fd..0719a98 100644 (file)
@@ -717,6 +717,8 @@ public:
 
     void setUseSystemAppearance(bool);
 
+    size_t pluginCount();
+
 private:
     explicit Internals(Document&);
     Document* contextDocument() const;
index ad562db..5db5fd0 100644 (file)
@@ -654,4 +654,6 @@ enum EventThrottlingBehavior {
     void reloadWithoutContentExtensions();
 
     void setUseSystemAppearance(boolean value);
+
+    unsigned long pluginCount();
 };
index e1d55bd..b41893d 100644 (file)
@@ -1,3 +1,18 @@
+2018-07-05  Youenn Fablet  <youenn@apple.com>
+
+        REGRESSION (r230843): Flash doesn't work; Produces blue box on page
+        https://bugs.webkit.org/show_bug.cgi?id=187346
+        <rdar://problem/41773974>
+
+        Reviewed by Ryosuke Niwa.
+
+        Reset page plugins when the load client policies are updated.
+        This will ensure that pages will rebuild their plugin lists based on the new policies.
+
+        * WebProcess/Plugins/WebPluginInfoProvider.cpp:
+        (WebKit::WebPluginInfoProvider::setPluginLoadClientPolicy):
+        (WebKit::WebPluginInfoProvider::clearPluginClientPolicies):
+
 2018-07-05  Brady Eidson  <beidson@apple.com>
 
         IndexedDB operations in a Page fail after a StorageProcess crash.
index 50f9eaa..e1c4f1e 100644 (file)
@@ -80,11 +80,14 @@ void WebPluginInfoProvider::setPluginLoadClientPolicy(WebCore::PluginLoadClientP
     versionsToPolicies.set(versionStringToSet, clientPolicy);
     policiesByIdentifier.set(bundleIdentifierToSet, versionsToPolicies);
     m_hostsToPluginIdentifierData.set(hostToSet, policiesByIdentifier);
+
+    clearPagesPluginData();
 }
 
 void WebPluginInfoProvider::clearPluginClientPolicies()
 {
     m_hostsToPluginIdentifierData.clear();
+    clearPagesPluginData();
 }
 #endif
 
index 6253374..fa1cba3 100644 (file)
@@ -1,3 +1,17 @@
+2018-07-05  Youenn Fablet  <youenn@apple.com>
+
+        REGRESSION (r230843): Flash doesn't work; Produces blue box on page
+        https://bugs.webkit.org/show_bug.cgi?id=187346
+        <rdar://problem/41773974>
+
+        Reviewed by Ryosuke Niwa.
+
+        * WebKitTestRunner/TestController.cpp:
+        (WTR::TestController::resetStateToConsistentValues):
+        (WTR::TestController::setBlockAllPlugins):
+        When not blocked, set the load policy to allow once.
+        * WebKitTestRunner/TestController.h:
+
 2018-07-05  Aakash Jain  <aakash_jain@apple.com>
 
         [ews-build] Bindings-tests-EWS should output result in json
index e61e5f7..4be88c6 100644 (file)
@@ -879,7 +879,7 @@ bool TestController::resetStateToConsistentValues(const TestOptions& options)
     m_authenticationUsername = String();
     m_authenticationPassword = String();
 
-    m_shouldBlockAllPlugins = false;
+    setBlockAllPlugins(false);
     setPluginSupportedMode({ });
 
     m_shouldLogDownloadCallbacks = false;
@@ -1740,6 +1740,21 @@ WKPluginLoadPolicy TestController::decidePolicyForPluginLoad(WKPageRef, WKPlugin
 #endif
 }
 
+void TestController::setBlockAllPlugins(bool shouldBlock)
+{
+    m_shouldBlockAllPlugins = shouldBlock;
+
+#if PLATFORM(MAC)
+    auto policy = shouldBlock ? kWKPluginLoadClientPolicyBlock : kWKPluginLoadClientPolicyAllow;
+
+    WKRetainPtr<WKStringRef> nameNetscape = adoptWK(WKStringCreateWithUTF8CString("com.apple.testnetscapeplugin"));
+    WKRetainPtr<WKStringRef> nameFlash = adoptWK(WKStringCreateWithUTF8CString("com.macromedia.Flash Player.plugin"));
+    WKRetainPtr<WKStringRef> emptyString = adoptWK(WKStringCreateWithUTF8CString(""));
+    WKContextSetPluginLoadClientPolicy(m_context.get(), policy, emptyString.get(), nameNetscape.get(), emptyString.get());
+    WKContextSetPluginLoadClientPolicy(m_context.get(), policy, emptyString.get(), nameFlash.get(), emptyString.get());
+#endif
+}
+
 void TestController::setPluginSupportedMode(const String& mode)
 {
     if (m_unsupportedPluginMode == mode)
index a48103f..4adebd6 100644 (file)
@@ -139,7 +139,7 @@ public:
     void setAuthenticationPassword(String password) { m_authenticationPassword = password; }
     void setAllowsAnySSLCertificate(bool);
 
-    void setBlockAllPlugins(bool shouldBlock) { m_shouldBlockAllPlugins = shouldBlock; }
+    void setBlockAllPlugins(bool shouldBlock);
     void setPluginSupportedMode(const String&);
 
     void setShouldLogHistoryClientCallbacks(bool shouldLog) { m_shouldLogHistoryClientCallbacks = shouldLog; }