зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1622306 - Group cookie console info/warning logs - tests, r=nchevobbe
Differential Revision: https://phabricator.services.mozilla.com/D67904 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
4fa365563a
Коммит
6040af7a0d
|
@ -372,6 +372,7 @@ tags = trackingprotection
|
|||
[browser_webconsole_warn_about_replaced_api.js]
|
||||
[browser_webconsole_warning_group_content_blocking.js]
|
||||
skip-if = fission
|
||||
[browser_webconsole_warning_group_cookies.js]
|
||||
[browser_webconsole_warning_groups_filtering.js]
|
||||
skip-if = (os == "win" && bits == 32) && !debug # Bug 1560261
|
||||
[browser_webconsole_warning_group_multiples.js]
|
||||
|
|
|
@ -0,0 +1,106 @@
|
|||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
// Load a page that generates cookie warning/info messages. See bug 1622306.
|
||||
|
||||
"use strict";
|
||||
requestLongerTimeout(2);
|
||||
|
||||
const TEST_FILE =
|
||||
"browser/devtools/client/webconsole/test/browser/test-warning-groups.html";
|
||||
|
||||
pushPref("devtools.webconsole.groupWarningMessages", true);
|
||||
|
||||
async function cleanUp() {
|
||||
await new Promise(resolve => {
|
||||
Services.clearData.deleteData(Ci.nsIClearDataService.CLEAR_ALL, value =>
|
||||
resolve()
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
add_task(cleanUp);
|
||||
|
||||
add_task(async function testSameSiteCookieMessage() {
|
||||
const tests = [
|
||||
{
|
||||
pref: true,
|
||||
message1:
|
||||
"Cookie “a” has “sameSite” policy set to “lax” because it is missing a “sameSite” attribute, and “sameSite=lax” is the default value for this attribute.",
|
||||
typeMessage1: ".info",
|
||||
groupLabel:
|
||||
"Some cookies are misusing the “sameSite“ attribute, so it won’t work as expected",
|
||||
message2:
|
||||
"Cookie “b” has “sameSite” policy set to “lax” because it is missing a “sameSite” attribute, and “sameSite=lax” is the default value for this attribute.",
|
||||
},
|
||||
{
|
||||
pref: false,
|
||||
groupLabel:
|
||||
"Some cookies are misusing the recommended “sameSite“ attribute",
|
||||
message1:
|
||||
"Cookie “a” will be soon rejected because it has the “sameSite” attribute set to “none” or an invalid value, without the “secure” attribute.",
|
||||
typeMessage1: ".warn",
|
||||
message2:
|
||||
"Cookie “b” will be soon rejected because it has the “sameSite” attribute set to “none” or an invalid value, without the “secure” attribute.",
|
||||
},
|
||||
];
|
||||
|
||||
for (const test of tests) {
|
||||
info("LaxByDefault: " + test.pref);
|
||||
await pushPref("network.cookie.sameSite.laxByDefault", test.pref);
|
||||
|
||||
const { hud, tab, win } = await openNewWindowAndConsole(
|
||||
"http://example.org/" + TEST_FILE
|
||||
);
|
||||
|
||||
info("Test cookie messages");
|
||||
const onLaxMissingWarningMessage = waitForMessage(
|
||||
hud,
|
||||
test.message1,
|
||||
test.typeMessage1
|
||||
);
|
||||
|
||||
SpecialPowers.spawn(tab.linkedBrowser, [], () => {
|
||||
content.wrappedJSObject.createCookie("a=1");
|
||||
});
|
||||
|
||||
await onLaxMissingWarningMessage;
|
||||
|
||||
ok(true, "The first message was displayed");
|
||||
|
||||
info("Emit a new cookie message to check that it causes a grouping");
|
||||
|
||||
const onCookieSameSiteWarningGroupMessage = waitForMessage(
|
||||
hud,
|
||||
test.groupLabel,
|
||||
".warn"
|
||||
);
|
||||
|
||||
SpecialPowers.spawn(tab.linkedBrowser, [], () => {
|
||||
content.wrappedJSObject.createCookie("b=1");
|
||||
});
|
||||
|
||||
const { node } = await onCookieSameSiteWarningGroupMessage;
|
||||
is(
|
||||
node.querySelector(".warning-group-badge").textContent,
|
||||
"2",
|
||||
"The badge has the expected text"
|
||||
);
|
||||
|
||||
checkConsoleOutputForWarningGroup(hud, [`▶︎⚠ ${test.groupLabel} 2`]);
|
||||
|
||||
info("Open the group");
|
||||
node.querySelector(".arrow").click();
|
||||
await waitFor(() => findMessage(hud, "sameSite"));
|
||||
|
||||
checkConsoleOutputForWarningGroup(hud, [
|
||||
`▼︎⚠ ${test.groupLabel} 2`,
|
||||
`| ${test.message1}`,
|
||||
`| ${test.message2}`,
|
||||
]);
|
||||
|
||||
await win.close();
|
||||
}
|
||||
});
|
||||
|
||||
add_task(cleanUp);
|
|
@ -9,7 +9,7 @@
|
|||
<script>
|
||||
"use strict";
|
||||
|
||||
/* exported loadImage, loadIframe */
|
||||
/* exported loadImage, loadIframe, createCookie */
|
||||
function loadImage(src) {
|
||||
const img = document.createElement("img");
|
||||
img.src = src;
|
||||
|
@ -23,6 +23,10 @@
|
|||
iframe.src = src;
|
||||
document.body.appendChild(iframe);
|
||||
}
|
||||
|
||||
function createCookie(cookie) {
|
||||
document.cookie = cookie;
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
Загрузка…
Ссылка в новой задаче