mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-23 21:01:08 +00:00
Bug 1733498 - Add a test for migrated necko errors l10n strings r=necko-reviewers,jesup,valentin
Differential Revision: https://phabricator.services.mozilla.com/D224264
This commit is contained in:
parent
f75f7b7494
commit
f0c1e8e04f
@ -307,6 +307,11 @@ var allowlist = [
|
||||
// Referenced programmatically
|
||||
{ file: "chrome://browser/content/backup/BackupManifest.1.schema.json" },
|
||||
{ file: "chrome://browser/content/backup/ArchiveJSONBlock.1.schema.json" },
|
||||
|
||||
// Bug 1733498 - Migrate necko errors l10n strings from .properties to Fluent
|
||||
{
|
||||
file: "resource://gre/localization/en-US/netwerk/necko.ftl",
|
||||
},
|
||||
];
|
||||
|
||||
if (AppConstants.NIGHTLY_BUILD) {
|
||||
|
@ -174,6 +174,8 @@ support-files = ["file_lnk.lnk",]
|
||||
|
||||
["browser_http_index_format.js"]
|
||||
|
||||
["browser_necko_l10n.js"]
|
||||
|
||||
["browser_nsIFormPOSTActionChannel.js"]
|
||||
skip-if = ["true"] # protocol handler and channel does not work in content process
|
||||
|
||||
|
92
netwerk/test/browser/browser_necko_l10n.js
Normal file
92
netwerk/test/browser/browser_necko_l10n.js
Normal file
@ -0,0 +1,92 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
"use strict";
|
||||
|
||||
const { HttpServer } = ChromeUtils.importESModule(
|
||||
"resource://testing-common/httpd.sys.mjs"
|
||||
);
|
||||
|
||||
const gOverride = Cc["@mozilla.org/network/native-dns-override;1"].getService(
|
||||
Ci.nsINativeDNSResolverOverride
|
||||
);
|
||||
|
||||
const DOMAIN_NAME = "example.com";
|
||||
const HTTPS_FIRST = "dom.security.https_first";
|
||||
|
||||
registerCleanupFunction(function () {
|
||||
Services.prefs.clearUserPref(HTTPS_FIRST);
|
||||
});
|
||||
|
||||
function observeStatusLabel(statusLabel, expectedValues) {
|
||||
// Verify if all values from the expectedValues set are shown in statusLabel
|
||||
return new Promise(resolve => {
|
||||
let prevValue = statusLabel.value;
|
||||
if (prevValue) {
|
||||
expectedValues.delete(prevValue);
|
||||
}
|
||||
|
||||
const observer = new MutationObserver(mutations => {
|
||||
for (let mutation of mutations) {
|
||||
if (mutation.attributeName === "value") {
|
||||
if (statusLabel.value && statusLabel.value !== prevValue) {
|
||||
expectedValues.delete(statusLabel.value);
|
||||
|
||||
if (expectedValues.size === 0) {
|
||||
ok(true, "All expected values were matched");
|
||||
observer.disconnect();
|
||||
resolve();
|
||||
}
|
||||
prevValue = statusLabel.value;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
observer.observe(statusLabel, { attributes: true });
|
||||
return () => {
|
||||
observer.disconnect();
|
||||
is(expectedValues.size, 0, "Not all expected values were matched");
|
||||
resolve();
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
add_task(async function test_domain_change() {
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [[HTTPS_FIRST, false]],
|
||||
});
|
||||
|
||||
gOverride.addIPOverride(DOMAIN_NAME, "127.0.0.1");
|
||||
let server = new HttpServer();
|
||||
server.start(-1);
|
||||
registerCleanupFunction(async () => {
|
||||
await server.stop();
|
||||
gOverride.clearOverrides();
|
||||
});
|
||||
|
||||
// eslint-disable-next-line @microsoft/sdl/no-insecure-url
|
||||
let serverURL = `http://${DOMAIN_NAME}:${server.identity.primaryPort}/`;
|
||||
server.identity.add("http", DOMAIN_NAME, server.identity.primaryPort);
|
||||
|
||||
server.registerPathHandler("/", (request, response) => {
|
||||
response.setStatusLine(request.httpVersion, 200, "OK");
|
||||
response.setHeader("Content-Type", "text/html");
|
||||
const BODY = `testing..`;
|
||||
response.bodyOutputStream.write(BODY, BODY.length);
|
||||
});
|
||||
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [["network.proxy.no_proxies_on", DOMAIN_NAME]],
|
||||
});
|
||||
|
||||
let expectedValues = new Set([
|
||||
DOMAIN_NAME,
|
||||
`Transferring data from ${DOMAIN_NAME}…`,
|
||||
]);
|
||||
|
||||
let statusLabel = document.getElementById("statuspanel-label");
|
||||
let statusPromise = observeStatusLabel(statusLabel, expectedValues);
|
||||
BrowserTestUtils.startLoadingURIString(gBrowser.selectedBrowser, serverURL);
|
||||
await statusPromise;
|
||||
});
|
Loading…
Reference in New Issue
Block a user