Bug 838396 - Don't set hasMixedDisplayContentLoaded and hasMixedDisplayContentBlocked flag in nsMixedContentBlocker.cpp. r=smaug, r=bz
authorIvan Alagenchev <ialagenchev@mozilla.com>
Thu, 29 Aug 2013 16:46:25 -0400
changeset 145050 e3e615c2a30267a6e3b8cc38e25ea5816850dd47
parent 145007 8c5a94ba1096d776ba754d3b97fc2d9c027367ca
child 145051 9d925d047ba50e5312ccab8b48b6b5237bb4e35b
push id25192
push useremorley@mozilla.com
push dateFri, 30 Aug 2013 16:23:44 +0000
treeherdermozilla-central@cfe8b0ab6d59 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug, bz
bugs838396
milestone26.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 838396 - Don't set hasMixedDisplayContentLoaded and hasMixedDisplayContentBlocked flag in nsMixedContentBlocker.cpp. r=smaug, r=bz
browser/base/content/test/Makefile.in
browser/base/content/test/browser_mixedcontent_securityflags.js
browser/base/content/test/test-mixedcontent-securityerrors.html
content/base/src/nsMixedContentBlocker.cpp
--- a/browser/base/content/test/Makefile.in
+++ b/browser/base/content/test/Makefile.in
@@ -187,16 +187,17 @@ MOCHITEST_BROWSER_FILES = \
                  browser_bug822367.js \
                  browser_bug902156.js \
                  browser_bug832435.js \
                  browser_bug839103.js \
                  browser_bug880101.js \
                  browser_bug882977.js \
                  browser_bug887515.js \
                  browser_canonizeURL.js \
+                 browser_mixedcontent_securityflags.js \
                  browser_clearplugindata_noage.html \
                  browser_clearplugindata.html \
                  browser_clearplugindata.js \
                  browser_contentAreaClick.js \
                  browser_contextSearchTabPosition.js \
                  browser_CTP_drag_drop.js \
                  browser_CTP_data_urls.js \
                  browser_ctrlTab.js \
@@ -332,16 +333,17 @@ MOCHITEST_BROWSER_FILES = \
                  POSTSearchEngine.xml \
                  print_postdata.sjs \
                  redirect_bug623155.sjs \
                  test_bug435035.html \
                  test_bug462673.html \
                  test_bug628179.html \
                  test_bug839103.html \
                  test_wyciwyg_copying.html \
+                 test-mixedcontent-securityerrors.html \
                  title_test.svg \
                  video.ogg \
                  zoom_test.html \
                  $(NULL)
 
 # Disable tests on Windows due to frequent failures (bugs 825739, 841341)
 ifneq (windows,$(MOZ_WIDGET_TOOLKIT))
 MOCHITEST_BROWSER_FILES += \
