Bug 1186925 - Convert tests using bad-content notification to use gIdentityHandler;r=tanvi

--HG--
extra : commitid : L6WrcjaECSK
This commit is contained in:
Brian Grinstead 2015-08-07 15:22:52 -07:00
parent 5ca042183f
commit 225e4e60fa
12 changed files with 241 additions and 295 deletions

View File

@ -259,12 +259,15 @@ skip-if = os == "mac" # Bug 1102331 - does focus things on the content window wh
[browser_bug783614.js] [browser_bug783614.js]
[browser_bug817947.js] [browser_bug817947.js]
[browser_bug822367.js] [browser_bug822367.js]
tags = mcb
[browser_bug832435.js] [browser_bug832435.js]
[browser_bug839103.js] [browser_bug839103.js]
[browser_bug880101.js] [browser_bug880101.js]
[browser_bug882977.js] [browser_bug882977.js]
[browser_bug902156.js] [browser_bug902156.js]
tags = mcb
[browser_bug906190.js] [browser_bug906190.js]
tags = mcb
skip-if = buildapp == "mulet" || e10s # Bug 1093642 - test manipulates content and relies on content focus skip-if = buildapp == "mulet" || e10s # Bug 1093642 - test manipulates content and relies on content focus
[browser_mixedContentFromOnunload.js] [browser_mixedContentFromOnunload.js]
[browser_bug970746.js] [browser_bug970746.js]
@ -330,6 +333,7 @@ skip-if = os != "win" # The Fitts Law menu button is only supported on Windows (
[browser_minimize.js] [browser_minimize.js]
skip-if = e10s # Bug 1100664 - test directly access content docShells (TypeError: gBrowser.docShell is null) skip-if = e10s # Bug 1100664 - test directly access content docShells (TypeError: gBrowser.docShell is null)
[browser_mixedcontent_securityflags.js] [browser_mixedcontent_securityflags.js]
tags = mcb
[browser_notification_tab_switching.js] [browser_notification_tab_switching.js]
skip-if = buildapp == 'mulet' || e10s # Bug 1100662 - content access causing uncaught exception - Error: cannot ipc non-cpow object at chrome://mochitests/content/browser/browser/base/content/test/general/browser_notification_tab_switching.js:32 (or in RemoteAddonsChild.jsm) skip-if = buildapp == 'mulet' || e10s # Bug 1100662 - content access causing uncaught exception - Error: cannot ipc non-cpow object at chrome://mochitests/content/browser/browser/base/content/test/general/browser_notification_tab_switching.js:32 (or in RemoteAddonsChild.jsm)
[browser_offlineQuotaNotification.js] [browser_offlineQuotaNotification.js]
@ -489,6 +493,7 @@ skip-if = e10s # Bug 1094240 - has findbar-related failures
[browser_addCertException.js] [browser_addCertException.js]
skip-if = e10s # Bug 1100687 - test directly manipulates content (content.document.getElementById) skip-if = e10s # Bug 1100687 - test directly manipulates content (content.document.getElementById)
[browser_bug1045809.js] [browser_bug1045809.js]
tags = mcb
[browser_e10s_switchbrowser.js] [browser_e10s_switchbrowser.js]
[browser_e10s_about_process.js] [browser_e10s_about_process.js]
[browser_e10s_chrome_process.js] [browser_e10s_chrome_process.js]
@ -497,6 +502,7 @@ skip-if = e10s # Bug 1100687 - test directly manipulates content (content.docume
tags = psm tags = psm
skip-if = e10s # bug 1100687 - test directly manipulates content (content.document.getElementById) skip-if = e10s # bug 1100687 - test directly manipulates content (content.document.getElementById)
[browser_mcb_redirect.js] [browser_mcb_redirect.js]
tags = mcb
[browser_windowactivation.js] [browser_windowactivation.js]
[browser_contextmenu_childprocess.js] [browser_contextmenu_childprocess.js]
[browser_bug963945.js] [browser_bug963945.js]

View File

