Bug 1795255 - manual fixes for tests that break after applying this lint rule, r=Standard8,necko-reviewers,extension-reviewers,credential-management-reviewers,sgalich,willdurand

Differential Revision: https://phabricator.services.mozilla.com/D167802
This commit is contained in:
Gijs Kruitbosch 2023-01-31 11:48:41 +00:00
Родитель 17c6749deb
Коммит c906d6f529
18 изменённых файлов: 54 добавлений и 35 удалений

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

@ -1,8 +1,12 @@
"use strict";
let { AddonManager } = ChromeUtils.import(
"resource://gre/modules/AddonManager.jsm"
);
// testing/mochitest/tests/SimpleTest/ExtensionTestUtils.js loads
// ExtensionTestCommon, and is slated as part of the SimpleTest
// environment in tools/lint/eslint/eslint-plugin-mozilla/lib/environments/simpletest.js
// However, nothing but the ExtensionTestUtils global gets put
// into the scope, and so although eslint thinks this global is
// available, it really isn't.
// eslint-disable-next-line mozilla/no-redeclare-with-import-autofix
let { ExtensionTestCommon } = ChromeUtils.import(
"resource://testing-common/ExtensionTestCommon.jsm"
);

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

@ -34,8 +34,8 @@ add_task(async function() {
let pocketPanel = document.getElementById("customizationui-widget-panel");
let pocketFrame = pocketPanel.querySelector("browser");
await ContentTaskUtils.waitForCondition(
() => pocketFrame.src.split("?")[0] === "about:pocket-home",
await TestUtils.waitForCondition(
() => pocketFrame.src.startsWith("about:pocket-home?"),
"pocket home panel is showing"
);

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

@ -8,9 +8,7 @@ ChromeUtils.defineModuleGetter(
"pktApi",
"chrome://pocket/content/pktApi.jsm"
);
const { ContentTaskUtils } = ChromeUtils.importESModule(
"resource://testing-common/ContentTaskUtils.sys.mjs"
);
const { sinon } = ChromeUtils.import("resource://testing-common/Sinon.jsm");
// PocketEnabled/Disabled promises return true if it was already

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

@ -181,12 +181,12 @@ add_task(async function testSidebarSetExpressionResult() {
ok(cyclicNode.innerText.includes("cyclic"), "Found the expected node");
cyclicNode.click();
await ContentTaskUtils.waitForCondition(
await TestUtils.waitForCondition(
() => oi.querySelectorAll(".node").length === 7,
"Wait for the 'cyclic' node to be expanded"
);
await ContentTaskUtils.waitForCondition(
await TestUtils.waitForCondition(
() => oi.querySelector(".tree-node.focused"),
"Wait for the 'cyclic' node to be focused"
);
@ -197,7 +197,7 @@ add_task(async function testSidebarSetExpressionResult() {
info("Test keyboard navigation");
EventUtils.synthesizeKey("KEY_ArrowLeft", {}, oi.ownerDocument.defaultView);
await ContentTaskUtils.waitForCondition(
await TestUtils.waitForCondition(
() => oi.querySelectorAll(".node").length === 4,
"Wait for the 'cyclic' node to be collapsed"
);
@ -207,7 +207,7 @@ add_task(async function testSidebarSetExpressionResult() {
);
EventUtils.synthesizeKey("KEY_ArrowDown", {}, oi.ownerDocument.defaultView);
await ContentTaskUtils.waitForCondition(
await TestUtils.waitForCondition(
() => oi.querySelectorAll(".tree-node")[2].classList.contains("focused"),
"Wait for the 'prop1' node to be focused"
);
@ -229,7 +229,7 @@ add_task(async function testSidebarSetExpressionResult() {
);
sidebar.setExpressionResult(evalResult);
await ContentTaskUtils.waitForCondition(() => {
await TestUtils.waitForCondition(() => {
const longStringEl = sidebarPanelContent.querySelector(
".tree .objectBox-string"
);
@ -250,7 +250,7 @@ add_task(async function testSidebarSetExpressionResult() {
}
);
sidebar.setExpressionResult(evalResult);
const numberEl = await ContentTaskUtils.waitForCondition(
const numberEl = await TestUtils.waitForCondition(
() => sidebarPanelContent.querySelector(".objectBox-number"),
"Wait for the result number element to be rendered"
);
@ -285,7 +285,7 @@ add_task(async function testSidebarDOMNodeHighlighting() {
// Wait for the object to be expanded so we only target the "body" property node, and
// not the root object element.
await ContentTaskUtils.waitForCondition(
await TestUtils.waitForCondition(
() =>
sidebarPanelContent.querySelectorAll(".object-inspector .tree-node")
.length > 1

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

@ -54,7 +54,7 @@ async function expectNoSuchActorIDs(client, actors) {
function waitForObjectInspector(panelDoc, waitForNodeWithType = "object") {
const selector = `.object-inspector .objectBox-${waitForNodeWithType}`;
return ContentTaskUtils.waitForCondition(() => {
return TestUtils.waitForCondition(() => {
return !!panelDoc.querySelectorAll(selector).length;
}, `Wait for objectInspector's node type "${waitForNodeWithType}" to be loaded`);
}
@ -62,7 +62,7 @@ function waitForObjectInspector(panelDoc, waitForNodeWithType = "object") {
// Helper function used inside the sidebar.setExtensionPage test case.
async function testSetExtensionPageSidebarPanel(panelDoc, expectedURL) {
const selector = "iframe.inspector-extension-sidebar-page";
const iframesCount = await ContentTaskUtils.waitForCondition(() => {
const iframesCount = await TestUtils.waitForCondition(() => {
return panelDoc.querySelectorAll(selector).length;
}, "Wait for the extension page iframe");
@ -73,7 +73,7 @@ async function testSetExtensionPageSidebarPanel(panelDoc, expectedURL) {
);
const iframeWindow = panelDoc.querySelector(selector).contentWindow;
await ContentTaskUtils.waitForCondition(() => {
await TestUtils.waitForCondition(() => {
return iframeWindow.document.readyState === "complete";
}, "Wait for the extension page iframe to complete to load");
@ -98,7 +98,7 @@ async function testSetExpressionSidebarPanel(panel, expected) {
);
const [objectInspector] = objectInspectors;
await ContentTaskUtils.waitForCondition(() => {
await TestUtils.waitForCondition(() => {
return objectInspector.querySelectorAll(".node").length >= nodesLength;
}, "Wait the objectInspector to have been fully rendered");

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

@ -7,6 +7,7 @@
// corresponding DOM nodes mutate
// Have to use the same timer functions used by the inspector.
// eslint-disable-next-line mozilla/no-redeclare-with-import-autofix
const { clearTimeout } = ChromeUtils.importESModule(
"resource://gre/modules/Timer.sys.mjs"
);

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

@ -28,6 +28,9 @@ Services.scriptloader.loadSubScript(
EventUtils
);
// We're an actor so we don't run in the browser test environment, so
// we need to import TestUtils manually despite what the linter thinks.
// eslint-disable-next-line mozilla/no-redeclare-with-import-autofix
const { TestUtils } = ChromeUtils.importESModule(
"resource://testing-common/TestUtils.sys.mjs"
);

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

@ -13,6 +13,9 @@
const { traceAllJSCalls } = ChromeUtils.importESModule(
"resource://devtools/shared/test-helpers/thread-helpers.sys.mjs"
);
// ESLint thinks this is a browser test, but it's actually an xpcshell
// test and so `setTimeout` isn't available out of the box.
// eslint-disable-next-line mozilla/no-redeclare-with-import-autofix
const { setTimeout } = ChromeUtils.importESModule(
"resource://gre/modules/Timer.sys.mjs"
);

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

@ -6,6 +6,9 @@
// Functions that are automatically loaded as frame scripts for
// timeline tests.
// eslint assumes we inherit browser window stuff, but this
// framescript doesn't.
// eslint-disable-next-line mozilla/no-redeclare-with-import-autofix
const { setTimeout } = ChromeUtils.importESModule(
"resource://gre/modules/Timer.sys.mjs"
);

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

@ -39,7 +39,7 @@
// Do some sanity checking of our import rules.
let primaryRules = stylesheet.cssRules;
await ContentTaskUtils.waitForCondition(function() {
await SimpleTest.promiseWaitForCondition(function() {
try {
primaryRules[0].styleSheet.cssRules;
primaryRules[1].styleSheet.cssRules;

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

@ -1,4 +1,8 @@
"use strict";
// In an SJS file we need to get the setTimeout bits ourselves, despite
// what eslint might think applies for browser tests.
// eslint-disable-next-line mozilla/no-redeclare-with-import-autofix
let { setTimeout } = ChromeUtils.import("resource://gre/modules/Timer.jsm");
async function handleRequest(request, response) {

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

@ -1,5 +1,8 @@
"use strict";
// The name of this module conflicts with the window.Storage
// DOM global - https://developer.mozilla.org/en-US/docs/Web/API/Storage .
// eslint-disable-next-line mozilla/no-redeclare-with-import-autofix
const { Storage } = ChromeUtils.import("resource://normandy/lib/Storage.jsm");
add_task(async function() {

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

@ -12,7 +12,12 @@ const { ClientEnvironment } = ChromeUtils.import(
const { Heartbeat } = ChromeUtils.import(
"resource://normandy/lib/Heartbeat.jsm"
);
// The name of this module conflicts with the window.Storage
// DOM global - https://developer.mozilla.org/en-US/docs/Web/API/Storage .
// eslint-disable-next-line mozilla/no-redeclare-with-import-autofix
const { Storage } = ChromeUtils.import("resource://normandy/lib/Storage.jsm");
const { Uptake } = ChromeUtils.import("resource://normandy/lib/Uptake.jsm");
const { NormandyTestUtils } = ChromeUtils.import(
"resource://testing-common/NormandyTestUtils.jsm"

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

@ -91,7 +91,7 @@ add_task(async function test_changeUPLoginOnPUpdateForm_accept() {
dialog.acceptDialog();
await ContentTaskUtils.waitForCondition(() => {
await TestUtils.waitForCondition(() => {
return !getSelectDialogDoc();
}, "Wait for selection dialog to disappear.");
}
@ -154,7 +154,7 @@ add_task(async function test_changeUPLoginOnPUpdateForm_cancel() {
dialog.cancelDialog();
await ContentTaskUtils.waitForCondition(() => {
await TestUtils.waitForCondition(() => {
return !getSelectDialogDoc();
}, "Wait for selection dialog to disappear.");
}

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

@ -6,6 +6,9 @@
const DELAY = 2 * 1000; // Delay two seconds before completing the request.
// In an SJS file we need to get the setTimeout bits ourselves, despite
// what eslint might think applies for browser tests.
// eslint-disable-next-line mozilla/no-redeclare-with-import-autofix
let { setTimeout } = ChromeUtils.importESModule(
"resource://gre/modules/Timer.sys.mjs"
);

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

@ -1,17 +1,9 @@
const DIRECTORY_PATH = "/browser/toolkit/components/passwordmgr/test/browser/";
const { LoginHelper } = ChromeUtils.import(
"resource://gre/modules/LoginHelper.jsm"
);
const { LoginManagerParent } = ChromeUtils.import(
"resource://gre/modules/LoginManagerParent.jsm"
);
var { LoginTestUtils } = ChromeUtils.import(
"resource://testing-common/LoginTestUtils.jsm"
);
const { ContentTaskUtils } = ChromeUtils.importESModule(
"resource://testing-common/ContentTaskUtils.sys.mjs"
);
const { TelemetryTestUtils } = ChromeUtils.importESModule(
"resource://testing-common/TelemetryTestUtils.sys.mjs"
);

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

@ -1,8 +1,5 @@
"use strict";
const { ContentTaskUtils } = ChromeUtils.importESModule(
"resource://testing-common/ContentTaskUtils.sys.mjs"
);
const { TelemetryController } = ChromeUtils.importESModule(
"resource://gre/modules/TelemetryController.sys.mjs"
);
@ -17,7 +14,7 @@ async function waitForProcessesScalars(
aKeyed,
aAdditionalCondition = data => true
) {
await ContentTaskUtils.waitForCondition(() => {
await TestUtils.waitForCondition(() => {
const scalars = aKeyed
? Services.telemetry.getSnapshotForKeyedScalars("main", false)
: Services.telemetry.getSnapshotForScalars("main", false);

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

@ -1,3 +1,6 @@
// In an SJS file we need to get NetUtil ourselves, despite
// what eslint might think applies for browser tests.
// eslint-disable-next-line mozilla/no-redeclare-with-import-autofix
let { NetUtil } = ChromeUtils.import("resource://gre/modules/NetUtil.jsm");
Cu.importGlobalProperties(["IOUtils", "PathUtils"]);