new file mode 100644
--- /dev/null
+++ b/browser/base/content/test/browser_mixedcontent_securityflags.js
@@ -0,0 +1,57 @@
+/* Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/ */
+
+// The test loads a web page with mixed active and display content
+// on it while the "block mixed content" settings are _on_.
+// It then checks that the mixed content flags have been set correctly.
+// The test then overrides the MCB settings and checks that the flags
+// have been set correctly again.
+// Bug 838396 - Not setting hasMixedDisplayContentLoaded and
+// hasMixedDisplayContentBlocked flag in nsMixedContentBlocker.cpp
+
+const TEST_URI = "https://example.com/browser/browser/base/content/test/test-mixedcontent-securityerrors.html";
+let gTestBrowser = null;
+
+function test()
+{
+  waitForExplicitFinish();
+  SpecialPowers.pushPrefEnv({"set": [["security.mixed_content.block_active_content", true],
+                            ["security.mixed_content.block_display_content", true]]}, blockMixedContentTest);
+}
+
+function blockMixedContentTest()
+{
+  gBrowser.selectedTab = gBrowser.addTab(TEST_URI);
+  let tab = gBrowser.selectedTab;
+  gTestBrowser = gBrowser.getBrowserForTab(tab);
+
+  gTestBrowser.addEventListener("load", function onLoad(aEvent) {
+    gTestBrowser.removeEventListener(aEvent.type, onLoad, true);
+    is(gTestBrowser.docShell.hasMixedDisplayContentBlocked, true, "hasMixedDisplayContentBlocked flag has been set");
+    is(gTestBrowser.docShell.hasMixedActiveContentBlocked, true, "hasMixedActiveContentBlocked flag has been set");
+    is(gTestBrowser.docShell.hasMixedDisplayContentLoaded, false, "hasMixedDisplayContentLoaded flag has been set");
+    is(gTestBrowser.docShell.hasMixedActiveContentLoaded, false, "hasMixedActiveContentLoaded flag has been set");
+    overrideMCB();
+  }, true);
+}
+
+function overrideMCB()
+{
+  gTestBrowser.addEventListener("load", mixedContentOverrideTest, true);
+  var notification = PopupNotifications.getNotification("mixed-content-blocked", gTestBrowser);
+  ok(notification, "Mixed Content Doorhanger didn't appear");
+  // Click on the doorhanger to allow mixed content.
+  notification.secondaryActions[0].callback(mixedContentOverrideTest);
+}
+
+function mixedContentOverrideTest()
+{
+  gTestBrowser.removeEventListener("load", mixedContentOverrideTest, true);
+
+  is(gTestBrowser.docShell.hasMixedDisplayContentLoaded, true, "hasMixedDisplayContentLoaded flag has not been set");
+  is(gTestBrowser.docShell.hasMixedActiveContentLoaded, true, "hasMixedActiveContentLoaded flag has not been set");
+  is(gTestBrowser.docShell.hasMixedDisplayContentBlocked, false, "second hasMixedDisplayContentBlocked flag has been set");
+  is(gTestBrowser.docShell.hasMixedActiveContentBlocked, false, "second hasMixedActiveContentBlocked flag has been set");
+  gBrowser.removeCurrentTab();
+  finish();
+}
new file mode 100644
--- /dev/null
+++ b/browser/base/content/test/test-mixedcontent-securityerrors.html
@@ -0,0 +1,21 @@
+<!--
+  Bug 875456 - Log mixed content messages from the Mixed Content Blocker to the
+  Security Pane in the Web Console
+-->
+
+<!DOCTYPE HTML>
+<html dir="ltr" xml:lang="en-US" lang="en-US">
+  <head>
+    <meta charset="utf8">
+    <title>Mixed Content test - http on https</title>
+    <script src="testscript.js"></script>
+    <!--
+      Any copyright is dedicated to the Public Domain.
+      http://creativecommons.org/publicdomain/zero/1.0/
+    -->
+  </head>
+  <body>
+    <iframe src="http://example.com"></iframe>
+    <img src="http://example.com/tests/image/test/mochitest/blue.png"></img>
+  </body>
+</html>
--- a/content/base/src/nsMixedContentBlocker.cpp
+++ b/content/base/src/nsMixedContentBlocker.cpp
@@ -477,22 +477,24 @@ nsMixedContentBlocker::ShouldLoad(uint32
 
   // If the content is display content, and the pref says display content should be blocked, block it.
   if (sBlockMixedDisplay && classification == eMixedDisplay) {
     if (allowMixedContent) {
       LogMixedContentMessage(classification, aContentLocation, rootDoc, eUserOverride);
       *aDecision = nsIContentPolicy::ACCEPT;
       rootDoc->SetHasMixedActiveContentLoaded(true);
       if (!rootDoc->GetHasMixedDisplayContentLoaded() && NS_SUCCEEDED(stateRV)) {
+        rootDoc->SetHasMixedDisplayContentLoaded(true);
         eventSink->OnSecurityChange(aRequestingContext, (State | nsIWebProgressListener::STATE_LOADED_MIXED_DISPLAY_CONTENT));
       }
     } else {
       *aDecision = nsIContentPolicy::REJECT_REQUEST;
       LogMixedContentMessage(classification, aContentLocation, rootDoc, eBlocked);
       if (!rootDoc->GetHasMixedDisplayContentBlocked() && NS_SUCCEEDED(stateRV)) {
+        rootDoc->SetHasMixedDisplayContentBlocked(true);
         eventSink->OnSecurityChange(aRequestingContext, (State | nsIWebProgressListener::STATE_BLOCKED_MIXED_DISPLAY_CONTENT));
       }
     }
     return NS_OK;
 
   } else if (sBlockMixedScript && classification == eMixedScript) {
     // If the content is active content, and the pref says active content should be blocked, block it
     // unless the user has choosen to override the pref