Bug 749455 - Use mContentType for click-to-play plugins in nsObjectLoadingContent::OnStartRequest. r=josh

This commit is contained in:
David Keeler 2012-04-27 17:01:07 -07:00
Родитель 21aa5a51e2
Коммит bd26af8894
4 изменённых файлов: 44 добавлений и 13 удалений

Просмотреть файл

@ -228,6 +228,7 @@ _BROWSER_FILES = \
plugin_bug743421.html \ plugin_bug743421.html \
plugin_clickToPlayAllow.html \ plugin_clickToPlayAllow.html \
plugin_clickToPlayDeny.html \ plugin_clickToPlayDeny.html \
plugin_bug749455.html \
alltabslistener.html \ alltabslistener.html \
zoom_test.html \ zoom_test.html \
dummy_page.html \ dummy_page.html \

Просмотреть файл

@ -502,5 +502,16 @@ function test16d() {
var objLoadingContent = plugin.QueryInterface(Ci.nsIObjectLoadingContent); var objLoadingContent = plugin.QueryInterface(Ci.nsIObjectLoadingContent);
ok(!objLoadingContent.activated, "Test 16d, Plugin should not be activated"); ok(!objLoadingContent.activated, "Test 16d, Plugin should not be activated");
prepareTest(test17, gTestRoot + "plugin_bug749455.html");
}
// Tests that mContentType is used for click-to-play plugins, and not the
// inspected type.
function test17() {
var clickToPlayNotification = PopupNotifications.getNotification("click-to-play-plugins", gTestBrowser);
ok(clickToPlayNotification, "Test 17, Should have a click-to-play notification");
var missingNotification = PopupNotifications.getNotification("missing-plugins", gTestBrowser);
ok(!missingNotification, "Test 17, Should not have a missing plugin notification");
finishTest(); finishTest();
} }

Просмотреть файл

@ -0,0 +1,8 @@
<!-- bug 749455 -->
<html>
<head><meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
</head>
<body>
<embed src="plugin_bug749455.html" type="application/x-test" width="100px" height="100px"></embed>
</body>
</html>

Просмотреть файл

@ -777,20 +777,31 @@ nsObjectLoadingContent::OnStartRequest(nsIRequest *aRequest,
chan->SetContentType(channelType); chan->SetContentType(channelType);
} }
// We want to use the channel type unless one of the following is true: // We want to ignore the channel type if one of the following is true:
// //
// 1) The channel type is application/octet-stream and we have a // 1) The channel type is application/octet-stream or binary/octet-stream
// type hint and the type hint is not a document type. // and we have a type hint (in mContentType) and the type hint is not a
// 2) Our type hint is a type that we support with a plugin. // document type.
if (((channelType.EqualsASCII(APPLICATION_OCTET_STREAM) || // 2) Our type hint is a type that we support with a plugin
channelType.EqualsASCII(BINARY_OCTET_STREAM)) && // (where "support" means it is enabled or it is click-to-play)
!mContentType.IsEmpty() && // and this object loading content has the capability to load a plugin.
GetTypeOfContent(mContentType) != eType_Document) || // We have to be careful here - there might be a plugin that supports
// Need to check IsPluginEnabledForType() in addition to GetTypeOfContent() // image types, so make sure the type of the content is not an image.
// because otherwise the default plug-in's catch-all behavior would bool isOctetStream = (channelType.EqualsASCII(APPLICATION_OCTET_STREAM) ||
// confuse things. channelType.EqualsASCII(BINARY_OCTET_STREAM));
(NS_SUCCEEDED(IsPluginEnabledForType(mContentType)) && ObjectType typeOfContent = GetTypeOfContent(mContentType);
GetTypeOfContent(mContentType) == eType_Plugin)) { bool caseOne = (isOctetStream &&
!mContentType.IsEmpty() &&
typeOfContent != eType_Document);
nsresult pluginState = IsPluginEnabledForType(mContentType);
bool pluginSupported = (NS_SUCCEEDED(pluginState) ||
pluginState == NS_ERROR_PLUGIN_CLICKTOPLAY);
PRUint32 caps = GetCapabilities();
bool caseTwo = (pluginSupported &&
(caps & eSupportPlugins) &&
typeOfContent != eType_Image &&
typeOfContent != eType_Document);
if (caseOne || caseTwo) {
// Set the type we'll use for dispatch on the channel. Otherwise we could // Set the type we'll use for dispatch on the channel. Otherwise we could
// end up trying to dispatch to a nsFrameLoader, which will complain that // end up trying to dispatch to a nsFrameLoader, which will complain that
// it couldn't find a way to handle application/octet-stream // it couldn't find a way to handle application/octet-stream