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
Родитель 5ca042183f
Коммит 225e4e60fa
12 изменённых файлов: 241 добавлений и 295 удалений

Просмотреть файл

@ -259,12 +259,15 @@ skip-if = os == "mac" # Bug 1102331 - does focus things on the content window wh
[browser_bug783614.js]
[browser_bug817947.js]
[browser_bug822367.js]
tags = mcb
[browser_bug832435.js]
[browser_bug839103.js]
[browser_bug880101.js]
[browser_bug882977.js]
[browser_bug902156.js]
tags = mcb
[browser_bug906190.js]
tags = mcb
skip-if = buildapp == "mulet" || e10s # Bug 1093642 - test manipulates content and relies on content focus
[browser_mixedContentFromOnunload.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]
skip-if = e10s # Bug 1100664 - test directly access content docShells (TypeError: gBrowser.docShell is null)
[browser_mixedcontent_securityflags.js]
tags = mcb
[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)
[browser_offlineQuotaNotification.js]
@ -489,6 +493,7 @@ skip-if = e10s # Bug 1094240 - has findbar-related failures
[browser_addCertException.js]
skip-if = e10s # Bug 1100687 - test directly manipulates content (content.document.getElementById)
[browser_bug1045809.js]
tags = mcb
[browser_e10s_switchbrowser.js]
[browser_e10s_about_process.js]
[browser_e10s_chrome_process.js]
@ -497,6 +502,7 @@ skip-if = e10s # Bug 1100687 - test directly manipulates content (content.docume
tags = psm
skip-if = e10s # bug 1100687 - test directly manipulates content (content.document.getElementById)
[browser_mcb_redirect.js]
tags = mcb
[browser_windowactivation.js]
[browser_contextmenu_childprocess.js]
[browser_bug963945.js]

Просмотреть файл

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

Просмотреть файл