@ -35,42 +35,27 @@ add_task(function* () {
}); });
function* test1(gTestBrowser) { function* test1(gTestBrowser) {
var notification = assertMixedContentBlockingState(gTestBrowser, {activeLoaded: false, activeBlocked: true, passiveLoaded: false});
PopupNotifications.getNotification("bad-content", gTestBrowser);
isnot(notification, null, "Mixed Content Doorhanger did appear in Test1");
yield promiseNotificationShown(notification);
isnot(PopupNotifications.panel.firstChild.isMixedContentBlocked, 0,
"Mixed Content is being blocked in Test1");
var x = content.document.getElementsByTagName('iframe')[0].contentDocument.getElementById('mixedContentContainer'); var x = content.document.getElementsByTagName('iframe')[0].contentDocument.getElementById('mixedContentContainer');
is(x, null, "Mixed Content is NOT to be found in Test1"); is(x, null, "Mixed Content is NOT to be found in Test1");
// Disable Mixed Content Protection for the page (and reload) // Disable Mixed Content Protection for the page (and reload)
PopupNotifications.panel.firstChild.disableMixedContentProtection(); gIdentityHandler.disableMixedContentProtection();
} }
function* test2(gTestBrowser) { function* test2(gTestBrowser) {
var notification = assertMixedContentBlockingState(gTestBrowser, {activeLoaded: true, activeBlocked: false, passiveLoaded: false});
PopupNotifications.getNotification("bad-content", gTestBrowser);
isnot(notification, null, "Mixed Content Doorhanger did appear in Test2");
yield promiseNotificationShown(notification);
is(PopupNotifications.panel.firstChild.isMixedContentBlocked, 0,
"Mixed Content is NOT being blocked in Test2");
var x = content.document.getElementsByTagName('iframe')[0].contentDocument.getElementById('mixedContentContainer'); var x = content.document.getElementsByTagName('iframe')[0].contentDocument.getElementById('mixedContentContainer');
isnot(x, null, "Mixed Content is to be found in Test2"); isnot(x, null, "Mixed Content is to be found in Test2");
// Re-enable Mixed Content Protection for the page (and reload) // Re-enable Mixed Content Protection for the page (and reload)
PopupNotifications.panel.firstChild.enableMixedContentProtection(); gIdentityHandler.enableMixedContentProtection();
} }
function* test3(gTestBrowser) { function* test3(gTestBrowser) {
var notification = assertMixedContentBlockingState(gTestBrowser, {activeLoaded: false, activeBlocked: true, passiveLoaded: false});
PopupNotifications.getNotification("bad-content", gTestBrowser);
isnot(notification, null, "Mixed Content Doorhanger did appear in Test3");
yield promiseNotificationShown(notification);
isnot(PopupNotifications.panel.firstChild.isMixedContentBlocked, 0,
"Mixed Content is being blocked in Test3");
var x = content.document.getElementsByTagName('iframe')[0].contentDocument.getElementById('mixedContentContainer'); var x = content.document.getElementsByTagName('iframe')[0].contentDocument.getElementById('mixedContentContainer');
is(x, null, "Mixed Content is NOT to be found in Test3"); is(x, null, "Mixed Content is NOT to be found in Test3");

View File

@ -50,11 +50,11 @@ function test() {
function MixedTest1A() { function MixedTest1A() {
gTestBrowser.removeEventListener("load", MixedTest1A, true); gTestBrowser.removeEventListener("load", MixedTest1A, true);
gTestBrowser.addEventListener("load", MixedTest1B, true); gTestBrowser.addEventListener("load", MixedTest1B, true);
var notification = PopupNotifications.getNotification("bad-content", gTestBrowser);
ok(notification, "Mixed Content Doorhanger did appear"); assertMixedContentBlockingState(gTestBrowser, {activeLoaded: false, activeBlocked: true, passiveLoaded: false});
notification.reshow();
ok(PopupNotifications.panel.firstChild.isMixedContentBlocked, "OK: Mixed Content is being blocked"); let {gIdentityHandler} = gTestBrowser.ownerGlobal;
PopupNotifications.panel.firstChild.disableMixedContentProtection(); gIdentityHandler.disableMixedContentProtection();
} }
function MixedTest1B() { function MixedTest1B() {
waitForCondition(function() content.document.getElementById('p1').innerHTML == "hello", MixedTest1C, "Waited too long for mixed script to run in Test 1"); waitForCondition(function() content.document.getElementById('p1').innerHTML == "hello", MixedTest1C, "Waited too long for mixed script to run in Test 1");
@ -73,8 +73,7 @@ function MixedTest2() {
} }
function MixedTest2A() { function MixedTest2A() {
var notification = PopupNotifications.getNotification("bad-content", gTestBrowser); assertMixedContentBlockingState(gTestBrowser, {activeLoaded: false, activeBlocked: false, passiveLoaded: false});
ok(!notification, "Mixed Content Doorhanger did not appear for mixed display content!");
MixedTest3(); MixedTest3();
} }
@ -88,11 +87,11 @@ function MixedTest3() {
function MixedTest3A() { function MixedTest3A() {
gTestBrowser.removeEventListener("load", MixedTest3A, true); gTestBrowser.removeEventListener("load", MixedTest3A, true);
gTestBrowser.addEventListener("load", MixedTest3B, true); gTestBrowser.addEventListener("load", MixedTest3B, true);
var notification = PopupNotifications.getNotification("bad-content", gTestBrowser);
ok(notification, "Mixed Content Doorhanger did appear for test 3"); assertMixedContentBlockingState(gTestBrowser, {activeLoaded: false, activeBlocked: true, passiveLoaded: false});
notification.reshow();
ok(PopupNotifications.panel.firstChild.isMixedContentBlocked, "OK: Mixed Content is being blocked in test 3"); let {gIdentityHandler} = gTestBrowser.ownerGlobal;
PopupNotifications.panel.firstChild.disableMixedContentProtection(); gIdentityHandler.disableMixedContentProtection();
} }
function MixedTest3B() { function MixedTest3B() {
waitForCondition(function() content.document.getElementById('p1').innerHTML == "hello", MixedTest3C, "Waited too long for mixed script to run in Test 3"); waitForCondition(function() content.document.getElementById('p1').innerHTML == "hello", MixedTest3C, "Waited too long for mixed script to run in Test 3");
@ -103,6 +102,7 @@ function MixedTest3C() {
function MixedTest3D() { function MixedTest3D() {
ok(content.document.getElementById('p1').innerHTML == "hello","Mixed script didn't load in Test 3"); ok(content.document.getElementById('p1').innerHTML == "hello","Mixed script didn't load in Test 3");
ok(content.document.getElementById('p2').innerHTML == "bye","Mixed image didn't load in Test 3"); ok(content.document.getElementById('p2').innerHTML == "bye","Mixed image didn't load in Test 3");
assertMixedContentBlockingState(gTestBrowser, {activeLoaded: true, activeBlocked: false, passiveLoaded: true});
MixedTest4(); MixedTest4();
} }
@ -116,22 +116,21 @@ function MixedTest4() {
function MixedTest4A() { function MixedTest4A() {
gTestBrowser.removeEventListener("load", MixedTest4A, true); gTestBrowser.removeEventListener("load", MixedTest4A, true);
gTestBrowser.addEventListener("load", MixedTest4B, true); gTestBrowser.addEventListener("load", MixedTest4B, true);
var notification = PopupNotifications.getNotification("bad-content", gTestBrowser);
ok(notification, "Mixed Content Doorhanger did appear for Test 4"); assertMixedContentBlockingState(gTestBrowser, {activeLoaded: false, activeBlocked: true, passiveLoaded: false});
notification.reshow();
ok(PopupNotifications.panel.firstChild.isMixedContentBlocked, "OK: Mixed Content is being blocked in Test 4"); let {gIdentityHandler} = gTestBrowser.ownerGlobal;
PopupNotifications.panel.firstChild.disableMixedContentProtection(); gIdentityHandler.disableMixedContentProtection();
} }
function MixedTest4B() { function MixedTest4B() {
waitForCondition(function() content.document.location == gHttpTestRoot + "file_bug822367_4B.html", MixedTest4C, "Waited too long for mixed script to run in Test 4"); waitForCondition(function() content.document.location == gHttpTestRoot + "file_bug822367_4B.html", MixedTest4C, "Waited too long for mixed script to run in Test 4");
} }
function MixedTest4C() { function MixedTest4C() {
ok(content.document.location == gHttpTestRoot + "file_bug822367_4B.html", "Location didn't change in test 4"); ok(content.document.location == gHttpTestRoot + "file_bug822367_4B.html", "Location didn't change in test 4");
var notification = PopupNotifications.getNotification("bad-content", gTestBrowser);
ok(notification, "Mixed Content Doorhanger did appear after location change in Test 4"); assertMixedContentBlockingState(gTestBrowser, {activeLoaded: false, activeBlocked: true, passiveLoaded: false});
notification.reshow();
ok(PopupNotifications.panel.firstChild.isMixedContentBlocked, "OK: Mixed Content is being blocked in test 4"); let {gIdentityHandler} = gTestBrowser.ownerGlobal;
notification.remove();
waitForCondition(function() content.document.getElementById('p1').innerHTML == "", MixedTest4D, "Mixed script loaded in test 4 after location change!"); waitForCondition(function() content.document.getElementById('p1').innerHTML == "", MixedTest4D, "Mixed script loaded in test 4 after location change!");
} }
function MixedTest4D() { function MixedTest4D() {
@ -149,11 +148,11 @@ function MixedTest5() {
function MixedTest5A() { function MixedTest5A() {
gTestBrowser.removeEventListener("load", MixedTest5A, true); gTestBrowser.removeEventListener("load", MixedTest5A, true);
gTestBrowser.addEventListener("load", MixedTest5B, true); gTestBrowser.addEventListener("load", MixedTest5B, true);
var notification = PopupNotifications.getNotification("bad-content", gTestBrowser);
ok(notification, "Mixed Content Doorhanger did appear for Test 5"); assertMixedContentBlockingState(gTestBrowser, {activeLoaded: false, activeBlocked: true, passiveLoaded: false});
notification.reshow();
ok(PopupNotifications.panel.firstChild.isMixedContentBlocked, "OK: Mixed Content is being blocked in Test 5"); let {gIdentityHandler} = gTestBrowser.ownerGlobal;
PopupNotifications.panel.firstChild.disableMixedContentProtection(); gIdentityHandler.disableMixedContentProtection();
} }
function MixedTest5B() { function MixedTest5B() {
waitForCondition(function() content.document.getElementById('p1').innerHTML == "hello", MixedTest5C, "Waited too long for mixed script to run in Test 5"); waitForCondition(function() content.document.getElementById('p1').innerHTML == "hello", MixedTest5C, "Waited too long for mixed script to run in Test 5");
@ -172,16 +171,17 @@ function MixedTest6() {
} }
function MixedTest6A() { function MixedTest6A() {
gTestBrowser.removeEventListener("load", MixedTest6A, true); gTestBrowser.removeEventListener("load", MixedTest6A, true);
waitForCondition(function() PopupNotifications.getNotification("bad-content", gTestBrowser), MixedTest6B, "waited too long for doorhanger"); let {gIdentityHandler} = gTestBrowser.ownerGlobal;
waitForCondition(() => gIdentityHandler._identityBox.classList.contains("mixedActiveBlocked"), MixedTest6B, "Waited too long for control center to get mixed active blocked state");
} }
function MixedTest6B() { function MixedTest6B() {
var notification = PopupNotifications.getNotification("bad-content", gTestBrowser);
ok(notification, "Mixed Content Doorhanger did appear for Test 6");
gTestBrowser.addEventListener("load", MixedTest6C, true); gTestBrowser.addEventListener("load", MixedTest6C, true);
notification.reshow();
ok(PopupNotifications.panel.firstChild.isMixedContentBlocked, "OK: Mixed Content is being blocked in Test 6"); assertMixedContentBlockingState(gTestBrowser, {activeLoaded: false, activeBlocked: true, passiveLoaded: false});
PopupNotifications.panel.firstChild.disableMixedContentProtection();
let {gIdentityHandler} = gTestBrowser.ownerGlobal;
gIdentityHandler.disableMixedContentProtection();
} }
function MixedTest6C() { function MixedTest6C() {
@ -196,5 +196,6 @@ function MixedTest6C() {
} }
function MixedTest6D() { function MixedTest6D() {
ok(content.document.getElementById('f1').contentDocument.getElementById('p1').innerHTML == "hello","Mixed script didn't load in Test 6"); ok(content.document.getElementById('f1').contentDocument.getElementById('p1').innerHTML == "hello","Mixed script didn't load in Test 6");
assertMixedContentBlockingState(gTestBrowser, {activeLoaded: true, activeBlocked: false, passiveLoaded: false});
MixedTestsCompleted(); MixedTestsCompleted();
} }

View File

@ -4,19 +4,19 @@
* *
* 1. Navigate to the same domain via document.location * 1. Navigate to the same domain via document.location
* - Load a html page which has mixed content * - Load a html page which has mixed content
* - Doorhanger to disable protection appears - we disable it * - Control Center button to disable protection appears - we disable it
* - Load a new page from the same origin using document.location * - Load a new page from the same origin using document.location
* - Doorhanger should not appear anymore! * - Control Center button should not appear anymore!
* *
* 2. Navigate to the same domain via simulateclick for a link on the page * 2. Navigate to the same domain via simulateclick for a link on the page
* - Load a html page which has mixed content * - Load a html page which has mixed content
* - Doorhanger to disable protection appears - we disable it * - Control Center button to disable protection appears - we disable it
* - Load a new page from the same origin simulating a click * - Load a new page from the same origin simulating a click
* - Doorhanger should not appear anymore! * - Control Center button should not appear anymore!
* *
* 3. Navigate to a differnet domain and show the content is still blocked * 3. Navigate to a differnet domain and show the content is still blocked
* - Load a different html page which has mixed content * - Load a different html page which has mixed content
* - Doorhanger to disable protection should appear again because * - Control Center button to disable protection should appear again because
* we navigated away from html page where we disabled the protection. * we navigated away from html page where we disabled the protection.
* *
* Note, for all tests we set gHttpTestRoot to use 'https'. * Note, for all tests we set gHttpTestRoot to use 'https'.
@ -50,14 +50,11 @@ function test1A() {
gTestBrowser.removeEventListener("load", test1A, true); gTestBrowser.removeEventListener("load", test1A, true);
gTestBrowser.addEventListener("load", test1B, true); gTestBrowser.addEventListener("load", test1B, true);
var notification = PopupNotifications.getNotification("bad-content", gTestBrowser); assertMixedContentBlockingState(gTestBrowser, {activeLoaded: false, activeBlocked: true, passiveLoaded: false});
ok(notification, "OK: Mixed Content Doorhanger did appear in Test1A!");
notification.reshow();
ok(PopupNotifications.panel.firstChild.isMixedContentBlocked, "OK: Mixed Content is being blocked in Test1A!");
// Disable Mixed Content Protection for the page (and reload) // Disable Mixed Content Protection for the page (and reload)
PopupNotifications.panel.firstChild.disableMixedContentProtection(); let {gIdentityHandler} = gTestBrowser.ownerGlobal;
notification.remove(); gIdentityHandler.disableMixedContentProtection();
} }
function test1B() { function test1B() {
@ -83,13 +80,9 @@ function test1C() {
function test1D() { function test1D() {
gTestBrowser.removeEventListener("load", test1D, true); gTestBrowser.removeEventListener("load", test1D, true);
// The Doorhanger should appear but isMixedContentBlocked should be NOT true, // The Control Center button should appear but isMixedContentBlocked should be NOT true,
// because our decision of disabling the mixed content blocker is persistent. // because our decision of disabling the mixed content blocker is persistent.
var notification = PopupNotifications.getNotification("bad-content", gTestBrowser); assertMixedContentBlockingState(gTestBrowser, {activeLoaded: true, activeBlocked: false, passiveLoaded: false});
ok(notification, "OK: Mixed Content Doorhanger did appear in Test1D!");
notification.reshow();
ok(!PopupNotifications.panel.firstChild.isMixedContentBlocked, "OK: Mixed Content is NOT being blocked in Test1D!");
notification.remove();
var actual = content.document.getElementById('mctestdiv').innerHTML; var actual = content.document.getElementById('mctestdiv').innerHTML;
is(actual, "Mixed Content Blocker disabled", "OK: Executed mixed script in Test 1D"); is(actual, "Mixed Content Blocker disabled", "OK: Executed mixed script in Test 1D");
@ -112,14 +105,11 @@ function test2A() {
gTestBrowser.removeEventListener("load", test2A, true); gTestBrowser.removeEventListener("load", test2A, true);
gTestBrowser.addEventListener("load", test2B, true); gTestBrowser.addEventListener("load", test2B, true);
var notification = PopupNotifications.getNotification("bad-content", gTestBrowser); assertMixedContentBlockingState(gTestBrowser, {activeLoaded: false, activeBlocked: true, passiveLoaded: false});
ok(notification, "OK: Mixed Content Doorhanger did appear in Test 2A!");
notification.reshow();
ok(PopupNotifications.panel.firstChild.isMixedContentBlocked, "OK: Mixed Content is being blocked in Test 2A!");
// Disable Mixed Content Protection for the page (and reload) // Disable Mixed Content Protection for the page (and reload)
PopupNotifications.panel.firstChild.disableMixedContentProtection(); let {gIdentityHandler} = gTestBrowser.ownerGlobal;
notification.remove(); gIdentityHandler.disableMixedContentProtection();
} }
function test2B() { function test2B() {
@ -146,13 +136,9 @@ function test2C() {
function test2D() { function test2D() {
gTestBrowser.removeEventListener("load", test2D, true); gTestBrowser.removeEventListener("load", test2D, true);
// The Doorhanger should appear but isMixedContentBlocked should be NOT true, // The Control Center button should appear but isMixedContentBlocked should be NOT true,
// because our decision of disabling the mixed content blocker is persistent. // because our decision of disabling the mixed content blocker is persistent.
var notification = PopupNotifications.getNotification("bad-content", gTestBrowser); assertMixedContentBlockingState(gTestBrowser, {activeLoaded: true, activeBlocked: false, passiveLoaded: false});
ok(notification, "OK: Mixed Content Doorhanger did appear in Test2D!");
notification.reshow();
ok(!PopupNotifications.panel.firstChild.isMixedContentBlocked, "OK: Mixed Content is NOT being blocked");
notification.remove();
var actual = content.document.getElementById('mctestdiv').innerHTML; var actual = content.document.getElementById('mctestdiv').innerHTML;
is(actual, "Mixed Content Blocker disabled", "OK: Executed mixed script in Test 2D"); is(actual, "Mixed Content Blocker disabled", "OK: Executed mixed script in Test 2D");
@ -174,11 +160,7 @@ function test3A() {
// one once the page is loaded with mixed content blocker disabled // one once the page is loaded with mixed content blocker disabled
gTestBrowser.removeEventListener("load", test3A, true); gTestBrowser.removeEventListener("load", test3A, true);
var notification = PopupNotifications.getNotification("bad-content", gTestBrowser); assertMixedContentBlockingState(gTestBrowser, {activeLoaded: false, activeBlocked: true, passiveLoaded: false});
ok(notification, "OK: Mixed Content Doorhanger did appear in Test 3A!");
notification.reshow();
ok(PopupNotifications.panel.firstChild.isMixedContentBlocked, "OK: Mixed Content is being blocked in Test 3A");
notification.remove();
// We are done with tests, clean up // We are done with tests, clean up
cleanUpAfterTests(); cleanUpAfterTests();

View File

@ -143,15 +143,11 @@ function waitForSomeTabToLoad(callback) {
function checkPopUpNotification() { function checkPopUpNotification() {
waitForSomeTabToLoad(reloadedTabAfterDisablingMCB); waitForSomeTabToLoad(reloadedTabAfterDisablingMCB);
var notification = PopupNotifications.getNotification("bad-content", gTestWin.gBrowser.selectedBrowser); assertMixedContentBlockingState(gTestWin.gBrowser, {activeLoaded: false, activeBlocked: true, passiveLoaded: false});
ok(notification, "OK: Mixed Content Doorhanger did appear in " + curTestName + "!");
promiseNotificationShown(notification).then(function() {
ok(gTestWin.PopupNotifications.panel.firstChild.isMixedContentBlocked, "OK: Mixed Content is being blocked in " + curTestName + "!");
// Disable Mixed Content Protection for the page (and reload page) // Disable Mixed Content Protection for the page (which reloads the page)
gTestWin.PopupNotifications.panel.firstChild.disableMixedContentProtection(); let {gIdentityHandler} = gTestWin.gBrowser.ownerGlobal;
notification.remove(); gIdentityHandler.disableMixedContentProtection();
});
} }
function reloadedTabAfterDisablingMCB() { function reloadedTabAfterDisablingMCB() {
@ -192,18 +188,13 @@ function test1A() {
// The Doorhanger should appear but isMixedContentBlocked should be >> NOT << true, // The Doorhanger should appear but isMixedContentBlocked should be >> NOT << true,
// because our decision of disabling the mixed content blocker is persistent across tabs. // because our decision of disabling the mixed content blocker is persistent across tabs.
var notification = PopupNotifications.getNotification("bad-content", gTestWin.gBrowser.selectedBrowser); assertMixedContentBlockingState(gTestWin.gBrowser, {activeLoaded: true, activeBlocked: false, passiveLoaded: false});
ok(notification, "OK: Mixed Content Doorhanger did appear in Test 1A!");
promiseNotificationShown(notification).then(function() {
ok(!gTestWin.PopupNotifications.panel.firstChild.isMixedContentBlocked, "OK: Mixed Content is NOT being blocked in Test 1A!");
notification.remove();
var actual = gTestWin.content.document.getElementById('mctestdiv').innerHTML; var actual = gTestWin.content.document.getElementById('mctestdiv').innerHTML;
is(actual, "Mixed Content Blocker disabled", "OK: Executed mixed script in Test 1A"); is(actual, "Mixed Content Blocker disabled", "OK: Executed mixed script in Test 1A");
gTestWin.gBrowser.removeCurrentTab(); gTestWin.gBrowser.removeCurrentTab();
test1B(); test1B();
});
} }
function test1B() { function test1B() {
@ -221,23 +212,18 @@ function test1C() {
// The Doorhanger should appear but isMixedContentBlocked should be >> NOT << true, // The Doorhanger should appear but isMixedContentBlocked should be >> NOT << true,
// because our decision of disabling the mixed content blocker is persistent across tabs. // because our decision of disabling the mixed content blocker is persistent across tabs.
var notification = PopupNotifications.getNotification("bad-content", gTestWin.gBrowser.selectedBrowser); assertMixedContentBlockingState(gTestWin.gBrowser, {activeLoaded: true, activeBlocked: false, passiveLoaded: false});
ok(notification, "OK: Mixed Content Doorhanger did appear in Test 1C!");
promiseNotificationShown(notification).then(function() {
ok(!gTestWin.PopupNotifications.panel.firstChild.isMixedContentBlocked, "OK: Mixed Content is NOT being blocked in Test 1C!");
notification.remove();
var actual = gTestWin.content.document.getElementById('mctestdiv').innerHTML; var actual = gTestWin.content.document.getElementById('mctestdiv').innerHTML;
is(actual, "Mixed Content Blocker disabled", "OK: Executed mixed script in Test 1C"); is(actual, "Mixed Content Blocker disabled", "OK: Executed mixed script in Test 1C");
// remove tabs // remove tabs
gTestWin.gBrowser.removeTab(gTestWin.gBrowser.tabs[2], {animate: false}); gTestWin.gBrowser.removeTab(gTestWin.gBrowser.tabs[2], {animate: false});
gTestWin.gBrowser.removeTab(gTestWin.gBrowser.tabs[1], {animate: false}); gTestWin.gBrowser.removeTab(gTestWin.gBrowser.tabs[1], {animate: false});
gTestWin.gBrowser.selectTabAtIndex(0); gTestWin.gBrowser.selectTabAtIndex(0);
var childTabLink = gHttpTestRoot2 + "file_bug906190_2.html"; var childTabLink = gHttpTestRoot2 + "file_bug906190_2.html";
setUpTest("Test2", "linkForTest2", test2, childTabLink); setUpTest("Test2", "linkForTest2", test2, childTabLink);
});
} }
//------------------------ Test 2 ------------------------------ //------------------------ Test 2 ------------------------------
@ -256,18 +242,13 @@ function test2A() {
// The Doorhanger should appear and isMixedContentBlocked should be >> TRUE <<, // The Doorhanger should appear and isMixedContentBlocked should be >> TRUE <<,
// because our decision of disabling the mixed content blocker should only persist if pages are from the same domain. // because our decision of disabling the mixed content blocker should only persist if pages are from the same domain.
var notification = PopupNotifications.getNotification("bad-content", gTestWin.gBrowser.selectedBrowser); assertMixedContentBlockingState(gTestWin.gBrowser, {activeLoaded: false, activeBlocked: true, passiveLoaded: false});
ok(notification, "OK: Mixed Content Doorhanger did appear in Test 2A!");
promiseNotificationShown(notification).then(function() {
ok(gTestWin.PopupNotifications.panel.firstChild.isMixedContentBlocked, "OK: Mixed Content is being blocked in Test 2A!");
notification.remove();
var actual = gTestWin.content.document.getElementById('mctestdiv').innerHTML; var actual = gTestWin.content.document.getElementById('mctestdiv').innerHTML;
is(actual, "Mixed Content Blocker enabled", "OK: Blocked mixed script in Test 2A"); is(actual, "Mixed Content Blocker enabled", "OK: Blocked mixed script in Test 2A");
gTestWin.gBrowser.removeCurrentTab(); gTestWin.gBrowser.removeCurrentTab();
test2B(); test2B();
});
} }
function test2B() { function test2B() {
@ -285,24 +266,19 @@ function test2C() {
// The Doorhanger should appear and isMixedContentBlocked should be >> TRUE <<, // The Doorhanger should appear and isMixedContentBlocked should be >> TRUE <<,
// because our decision of disabling the mixed content blocker should only persist if pages are from the same domain. // because our decision of disabling the mixed content blocker should only persist if pages are from the same domain.
var notification = PopupNotifications.getNotification("bad-content", gTestWin.gBrowser.selectedBrowser); assertMixedContentBlockingState(gTestWin.gBrowser, {activeLoaded: false, activeBlocked: true, passiveLoaded: false});
ok(notification, "OK: Mixed Content Doorhanger did appear in Test 2C!");
promiseNotificationShown(notification).then(function() {
ok(gTestWin.PopupNotifications.panel.firstChild.isMixedContentBlocked, "OK: Mixed Content is being blocked in Test 2C!");
notification.remove();
var actual = gTestWin.content.document.getElementById('mctestdiv').innerHTML; var actual = gTestWin.content.document.getElementById('mctestdiv').innerHTML;
is(actual, "Mixed Content Blocker enabled", "OK: Blocked mixed script in Test 2C"); is(actual, "Mixed Content Blocker enabled", "OK: Blocked mixed script in Test 2C");
// remove tabs // remove tabs
gTestWin.gBrowser.removeTab(gTestWin.gBrowser.tabs[2], {animate: false}); gTestWin.gBrowser.removeTab(gTestWin.gBrowser.tabs[2], {animate: false});
gTestWin.gBrowser.removeTab(gTestWin.gBrowser.tabs[1], {animate: false}); gTestWin.gBrowser.removeTab(gTestWin.gBrowser.tabs[1], {animate: false});
gTestWin.gBrowser.selectTabAtIndex(0); gTestWin.gBrowser.selectTabAtIndex(0);
// file_bug906190_3_4.html redirects to page test1.example.com/* using meta-refresh // file_bug906190_3_4.html redirects to page test1.example.com/* using meta-refresh
var childTabLink = gHttpTestRoot1 + "file_bug906190_3_4.html"; var childTabLink = gHttpTestRoot1 + "file_bug906190_3_4.html";
setUpTest("Test3", "linkForTest3", test3, childTabLink); setUpTest("Test3", "linkForTest3", test3, childTabLink);
});
} }
//------------------------ Test 3 ------------------------------ //------------------------ Test 3 ------------------------------
@ -324,19 +300,14 @@ function test3B() {
gTestWin.gBrowser.selectTabAtIndex(2); gTestWin.gBrowser.selectTabAtIndex(2);
// The Doorhanger should appear but isMixedContentBlocked should be >> NOT << true! // The Doorhanger should appear but isMixedContentBlocked should be >> NOT << true!
var notification = PopupNotifications.getNotification("bad-content", gTestWin.gBrowser.selectedBrowser); assertMixedContentBlockingState(gTestWin.gBrowser, {activeLoaded: true, activeBlocked: false, passiveLoaded: false});
ok(notification, "OK: Mixed Content Doorhanger did appear in Test 3B!");
promiseNotificationShown(notification).then(function() {
ok(!gTestWin.PopupNotifications.panel.firstChild.isMixedContentBlocked, "OK: Mixed Content is NOT being blocked in Test 3B!");
notification.remove();
var actual = gTestWin.content.document.getElementById('mctestdiv').innerHTML; var actual = gTestWin.content.document.getElementById('mctestdiv').innerHTML;
is(actual, "Mixed Content Blocker disabled", "OK: Executed mixed script in Test 3B"); is(actual, "Mixed Content Blocker disabled", "OK: Executed mixed script in Test 3B");
// remove tabs // remove tabs
gTestWin.gBrowser.removeCurrentTab(); gTestWin.gBrowser.removeCurrentTab();
test3C(); test3C();
});
} }
function test3C() { function test3C() {
@ -357,23 +328,18 @@ function test3E() {
gTestWin.gBrowser.selectTabAtIndex(2); gTestWin.gBrowser.selectTabAtIndex(2);
// The Doorhanger should appear but isMixedContentBlocked should be >> NOT << true! // The Doorhanger should appear but isMixedContentBlocked should be >> NOT << true!
var notification = PopupNotifications.getNotification("bad-content", gTestWin.gBrowser.selectedBrowser); assertMixedContentBlockingState(gTestWin.gBrowser, {activeLoaded: true, activeBlocked: false, passiveLoaded: false});
ok(notification, "OK: Mixed Content Doorhanger did appear in Test 3E!");
promiseNotificationShown(notification).then(function() {
ok(!gTestWin.PopupNotifications.panel.firstChild.isMixedContentBlocked, "OK: Mixed Content is NOT being blocked in Test 3E!");
notification.remove();
var actual = gTestWin.content.document.getElementById('mctestdiv').innerHTML; var actual = gTestWin.content.document.getElementById('mctestdiv').innerHTML;
is(actual, "Mixed Content Blocker disabled", "OK: Executed mixed script in Test 3E"); is(actual, "Mixed Content Blocker disabled", "OK: Executed mixed script in Test 3E");
// remove tabs // remove tabs
gTestWin.gBrowser.removeTab(gTestWin.gBrowser.tabs[2], {animate: false}); gTestWin.gBrowser.removeTab(gTestWin.gBrowser.tabs[2], {animate: false});
gTestWin.gBrowser.removeTab(gTestWin.gBrowser.tabs[1], {animate: false}); gTestWin.gBrowser.removeTab(gTestWin.gBrowser.tabs[1], {animate: false});
gTestWin.gBrowser.selectTabAtIndex(0); gTestWin.gBrowser.selectTabAtIndex(0);
var childTabLink = gHttpTestRoot1 + "file_bug906190_3_4.html"; var childTabLink = gHttpTestRoot1 + "file_bug906190_3_4.html";
setUpTest("Test4", "linkForTest4", test4, childTabLink); setUpTest("Test4", "linkForTest4", test4, childTabLink);
});
} }
//------------------------ Test 4 ------------------------------ //------------------------ Test 4 ------------------------------
@ -396,19 +362,14 @@ function test4B() {
gTestWin.gBrowser.selectTabAtIndex(2); gTestWin.gBrowser.selectTabAtIndex(2);
// The Doorhanger should appear and isMixedContentBlocked should be >> TRUE << // The Doorhanger should appear and isMixedContentBlocked should be >> TRUE <<
var notification = PopupNotifications.getNotification("bad-content", gTestWin.gBrowser.selectedBrowser); assertMixedContentBlockingState(gTestWin.gBrowser, {activeLoaded: false, activeBlocked: true, passiveLoaded: false});
ok(notification, "OK: Mixed Content Doorhanger did appear in Test 4B!");
promiseNotificationShown(notification).then(function() {
ok(gTestWin.PopupNotifications.panel.firstChild.isMixedContentBlocked, "OK: Mixed Content is being blocked in Test 4B!");
notification.remove();
var actual = gTestWin.content.document.getElementById('mctestdiv').innerHTML; var actual = gTestWin.content.document.getElementById('mctestdiv').innerHTML;
is(actual, "Mixed Content Blocker enabled", "OK: Blocked mixed script in Test 4B"); is(actual, "Mixed Content Blocker enabled", "OK: Blocked mixed script in Test 4B");
// remove tabs // remove tabs
gTestWin.gBrowser.removeCurrentTab(); gTestWin.gBrowser.removeCurrentTab();
test4C(); test4C();
});
} }
function test4C() { function test4C() {
@ -429,24 +390,19 @@ function test4E() {
gTestWin.gBrowser.selectTabAtIndex(2); gTestWin.gBrowser.selectTabAtIndex(2);
// The Doorhanger should appear and isMixedContentBlocked should be >> TRUE << // The Doorhanger should appear and isMixedContentBlocked should be >> TRUE <<
var notification = PopupNotifications.getNotification("bad-content", gTestWin.gBrowser.selectedBrowser); assertMixedContentBlockingState(gTestWin.gBrowser, {activeLoaded: false, activeBlocked: true, passiveLoaded: false});
ok(notification, "OK: Mixed Content Doorhanger did appear in Test 4E!");
promiseNotificationShown(notification).then(function() {
ok(gTestWin.PopupNotifications.panel.firstChild.isMixedContentBlocked, "OK: Mixed Content is being blocked in Test 4E!");
notification.remove();
var actual = gTestWin.content.document.getElementById('mctestdiv').innerHTML; var actual = gTestWin.content.document.getElementById('mctestdiv').innerHTML;
is(actual, "Mixed Content Blocker enabled", "OK: Blocked mixed script in Test 4E"); is(actual, "Mixed Content Blocker enabled", "OK: Blocked mixed script in Test 4E");
// remove tabs // remove tabs
gTestWin.gBrowser.removeTab(gTestWin.gBrowser.tabs[2], {animate: false}); gTestWin.gBrowser.removeTab(gTestWin.gBrowser.tabs[2], {animate: false});
gTestWin.gBrowser.removeTab(gTestWin.gBrowser.tabs[1], {animate: false}); gTestWin.gBrowser.removeTab(gTestWin.gBrowser.tabs[1], {animate: false});
gTestWin.gBrowser.selectTabAtIndex(0); gTestWin.gBrowser.selectTabAtIndex(0);
// the sjs files returns a 302 redirect- note, same origins // the sjs files returns a 302 redirect- note, same origins
var childTabLink = gHttpTestRoot1 + "file_bug906190.sjs"; var childTabLink = gHttpTestRoot1 + "file_bug906190.sjs";
setUpTest("Test5", "linkForTest5", test5, childTabLink); setUpTest("Test5", "linkForTest5", test5, childTabLink);
});
} }
//------------------------ Test 5 ------------------------------ //------------------------ Test 5 ------------------------------
@ -465,19 +421,15 @@ function test5A() {
// The Doorhanger should appear but isMixedContentBlocked should be >> NOT << true // The Doorhanger should appear but isMixedContentBlocked should be >> NOT << true
// Currently it is >> TRUE << - see follow up bug 914860 // Currently it is >> TRUE << - see follow up bug 914860
var notification = PopupNotifications.getNotification("bad-content", gTestWin.gBrowser.selectedBrowser); let {gIdentityHandler} = gTestWin.gBrowser.ownerGlobal;
ok(notification, "OK: Mixed Content Doorhanger did appear in Test 5A!"); todo(!gIdentityHandler._identityBox.classList.contains("mixedActiveBlocked"), "OK: Mixed Content is NOT being blocked in Test 5A!");
promiseNotificationShown(notification).then(function() {
todo(!gTestWin.PopupNotifications.panel.firstChild.isMixedContentBlocked, "OK: Mixed Content is NOT being blocked in Test 5A!");
notification.remove();
var actual = gTestWin.content.document.getElementById('mctestdiv').innerHTML; var actual = gTestWin.content.document.getElementById('mctestdiv').innerHTML;
todo_is(actual, "Mixed Content Blocker disabled", "OK: Executed mixed script in Test 5A!"); todo_is(actual, "Mixed Content Blocker disabled", "OK: Executed mixed script in Test 5A!");
// remove tabs // remove tabs
gTestWin.gBrowser.removeCurrentTab(); gTestWin.gBrowser.removeCurrentTab();
test5B(); test5B();
});
} }
function test5B() { function test5B() {
@ -493,26 +445,23 @@ function test5C() {
// move the tab again // move the tab again
gTestWin.gBrowser.selectTabAtIndex(2); gTestWin.gBrowser.selectTabAtIndex(2);
let {gIdentityHandler} = gTestWin.gBrowser.ownerGlobal;
// The Doorhanger should appear but isMixedContentBlocked should be >> NOT << true // The Doorhanger should appear but isMixedContentBlocked should be >> NOT << true
// Currently it is >> TRUE << - see follow up bug 914860 // Currently it is >> TRUE << - see follow up bug 914860
var notification = PopupNotifications.getNotification("bad-content", gTestWin.gBrowser.selectedBrowser); todo(!gIdentityHandler._identityBox.classList.contains("mixedActiveBlocked"), "OK: Mixed Content is NOT being blocked in Test 5C!");
ok(notification, "OK: Mixed Content Doorhanger did appear in Test 5C!");
promiseNotificationShown(notification).then(function() {
todo(!gTestWin.PopupNotifications.panel.firstChild.isMixedContentBlocked, "OK: Mixed Content is NOT being blocked in Test 5C!");
notification.remove();
var actual = gTestWin.content.document.getElementById('mctestdiv').innerHTML; var actual = gTestWin.content.document.getElementById('mctestdiv').innerHTML;
todo_is(actual, "Mixed Content Blocker disabled", "OK: Executed mixed script in Test 5C!"); todo_is(actual, "Mixed Content Blocker disabled", "OK: Executed mixed script in Test 5C!");
// remove tabs // remove tabs
gTestWin.gBrowser.removeTab(gTestWin.gBrowser.tabs[2], {animate: false}); gTestWin.gBrowser.removeTab(gTestWin.gBrowser.tabs[2], {animate: false});
gTestWin.gBrowser.removeTab(gTestWin.gBrowser.tabs[1], {animate: false}); gTestWin.gBrowser.removeTab(gTestWin.gBrowser.tabs[1], {animate: false});
gTestWin.gBrowser.selectTabAtIndex(0); gTestWin.gBrowser.selectTabAtIndex(0);
// the sjs files returns a 302 redirect - note, different origins // the sjs files returns a 302 redirect - note, different origins
var childTabLink = gHttpTestRoot2 + "file_bug906190.sjs"; var childTabLink = gHttpTestRoot2 + "file_bug906190.sjs";
setUpTest("Test6", "linkForTest6", test6, childTabLink); setUpTest("Test6", "linkForTest6", test6, childTabLink);
});
} }
//------------------------ Test 6 ------------------------------ //------------------------ Test 6 ------------------------------
@ -530,19 +479,14 @@ function test6A() {
gTestWin.gBrowser.selectTabAtIndex(2); gTestWin.gBrowser.selectTabAtIndex(2);
// The Doorhanger should appear and isMixedContentBlocked should be >> TRUE << // The Doorhanger should appear and isMixedContentBlocked should be >> TRUE <<
var notification = PopupNotifications.getNotification("bad-content", gTestWin.gBrowser.selectedBrowser); assertMixedContentBlockingState(gTestWin.gBrowser, {activeLoaded: false, activeBlocked: true, passiveLoaded: false});
ok(notification, "OK: Mixed Content Doorhanger did appear in Test 6A!");
promiseNotificationShown(notification).then(function() {
ok(gTestWin.PopupNotifications.panel.firstChild.isMixedContentBlocked, "OK: Mixed Content is being blocked in Test 6A!");
notification.remove();
var actual = gTestWin.content.document.getElementById('mctestdiv').innerHTML; var actual = gTestWin.content.document.getElementById('mctestdiv').innerHTML;
is(actual, "Mixed Content Blocker enabled", "OK: Blocked mixed script in Test 6A"); is(actual, "Mixed Content Blocker enabled", "OK: Blocked mixed script in Test 6A");
// done // done
gTestWin.gBrowser.removeCurrentTab(); gTestWin.gBrowser.removeCurrentTab();
test6B(); test6B();
});
} }
function test6B() { function test6B() {
@ -558,18 +502,13 @@ function test6C() {
gTestWin.gBrowser.selectTabAtIndex(2); gTestWin.gBrowser.selectTabAtIndex(2);
// The Doorhanger should appear and isMixedContentBlocked should be >> TRUE << // The Doorhanger should appear and isMixedContentBlocked should be >> TRUE <<
var notification = PopupNotifications.getNotification("bad-content", gTestWin.gBrowser.selectedBrowser); assertMixedContentBlockingState(gTestWin.gBrowser, {activeLoaded: false, activeBlocked: true, passiveLoaded: false});
ok(notification, "OK: Mixed Content Doorhanger did appear in Test 6C!");
promiseNotificationShown(notification).then(function() {
ok(gTestWin.PopupNotifications.panel.firstChild.isMixedContentBlocked, "OK: Mixed Content is being blocked in Test 6C!");
notification.remove();
var actual = gTestWin.content.document.getElementById('mctestdiv').innerHTML; var actual = gTestWin.content.document.getElementById('mctestdiv').innerHTML;
is(actual, "Mixed Content Blocker enabled", "OK: Blocked mixed script in Test 6C"); is(actual, "Mixed Content Blocker enabled", "OK: Blocked mixed script in Test 6C");
gTestWin.close(); gTestWin.close();
finish(); finish();
});
} }
//------------------------ SETUP ------------------------------ //------------------------ SETUP ------------------------------

View File

@ -100,16 +100,15 @@ function waitForCondition(condition, nextTest, errorMsg, okMsg) {
//------------------------ Test 1 ------------------------------ //------------------------ Test 1 ------------------------------
function test1() { function test1() {
gTestBrowser.addEventListener("load", checkPopUpNotificationsForTest1, true); gTestBrowser.addEventListener("load", checkUIForTest1, true);
var url = gHttpsTestRoot + "test_mcb_redirect.html" var url = gHttpsTestRoot + "test_mcb_redirect.html"
gTestBrowser.contentWindow.location = url; gTestBrowser.contentWindow.location = url;
} }
function checkPopUpNotificationsForTest1() { function checkUIForTest1() {
gTestBrowser.removeEventListener("load", checkPopUpNotificationsForTest1, true); gTestBrowser.removeEventListener("load", checkUIForTest1, true);
var notification = PopupNotifications.getNotification("bad-content", gTestBrowser.selectedBrowser); assertMixedContentBlockingState(gTestBrowser, {activeLoaded: false, activeBlocked: true, passiveLoaded: false});
ok(notification, "OK: Mixed Content Doorhanger appeared in Test1!");
var expected = "script blocked"; var expected = "script blocked";
waitForCondition( waitForCondition(
@ -121,16 +120,15 @@ function checkPopUpNotificationsForTest1() {
//------------------------ Test 2 ------------------------------ //------------------------ Test 2 ------------------------------
function test2() { function test2() {
gTestBrowser.addEventListener("load", checkPopUpNotificationsForTest2, true); gTestBrowser.addEventListener("load", checkUIForTest2, true);
var url = gHttpTestRoot + "test_mcb_redirect.html" var url = gHttpTestRoot + "test_mcb_redirect.html"
gTestBrowser.contentWindow.location = url; gTestBrowser.contentWindow.location = url;
} }
function checkPopUpNotificationsForTest2() { function checkUIForTest2() {
gTestBrowser.removeEventListener("load", checkPopUpNotificationsForTest2, true); gTestBrowser.removeEventListener("load", checkUIForTest2, true);
var notification = PopupNotifications.getNotification("bad-content", gTestBrowser.selectedBrowser); assertMixedContentBlockingState(gTestBrowser, {activeLoaded: false, activeBlocked: false, passiveLoaded: false});
ok(!notification, "OK: Mixed Content Doorhanger did not appear in 2!");
var expected = "script executed"; var expected = "script executed";
waitForCondition( waitForCondition(

View File

@ -39,16 +39,13 @@ function overrideMCB()
{ {
// test mixed content flags on load (reload) // test mixed content flags on load (reload)
gTestBrowser.addEventListener("load", mixedContentOverrideTest, true); gTestBrowser.addEventListener("load", mixedContentOverrideTest, true);
var notification = PopupNotifications.getNotification("bad-content", gTestBrowser);
ok(notification, "Mixed Content Doorhanger should appear");
notification.reshow();
ok(PopupNotifications.panel.firstChild.isMixedContentBlocked, "OK: Mixed Content is being blocked");
// Make sure the notification has no mixedblockdisabled attribute assertMixedContentBlockingState(gTestBrowser, {activeLoaded: false, activeBlocked: true, passiveLoaded: false});
ok(!PopupNotifications.panel.firstChild.hasAttribute("mixedblockdisabled"),
"Doorhanger must have no mixedblockdisabled attribute");
// Click on the doorhanger to allow mixed content (and reload page) // Click on the doorhanger to allow mixed content (and reload page)
PopupNotifications.panel.firstChild.disableMixedContentProtection(); let {gIdentityHandler} = gTestBrowser.ownerGlobal;
gIdentityHandler.disableMixedContentProtection();
notification.remove(); notification.remove();
} }
@ -61,13 +58,7 @@ function mixedContentOverrideTest()
is(gTestBrowser.docShell.hasMixedDisplayContentBlocked, false, "second hasMixedDisplayContentBlocked flag has been set"); is(gTestBrowser.docShell.hasMixedDisplayContentBlocked, false, "second hasMixedDisplayContentBlocked flag has been set");
is(gTestBrowser.docShell.hasMixedActiveContentBlocked, false, "second hasMixedActiveContentBlocked flag has been set"); is(gTestBrowser.docShell.hasMixedActiveContentBlocked, false, "second hasMixedActiveContentBlocked flag has been set");
let notification = PopupNotifications.getNotification("bad-content", gTestBrowser); assertMixedContentBlockingState(gTestBrowser, {activeLoaded: true, activeBlocked: false, passiveLoaded: true});
ok(notification, "Mixed Content Doorhanger should appear");
notification.reshow();
// Make sure the notification has the mixedblockdisabled attribute set to true
is(PopupNotifications.panel.firstChild.getAttribute("mixedblockdisabled"), "true",
"Doorhanger must have [mixedblockdisabled='true'] attribute");
gBrowser.removeCurrentTab(); gBrowser.removeCurrentTab();
finish(); finish();

View File

@ -758,6 +758,66 @@ function assertWebRTCIndicatorStatus(expected) {
} }
} }
/**
* Test the state of the identity box and control center to make
* sure they are correctly showing the expected mixed content states.
*
* @param tabbrowser
* @param Object states
* MUST include the following properties:
* {
* activeLoaded: true|false,
* activeBlocked: true|false,
* passiveLoaded: true|false,
* }
*/
function assertMixedContentBlockingState(tabbrowser, states = {}) {
if (!tabbrowser || !("activeLoaded" in states) ||
!("activeBlocked" in states) || !("passiveLoaded" in states)) {
throw new Error("assertMixedContentBlockingState requires a browser and a states object");
}
let {passiveLoaded,activeLoaded,activeBlocked} = states;
let {gIdentityHandler} = tabbrowser.ownerGlobal;
let doc = tabbrowser.ownerDocument;
let identityBox = gIdentityHandler._identityBox;
let classList = identityBox.classList;
// Make sure the identity box UI has the correct mixedcontent states
is(classList.contains("mixedActiveContent"), activeLoaded,
"identityBox has expected class for activeLoaded");
is(classList.contains("mixedActiveBlocked"), activeBlocked && !passiveLoaded,
"identityBox has expected class for activeBlocked && !passiveLoaded");
is(classList.contains("mixedDisplayContent"), passiveLoaded && !activeLoaded,
"identityBox has expected class for passiveLoaded && activeLoaded");
is(classList.contains("mixedDisplayContentLoadedActiveBlocked"), passiveLoaded && activeBlocked,
"identityBox has expected class for passiveLoaded && activeBlocked");
is (classList.contains("mixedContent"), activeBlocked || activeLoaded || passiveLoaded,
"identityBox is showing no mixed content");
// Make sure the identity popup has the correct mixedcontent states
gIdentityHandler._identityBox.click();
let popupAttr = doc.getElementById("identity-popup").getAttribute("mixedcontent");
let bodyAttr = doc.getElementById("identity-popup-securityView-body").getAttribute("mixedcontent");
is(popupAttr.contains("active-loaded"), activeLoaded,
"identity-popup has expected attr for activeLoaded");
is(bodyAttr.contains("active-loaded"), activeLoaded,
"securityView-body has expected attr for activeLoaded");
is(popupAttr.contains("active-blocked"), activeBlocked,
"identity-popup has expected attr for activeBlocked");
is(bodyAttr.contains("active-blocked"), activeBlocked,
"securityView-body has expected attr for activeBlocked");
is(popupAttr.contains("passive-loaded"), passiveLoaded,
"identity-popup has expected attr for passiveLoaded");
is(bodyAttr.contains("passive-loaded"), passiveLoaded,
"securityView-body has expected attr for passiveLoaded");
gIdentityHandler._identityPopup.hidden = true;
}
function makeActionURI(action, params) { function makeActionURI(action, params) {
let url = "moz-action:" + action + "," + JSON.stringify(params); let url = "moz-action:" + action + "," + JSON.stringify(params);
return NetUtil.newURI(url); return NetUtil.newURI(url);

View File

@ -197,10 +197,12 @@ skip-if = buildapp == 'mulet'
[browser_warn_user_about_replaced_api.js] [browser_warn_user_about_replaced_api.js]
[browser_webconsole_abbreviate_source_url.js] [browser_webconsole_abbreviate_source_url.js]
[browser_webconsole_allow_mixedcontent_securityerrors.js] [browser_webconsole_allow_mixedcontent_securityerrors.js]
tags = mcb
skip-if = buildapp == 'mulet' skip-if = buildapp == 'mulet'
[browser_webconsole_assert.js] [browser_webconsole_assert.js]
[browser_webconsole_basic_net_logging.js] [browser_webconsole_basic_net_logging.js]
[browser_webconsole_block_mixedcontent_securityerrors.js] [browser_webconsole_block_mixedcontent_securityerrors.js]
tags = mcb
skip-if = buildapp == 'mulet' skip-if = buildapp == 'mulet'
[browser_webconsole_bug_579412_input_focus.js] [browser_webconsole_bug_579412_input_focus.js]
[browser_webconsole_bug_580001_closing_after_completion.js] [browser_webconsole_bug_580001_closing_after_completion.js]

View File

@ -63,34 +63,12 @@ function pushPrefEnv() {
return deferred.promise; return deferred.promise;
} }
function waitForNotificationShown(notification, callback) {
if (PopupNotifications.panel.state == "open") {
executeSoon(callback);
return;
}
PopupNotifications.panel.addEventListener("popupshown", function onShown() {
PopupNotifications.panel.removeEventListener("popupshown", onShown);
callback();
}, false);
notification.reshow();
}
function mixedContentOverrideTest2(hud, browser) { function mixedContentOverrideTest2(hud, browser) {
let notification = PopupNotifications.getNotification("bad-content", browser);
ok(notification, "Mixed Content Doorhanger did appear");
let deferred = promise.defer(); let deferred = promise.defer();
waitForNotificationShown(notification, () => { let {gIdentityHandler} = browser.ownerGlobal;
afterNotificationShown(hud, notification, deferred); ok(gIdentityHandler._identityBox.classList.contains("mixedActiveBlocked"),
}); "Mixed Active Content state appeared on identity box");
return deferred.promise; gIdentityHandler.disableMixedContentProtection();
}
function afterNotificationShown(hud, notification, deferred) {
ok(PopupNotifications.panel.firstChild.isMixedContentBlocked,
"OK: Mixed Content is being blocked");
// Click on the doorhanger.
PopupNotifications.panel.firstChild.disableMixedContentProtection();
notification.remove();
waitForMessages({ waitForMessages({
webconsole: hud, webconsole: hud,
@ -114,6 +92,8 @@ function afterNotificationShown(hud, notification, deferred) {
}, },
], ],
}).then(msgs => deferred.resolve(msgs), Cu.reportError); }).then(msgs => deferred.resolve(msgs), Cu.reportError);
return deferred.promise;
} }
function testClickOpenNewTab(hud, match) { function testClickOpenNewTab(hud, match) {

View File

@ -5,6 +5,7 @@ support-files =
[browser_bug593387.js] [browser_bug593387.js]
skip-if = e10s # Bug ?????? - test directly touches content (contentWindow.iframe.addEventListener) skip-if = e10s # Bug ?????? - test directly touches content (contentWindow.iframe.addEventListener)
[browser_bug902350.js] [browser_bug902350.js]
tags = mcb
skip-if = e10s # Bug ?????? - test e10s utils don't support load events from iframe etc, which this test relies on. skip-if = e10s # Bug ?????? - test e10s utils don't support load events from iframe etc, which this test relies on.
[browser_messagemanager_loadprocessscript.js] [browser_messagemanager_loadprocessscript.js]
[browser_messagemanager_targetframeloader.js] [browser_messagemanager_targetframeloader.js]

View File

@ -51,8 +51,9 @@ function MixedTest1B() {
topTarget.click(); topTarget.click();
// The link click should have caused a load and should not invoke the Mixed Content Blocker // The link click should have caused a load and should not invoke the Mixed Content Blocker
var notification = PopupNotifications.getNotification("bad-content", gTestBrowser); let {gIdentityHandler} = gTestBrowser.ownerGlobal;
ok(!notification, "Mixed Content Doorhanger did not appear when trying to navigate top"); ok (!gIdentityHandler._identityBox.classList.contains("mixedActiveBlocked"),
"Mixed Content Doorhanger did not appear when trying to navigate top");
} }
function MixedTest1C() { function MixedTest1C() {