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
parent c0732b5859
commit a8f237eaa9
4 changed files with 44 additions and 13 deletions

View File

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

View File

@ -502,5 +502,16 @@ function test16d() {
var objLoadingContent = plugin.QueryInterface(Ci.nsIObjectLoadingContent);
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();
}

View File

@ -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>

View File

@ -777,20 +777,31 @@ nsObjectLoadingContent::OnStartRequest(nsIRequest *aRequest,
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
// type hint and the type hint is not a document type.
// 2) Our type hint is a type that we support with a plugin.
if (((channelType.EqualsASCII(APPLICATION_OCTET_STREAM) ||
channelType.EqualsASCII(BINARY_OCTET_STREAM)) &&
!mContentType.IsEmpty() &&
GetTypeOfContent(mContentType) != eType_Document) ||
// Need to check IsPluginEnabledForType() in addition to GetTypeOfContent()
// because otherwise the default plug-in's catch-all behavior would
// confuse things.
(NS_SUCCEEDED(IsPluginEnabledForType(mContentType)) &&
GetTypeOfContent(mContentType) == eType_Plugin)) {
// 1) The channel type is application/octet-stream or binary/octet-stream
// and we have a type hint (in mContentType) and the type hint is not a
// document type.
// 2) Our type hint is a type that we support with a plugin
// (where "support" means it is enabled or it is click-to-play)
// and this object loading content has the capability to load a plugin.
// We have to be careful here - there might be a plugin that supports
// image types, so make sure the type of the content is not an image.
bool isOctetStream = (channelType.EqualsASCII(APPLICATION_OCTET_STREAM) ||
channelType.EqualsASCII(BINARY_OCTET_STREAM));
ObjectType typeOfContent = GetTypeOfContent(mContentType);
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
// end up trying to dispatch to a nsFrameLoader, which will complain that
// it couldn't find a way to handle application/octet-stream