Bug 1808941 - In newtab's ESLint configuration, only specify test environments where they are actually used to get the correct globals and rules. r=aminomancer
Differential Revision: https://phabricator.services.mozilla.com/D166194
This commit is contained in:
@@ -28,8 +28,6 @@ module.exports = {
|
||||
"eslint:recommended",
|
||||
"plugin:jsx-a11y/recommended", // require("eslint-plugin-jsx-a11y")
|
||||
"plugin:mozilla/recommended", // require("eslint-plugin-mozilla") require("eslint-plugin-fetch-options") require("eslint-plugin-html") require("eslint-plugin-no-unsanitized")
|
||||
"plugin:mozilla/browser-test",
|
||||
"plugin:mozilla/mochitest-test",
|
||||
"plugin:prettier/recommended", // require("eslint-plugin-prettier")
|
||||
"prettier", // require("eslint-config-prettier")
|
||||
],
|
||||
@@ -76,6 +74,10 @@ module.exports = {
|
||||
files: "test/xpcshell/**",
|
||||
extends: ["plugin:mozilla/xpcshell-test"],
|
||||
},
|
||||
{
|
||||
files: "test/browser/**",
|
||||
extends: ["plugin:mozilla/browser-test"],
|
||||
},
|
||||
{
|
||||
// Exempt all files without a 'test' string in their path name since no-insecure-url
|
||||
// is focussing on the test base
|
||||
|
||||
@@ -327,7 +327,7 @@ describe("MultiStageAboutWelcomeProton module", () => {
|
||||
],
|
||||
};
|
||||
it("should not set url for default qrcode svg", async () => {
|
||||
sandbox.stub(AppConstants, "isChinaRepack").returns(false);
|
||||
sandbox.stub(global.AppConstants, "isChinaRepack").returns(false);
|
||||
const data = await AboutWelcomeDefaults.prepareContentForReact(
|
||||
TEST_CONTENT
|
||||
);
|
||||
@@ -338,7 +338,7 @@ describe("MultiStageAboutWelcomeProton module", () => {
|
||||
);
|
||||
});
|
||||
it("should set url for cn qrcode svg", async () => {
|
||||
sandbox.stub(AppConstants, "isChinaRepack").returns(true);
|
||||
sandbox.stub(global.AppConstants, "isChinaRepack").returns(true);
|
||||
const data = await AboutWelcomeDefaults.prepareContentForReact(
|
||||
TEST_CONTENT
|
||||
);
|
||||
@@ -414,7 +414,9 @@ describe("MultiStageAboutWelcomeProton module", () => {
|
||||
);
|
||||
});
|
||||
it("should remove theme screens on win7", async () => {
|
||||
sandbox.stub(AppConstants, "isPlatformAndVersionAtMost").returns(true);
|
||||
sandbox
|
||||
.stub(global.AppConstants, "isPlatformAndVersionAtMost")
|
||||
.returns(true);
|
||||
|
||||
const { screens } = await AboutWelcomeDefaults.prepareContentForReact({
|
||||
screens: [
|
||||
@@ -436,7 +438,9 @@ describe("MultiStageAboutWelcomeProton module", () => {
|
||||
assert.deepEqual(screens, [{ id: "hello" }, { id: "world" }]);
|
||||
});
|
||||
it("shouldn't remove colorway screens on win7", async () => {
|
||||
sandbox.stub(AppConstants, "isPlatformAndVersionAtMost").returns(true);
|
||||
sandbox
|
||||
.stub(global.AppConstants, "isPlatformAndVersionAtMost")
|
||||
.returns(true);
|
||||
|
||||
const { screens } = await AboutWelcomeDefaults.prepareContentForReact({
|
||||
screens: [
|
||||
|
||||
@@ -1978,7 +1978,7 @@ describe("ASRouter", () => {
|
||||
);
|
||||
});
|
||||
it("should set referrer on mac", async () => {
|
||||
sandbox.stub(AppConstants, "platform").value("macosx");
|
||||
sandbox.stub(global.AppConstants, "platform").value("macosx");
|
||||
|
||||
Router.forceAttribution({ foo: "FOO!", eh: "NOPE", bar: "BAR?" });
|
||||
|
||||
|
||||
@@ -300,7 +300,7 @@ describe("#CacheListAttachedOAuthClients", () => {
|
||||
globals.set("fxAccounts", fakeFxAccount);
|
||||
authClientsCache = QueryCache.queries.ListAttachedOAuthClients;
|
||||
sandbox
|
||||
.stub(fxAccounts, "listAttachedOAuthClients")
|
||||
.stub(global.fxAccounts, "listAttachedOAuthClients")
|
||||
.returns(Promise.resolve({}));
|
||||
});
|
||||
|
||||
@@ -314,21 +314,21 @@ describe("#CacheListAttachedOAuthClients", () => {
|
||||
clock.tick(fourHours);
|
||||
|
||||
await authClientsCache.get();
|
||||
assert.calledOnce(fxAccounts.listAttachedOAuthClients);
|
||||
assert.calledOnce(global.fxAccounts.listAttachedOAuthClients);
|
||||
|
||||
clock.tick(fourHours);
|
||||
await authClientsCache.get();
|
||||
assert.calledTwice(fxAccounts.listAttachedOAuthClients);
|
||||
assert.calledTwice(global.fxAccounts.listAttachedOAuthClients);
|
||||
});
|
||||
|
||||
it("should not make additional request before 4 hours", async () => {
|
||||
clock.tick(fourHours);
|
||||
|
||||
await authClientsCache.get();
|
||||
assert.calledOnce(fxAccounts.listAttachedOAuthClients);
|
||||
assert.calledOnce(global.fxAccounts.listAttachedOAuthClients);
|
||||
|
||||
await authClientsCache.get();
|
||||
assert.calledOnce(fxAccounts.listAttachedOAuthClients);
|
||||
assert.calledOnce(global.fxAccounts.listAttachedOAuthClients);
|
||||
});
|
||||
});
|
||||
describe("ASRouterTargeting", () => {
|
||||
|
||||
@@ -742,13 +742,15 @@ describe("PlacesFeed", () => {
|
||||
});
|
||||
it("should properly handle handoff with text data passed in", () => {
|
||||
const sessionId = "decafc0ffee";
|
||||
sandbox.stub(AboutNewTab.activityStream.store.feeds, "get").returns({
|
||||
sessions: {
|
||||
get: () => {
|
||||
return { session_id: sessionId };
|
||||
sandbox
|
||||
.stub(global.AboutNewTab.activityStream.store.feeds, "get")
|
||||
.returns({
|
||||
sessions: {
|
||||
get: () => {
|
||||
return { session_id: sessionId };
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
});
|
||||
feed.handoffSearchToAwesomebar({
|
||||
_target: { browser: { ownerGlobal: { gURLBar: fakeUrlBar } } },
|
||||
data: { text: "foo" },
|
||||
@@ -838,13 +840,15 @@ describe("PlacesFeed", () => {
|
||||
});
|
||||
it("should properly handoff a newtab session id with no text passed in", () => {
|
||||
const sessionId = "decafc0ffee";
|
||||
sandbox.stub(AboutNewTab.activityStream.store.feeds, "get").returns({
|
||||
sessions: {
|
||||
get: () => {
|
||||
return { session_id: sessionId };
|
||||
sandbox
|
||||
.stub(global.AboutNewTab.activityStream.store.feeds, "get")
|
||||
.returns({
|
||||
sessions: {
|
||||
get: () => {
|
||||
return { session_id: sessionId };
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
});
|
||||
feed.handoffSearchToAwesomebar({
|
||||
_target: { browser: { ownerGlobal: { gURLBar: fakeUrlBar } } },
|
||||
data: {},
|
||||
|
||||
@@ -322,7 +322,7 @@ describe("ToolbarPanelHub", () => {
|
||||
});
|
||||
it("should not do anything if the window is closed", () => {
|
||||
instance._hideAppmenuButton(fakeWindow, true);
|
||||
assert.notCalled(PanelMultiView.getViewNode);
|
||||
assert.notCalled(global.PanelMultiView.getViewNode);
|
||||
});
|
||||
it("should not throw if the element does not exist", () => {
|
||||
let fn = instance._hideAppmenuButton.bind(null, {
|
||||
|
||||
Reference in New Issue
Block a user