Title: [149830] trunk
Revision
149830
Author
[email protected]
Date
2013-05-09 11:49:03 -0700 (Thu, 09 May 2013)

Log Message

shouldUsePluginDocument() needs to be respected when a document is created
https://bugs.webkit.org/show_bug.cgi?id=110308

Patch by Max Feil <[email protected]> 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):

Modified Paths

Added Paths

Diff

Added: trunk/LayoutTests/platform/blackberry/plugins/swf-as-src-of-iframe-expected.txt (0 => 149830)


--- trunk/LayoutTests/platform/blackberry/plugins/swf-as-src-of-iframe-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/platform/blackberry/plugins/swf-as-src-of-iframe-expected.txt	2013-05-09 18:49:03 UTC (rev 149830)
@@ -0,0 +1 @@
+PASSED

Added: trunk/LayoutTests/platform/blackberry/plugins/swf-as-src-of-iframe.html (0 => 149830)


--- trunk/LayoutTests/platform/blackberry/plugins/swf-as-src-of-iframe.html	                        (rev 0)
+++ trunk/LayoutTests/platform/blackberry/plugins/swf-as-src-of-iframe.html	2013-05-09 18:49:03 UTC (rev 149830)
@@ -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="" width="100" height="100">
+</iframe>
+
+<div id="console"></div>
+</body>
+
+</html>

Modified: trunk/Source/WebCore/ChangeLog (149829 => 149830)


--- trunk/Source/WebCore/ChangeLog	2013-05-09 18:47:52 UTC (rev 149829)
+++ trunk/Source/WebCore/ChangeLog	2013-05-09 18:49:03 UTC (rev 149830)
@@ -1,3 +1,23 @@
+2013-05-09  Max Feil  <[email protected]>
+
+        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  <[email protected]>
 
         Fix an exception when hovering native functions while paused in the debugger.

Modified: trunk/Source/WebCore/dom/DOMImplementation.cpp (149829 => 149830)


--- trunk/Source/WebCore/dom/DOMImplementation.cpp	2013-05-09 18:47:52 UTC (rev 149829)
+++ trunk/Source/WebCore/dom/DOMImplementation.cpp	2013-05-09 18:49:03 UTC (rev 149830)
@@ -418,7 +418,7 @@
     // 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);

Modified: trunk/Source/WebCore/loader/DocumentWriter.cpp (149829 => 149830)


--- trunk/Source/WebCore/loader/DocumentWriter.cpp	2013-05-09 18:47:52 UTC (rev 149829)
+++ trunk/Source/WebCore/loader/DocumentWriter.cpp	2013-05-09 18:49:03 UTC (rev 149830)
@@ -104,7 +104,7 @@
 
 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);

Modified: trunk/Source/WebCore/loader/FrameLoaderClient.h (149829 => 149830)


--- trunk/Source/WebCore/loader/FrameLoaderClient.h	2013-05-09 18:47:52 UTC (rev 149829)
+++ trunk/Source/WebCore/loader/FrameLoaderClient.h	2013-05-09 18:49:03 UTC (rev 149830)
@@ -293,7 +293,7 @@
         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() { }

Modified: trunk/Source/WebCore/loader/SubframeLoader.cpp (149829 => 149830)


--- trunk/Source/WebCore/loader/SubframeLoader.cpp	2013-05-09 18:47:52 UTC (rev 149829)
+++ trunk/Source/WebCore/loader/SubframeLoader.cpp	2013-05-09 18:49:03 UTC (rev 149830)
@@ -414,7 +414,7 @@
 
 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;
     }

Modified: trunk/Source/WebKit/blackberry/ChangeLog (149829 => 149830)


--- trunk/Source/WebKit/blackberry/ChangeLog	2013-05-09 18:47:52 UTC (rev 149829)
+++ trunk/Source/WebKit/blackberry/ChangeLog	2013-05-09 18:49:03 UTC (rev 149830)
@@ -1,3 +1,22 @@
+2013-05-09  Max Feil  <[email protected]>
+
+        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 <[email protected]>
 
         [BlackBerry] Style updates required based on new check-webkit-style

Modified: trunk/Source/WebKit/blackberry/WebCoreSupport/FrameLoaderClientBlackBerry.cpp (149829 => 149830)