@ -50,11 +50,11 @@ function test() {
function MixedTest1A() {
gTestBrowser.removeEventListener("load", MixedTest1A, true);
gTestBrowser.addEventListener("load", MixedTest1B, true);
var notification = PopupNotifications.getNotification("bad-content", gTestBrowser);
ok(notification, "Mixed Content Doorhanger did appear");
notification.reshow();
ok(PopupNotifications.panel.firstChild.isMixedContentBlocked, "OK: Mixed Content is being blocked");
PopupNotifications.panel.firstChild.disableMixedContentProtection();
assertMixedContentBlockingState(gTestBrowser, {activeLoaded: false, activeBlocked: true, passiveLoaded: false});
let {gIdentityHandler} = gTestBrowser.ownerGlobal;
gIdentityHandler.disableMixedContentProtection();
}
function MixedTest1B() {
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() {
var notification = PopupNotifications.getNotification("bad-content", gTestBrowser);
ok(!notification, "Mixed Content Doorhanger did not appear for mixed display content!");
assertMixedContentBlockingState(gTestBrowser, {activeLoaded: false, activeBlocked: false, passiveLoaded: false});
MixedTest3();
}
@ -88,11 +87,11 @@ function MixedTest3() {
function MixedTest3A() {
gTestBrowser.removeEventListener("load", MixedTest3A, true);
gTestBrowser.addEventListener("load", MixedTest3B, true);
var notification = PopupNotifications.getNotification("bad-content", gTestBrowser);
ok(notification, "Mixed Content Doorhanger did appear for test 3");
notification.reshow();
ok(PopupNotifications.panel.firstChild.isMixedContentBlocked, "OK: Mixed Content is being blocked in test 3");
PopupNotifications.panel.firstChild.disableMixedContentProtection();
assertMixedContentBlockingState(gTestBrowser, {activeLoaded: false, activeBlocked: true, passiveLoaded: false});
let {gIdentityHandler} = gTestBrowser.ownerGlobal;
gIdentityHandler.disableMixedContentProtection();
}
function MixedTest3B() {
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() {
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");
assertMixedContentBlockingState(gTestBrowser, {activeLoaded: true, activeBlocked: false, passiveLoaded: true});
MixedTest4();
}
@ -116,22 +116,21 @@ function MixedTest4() {
function MixedTest4A() {
gTestBrowser.removeEventListener("load", MixedTest4A, true);
gTestBrowser.addEventListener("load", MixedTest4B, true);
var notification = PopupNotifications.getNotification("bad-content", gTestBrowser);
ok(notification, "Mixed Content Doorhanger did appear for Test 4");
notification.reshow();
ok(PopupNotifications.panel.firstChild.isMixedContentBlocked, "OK: Mixed Content is being blocked in Test 4");
PopupNotifications.panel.firstChild.disableMixedContentProtection();
assertMixedContentBlockingState(gTestBrowser, {activeLoaded: false, activeBlocked: true, passiveLoaded: false});
let {gIdentityHandler} = gTestBrowser.ownerGlobal;
gIdentityHandler.disableMixedContentProtection();
}
function MixedTest4B() {
waitForCondition(function() content.document.location == gHttpTestRoot + "file_bug822367_4B.html", MixedTest4C, "Waited too long for mixed script to run in Test 4");
}
function MixedTest4C() {
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");
notification.reshow();
ok(PopupNotifications.panel.firstChild.isMixedContentBlocked, "OK: Mixed Content is being blocked in test 4");
notification.remove();
assertMixedContentBlockingState(gTestBrowser, {activeLoaded: false, activeBlocked: true, passiveLoaded: false});
let {gIdentityHandler} = gTestBrowser.ownerGlobal;
waitForCondition(function() content.document.getElementById('p1').innerHTML == "", MixedTest4D, "Mixed script loaded in test 4 after location change!");
}
function MixedTest4D() {
@ -149,11 +148,11 @@ function MixedTest5() {
function MixedTest5A() {
gTestBrowser.removeEventListener("load", MixedTest5A, true);
gTestBrowser.addEventListener("load", MixedTest5B, true);
var notification = PopupNotifications.getNotification("bad-content", gTestBrowser);
ok(notification, "Mixed Content Doorhanger did appear for Test 5");
notification.reshow();
ok(PopupNotifications.panel.firstChild.isMixedContentBlocked, "OK: Mixed Content is being blocked in Test 5");
PopupNotifications.panel.firstChild.disableMixedContentProtection();
assertMixedContentBlockingState(gTestBrowser, {activeLoaded: false, activeBlocked: true, passiveLoaded: false});
let {gIdentityHandler} = gTestBrowser.ownerGlobal;
gIdentityHandler.disableMixedContentProtection();
}
function MixedTest5B() {
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() {
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() {
var notification = PopupNotifications.getNotification("bad-content", gTestBrowser);
ok(notification, "Mixed Content Doorhanger did appear for Test 6");
gTestBrowser.addEventListener("load", MixedTest6C, true);
notification.reshow();
ok(PopupNotifications.panel.firstChild.isMixedContentBlocked, "OK: Mixed Content is being blocked in Test 6");
PopupNotifications.panel.firstChild.disableMixedContentProtection();
assertMixedContentBlockingState(gTestBrowser, {activeLoaded: false, activeBlocked: true, passiveLoaded: false});
let {gIdentityHandler} = gTestBrowser.ownerGlobal;
gIdentityHandler.disableMixedContentProtection();
}
function MixedTest6C() {
@ -196,5 +196,6 @@ function MixedTest6C() {
}
function MixedTest6D() {
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();
}

Просмотреть файл

@ -4,19 +4,19 @@
*
* 1. Navigate to the same domain via document.location
* - 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
* - 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
* - 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
* - 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
* - 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.
*
* Note, for all tests we set gHttpTestRoot to use 'https'.
@ -50,14 +50,11 @@ function test1A() {
gTestBrowser.removeEventListener("load", test1A, true);
gTestBrowser.addEventListener("load", test1B, true);
var notification = PopupNotifications.getNotification("bad-content", gTestBrowser);
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!");
assertMixedContentBlockingState(gTestBrowser, {activeLoaded: false, activeBlocked: true, passiveLoaded: false});
// Disable Mixed Content Protection for the page (and reload)
PopupNotifications.panel.firstChild.disableMixedContentProtection();
notification.remove();
let {gIdentityHandler} = gTestBrowser.ownerGlobal;
gIdentityHandler.disableMixedContentProtection();
}
function test1B() {
@ -83,13 +80,9 @@ function test1C() {
function test1D() {
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.
var notification = PopupNotifications.getNotification("bad-content", gTestBrowser);
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();
assertMixedContentBlockingState(gTestBrowser, {activeLoaded: true, activeBlocked: false, passiveLoaded: false});
var actual = content.document.getElementById('mctestdiv').innerHTML;
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.addEventListener("load", test2B, true);
var notification = PopupNotifications.getNotification("bad-content", gTestBrowser);
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!");
assertMixedContentBlockingState(gTestBrowser, {activeLoaded: false, activeBlocked: true, passiveLoaded: false});
// Disable Mixed Content Protection for the page (and reload)
PopupNotifications.panel.firstChild.disableMixedContentProtection();
notification.remove();
let {gIdentityHandler} = gTestBrowser.ownerGlobal;
gIdentityHandler.disableMixedContentProtection();
}
function test2B() {
@ -146,13 +136,9 @@ function test2C() {
function test2D() {
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.
var notification = PopupNotifications.getNotification("bad-content", gTestBrowser);
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();
assertMixedContentBlockingState(gTestBrowser, {activeLoaded: true, activeBlocked: false, passiveLoaded: false});
var actual = content.document.getElementById('mctestdiv').innerHTML;
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
gTestBrowser.removeEventListener("load", test3A, true);
var notification = PopupNotifications.getNotification("bad-content", gTestBrowser);
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();
assertMixedContentBlockingState(gTestBrowser, {activeLoaded: false, activeBlocked: true, passiveLoaded: false});
// We are done with tests, clean up
cleanUpAfterTests();

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

@ -39,16 +39,13 @@ function overrideMCB()
{
// test mixed content flags on load (reload)
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
ok(!PopupNotifications.panel.firstChild.hasAttribute("mixedblockdisabled"),
"Doorhanger must have no mixedblockdisabled attribute");
assertMixedContentBlockingState(gTestBrowser, {activeLoaded: false, activeBlocked: true, passiveLoaded: false});
// Click on the doorhanger to allow mixed content (and reload page)
PopupNotifications.panel.firstChild.disableMixedContentProtection();
let {gIdentityHandler} = gTestBrowser.ownerGlobal;
gIdentityHandler.disableMixedContentProtection();
notification.remove();
}
@ -61,13 +58,7 @@ function mixedContentOverrideTest()
is(gTestBrowser.docShell.hasMixedDisplayContentBlocked, false, "second hasMixedDisplayContentBlocked flag has been set");
is(gTestBrowser.docShell.hasMixedActiveContentBlocked, false, "second hasMixedActiveContentBlocked flag has been set");
let notification = PopupNotifications.getNotification("bad-content", gTestBrowser);
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");
assertMixedContentBlockingState(gTestBrowser, {activeLoaded: true, activeBlocked: false, passiveLoaded: true});
gBrowser.removeCurrentTab();
finish();

Просмотреть файл

@ -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) {
let url = "moz-action:" + action + "," + JSON.stringify(params);
return NetUtil.newURI(url);

Просмотреть файл

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

Просмотреть файл

@ -63,34 +63,12 @@ function pushPrefEnv() {
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) {
let notification = PopupNotifications.getNotification("bad-content", browser);
ok(notification, "Mixed Content Doorhanger did appear");
let deferred = promise.defer();
waitForNotificationShown(notification, () => {
afterNotificationShown(hud, notification, deferred);
});
return deferred.promise;
}
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();
let {gIdentityHandler} = browser.ownerGlobal;
ok(gIdentityHandler._identityBox.classList.contains("mixedActiveBlocked"),
"Mixed Active Content state appeared on identity box");
gIdentityHandler.disableMixedContentProtection();
waitForMessages({
webconsole: hud,
@ -114,6 +92,8 @@ function afterNotificationShown(hud, notification, deferred) {
},
],
}).then(msgs => deferred.resolve(msgs), Cu.reportError);
return deferred.promise;
}
function testClickOpenNewTab(hud, match) {

Просмотреть файл

@ -5,6 +5,7 @@ support-files =
[browser_bug593387.js]
skip-if = e10s # Bug ?????? - test directly touches content (contentWindow.iframe.addEventListener)
[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.
[browser_messagemanager_loadprocessscript.js]
[browser_messagemanager_targetframeloader.js]

Просмотреть файл

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