mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 822367 - Mochitests - User overrides mixed content blocking. r=smaug
This commit is contained in:
parent
a2a67ad5a7
commit
82329b3016
@ -610,6 +610,15 @@ MOCHITEST_FILES_B = \
|
||||
test_mixed_content_blocker_bug803225.html \
|
||||
file_mixed_content_main_bug803225.html \
|
||||
file_mixed_content_main_bug803225_websocket_wsh.py \
|
||||
file_bug822367_1.html \
|
||||
file_bug822367_1.js \
|
||||
file_bug822367_2.html \
|
||||
file_bug822367_3.html \
|
||||
file_bug822367_4.html \
|
||||
file_bug822367_4.js \
|
||||
file_bug822367_4B.html \
|
||||
file_bug822367_5.html \
|
||||
file_bug822367_6.html \
|
||||
bug803225_test_mailto.html \
|
||||
test_bug789856.html \
|
||||
file_bug804395.jar \
|
||||
|
@ -57,4 +57,7 @@ MOCHITEST_CHROME_FILES = \
|
||||
frame_bug814638.xul \
|
||||
$(NULL)
|
||||
|
||||
MOCHITEST_BROWSER_FILES = \
|
||||
browser_bug822367.js \
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
192
content/base/test/chrome/browser_bug822367.js
Normal file
192
content/base/test/chrome/browser_bug822367.js
Normal file
@ -0,0 +1,192 @@
|
||||
/*
|
||||
* User Override Mixed Content Block - Tests for Bug 822367
|
||||
*/
|
||||
|
||||
|
||||
const PREF_DISPLAY = "security.mixed_content.block_display_content";
|
||||
const PREF_ACTIVE = "security.mixed_content.block_active_content";
|
||||
const gHttpTestRoot = "https://example.com/tests/content/base/test/";
|
||||
var origBlockDisplay;
|
||||
var origBlockActive;
|
||||
var gTestBrowser = null;
|
||||
|
||||
registerCleanupFunction(function() {
|
||||
// Set preferences back to their original values
|
||||
Services.prefs.setBoolPref(PREF_DISPLAY, origBlockDisplay);
|
||||
Services.prefs.setBoolPref(PREF_ACTIVE, origBlockActive);
|
||||
});
|
||||
|
||||
function MixedTestsCompleted() {
|
||||
gBrowser.removeCurrentTab();
|
||||
window.focus();
|
||||
finish();
|
||||
}
|
||||
|
||||
function test() {
|
||||
waitForExplicitFinish();
|
||||
|
||||
origBlockDisplay = Services.prefs.getBoolPref(PREF_DISPLAY);
|
||||
origBlockActive = Services.prefs.getBoolPref(PREF_ACTIVE);
|
||||
|
||||
Services.prefs.setBoolPref(PREF_DISPLAY, true);
|
||||
Services.prefs.setBoolPref(PREF_ACTIVE, true);
|
||||
|
||||
var newTab = gBrowser.addTab();
|
||||
gBrowser.selectedTab = newTab;
|
||||
gTestBrowser = gBrowser.selectedBrowser;
|
||||
newTab.linkedBrowser.stop()
|
||||
|
||||
// Mixed Script Test
|
||||
gTestBrowser.addEventListener("load", MixedTest1A, true);
|
||||
var url = gHttpTestRoot + "file_bug822367_1.html";
|
||||
gTestBrowser.contentWindow.location = url;
|
||||
}
|
||||
|
||||
// Mixed Script Test
|
||||
function MixedTest1A() {
|
||||
gTestBrowser.removeEventListener("load", MixedTest1A, true);
|
||||
gTestBrowser.addEventListener("load", MixedTest1B, true);
|
||||
var notification = PopupNotifications.getNotification("mixed-content-blocked", gTestBrowser);
|
||||
ok(notification, "Mixed Content Doorhanger didn't appear");
|
||||
notification.secondaryActions[0].callback();
|
||||
}
|
||||
function MixedTest1B() {
|
||||
waitForCondition(function() content.document.getElementById('p1').innerHTML == "hello", MixedTest1C, "Waited too long for mixed script to run in Test 1");
|
||||
}
|
||||
function MixedTest1C() {
|
||||
ok(content.document.getElementById('p1').innerHTML == "hello","Mixed script didn't load in Test 1");
|
||||
gTestBrowser.removeEventListener("load", MixedTest1B, true);
|
||||
MixedTest2();
|
||||
}
|
||||
|
||||
//Mixed Display Test - Doorhanger should not appear
|
||||
function MixedTest2() {
|
||||
gTestBrowser.addEventListener("load", MixedTest2A, true);
|
||||
var url = gHttpTestRoot + "file_bug822367_2.html";
|
||||
gTestBrowser.contentWindow.location = url;
|
||||
}
|
||||
|
||||
function MixedTest2A() {
|
||||
var notification = PopupNotifications.getNotification("mixed-content-blocked", gTestBrowser);
|
||||
ok(!notification, "Mixed Content Doorhanger appears for mixed display content!");
|
||||
MixedTest3();
|
||||
}
|
||||
|
||||
// Mixed Script and Display Test - User Override should cause both the script and the image to load.
|
||||
function MixedTest3() {
|
||||
gTestBrowser.removeEventListener("load", MixedTest2A, true);
|
||||
gTestBrowser.addEventListener("load", MixedTest3A, true);
|
||||
var url = gHttpTestRoot + "file_bug822367_3.html";
|
||||
gTestBrowser.contentWindow.location = url;
|
||||
}
|
||||
function MixedTest3A() {
|
||||
gTestBrowser.removeEventListener("load", MixedTest3A, true);
|
||||
gTestBrowser.addEventListener("load", MixedTest3B, true);
|
||||
var notification = PopupNotifications.getNotification("mixed-content-blocked", gTestBrowser);
|
||||
ok(notification, "Mixed Content Doorhanger doesn't appear for test 3");
|
||||
notification.secondaryActions[0].callback();
|
||||
}
|
||||
function MixedTest3B() {
|
||||
waitForCondition(function() content.document.getElementById('p1').innerHTML == "hello", MixedTest3C, "Waited too long for mixed script to run in Test 3");
|
||||
}
|
||||
function MixedTest3C() {
|
||||
waitForCondition(function() content.document.getElementById('p2').innerHTML == "bye", MixedTest3D, "Waited too long for mixed image to load in Test 3");
|
||||
}
|
||||
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");
|
||||
MixedTest4();
|
||||
}
|
||||
|
||||
// Location change - User override on one page doesn't propogate to another page after location change.
|
||||
function MixedTest4() {
|
||||
gTestBrowser.removeEventListener("load", MixedTest3B, true);
|
||||
gTestBrowser.addEventListener("load", MixedTest4A, true);
|
||||
var url = gHttpTestRoot + "file_bug822367_4.html";
|
||||
gTestBrowser.contentWindow.location = url;
|
||||
}
|
||||
function MixedTest4A() {
|
||||
gTestBrowser.removeEventListener("load", MixedTest4A, true);
|
||||
gTestBrowser.addEventListener("load", MixedTest4B, true);
|
||||
var notification = PopupNotifications.getNotification("mixed-content-blocked", gTestBrowser);
|
||||
ok(notification, "Mixed Content Doorhanger doesn't appear for Test 4");
|
||||
notification.secondaryActions[0].callback();
|
||||
}
|
||||
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("mixed-content-blocked", gTestBrowser);
|
||||
ok(notification, "Mixed Content Doorhanger doesn't appear after location change in Test 4");
|
||||
waitForCondition(function() content.document.getElementById('p1').innerHTML == "", MixedTest4D, "Mixed script loaded in test 4 after location change!");
|
||||
}
|
||||
function MixedTest4D() {
|
||||
ok(content.document.getElementById('p1').innerHTML == "","p1.innerHTML changed; mixed script loaded after location change in Test 4");
|
||||
MixedTest5();
|
||||
}
|
||||
|
||||
// Mixed script attempts to load in a document.open()
|
||||
function MixedTest5() {
|
||||
gTestBrowser.removeEventListener("load", MixedTest4B, true);
|
||||
gTestBrowser.addEventListener("load", MixedTest5A, true);
|
||||
var url = gHttpTestRoot + "file_bug822367_5.html";
|
||||
gTestBrowser.contentWindow.location = url;
|
||||
}
|
||||
function MixedTest5A() {
|
||||
gTestBrowser.removeEventListener("load", MixedTest5A, true);
|
||||
gTestBrowser.addEventListener("load", MixedTest5B, true);
|
||||
var notification = PopupNotifications.getNotification("mixed-content-blocked", gTestBrowser);
|
||||
ok(notification, "Mixed Content Doorhanger doesn't appear for Test 5");
|
||||
notification.secondaryActions[0].callback();
|
||||
}
|
||||
function MixedTest5B() {
|
||||
waitForCondition(function() content.document.getElementById('p1').innerHTML == "hello", MixedTest5C, "Waited too long for mixed script to run in Test 5");
|
||||
}
|
||||
function MixedTest5C() {
|
||||
ok(content.document.getElementById('p1').innerHTML == "hello","Mixed script didn't load in Test 5");
|
||||
MixedTest6();
|
||||
}
|
||||
|
||||
// Mixed script attempts to load in a document.open() that is within an iframe.
|
||||
function MixedTest6() {
|
||||
gTestBrowser.removeEventListener("load", MixedTest5B, true);
|
||||
gTestBrowser.addEventListener("load", MixedTest6A, true);
|
||||
var url = gHttpTestRoot + "file_bug822367_6.html";
|
||||
gTestBrowser.contentWindow.location = url;
|
||||
}
|
||||
function MixedTest6A() {
|
||||
gTestBrowser.removeEventListener("load", MixedTest6A, true);
|
||||
waitForCondition(function() PopupNotifications.getNotification("mixed-content-blocked", gTestBrowser), MixedTest6B, "waited to long for doorhanger");
|
||||
}
|
||||
|
||||
function MixedTest6B() {
|
||||
var notification = PopupNotifications.getNotification("mixed-content-blocked", gTestBrowser);
|
||||
ok(notification, "Mixed Content Doorhanger doesn't appear for Test 6");
|
||||
gTestBrowser.addEventListener("load", MixedTest6C, true);
|
||||
notification.secondaryActions[0].callback();
|
||||
}
|
||||
|
||||
function MixedTest6C() {
|
||||
gTestBrowser.removeEventListener("load", MixedTest6C, true);
|
||||
waitForCondition(function() content.document.getElementById('f1').contentDocument.getElementById('p1').innerHTML == "hello", MixedTest6D, "Waited too long for mixed script to run in Test 6");
|
||||
}
|
||||
function MixedTest6D() {
|
||||
ok(content.document.getElementById('f1').contentDocument.getElementById('p1').innerHTML == "hello","Mixed script didn't load in Test 6");
|
||||
MixedTestsCompleted();
|
||||
}
|
||||
|
||||
function waitForCondition(condition, nextTest, errorMsg) {
|
||||
var tries = 0;
|
||||
var interval = setInterval(function() {
|
||||
if (tries >= 30) {
|
||||
ok(false, errorMsg);
|
||||
moveOn();
|
||||
}
|
||||
if (condition()) {
|
||||
moveOn();
|
||||
}
|
||||
tries++;
|
||||
}, 100);
|
||||
var moveOn = function() { clearInterval(interval); nextTest(); };
|
||||
}
|
18
content/base/test/file_bug822367_1.html
Normal file
18
content/base/test/file_bug822367_1.html
Normal file
@ -0,0 +1,18 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
Test 1 for Mixed Content Blocker User Override - Mixed Script
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=822367
|
||||
-->
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Test 1 for Bug 822367</title>
|
||||
</head>
|
||||
<body>
|
||||
<div id="testContent">
|
||||
<p id="p1"></p>
|
||||
</div>
|
||||
<script src="http://example.com/tests/content/base/test/file_bug822367_1.js">
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
1
content/base/test/file_bug822367_1.js
Normal file
1
content/base/test/file_bug822367_1.js
Normal file
@ -0,0 +1 @@
|
||||
document.getElementById('p1').innerHTML="hello";
|
16
content/base/test/file_bug822367_2.html
Normal file
16
content/base/test/file_bug822367_2.html
Normal file
@ -0,0 +1,16 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
Test 2 for Mixed Content Blocker User Override - Mixed Display
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=822367
|
||||
-->
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Test 2 for Bug 822367 - Mixed Display</title>
|
||||
</head>
|
||||
<body>
|
||||
<div id="testContent">
|
||||
<img src="http://example.com/tests/image/test/mochitest/blue.png">
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
27
content/base/test/file_bug822367_3.html
Normal file
27
content/base/test/file_bug822367_3.html
Normal file
@ -0,0 +1,27 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
Test 3 for Mixed Content Blocker User Override - Mixed Script and Display
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=822367
|
||||
-->
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Test 3 for Bug 822367</title>
|
||||
<script>
|
||||
function foo() {
|
||||
var x = document.createElement('p');
|
||||
x.setAttribute("id", "p2");
|
||||
x.innerHTML = "bye";
|
||||
document.getElementById("testContent").appendChild(x);
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="testContent">
|
||||
<p id="p1"></p>
|
||||
<img src="http://example.com/tests/image/test/mochitest/blue.png" onload="foo()">
|
||||
</div>
|
||||
<script src="http://example.com/tests/content/base/test/file_bug822367_1.js">
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
18
content/base/test/file_bug822367_4.html
Normal file
18
content/base/test/file_bug822367_4.html
Normal file
@ -0,0 +1,18 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
Test 4 for Mixed Content Blocker User Override - Mixed Script and Display
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=822367
|
||||
-->
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Test 4 for Bug 822367</title>
|
||||
</head>
|
||||
<body>
|
||||
<div id="testContent">
|
||||
<p id="p1"></p>
|
||||
</div>
|
||||
<script src="http://example.com/tests/content/base/test/file_bug822367_4.js">
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
1
content/base/test/file_bug822367_4.js
Normal file
1
content/base/test/file_bug822367_4.js
Normal file
@ -0,0 +1 @@
|
||||
document.location = "https://example.com/tests/content/base/test/file_bug822367_4B.html";
|
18
content/base/test/file_bug822367_4B.html
Normal file
18
content/base/test/file_bug822367_4B.html
Normal file
@ -0,0 +1,18 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
Test 4B for Mixed Content Blocker User Override - Location Changed
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=822367
|
||||
-->
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Test 4B Location Change for Bug 822367</title>
|
||||
</head>
|
||||
<body>
|
||||
<div id="testContent">
|
||||
<p id="p1"></p>
|
||||
</div>
|
||||
<script src="http://example.com/tests/content/base/test/file_bug822367_1.js">
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
24
content/base/test/file_bug822367_5.html
Normal file
24
content/base/test/file_bug822367_5.html
Normal file
@ -0,0 +1,24 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
Test 5 for Mixed Content Blocker User Override - Mixed Script in document.open()
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=822367
|
||||
-->
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Test 5 for Bug 822367</title>
|
||||
<script>
|
||||
function createDoc()
|
||||
{
|
||||
var doc=document.open("text/html","replace");
|
||||
doc.write('<!DOCTYPE html><html><body><p id="p1">This is some content</p><script src="http://example.com/tests/content/base/test/file_bug822367_1.js">\<\/script\>\<\/body>\<\/html>');
|
||||
doc.close();
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="testContent">
|
||||
<img src="https://example.com/tests/image/test/mochitest/blue.png" onload="createDoc()">
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
16
content/base/test/file_bug822367_6.html
Normal file
16
content/base/test/file_bug822367_6.html
Normal file
@ -0,0 +1,16 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
Test 6 for Mixed Content Blocker User Override - Mixed Script in document.open() within an iframe
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=822367
|
||||
-->
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Test 6 for Bug 822367</title>
|
||||
</head>
|
||||
<body>
|
||||
<div id="testContent">
|
||||
<iframe name="f1" id="f1" src="https://example.com/tests/content/base/test/file_bug822367_5.html"></iframe>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in New Issue
Block a user