Bug 1525976 - Implement a basic browser-chrome mochitest for Firefox Monitor. r=johannh

Differential Revision: https://phabricator.services.mozilla.com/D21551

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Nihanth Subramanya 2019-04-27 21:39:39 +00:00
Родитель c541551107
Коммит 6861e8c2b4
4 изменённых файлов: 57 добавлений и 0 удалений

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

@ -25,5 +25,7 @@ FINAL_TARGET_FILES.features['fxmonitor@mozilla.org']['privileged'] += [
'privileged/schema.json'
]
BROWSER_CHROME_MANIFESTS += ['test/browser/browser.ini']
with Files('**'):
BUG_COMPONENT = ('Firefox', 'Firefox Monitor')

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

@ -0,0 +1,7 @@
"use strict";
module.exports = {
"extends": [
"plugin:mozilla/browser-test"
]
};

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

@ -0,0 +1 @@
[browser_fxmonitor_doorhanger.js]

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

@ -0,0 +1,47 @@
"use strict";
ChromeUtils.defineModuleGetter(this, "RemoteSettings",
"resource://services-settings/remote-settings.js");
const kNotificationId = "fxmonitor";
const kRemoteSettingsKey = "fxmonitor-breaches";
async function fxmonitorNotificationShown() {
await TestUtils.waitForCondition(() => {
return PopupNotifications.getNotification(kNotificationId);
});
ok(true, "Firefox Monitor PopupNotification was added.");
}
add_task(async function test_remotesettings_get() {
// Pre-populate the Remote Settings collection with a breach.
let collection = await RemoteSettings(kRemoteSettingsKey).openCollection();
let BreachDate = new Date();
let AddedDate = new Date();
await collection.create({
Domain: "example.com",
Name: "Example Site",
BreachDate: `${BreachDate.getFullYear()}-${BreachDate.getMonth()}-${BreachDate.getDate()}`,
AddedDate: `${AddedDate.getFullYear()}-${AddedDate.getMonth()}-${AddedDate.getDate()}`,
PwnCount: 1000000,
});
await collection.db.saveLastModified(1234567);
// Enable the extension.
await SpecialPowers.pushPrefEnv({
set: [["extensions.fxmonitor.enabled", true]],
});
// Open a tab and wait for the alert.
let tab = await BrowserTestUtils.openNewForegroundTab(gBrowser, "http://example.com");
await fxmonitorNotificationShown();
// Clean up.
BrowserTestUtils.removeTab(tab);
await collection.clear();
await SpecialPowers.pushPrefEnv({
clear: [["extensions.fxmonitor.enabled"],
["extensions.fxmonitor.warnedHosts"],
["extensions.fxmonitor.firstAlertShown"]],
});
});