Bug 739575 - Prioritize click-to-play over alternate content in nsObjectLoadingContent::GetPluginSupport. r=josh
authorDavid Keeler <dkeeler@mozilla.com>
Thu, 26 Apr 2012 16:25:21 -0700
changeset 92556 c5e876a76c57f95bc322b8899753859a8a88668f
parent 92555 94f63dd34a0d50118f6fa3a5f2b2cc3ac88a57a3
child 92557 2841b49cfb165b575697ed509ad8ef21a2101823
push id8752
push userryanvm@gmail.com
push dateFri, 27 Apr 2012 00:13:26 +0000
treeherdermozilla-inbound@c5e876a76c57 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjosh
bugs739575
milestone15.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 739575 - Prioritize click-to-play over alternate content in nsObjectLoadingContent::GetPluginSupport. r=josh
browser/base/content/test/Makefile.in
browser/base/content/test/browser_pluginnotification.js
browser/base/content/test/plugin_alternate_content.html
content/base/src/nsObjectLoadingContent.cpp
--- a/browser/base/content/test/Makefile.in
+++ b/browser/base/content/test/Makefile.in
@@ -245,16 +245,17 @@ endif
                  test_bug435035.html \
                  test_bug462673.html \
                  page_style_sample.html \
                  feed_tab.html \
                  plugin_unknown.html \
                  plugin_test.html \
                  plugin_test2.html \
                  plugin_test3.html \
+                 plugin_alternate_content.html \
                  plugin_both.html \
                  plugin_both2.html \
                  plugin_clickToPlayAllow.html \
                  plugin_clickToPlayDeny.html \
                  alltabslistener.html \
                  zoom_test.html \
                  dummy_page.html \
                  browser_tabMatchesInAwesomebar.js \
--- a/browser/base/content/test/browser_pluginnotification.js
+++ b/browser/base/content/test/browser_pluginnotification.js
@@ -402,10 +402,26 @@ function test13c() {
 }
 
 // Tests that the plugin's "activated" property is true for working plugins with click-to-play disabled.
 function test14() {
   var plugin = gTestBrowser.contentDocument.getElementById("test");
   var objLoadingContent = plugin.QueryInterface(Ci.nsIObjectLoadingContent);
   ok(objLoadingContent.activated, "Test 14, Plugin should be activated");
 
+  var plugin = get_test_plugin();
+  plugin.disabled = false;
+  plugin.blocklisted = false;
+  Services.perms.removeAll();
+  Services.prefs.setBoolPref("plugins.click_to_play", true);
+  prepareTest(test15, gTestRoot + "plugin_alternate_content.html");
+}
+
+// Tests that the overlay is shown instead of alternate content when
+// plugins are click to play
+function test15() {
+  var plugin = gTestBrowser.contentDocument.getElementById("test");
+  var doc = gTestBrowser.contentDocument;
+  var mainBox = doc.getAnonymousElementByAttribute(plugin, "class", "mainBox");
+  ok(mainBox, "Test 15, Plugin with id=" + plugin.id + " overlay should exist");
+
   finishTest();
 }
new file mode 100644
--- /dev/null
+++ b/browser/base/content/test/plugin_alternate_content.html
@@ -0,0 +1,9 @@
+<!-- bug 739575 -->
+<html>
+<head><meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
+</head>
+<body>
+<object id="test" type="application/x-test" style="height: 200px; width:200px">
+<p><a href="about:blank">you should not see this link when plugins are click-to-play</a></p>
+</object>
+</body></html>
--- a/content/base/src/nsObjectLoadingContent.cpp
+++ b/content/base/src/nsObjectLoadingContent.cpp
@@ -2017,18 +2017,24 @@ nsObjectLoadingContent::GetPluginSupport
         return GetPluginDisabledState(aContentType);
       }
     } else if (!hasAlternateContent) {
       hasAlternateContent =
         nsStyleUtil::IsSignificantChild(child, true, false);
     }
   }
 
-  return hasAlternateContent ? ePluginOtherState :
-    GetPluginDisabledState(aContentType);
+  PluginSupportState pluginDisabledState = GetPluginDisabledState(aContentType);
+  if (pluginDisabledState == ePluginClickToPlay) {
+    return ePluginClickToPlay;
+  } else if (hasAlternateContent) {
+    return ePluginOtherState;
+  } else {
+    return pluginDisabledState;
+  }
 }
 
 PluginSupportState
 nsObjectLoadingContent::GetPluginDisabledState(const nsCString& aContentType)
 {
   nsresult rv = IsPluginEnabledForType(aContentType);
   if (rv == NS_ERROR_PLUGIN_DISABLED)
     return ePluginDisabled;