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 5b4816ddd6
commit 13e34433a6
4 changed files with 38 additions and 13 deletions

View File

@ -259,6 +259,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

@ -427,5 +427,16 @@ function test15() {
var mainBox = doc.getAnonymousElementByAttribute(plugin, "class", "mainBox");
ok(mainBox, "Test 15, Plugin with id=" + plugin.id + " overlay should exist");
prepareTest(test16, gTestRoot + "plugin_bug749455.html");
}
// Tests that mContentType is used for click-to-play plugins, and not the
// inspected type.
function test16() {
var clickToPlayNotification = PopupNotifications.getNotification("click-to-play-plugins", gTestBrowser);
ok(clickToPlayNotification, "Test 16, Should have a click-to-play notification");
var missingNotification = PopupNotifications.getNotification("missing-plugins", gTestBrowser);
ok(!missingNotification, "Test 16, 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

@ -800,20 +800,25 @@ 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
bool isOctetStream = (channelType.EqualsASCII(APPLICATION_OCTET_STREAM) ||
channelType.EqualsASCII(BINARY_OCTET_STREAM));
bool caseOne = (isOctetStream &&
!mContentType.IsEmpty() &&
GetTypeOfContent(mContentType) != eType_Document);
nsresult pluginState = IsPluginEnabledForType(mContentType);
bool pluginSupported = (NS_SUCCEEDED(pluginState) ||
pluginState == NS_ERROR_PLUGIN_CLICKTOPLAY);
PRUint32 caps = GetCapabilities();
bool caseTwo = (pluginSupported && (caps & eSupportPlugins));
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