shouldUsePluginDocument() needs to be respected when a document is created
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 9 May 2013 18:49:03 +0000 (18:49 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 9 May 2013 18:49:03 +0000 (18:49 +0000)
https://bugs.webkit.org/show_bug.cgi?id=110308

Patch by Max Feil <mfeil@rim.com> on 2013-05-09
Reviewed by Rob Buis.

Source/WebCore:

In DOMImplementation::createDocument() we should create
a PluginDocument for mime types that return "true" for
shouldAlwaysUsePluginDocument(), even if there is no pluginData
for them. This lets a client choose plugins for which the "missing
plugin" text or icon should appear more consistently. Otherwise
plugins referenced by iFrames will be treated as an HTMLDocument,
possibly resulting in binary files rendered as gibberish text.

Layout test platform/blackberry/plugins/swf-as-src-of-iframe.html

* dom/DOMImplementation.cpp:
(WebCore::DOMImplementation::createDocument):

Source/WebKit/blackberry:

This patch implements shouldAlwaysUsePluginDocument() in the
BlackBerry frame loader client. It is called in several places
within WebCore to determine whether a PluginDocument should
be created.

* WebCoreSupport/FrameLoaderClientBlackBerry.cpp:
(WebCore::FrameLoaderClientBlackBerry::shouldAlwaysUsePluginDocument):
(WebCore):
(WebCore::FrameLoaderClientBlackBerry::createPlugin):
* WebCoreSupport/FrameLoaderClientBlackBerry.h:
(FrameLoaderClientBlackBerry):

Source/WebKit/win:

Renaming shouldUsePluginDocument() to shouldAlwaysUsePluginDocument()
for clarity.

* WebCoreSupport/WebFrameLoaderClient.cpp:
(WebFrameLoaderClient::shouldAlwaysUsePluginDocument):
* WebCoreSupport/WebFrameLoaderClient.h:
(WebFrameLoaderClient):

Source/WebKit2:

Renaming shouldUsePluginDocument() to shouldAlwaysUsePluginDocument()
for clarity.

* WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
(WebKit::WebFrameLoaderClient::shouldAlwaysUsePluginDocument):
* WebProcess/WebCoreSupport/WebFrameLoaderClient.h:
(WebFrameLoaderClient):

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

16 files changed:
LayoutTests/platform/blackberry/plugins/swf-as-src-of-iframe-expected.txt [new file with mode: 0644]
LayoutTests/platform/blackberry/plugins/swf-as-src-of-iframe.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/dom/DOMImplementation.cpp
Source/WebCore/loader/DocumentWriter.cpp
Source/WebCore/loader/FrameLoaderClient.h
Source/WebCore/loader/SubframeLoader.cpp
Source/WebKit/blackberry/ChangeLog
Source/WebKit/blackberry/WebCoreSupport/FrameLoaderClientBlackBerry.cpp
Source/WebKit/blackberry/WebCoreSupport/FrameLoaderClientBlackBerry.h
Source/WebKit/win/ChangeLog
Source/WebKit/win/WebCoreSupport/WebFrameLoaderClient.cpp
Source/WebKit/win/WebCoreSupport/WebFrameLoaderClient.h
Source/WebKit2/ChangeLog
Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp
Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.h

diff --git a/LayoutTests/platform/blackberry/plugins/swf-as-src-of-iframe-expected.txt b/LayoutTests/platform/blackberry/plugins/swf-as-src-of-iframe-expected.txt
new file mode 100644 (file)
index 0000000..53cdf1e
--- /dev/null
@@ -0,0 +1 @@
+PASSED
diff --git a/LayoutTests/platform/blackberry/plugins/swf-as-src-of-iframe.html b/LayoutTests/platform/blackberry/plugins/swf-as-src-of-iframe.html
new file mode 100644 (file)
index 0000000..41bd98b
--- /dev/null
@@ -0,0 +1,46 @@
+<html>
+<head>
+<title>Test that iframe with src set to swf uses plugin document</title>
+<!--- This will ensure that the "missing plugin text" is shown when the FlashPlayer plugin is disabled. -->
+<script>
+function runTest() {
+  framedocument = document.getElementById('frame').contentWindow.document;
+  innerhtml = framedocument.getElementsByTagName('body')[0].innerHTML;
+  if (innerhtml[0] === 'C') {
+    // This is the 'C' from the ActionScript SWC. The contents are being
+    // rendered as text. Fail the test.
+    document.getElementById('console').textContent = "FAILED due to plugin rendered as gibberish text (PR293098).";
+  } else {
+    var flashplayerLoaded = false;
+    for (i = 0; i < navigator.plugins.length; ++i) {
+      for (j = 0; j < navigator.plugins[i].length; ++j) {
+        if (navigator.plugins[i][j].type == "application/x-shockwave-flash") {
+          flashplayerLoaded = true;
+        }
+      }
+    }
+    if (flashplayerLoaded) {
+      document.getElementById('console').textContent = "FAILED due to FlashPlayer plugin enabled. Please disable it.";
+    } else if (framedocument.getElementsByTagName('embed')[0]){
+      // There is an embed element instead of gibberish text. This is what we
+      // want and indicates that a plugin document was created instead of an
+      // HTML document.
+      document.getElementById('console').textContent = "PASSED";
+    } else {
+      document.getElementById('console').textContent = "FAILED for an unknown reson.";
+    }
+  }
+
+}
+</script>
+</head>
+
+<body onload="runTest();">
+
+<iframe id="frame" src="../../../plugins/resources/simple_blank.swf" width="100" height="100">
+</iframe>
+
+<div id="console"></div>
+</body>
+
+</html>
index 1085739..5cbd425 100644 (file)
@@ -1,3 +1,23 @@
+2013-05-09  Max Feil  <mfeil@rim.com>
+
+        shouldUsePluginDocument() needs to be respected when a document is created
+        https://bugs.webkit.org/show_bug.cgi?id=110308
+
+        Reviewed by Rob Buis.
+
+        In DOMImplementation::createDocument() we should create
+        a PluginDocument for mime types that return "true" for
+        shouldAlwaysUsePluginDocument(), even if there is no pluginData
+        for them. This lets a client choose plugins for which the "missing
+        plugin" text or icon should appear more consistently. Otherwise
+        plugins referenced by iFrames will be treated as an HTMLDocument,
+        possibly resulting in binary files rendered as gibberish text.
+
+        Layout test platform/blackberry/plugins/swf-as-src-of-iframe.html
+
+        * dom/DOMImplementation.cpp:
+        (WebCore::DOMImplementation::createDocument):
+
 2013-05-09  Timothy Hatcher  <timothy@apple.com>
 
         Fix an exception when hovering native functions while paused in the debugger.
index 970c3b5..b60b2af 100644 (file)
@@ -418,7 +418,7 @@ PassRefPtr<Document> DOMImplementation::createDocument(const String& type, Frame
     // Everything else except text/plain can be overridden by plugins. In particular, Adobe SVG Viewer should be used for SVG, if installed.
     // Disallowing plug-ins to use text/plain prevents plug-ins from hijacking a fundamental type that the browser is expected to handle,
     // and also serves as an optimization to prevent loading the plug-in database in the common case.
-    if (type != "text/plain" && pluginData && pluginData->supportsMimeType(type))
+    if (type != "text/plain" && ((pluginData && pluginData->supportsMimeType(type)) || (frame && frame->loader()->client()->shouldAlwaysUsePluginDocument(type))))
         return PluginDocument::create(frame, url);
     if (isTextMIMEType(type))
         return TextDocument::create(frame, url);
index fd94821..749caa4 100644 (file)
@@ -104,7 +104,7 @@ void DocumentWriter::begin()
 
 PassRefPtr<Document> DocumentWriter::createDocument(const KURL& url)
 {
-    if (!m_frame->loader()->stateMachine()->isDisplayingInitialEmptyDocument() && m_frame->loader()->client()->shouldUsePluginDocument(m_mimeType))
+    if (!m_frame->loader()->stateMachine()->isDisplayingInitialEmptyDocument() && m_frame->loader()->client()->shouldAlwaysUsePluginDocument(m_mimeType))
         return PluginDocument::create(m_frame, url);
     if (!m_frame->loader()->client()->hasHTMLView())
         return PlaceholderDocument::create(m_frame, url);
index bc9458e..0b04936 100644 (file)
@@ -293,7 +293,7 @@ namespace WebCore {
         virtual bool shouldCacheResponse(DocumentLoader*, unsigned long identifier, const ResourceResponse&, const unsigned char* data, unsigned long long length) = 0;
 #endif
 
-        virtual bool shouldUsePluginDocument(const String& /*mimeType*/) const { return false; }
+        virtual bool shouldAlwaysUsePluginDocument(const String& /*mimeType*/) const { return false; }
         virtual bool shouldLoadMediaElementURL(const KURL&) const { return true; }
 
         virtual void didChangeScrollOffset() { }
index ac161c3..1aeaa95 100644 (file)
@@ -414,7 +414,7 @@ bool SubframeLoader::allowPlugins(ReasonForCallingAllowPlugins reason)
 
 bool SubframeLoader::shouldUsePlugin(const KURL& url, const String& mimeType, bool shouldPreferPlugInsForImages, bool hasFallback, bool& useFallback)
 {
-    if (m_frame->loader()->client()->shouldUsePluginDocument(mimeType)) {
+    if (m_frame->loader()->client()->shouldAlwaysUsePluginDocument(mimeType)) {
         useFallback = false;
         return true;
     }
index e2ac55f..e9d6055 100644 (file)
@@ -1,3 +1,22 @@
+2013-05-09  Max Feil  <mfeil@rim.com>
+
+        shouldUsePluginDocument() needs to be respected when a document is created
+        https://bugs.webkit.org/show_bug.cgi?id=110308
+
+        Reviewed by Rob Buis.
+
+        This patch implements shouldAlwaysUsePluginDocument() in the
+        BlackBerry frame loader client. It is called in several places
+        within WebCore to determine whether a PluginDocument should
+        be created.
+
+        * WebCoreSupport/FrameLoaderClientBlackBerry.cpp:
+        (WebCore::FrameLoaderClientBlackBerry::shouldAlwaysUsePluginDocument):
+        (WebCore):
+        (WebCore::FrameLoaderClientBlackBerry::createPlugin):
+        * WebCoreSupport/FrameLoaderClientBlackBerry.h:
+        (FrameLoaderClientBlackBerry):
+
 2013-05-09  Mike Fenton <mifenton@rim.com>
 
         [BlackBerry] Style updates required based on new check-webkit-style
index ee8c97f..f46e2ea 100644 (file)
@@ -308,6 +308,11 @@ void FrameLoaderClientBlackBerry::committedLoad(DocumentLoader* loader, const ch
     }
 }
 
+bool FrameLoaderClientBlackBerry::shouldAlwaysUsePluginDocument(const String& mimeType) const
+{
+    return mimeType == "application/x-shockwave-flash";
+}
+
 PassRefPtr<Widget> FrameLoaderClientBlackBerry::createPlugin(const IntSize& pluginSize,
     HTMLPlugInElement* element, const KURL& url, const Vector<String>& paramNames,
     const Vector<String>& paramValues, const String& mimeTypeIn, bool loadManually)
@@ -316,7 +321,7 @@ PassRefPtr<Widget> FrameLoaderClientBlackBerry::createPlugin(const IntSize& plug
     if (mimeType.isEmpty()) {
         mimeType = MIMETypeRegistry::getMIMETypeForPath(url.path());
         mimeType = MIMETypeRegistry::getNormalizedMIMEType(mimeType);
-        if (mimeType != "application/x-shockwave-flash")
+        if (!shouldAlwaysUsePluginDocument(mimeType))
             mimeType = mimeTypeIn;
     }
 
@@ -330,7 +335,7 @@ PassRefPtr<Widget> FrameLoaderClientBlackBerry::createPlugin(const IntSize& plug
     // will generally be a valid media mime type, or it may be null. We
     // explicitly check for Flash content so it does not get rendered as
     // text at this point, producing garbled characters.
-    if (mimeType != "application/x-shockwave-flash" && m_frame->loader() && m_frame->loader()->subframeLoader() && !url.isNull())
+    if (!shouldAlwaysUsePluginDocument(mimeType) && m_frame->loader() && m_frame->loader()->subframeLoader() && !url.isNull())
         m_frame->loader()->subframeLoader()->requestFrame(element, url, String());
 
     return 0;
index d159bf8..e277e67 100644 (file)
@@ -144,6 +144,7 @@ public:
     virtual void dispatchDidBecomeFrameset(bool) { }
     virtual void convertMainResourceLoadToDownload(DocumentLoader*, const ResourceRequest&, const ResourceResponse&);
     virtual PassRefPtr<Frame> createFrame(const KURL&, const String&, HTMLFrameOwnerElement*, const String&, bool, int, int);
+    virtual bool shouldAlwaysUsePluginDocument(const String&) const;
     virtual PassRefPtr<Widget> createPlugin(const IntSize&, HTMLPlugInElement*, const KURL&, const Vector<String>&, const Vector<String>&, const String&, bool);
     virtual void redirectDataToPlugin(Widget*);
     virtual PassRefPtr<Widget> createJavaAppletWidget(const IntSize&, HTMLAppletElement*, const KURL&, const Vector<String>&, const Vector<String>&) { notImplemented(); return 0; }
index 364e877..1611d19 100644 (file)
@@ -1,3 +1,18 @@
+2013-05-09  Max Feil  <mfeil@rim.com>
+
+        shouldUsePluginDocument() needs to be respected when a document is created
+        https://bugs.webkit.org/show_bug.cgi?id=110308
+
+        Reviewed by Rob Buis.
+
+        Renaming shouldUsePluginDocument() to shouldAlwaysUsePluginDocument()
+        for clarity.
+
+        * WebCoreSupport/WebFrameLoaderClient.cpp:
+        (WebFrameLoaderClient::shouldAlwaysUsePluginDocument):
+        * WebCoreSupport/WebFrameLoaderClient.h:
+        (WebFrameLoaderClient):
+
 2013-05-06  Darin Adler  <darin@apple.com>
 
         Use adoptCF and adoptNS in more places
index 5f52cf0..7c0c051 100644 (file)
@@ -896,7 +896,7 @@ WebHistory* WebFrameLoaderClient::webHistory() const
     return WebHistory::sharedHistory();
 }
 
-bool WebFrameLoaderClient::shouldUsePluginDocument(const String& mimeType) const
+bool WebFrameLoaderClient::shouldAlwaysUsePluginDocument(const String& mimeType) const
 {
     WebView* webView = m_webFrame->webView();
     if (!webView)
index ca02f87..332e889 100644 (file)
@@ -118,7 +118,7 @@ public:
     virtual void recreatePlugin(WebCore::Widget*) { }
     virtual void redirectDataToPlugin(WebCore::Widget* pluginWidget);
 
-    virtual bool shouldUsePluginDocument(const WTF::String& mimeType) const;
+    virtual bool shouldAlwaysUsePluginDocument(const WTF::String& mimeType) const;
 
     virtual void dispatchDidFailToStartPlugin(const WebCore::PluginView*) const;
 
index 8b992fc..40e3270 100644 (file)
@@ -1,3 +1,18 @@
+2013-05-09  Max Feil  <mfeil@rim.com>
+
+        shouldUsePluginDocument() needs to be respected when a document is created
+        https://bugs.webkit.org/show_bug.cgi?id=110308
+
+        Reviewed by Rob Buis.
+
+        Renaming shouldUsePluginDocument() to shouldAlwaysUsePluginDocument()
+        for clarity.
+
+        * WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
+        (WebKit::WebFrameLoaderClient::shouldAlwaysUsePluginDocument):
+        * WebProcess/WebCoreSupport/WebFrameLoaderClient.h:
+        (WebFrameLoaderClient):
+
 2013-05-09  Timothy Hatcher  <timothy@apple.com>
 
         Make dragging off a tab in Safari with a docked Inspector reattach the Inspector.
index 8800595..63ff90a 100644 (file)
@@ -1536,7 +1536,7 @@ NSCachedURLResponse* WebFrameLoaderClient::willCacheResponse(DocumentLoader*, un
 
 #endif // PLATFORM(MAC)
 
-bool WebFrameLoaderClient::shouldUsePluginDocument(const String& /*mimeType*/) const
+bool WebFrameLoaderClient::shouldAlwaysUsePluginDocument(const String& /*mimeType*/) const
 {
     notImplemented();
     return false;
index 4f73266..c067825 100644 (file)
@@ -214,7 +214,7 @@ private:
     virtual NSCachedURLResponse* willCacheResponse(WebCore::DocumentLoader*, unsigned long identifier, NSCachedURLResponse*) const OVERRIDE;
 #endif
 
-    virtual bool shouldUsePluginDocument(const String& /*mimeType*/) const OVERRIDE;
+    virtual bool shouldAlwaysUsePluginDocument(const String& /*mimeType*/) const OVERRIDE;
 
     virtual void didChangeScrollOffset() OVERRIDE;