mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-20 16:55:40 +00:00
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:
parent
c541551107
commit
6861e8c2b4
@ -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')
|
||||
|
7
browser/extensions/fxmonitor/test/browser/.eslintrc.js
Normal file
7
browser/extensions/fxmonitor/test/browser/.eslintrc.js
Normal file
@ -0,0 +1,7 @@
|
||||
"use strict";
|
||||
|
||||
module.exports = {
|
||||
"extends": [
|
||||
"plugin:mozilla/browser-test"
|
||||
]
|
||||
};
|
1
browser/extensions/fxmonitor/test/browser/browser.ini
Normal file
1
browser/extensions/fxmonitor/test/browser/browser.ini
Normal file
@ -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"]],
|
||||
});
|
||||
});
|
Loading…
Reference in New Issue
Block a user