Bug 1631405 - Update tests to account for security UI only living in the parent process. r=kmag,ckerschb,webcompat-reviewers,twisniewski

This is mostly changes to handle retrieving the security state asynchronously via the parent process, needing lots of async/await additions.

It also removes the docshell mixed content flag checks (which don't seem to be used in code, only tests), which are mostly still covered by checks of the security UI.

Differential Revision: https://phabricator.services.mozilla.com/D75448
This commit is contained in:
Matt Woodrow 2020-05-27 00:31:25 +00:00
Родитель e060a86c42
Коммит 5cf1f845a8
48 изменённых файлов: 220 добавлений и 309 удалений

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

@ -82,7 +82,6 @@ tags = mcb
support-files =
test-mixedcontent-securityerrors.html
[browser_mixedContentFramesOnHttp.js]
fail-if = fission
tags = mcb
support-files =
file_mixedContentFramesOnHttp.html

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

@ -37,28 +37,6 @@ add_task(async function blockMixedActiveContentTest() {
let tab = await BrowserTestUtils.openNewForegroundTab(gBrowser, TEST_URI);
gTestBrowser = gBrowser.getBrowserForTab(tab);
await SpecialPowers.spawn(gTestBrowser, [], function() {
is(
docShell.hasMixedDisplayContentBlocked,
false,
"hasMixedDisplayContentBlocked flag has been set"
);
is(
docShell.hasMixedActiveContentBlocked,
true,
"hasMixedActiveContentBlocked flag has been set"
);
is(
docShell.hasMixedDisplayContentLoaded,
true,
"hasMixedDisplayContentLoaded flag has been set"
);
is(
docShell.hasMixedActiveContentLoaded,
false,
"hasMixedActiveContentLoaded flag has been set"
);
});
await assertMixedContentBlockingState(gTestBrowser, {
activeLoaded: false,
activeBlocked: true,
@ -72,28 +50,6 @@ add_task(async function blockMixedActiveContentTest() {
gBrowser.reload();
await BrowserTestUtils.browserLoaded(gTestBrowser);
await SpecialPowers.spawn(gTestBrowser, [], function() {
is(
docShell.hasMixedDisplayContentBlocked,
true,
"hasMixedDisplayContentBlocked flag has been set"
);
is(
docShell.hasMixedActiveContentBlocked,
true,
"hasMixedActiveContentBlocked flag has been set"
);
is(
docShell.hasMixedDisplayContentLoaded,
false,
"hasMixedDisplayContentLoaded flag has been set"
);
is(
docShell.hasMixedActiveContentLoaded,
false,
"hasMixedActiveContentLoaded flag has been set"
);
});
await assertMixedContentBlockingState(gTestBrowser, {
activeLoaded: false,
activeBlocked: true,
@ -107,28 +63,6 @@ add_task(async function overrideMCB() {
gIdentityHandler.disableMixedContentProtection();
await BrowserTestUtils.browserLoaded(gTestBrowser);
await SpecialPowers.spawn(gTestBrowser, [], function() {
is(
docShell.hasMixedDisplayContentLoaded,
true,
"hasMixedDisplayContentLoaded flag has not been set"
);
is(
docShell.hasMixedActiveContentLoaded,
true,
"hasMixedActiveContentLoaded flag has not been set"
);
is(
docShell.hasMixedDisplayContentBlocked,
false,
"second hasMixedDisplayContentBlocked flag has been set"
);
is(
docShell.hasMixedActiveContentBlocked,
false,
"second hasMixedActiveContentBlocked flag has been set"
);
});
await assertMixedContentBlockingState(gTestBrowser, {
activeLoaded: true,
activeBlocked: false,

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

@ -55,19 +55,6 @@ add_task(async function allowLoopbackMixedContent() {
const tab = await BrowserTestUtils.openNewForegroundTab(gBrowser, TEST_URL);
const browser = gBrowser.getBrowserForTab(tab);
await SpecialPowers.spawn(browser, [], function() {
is(
docShell.hasMixedDisplayContentBlocked,
false,
"hasMixedDisplayContentBlocked not set"
);
is(
docShell.hasMixedActiveContentBlocked,
false,
"hasMixedActiveContentBlocked not set"
);
});
// Check that loopback content served from the cache is not blocked.
await SpecialPowers.spawn(browser, [LOOPBACK_PNG_URL], async function(
loopbackPNGUrl

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

@ -33,19 +33,6 @@ add_task(async function allowOnionMixedContent() {
).catch(Cu.reportError);
const browser = gBrowser.getBrowserForTab(tab);
await SpecialPowers.spawn(browser, [], function() {
is(
docShell.hasMixedDisplayContentBlocked,
false,
"hasMixedDisplayContentBlocked not set"
);
is(
docShell.hasMixedActiveContentBlocked,
false,
"hasMixedActiveContentBlocked not set"
);
});
await assertMixedContentBlockingState(browser, {
activeBlocked: false,
activeLoaded: false,

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

@ -11,23 +11,23 @@
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="text/javascript">
function checkLoadStates() {
var ui = SpecialPowers.wrap(window).docShell.securityUI;
async function checkLoadStates() {
let state = await SpecialPowers.getSecurityState(window);
var loadedMixedActive = ui &&
!!(ui.state & SpecialPowers.Ci.nsIWebProgressListener.STATE_LOADED_MIXED_ACTIVE_CONTENT);
var loadedMixedActive =
!!(state & SpecialPowers.Ci.nsIWebProgressListener.STATE_LOADED_MIXED_ACTIVE_CONTENT);
is(loadedMixedActive, false, "OK: Should not load mixed active content!");
var blockedMixedActive = ui &&
!!(ui.state & SpecialPowers.Ci.nsIWebProgressListener.STATE_BLOCKED_MIXED_ACTIVE_CONTENT);
var blockedMixedActive =
!!(state & SpecialPowers.Ci.nsIWebProgressListener.STATE_BLOCKED_MIXED_ACTIVE_CONTENT);
is(blockedMixedActive, false, "OK: Should not block mixed active content!");
var loadedMixedDisplay = ui &&
!!(ui.state & SpecialPowers.Ci.nsIWebProgressListener.STATE_LOADED_MIXED_DISPLAY_CONTENT);
var loadedMixedDisplay =
!!(state & SpecialPowers.Ci.nsIWebProgressListener.STATE_LOADED_MIXED_DISPLAY_CONTENT);
is(loadedMixedDisplay, false, "OK: Should not load mixed display content!");
var blockedMixedDisplay = ui &&
!!(ui.state & SpecialPowers.Ci.nsIWebProgressListener.STATE_BLOCKED_MIXED_DISPLAY_CONTENT);
var blockedMixedDisplay =
!!(state & SpecialPowers.Ci.nsIWebProgressListener.STATE_BLOCKED_MIXED_DISPLAY_CONTENT);
is(blockedMixedDisplay, false, "OK: Should not block mixed display content!");
var newValue = "Verifying MCB does not trigger warning/error for an http page with https css that includes http font";

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

@ -11,23 +11,23 @@
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="text/javascript">
function checkLoadStates() {
var ui = SpecialPowers.wrap(window).docShell.securityUI;
async function checkLoadStates() {
let state = await SpecialPowers.getSecurityState(window);
var loadedMixedActive = ui &&
!!(ui.state & SpecialPowers.Ci.nsIWebProgressListener.STATE_LOADED_MIXED_ACTIVE_CONTENT);
var loadedMixedActive =
!!(state & SpecialPowers.Ci.nsIWebProgressListener.STATE_LOADED_MIXED_ACTIVE_CONTENT);
is(loadedMixedActive, false, "OK: Should not load mixed active content!");
var blockedMixedActive = ui &&
!!(ui.state & SpecialPowers.Ci.nsIWebProgressListener.STATE_BLOCKED_MIXED_ACTIVE_CONTENT);
var blockedMixedActive =
!!(state & SpecialPowers.Ci.nsIWebProgressListener.STATE_BLOCKED_MIXED_ACTIVE_CONTENT);
is(blockedMixedActive, false, "OK: Should not block mixed active content!");
var loadedMixedDisplay = ui &&
!!(ui.state & SpecialPowers.Ci.nsIWebProgressListener.STATE_LOADED_MIXED_DISPLAY_CONTENT);
var loadedMixedDisplay =
!!(state & SpecialPowers.Ci.nsIWebProgressListener.STATE_LOADED_MIXED_DISPLAY_CONTENT);
is(loadedMixedDisplay, false, "OK: Should not load mixed display content!");
var blockedMixedDisplay = ui &&
!!(ui.state & SpecialPowers.Ci.nsIWebProgressListener.STATE_BLOCKED_MIXED_DISPLAY_CONTENT);
var blockedMixedDisplay =
!!(state & SpecialPowers.Ci.nsIWebProgressListener.STATE_BLOCKED_MIXED_DISPLAY_CONTENT);
is(blockedMixedDisplay, false, "OK: Should not block mixed display content!");
var newValue = "Verifying MCB does not trigger warning/error for an http page ";

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

@ -11,23 +11,23 @@
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="text/javascript">
function checkLoadStates() {
var ui = SpecialPowers.wrap(window).docShell.securityUI;
async function checkLoadStates() {
let state = await SpecialPowers.getSecurityState(window);
var loadedMixedActive = ui &&
!!(ui.state & SpecialPowers.Ci.nsIWebProgressListener.STATE_LOADED_MIXED_ACTIVE_CONTENT);
var loadedMixedActive =
!!(state & SpecialPowers.Ci.nsIWebProgressListener.STATE_LOADED_MIXED_ACTIVE_CONTENT);
is(loadedMixedActive, false, "OK: Should not load mixed active content!");
var blockedMixedActive = ui &&
!!(ui.state & SpecialPowers.Ci.nsIWebProgressListener.STATE_BLOCKED_MIXED_ACTIVE_CONTENT);
var blockedMixedActive =
!!(state & SpecialPowers.Ci.nsIWebProgressListener.STATE_BLOCKED_MIXED_ACTIVE_CONTENT);
is(blockedMixedActive, false, "OK: Should not block mixed active content!");
var loadedMixedDisplay = ui &&
!!(ui.state & SpecialPowers.Ci.nsIWebProgressListener.STATE_LOADED_MIXED_DISPLAY_CONTENT);
var loadedMixedDisplay =
!!(state & SpecialPowers.Ci.nsIWebProgressListener.STATE_LOADED_MIXED_DISPLAY_CONTENT);
is(loadedMixedDisplay, false, "OK: Should not load mixed display content!");
var blockedMixedDisplay = ui &&
!!(ui.state & SpecialPowers.Ci.nsIWebProgressListener.STATE_BLOCKED_MIXED_DISPLAY_CONTENT);
var blockedMixedDisplay =
!!(state & SpecialPowers.Ci.nsIWebProgressListener.STATE_BLOCKED_MIXED_DISPLAY_CONTENT);
is(blockedMixedDisplay, false, "OK: Should not block mixed display content!");
var newValue = "Verifying MCB does not trigger warning/error for an http page with https css that includes http image";

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

@ -85,16 +85,6 @@ add_task(async function test_opened_page() {
);
let docShell = content.docShell;
is(
typeof docShell.hasMixedActiveContentBlocked,
"boolean",
"docShell.hasMixedActiveContentBlocked is available"
);
is(
typeof docShell.hasMixedDisplayContentBlocked,
"boolean",
"docShell.hasMixedDisplayContentBlocked is available"
);
is(
typeof docShell.getHasTrackingContentBlocked,
"function",

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

@ -95,7 +95,8 @@ function step1B(aWebProgress, aRequest, aLocation, aFlags) {
"This page is an error page.");
ok(!(aWebProgress.QueryInterface(Ci.nsIDocShell)
.securityUI.state &
.browsingContext
.secureBrowserUI.state &
Ci.nsIWebProgressListener.STATE_IS_SECURE),
"This is not a secure page (1)");
@ -124,7 +125,8 @@ function step2B(aWebProgress, aRequest, aLocation, aFlags) {
"This page is not an error page.");
ok((aWebProgress.QueryInterface(Ci.nsIDocShell)
.securityUI.state &
.browsingContext
.secureBrowserUI.state &
Ci.nsIWebProgressListener.STATE_IS_SECURE),
"This is a secure page (2)");
@ -154,7 +156,8 @@ function step3B(aWebProgress, aRequest, aLocation, aFlags) {
"This page is not an error page.");
ok((aWebProgress.QueryInterface(Ci.nsIDocShell)
.securityUI.state &
.browsingContext
.secureBrowserUI.state &
Ci.nsIWebProgressListener.STATE_IS_SECURE),
"This is a secure page (3)");
@ -184,7 +187,8 @@ function step4B(aWebProgress, aRequest, aLocation, aFlags) {
"This page is an error page.");
ok(!(aWebProgress.QueryInterface(Ci.nsIDocShell)
.securityUI.state &
.browsingContext
.secureBrowserUI.state &
Ci.nsIWebProgressListener.STATE_IS_SECURE),
"This is not a secure page (4)");

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

@ -21,7 +21,6 @@ support-files =
file_redirect_handler.sjs
[test_main.html]
fail-if = fission #Bug 1580771, object did not follow block_active_content pref
skip-if =
(toolkit == 'android') || webrender || (verify && !debug && (os == 'linux')) || # Android: TIMED_OUT; bug 1402554
tsan # Times out / Memory consumption, bug 1612707

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

@ -16,7 +16,7 @@
}, 0);
};
function afterNavigationTest()
async function afterNavigationTest()
{
}

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

@ -9,15 +9,15 @@
<script class="testbody" type="text/javascript">
"use strict";
function runTest()
async function runTest()
{
isSecurityState("secure", "secure page after insecure download and insecure subcontent still secure");
await isSecurityState("secure", "secure page after insecure download and insecure subcontent still secure");
finish();
}
function afterNavigationTest()
async function afterNavigationTest()
{
isSecurityState("secure", "still secure after back/forward");
await isSecurityState("secure", "still secure after back/forward");
finish();
}

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

@ -31,17 +31,17 @@ var hasMixedActiveContent = false;
// Internal variables
var _windowCount = 0;
window.onload = function onLoad() {
window.onload = async function onLoad() {
if (location.search == "?runtest") {
try {
if (history.length == 1) {
// Each test that includes this helper file is supposed to define
// runTest(). See the top level comment.
runTest(); // eslint-disable-line no-undef
await runTest(); // eslint-disable-line no-undef
} else {
// Each test that includes this helper file is supposed to define
// afterNavigationTest(). See the top level comment.
afterNavigationTest(); // eslint-disable-line no-undef
await afterNavigationTest(); // eslint-disable-line no-undef
}
} catch (ex) {
ok(false, "Exception thrown during test: " + ex);
@ -137,21 +137,19 @@ function is(a, b, message) {
}
}
function isSecurityState(expectedState, message, test) {
async function isSecurityState(expectedState, message, test) {
if (!test) {
test = ok;
}
let ui = SpecialPowers.wrap(window).docShell.securityUI;
let state = await SpecialPowers.getSecurityState(window);
let isInsecure =
!ui || ui.state & SpecialPowers.Ci.nsIWebProgressListener.STATE_IS_INSECURE;
state & SpecialPowers.Ci.nsIWebProgressListener.STATE_IS_INSECURE;
let isBroken =
ui && ui.state & SpecialPowers.Ci.nsIWebProgressListener.STATE_IS_BROKEN;
state & SpecialPowers.Ci.nsIWebProgressListener.STATE_IS_BROKEN;
let isEV =
ui &&
ui.state &
SpecialPowers.Ci.nsIWebProgressListener.STATE_IDENTITY_EV_TOPLEVEL;
state & SpecialPowers.Ci.nsIWebProgressListener.STATE_IDENTITY_EV_TOPLEVEL;
let gotState = "secure";
if (isInsecure) {
@ -176,19 +174,19 @@ function isSecurityState(expectedState, message, test) {
break;
case "broken":
test(
ui && !isInsecure && isBroken && !isEV,
!isInsecure && isBroken && !isEV,
"for 'broken' expected flags [0,1,0], " + (message || "")
);
break;
case "secure":
test(
ui && !isInsecure && !isBroken && !isEV,
!isInsecure && !isBroken && !isEV,
"for 'secure' expected flags [0,0,0], " + (message || "")
);
break;
case "EV":
test(
ui && !isInsecure && !isBroken && isEV,
!isInsecure && !isBroken && isEV,
"for 'EV' expected flags [0,0,1], " + (message || "")
);
break;
@ -199,8 +197,8 @@ function isSecurityState(expectedState, message, test) {
function waitForSecurityState(expectedState, callback) {
let roundsLeft = 200; // Wait for 20 seconds (=200*100ms)
let interval = window.setInterval(() => {
isSecurityState(expectedState, "", isok => {
let interval = window.setInterval(async () => {
await isSecurityState(expectedState, "", isok => {
if (isok) {
roundsLeft = 0;
}

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

@ -11,9 +11,9 @@
hasMixedActiveContent = true;
function runTest()
async function runTest()
{
isSecurityState("secure");
await isSecurityState("secure");
window.setTimeout(function () {
let newElement = document.createElement("script");
newElement.src = "http://example.org/tests/security/manager/ssl/tests/" +
@ -22,9 +22,9 @@
}, 0);
}
function afterNavigationTest()
async function afterNavigationTest()
{
isSecurityState("secure", "when we navigate back, we're loading our secure page again and not loading an insecure script, so our security state is secure");
await isSecurityState("secure", "when we navigate back, we're loading our secure page again and not loading an insecure script, so our security state is secure");
finish();
}

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

@ -16,7 +16,7 @@
// We don't want to go through the navigation back/forward test
bypassNavigationTest = true;
function runTest() {
async function runTest() {
let script = SpecialPowers.loadChromeScript(function() {
const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
// Force download to be w/o user assistance for our testing mime type
@ -60,7 +60,7 @@
});
}
function afterNavigationTest() {}
async function afterNavigationTest() {}
testCleanUp = function cleanup() {
SpecialPowers.loadChromeScript(function() {

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

@ -13,18 +13,18 @@
<script class="testbody" type="text/javascript">
"use strict";
function runTest()
async function runTest()
{
SpecialPowers.pushPrefEnv(
{"set": [["security.mixed_content.upgrade_display_content", false]]},
null);
isSecurityState("broken", "broken");
await isSecurityState("broken", "broken");
finish();
}
function afterNavigationTest()
async function afterNavigationTest()
{
isSecurityState("broken", "broken after navigation");
await isSecurityState("broken", "broken after navigation");
finish();
}

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

@ -25,15 +25,15 @@
img1.src = "https://example.com/tests/security/manager/ssl/tests/mochitest/mixedcontent/moonsurface.jpg";
};
function runTest()
async function runTest()
{
isSecurityState("secure", "secure");
await isSecurityState("secure", "secure");
finish();
}
function afterNavigationTest()
async function afterNavigationTest()
{
isSecurityState("secure", "secure after navigation");
await isSecurityState("secure", "secure after navigation");
finish();
}

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

@ -13,15 +13,15 @@
<script class="testbody" type="text/javascript">
"use strict";
function runTest()
async function runTest()
{
isSecurityState("secure", "data <img> doesn't break security");
await isSecurityState("secure", "data <img> doesn't break security");
finish();
}
function afterNavigationTest()
async function afterNavigationTest()
{
isSecurityState("secure", "still secure after navigation");
await isSecurityState("secure", "still secure after navigation");
finish();
}

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

@ -15,19 +15,19 @@
loadAsInsecure = true;
function runTest()
async function runTest()
{
window.location = "https://example.com/tests/security/manager/ssl/tests/mochitest/mixedcontent/nocontent.sjs";
window.setTimeout(function() {
isSecurityState("insecure", "location.href doesn't effect the security state");
window.setTimeout(async () => {
await isSecurityState("insecure", "location.href doesn't effect the security state");
is(document.body.innerHTML, "This is an unsecure page!\n", "Document has not changed content");
finish();
}, 1000);
}
function afterNavigationTest()
async function afterNavigationTest()
{
isSecurityState("insecure", "still not secure after navigation");
await isSecurityState("insecure", "still not secure after navigation");
is(document.body.innerHTML, "This is an unsecure page!\n", "Document has not changed content");
finish();
}

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

@ -19,15 +19,15 @@
<script class="testbody" type="text/javascript">
"use strict";
function runTest()
async function runTest()
{
isSecurityState("broken", "insecure content added by :before styling breaks security");
await isSecurityState("broken", "insecure content added by :before styling breaks security");
finish();
}
function afterNavigationTest()
async function afterNavigationTest()
{
isSecurityState("broken", "security still broken after navigation");
await isSecurityState("broken", "security still broken after navigation");
finish();
}

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

@ -20,15 +20,15 @@
<script class="testbody" type="text/javascript">
"use strict";
function runTest()
async function runTest()
{
isSecurityState("broken", "insecure content added by :before styling breaks security");
await isSecurityState("broken", "insecure content added by :before styling breaks security");
finish();
}
function afterNavigationTest()
async function afterNavigationTest()
{
isSecurityState("broken", "security still broken after navigation");
await isSecurityState("broken", "security still broken after navigation");
finish();
}

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

@ -17,23 +17,23 @@
SimpleTest.expectAssertions(0, 1);
}
function runTest()
async function runTest()
{
isSecurityState("secure");
await isSecurityState("secure");
document.getElementById("para").style.content =
"url('http://example.com/tests/security/manager/ssl/tests/mochitest/mixedcontent/moonsurface.jpg')";
waitForSecurityState("broken", function()
waitForSecurityState("broken", async () =>
{
isSecurityState("broken", "insecure content added by styling breaks security");
await isSecurityState("broken", "insecure content added by styling breaks security");
finish();
});
}
function afterNavigationTest()
async function afterNavigationTest()
{
is(document.getElementById("para").style.content, "");
isSecurityState("secure", "security full after navigation");
await isSecurityState("secure", "security full after navigation");
finish();
}

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

@ -13,15 +13,15 @@
<script class="testbody" type="text/javascript">
"use strict";
function runTest()
async function runTest()
{
isSecurityState("broken", "insecure <img> written dynamically breaks security");
await isSecurityState("broken", "insecure <img> written dynamically breaks security");
finish();
}
function afterNavigationTest()
async function afterNavigationTest()
{
isSecurityState("broken", "security still broken after navigation");
await isSecurityState("broken", "security still broken after navigation");
finish();
}

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

@ -15,15 +15,15 @@
hasMixedActiveContent = true;
function runTest()
async function runTest()
{
isSecurityState("broken", "insecure iframe written dynamically breaks security");
await isSecurityState("broken", "insecure iframe written dynamically breaks security");
finish();
}
function afterNavigationTest()
async function afterNavigationTest()
{
isSecurityState("broken", "security still broken after navigation");
await isSecurityState("broken", "security still broken after navigation");
finish();
}

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

@ -13,28 +13,28 @@
<script class="testbody" type="text/javascript">
"use strict";
function runTest()
async function runTest()
{
isSecurityState("secure");
await isSecurityState("secure");
window.setTimeout(function() {
// Don't do this synchronously from onload handler
document.getElementById("image1").src =
"http://example.com/tests/security/manager/ssl/tests/mochitest/mixedcontent/moonsurface.jpg";
}, 0);
waitForSecurityState("broken", function()
waitForSecurityState("broken", async () =>
{
isSecurityState("broken", "src='http://...' changed to broken");
await isSecurityState("broken", "src='http://...' changed to broken");
finish();
});
}
function afterNavigationTest()
async function afterNavigationTest()
{
is(document.getElementById("image1").src,
"https://example.com/tests/security/manager/ssl/tests/mochitest/mixedcontent/moonsurface.jpg",
"img.src secure again");
isSecurityState("secure", "security full after navigation");
await isSecurityState("secure", "security full after navigation");
finish();
}

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

@ -15,17 +15,17 @@
hasMixedActiveContent = true;
function runTest()
async function runTest()
{
isSecurityState("secure");
window.setTimeout(() => {
await isSecurityState("secure");
window.setTimeout(async () => {
try {
let req = new XMLHttpRequest();
req.open("GET", "http://example.com/tests/security/manager/ssl/tests/mochitest/mixedcontent/alloworigin.sjs", false);
req.send(null);
// Change should be immediate, the request was sent synchronously
isSecurityState("broken", "security broken after insecure XHR");
await isSecurityState("broken", "security broken after insecure XHR");
} catch (ex) {
ok(false, ex);
}
@ -34,9 +34,9 @@
}, 0);
}
function afterNavigationTest()
async function afterNavigationTest()
{
isSecurityState("secure", "security full after navigation");
await isSecurityState("secure", "security full after navigation");
finish();
}

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

@ -15,24 +15,24 @@
// This test, as is, equals to https://kuix.de/misc/test17/358438.php
function runTest()
async function runTest()
{
isSecurityState("secure");
await isSecurityState("secure");
document.body.background =
"http://example.com/tests/security/manager/ssl/tests/mochitest/mixedcontent/moonsurface.jpg";
waitForSecurityState("broken", function () {
isSecurityState("broken", "document.body.background='http://...' changed to broken");
waitForSecurityState("broken", async () => {
await isSecurityState("broken", "document.body.background='http://...' changed to broken");
finish();
});
}
function afterNavigationTest()
async function afterNavigationTest()
{
is(document.body.background,
"https://example.com/tests/security/manager/ssl/tests/mochitest/mixedcontent/moonsurface.jpg",
"document backround secure again");
isSecurityState("secure", "secure after re-navigation");
await isSecurityState("secure", "secure after re-navigation");
finish();
}

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

@ -15,13 +15,13 @@
hasMixedActiveContent = true;
function runTest()
async function runTest()
{
isSecurityState("secure");
await isSecurityState("secure");
let self = window;
let iframe = document.getElementById("iframe1");
iframe.onload = function() {
self.isSecurityState("broken", "src='redirect to unsecure' changed to broken");
iframe.onload = async () => {
await self.isSecurityState("broken", "src='redirect to unsecure' changed to broken");
self.finish();
};
@ -29,9 +29,9 @@
"https://example.com/tests/security/manager/ssl/tests/mochitest/mixedcontent/iframeunsecredirect.sjs";
}
function afterNavigationTest()
async function afterNavigationTest()
{
isSecurityState("broken", "security still broken after navigation");
await isSecurityState("broken", "security still broken after navigation");
finish();
}

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

@ -15,24 +15,24 @@
// This test, as is, equals to https://kuix.de/misc/test17/358438.php
function runTest()
async function runTest()
{
isSecurityState("secure");
await isSecurityState("secure");
document.getElementById("image1").src =
"http://example.com/tests/security/manager/ssl/tests/mochitest/mixedcontent/moonsurface.jpg";
window.setTimeout(function() {
isSecurityState("broken", "src='http://...' changed to broken");
window.setTimeout(async () => {
await isSecurityState("broken", "src='http://...' changed to broken");
finish();
}, 500);
}
function afterNavigationTest()
async function afterNavigationTest()
{
is(document.getElementById("image1").src,
"https://example.com/tests/security/manager/ssl/tests/mochitest/mixedcontent/moonsurface.jpg",
"img.src secure again");
isSecurityState("secure", "security full after navigation");
await isSecurityState("secure", "security full after navigation");
finish();
}

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

@ -16,15 +16,15 @@
(new Image()).src =
"http://example.com/tests/security/manager/ssl/tests/mochitest/mixedcontent/moonsurface.jpg";
function runTest()
async function runTest()
{
isSecurityState("broken", "(new Image()).src='http://...' changed to broken");
await isSecurityState("broken", "(new Image()).src='http://...' changed to broken");
finish();
}
function afterNavigationTest()
async function afterNavigationTest()
{
isSecurityState("broken", "security broken after navigation");
await isSecurityState("broken", "security broken after navigation");
finish();
}

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

@ -9,24 +9,24 @@
<script class="testbody" type="text/javascript">
"use strict";
function runTest()
async function runTest()
{
isSecurityState("secure");
await isSecurityState("secure");
document.getElementById("image1").src =
"https://example.com/tests/security/manager/ssl/tests/mochitest/mixedcontent/imgunsecredirect.sjs";
window.setTimeout(function() {
isSecurityState("broken", "src='redirect to unsecure' changed to broken");
window.setTimeout(async () => {
await isSecurityState("broken", "src='redirect to unsecure' changed to broken");
finish();
}, 500);
}
function afterNavigationTest()
async function afterNavigationTest()
{
is(document.getElementById("image1").src,
"https://example.com/tests/security/manager/ssl/tests/mochitest/mixedcontent/moonsurface.jpg",
"img.src secure again");
isSecurityState("secure", "security full after navigation");
await isSecurityState("secure", "security full after navigation");
finish();
}

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

@ -13,25 +13,25 @@
<script class="testbody" type="text/javascript">
"use strict";
function runTest()
async function runTest()
{
isSecurityState("secure");
await isSecurityState("secure");
window.setTimeout(function () {
document.getElementById("buddy").innerHTML =
"<img id='image1' src='http://example.com/tests/security/manager/ssl/tests/mochitest/mixedcontent/moonsurface.jpg' />";
}, 1);
waitForSecurityState("broken", function () {
isSecurityState("broken", "innerHTML loading insecure changed to broken");
waitForSecurityState("broken", async () => {
await isSecurityState("broken", "innerHTML loading insecure changed to broken");
finish();
});
}
function afterNavigationTest()
async function afterNavigationTest()
{
is(document.getElementById("buddy").innerHTML, "\n", "innerHTML back to previous");
isSecurityState("secure");
await isSecurityState("secure");
finish();
}

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

@ -13,23 +13,23 @@
<script class="testbody" type="text/javascript">
"use strict";
function runTest()
async function runTest()
{
isSecurityState("secure");
await isSecurityState("secure");
document.getElementById("buddy").innerHTML =
"<img id='image1' src='http://example.com/tests/security/manager/ssl/tests/mochitest/mixedcontent/moonsurface.jpg' />";
window.setTimeout(function() {
isSecurityState("broken", "innerHTML loading insecure changed to broken");
window.setTimeout(async () => {
await isSecurityState("broken", "innerHTML loading insecure changed to broken");
finish();
}, 500);
}
function afterNavigationTest()
async function afterNavigationTest()
{
is(document.getElementById("buddy").innerHTML, "\n", "innerHTML back to previous");
isSecurityState("secure");
await isSecurityState("secure");
finish();
}

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

@ -13,15 +13,15 @@
<script class="testbody" type="text/javascript">
"use strict";
function runTest()
async function runTest()
{
isSecurityState("secure", "javascript: <img> should not break security");
await isSecurityState("secure", "javascript: <img> should not break security");
finish();
}
function afterNavigationTest()
async function afterNavigationTest()
{
isSecurityState("secure", "Still secure after renavigation");
await isSecurityState("secure", "Still secure after renavigation");
finish();
}

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

@ -19,15 +19,15 @@
// Navigation test goes over an insecure page, test state leak
navigateToInsecure = true;
function runTest()
async function runTest()
{
isSecurityState("secure", "insecure <img> load breaks security");
await isSecurityState("secure", "insecure <img> load breaks security");
finish();
}
function afterNavigationTest()
async function afterNavigationTest()
{
isSecurityState("secure", "security still broken after navigation");
await isSecurityState("secure", "security still broken after navigation");
finish();
}

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

@ -15,15 +15,15 @@
loadAsInsecure = true;
function runTest()
async function runTest()
{
isSecurityState("insecure", "left insecure");
await isSecurityState("insecure", "left insecure");
finish();
}
function afterNavigationTest()
async function afterNavigationTest()
{
isSecurityState("insecure", "left insecure after renavigation");
await isSecurityState("insecure", "left insecure after renavigation");
finish();
}

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

@ -15,15 +15,15 @@
// This test, as is, equals to https://kuix.de/misc/test17/358438.php
function runTest()
async function runTest()
{
isSecurityState("broken", "security broken");
await isSecurityState("broken", "security broken");
finish();
}
function afterNavigationTest()
async function afterNavigationTest()
{
isSecurityState("broken", "security after navigation");
await isSecurityState("broken", "security after navigation");
finish();
}

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

@ -18,15 +18,15 @@
hasMixedActiveContent = true;
function runTest()
async function runTest()
{
isSecurityState("broken", "insecure <img> load breaks security");
await isSecurityState("broken", "insecure <img> load breaks security");
finish();
}
function afterNavigationTest()
async function afterNavigationTest()
{
isSecurityState("broken", "security still broken after navigation");
await isSecurityState("broken", "security still broken after navigation");
finish();
}

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

@ -15,15 +15,15 @@
hasMixedActiveContent = true;
function runTest()
async function runTest()
{
isSecurityState("broken", "insecure <iframe> load breaks security");
await isSecurityState("broken", "insecure <iframe> load breaks security");
finish();
}
function afterNavigationTest()
async function afterNavigationTest()
{
isSecurityState("broken", "security still broken after navigation");
await isSecurityState("broken", "security still broken after navigation");
finish();
}

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

@ -15,15 +15,15 @@
hasMixedActiveContent = true;
function runTest()
async function runTest()
{
isSecurityState("broken", "insecure <iframe> load breaks security");
await isSecurityState("broken", "insecure <iframe> load breaks security");
finish();
}
function afterNavigationTest()
async function afterNavigationTest()
{
isSecurityState("broken", "security still broken after navigation");
await isSecurityState("broken", "security still broken after navigation");
finish();
}

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

@ -9,20 +9,20 @@
<script class="testbody" type="text/javascript">
"use strict";
function runTest()
async function runTest()
{
window.setTimeout(function()
window.setTimeout(async () =>
{
isSecurityState("broken", "insecure meta-tag <iframe> load breaks security");
await isSecurityState("broken", "insecure meta-tag <iframe> load breaks security");
finish();
}, 500);
}
function afterNavigationTest()
async function afterNavigationTest()
{
window.setTimeout(function()
window.setTimeout(async () =>
{
isSecurityState("broken", "security still broken after navigation");
await isSecurityState("broken", "security still broken after navigation");
finish();
}, 500);
}

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

@ -15,15 +15,15 @@
hasMixedActiveContent = true;
function runTest()
async function runTest()
{
isSecurityState("broken", "insecure <iframe> load breaks security");
await isSecurityState("broken", "insecure <iframe> load breaks security");
finish();
}
function afterNavigationTest()
async function afterNavigationTest()
{
isSecurityState("broken", "security still broken after navigation");
await isSecurityState("broken", "security still broken after navigation");
finish();
}

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

@ -13,15 +13,15 @@
<script class="testbody" type="text/javascript">
"use strict";
function runTest()
async function runTest()
{
isSecurityState("broken", "insecure <img> load breaks security");
await isSecurityState("broken", "insecure <img> load breaks security");
finish();
}
function afterNavigationTest()
async function afterNavigationTest()
{
isSecurityState("broken", "security still broken after navigation");
await isSecurityState("broken", "security still broken after navigation");
finish();
}

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

@ -15,15 +15,15 @@
hasMixedActiveContent = true;
function runTest()
async function runTest()
{
isSecurityState("broken", "insecure <img> in an <iframe> load breaks security");
await isSecurityState("broken", "insecure <img> in an <iframe> load breaks security");
finish();
}
function afterNavigationTest()
async function afterNavigationTest()
{
isSecurityState("broken", "security still broken after navigation");
await isSecurityState("broken", "security still broken after navigation");
finish();
}

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

@ -15,15 +15,15 @@
hasMixedActiveContent = true;
function runTest()
async function runTest()
{
isSecurityState("broken", "insecure <img> load breaks security");
await isSecurityState("broken", "insecure <img> load breaks security");
finish();
}
function afterNavigationTest()
async function afterNavigationTest()
{
isSecurityState("broken", "security still broken after navigation");
await isSecurityState("broken", "security still broken after navigation");
finish();
}

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

@ -13,15 +13,15 @@
<script class="testbody" type="text/javascript">
"use strict";
function runTest()
async function runTest()
{
isSecurityState("broken", "insecure <img> load breaks security");
await isSecurityState("broken", "insecure <img> load breaks security");
finish();
}
function afterNavigationTest()
async function afterNavigationTest()
{
isSecurityState("broken", "security still broken after navigation");
await isSecurityState("broken", "security still broken after navigation");
finish();
}

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

@ -1723,6 +1723,14 @@ class SpecialPowersChild extends JSWindowActorChild {
});
}
getSecurityState(target) {
let browsingContext = this._browsingContextForTarget(target);
return this.sendQuery("SecurityState", {
browsingContext,
});
}
_spawnTask(task, args, caller, taskId, imports) {
let sb = new SpecialPowersSandbox(
null,

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

@ -1172,6 +1172,11 @@ class SpecialPowersParent extends JSWindowActorParent {
});
}
case "SecurityState": {
let { browsingContext } = aMessage.data;
return browsingContext.secureBrowserUI.state;
}
case "ProxiedAssert": {
let { taskId, data } = aMessage.data;