diff --git a/browser/base/content/test/Makefile.in b/browser/base/content/test/Makefile.in index c2b5b8c0746d..8c8154fde19c 100644 --- a/browser/base/content/test/Makefile.in +++ b/browser/base/content/test/Makefile.in @@ -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 \ diff --git a/browser/base/content/test/browser_pluginnotification.js b/browser/base/content/test/browser_pluginnotification.js index a31611782801..889fff965c0c 100644 --- a/browser/base/content/test/browser_pluginnotification.js +++ b/browser/base/content/test/browser_pluginnotification.js @@ -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(); } diff --git a/browser/base/content/test/plugin_bug749455.html b/browser/base/content/test/plugin_bug749455.html new file mode 100644 index 000000000000..831dc82f7cef --- /dev/null +++ b/browser/base/content/test/plugin_bug749455.html @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/content/base/src/nsObjectLoadingContent.cpp b/content/base/src/nsObjectLoadingContent.cpp index 9e21144b9cc5..63d393e0f224 100644 --- a/content/base/src/nsObjectLoadingContent.cpp +++ b/content/base/src/nsObjectLoadingContent.cpp @@ -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