--- trunk/Source/WebKit/blackberry/WebCoreSupport/FrameLoaderClientBlackBerry.cpp	2013-05-09 18:47:52 UTC (rev 149829)
+++ trunk/Source/WebKit/blackberry/WebCoreSupport/FrameLoaderClientBlackBerry.cpp	2013-05-09 18:49:03 UTC (rev 149830)
@@ -308,6 +308,11 @@
     }
 }
 
+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 @@
     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 @@
     // 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;

Modified: trunk/Source/WebKit/blackberry/WebCoreSupport/FrameLoaderClientBlackBerry.h (149829 => 149830)


--- trunk/Source/WebKit/blackberry/WebCoreSupport/FrameLoaderClientBlackBerry.h	2013-05-09 18:47:52 UTC (rev 149829)
+++ trunk/Source/WebKit/blackberry/WebCoreSupport/FrameLoaderClientBlackBerry.h	2013-05-09 18:49:03 UTC (rev 149830)
@@ -144,6 +144,7 @@
     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; }

Modified: trunk/Source/WebKit/win/ChangeLog (149829 => 149830)


--- trunk/Source/WebKit/win/ChangeLog	2013-05-09 18:47:52 UTC (rev 149829)
+++ trunk/Source/WebKit/win/ChangeLog	2013-05-09 18:49:03 UTC (rev 149830)
@@ -1,3 +1,18 @@
+2013-05-09  Max Feil  <[email protected]>
+
+        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  <[email protected]>
 
         Use adoptCF and adoptNS in more places

Modified: trunk/Source/WebKit/win/WebCoreSupport/WebFrameLoaderClient.cpp (149829 => 149830)


--- trunk/Source/WebKit/win/WebCoreSupport/WebFrameLoaderClient.cpp	2013-05-09 18:47:52 UTC (rev 149829)
+++ trunk/Source/WebKit/win/WebCoreSupport/WebFrameLoaderClient.cpp	2013-05-09 18:49:03 UTC (rev 149830)
@@ -896,7 +896,7 @@
     return WebHistory::sharedHistory();
 }
 
-bool WebFrameLoaderClient::shouldUsePluginDocument(const String& mimeType) const
+bool WebFrameLoaderClient::shouldAlwaysUsePluginDocument(const String& mimeType) const
 {
     WebView* webView = m_webFrame->webView();
     if (!webView)

Modified: trunk/Source/WebKit/win/WebCoreSupport/WebFrameLoaderClient.h (149829 => 149830)


--- trunk/Source/WebKit/win/WebCoreSupport/WebFrameLoaderClient.h	2013-05-09 18:47:52 UTC (rev 149829)
+++ trunk/Source/WebKit/win/WebCoreSupport/WebFrameLoaderClient.h	2013-05-09 18:49:03 UTC (rev 149830)
@@ -118,7 +118,7 @@
     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;
 

Modified: trunk/Source/WebKit2/ChangeLog (149829 => 149830)


--- trunk/Source/WebKit2/ChangeLog	2013-05-09 18:47:52 UTC (rev 149829)
+++ trunk/Source/WebKit2/ChangeLog	2013-05-09 18:49:03 UTC (rev 149830)
@@ -1,3 +1,18 @@
+2013-05-09  Max Feil  <[email protected]>
+
+        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  <[email protected]>
 
         Make dragging off a tab in Safari with a docked Inspector reattach the Inspector.

Modified: trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp (149829 => 149830)


--- trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp	2013-05-09 18:47:52 UTC (rev 149829)
+++ trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp	2013-05-09 18:49:03 UTC (rev 149830)
@@ -1536,7 +1536,7 @@
 
 #endif // PLATFORM(MAC)
 
-bool WebFrameLoaderClient::shouldUsePluginDocument(const String& /*mimeType*/) const
+bool WebFrameLoaderClient::shouldAlwaysUsePluginDocument(const String& /*mimeType*/) const
 {
     notImplemented();
     return false;

Modified: trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.h (149829 => 149830)


--- trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.h	2013-05-09 18:47:52 UTC (rev 149829)
+++ trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.h	2013-05-09 18:49:03 UTC (rev 149830)
@@ -214,7 +214,7 @@
     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;
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to