зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1613111 - Enable ESLint on testing/mochitest/tests/SimpleTest/ (manual changes). r=kmag
Differential Revision: https://phabricator.services.mozilla.com/D61864 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
32182ed29c
Коммит
053da90c15
|
@ -180,7 +180,6 @@ servo/
|
|||
|
||||
# third party modules
|
||||
testing/mochitest/tests/Harness_sanity/
|
||||
testing/mochitest/tests/SimpleTest/
|
||||
|
||||
# Test files that we don't want to lint (preprocessed, minified etc)
|
||||
testing/marionette/atom.js
|
||||
|
|
|
@ -27,7 +27,11 @@ const browserTestPaths = [
|
|||
];
|
||||
|
||||
const mochitestTestPaths = [
|
||||
"**/test*/mochitest/",
|
||||
// Note: we do not want to match testing/mochitest as that would apply
|
||||
// too many globals for that directory.
|
||||
"**/test/mochitest/",
|
||||
"**/tests/mochitest/",
|
||||
"testing/mochitest/tests/SimpleTest/",
|
||||
];
|
||||
|
||||
const chromeTestPaths = [
|
||||
|
@ -108,7 +112,6 @@ module.exports = {
|
|||
"excludedFiles": [
|
||||
"devtools/**",
|
||||
"security/manager/ssl/tests/mochitest/browser/**",
|
||||
"testing/mochitest/**",
|
||||
],
|
||||
}, {
|
||||
...removeOverrides(chromeTestConfig),
|
||||
|
|
|
@ -6,17 +6,19 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
/* eslint-env mozilla/frame-script */
|
||||
|
||||
function ChromeTask_ChromeScript() {
|
||||
"use strict";
|
||||
|
||||
const { Task } = ChromeUtils.import("resource://testing-common/Task.jsm");
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { Services } = ChromeUtils.import(
|
||||
"resource://gre/modules/Services.jsm"
|
||||
);
|
||||
const AssertCls = ChromeUtils.import(
|
||||
"resource://testing-common/Assert.jsm",
|
||||
null
|
||||
).Assert;
|
||||
const { Assert: AssertCls } = ChromeUtils.import(
|
||||
"resource://testing-common/Assert.jsm"
|
||||
);
|
||||
|
||||
addMessageListener("chrome-task:spawn", function(aData) {
|
||||
let id = aData.id;
|
||||
|
|
|
@ -26,6 +26,10 @@
|
|||
* When adding methods to this file, please add a performance test for it.
|
||||
*/
|
||||
|
||||
// Certain functions assume this is loaded into browser window scope.
|
||||
// This is modifiable because certain chrome tests create their own gBrowser.
|
||||
/* global gBrowser:true */
|
||||
|
||||
// This file is used both in privileged and unprivileged contexts, so we have to
|
||||
// be careful about our access to Components.interfaces. We also want to avoid
|
||||
// naming collisions with anything that might be defined in the scope that imports
|
||||
|
@ -35,6 +39,7 @@
|
|||
// placebo for compat. An easy way to differentiate this from the real thing
|
||||
// is whether the property is read-only or not. The real |Components| property
|
||||
// is read-only.
|
||||
/* global _EU_Ci, _EU_Cc, _EU_Cu, _EU_OS */
|
||||
window.__defineGetter__("_EU_Ci", function() {
|
||||
var c = Object.getOwnPropertyDescriptor(window, "Components");
|
||||
return c && c.value && !c.writable ? Ci : SpecialPowers.Ci;
|
||||
|
@ -189,6 +194,7 @@ function sendMouseEvent(aEvent, aTarget, aWindow) {
|
|||
var viewArg = aWindow;
|
||||
var detailArg =
|
||||
aEvent.detail ||
|
||||
// eslint-disable-next-line no-nested-ternary
|
||||
(aEvent.type == "click" ||
|
||||
aEvent.type == "mousedown" ||
|
||||
aEvent.type == "mouseup"
|
||||
|
@ -394,7 +400,6 @@ function sendKey(aKey, aWindow) {
|
|||
* synthesizeMouse and synthesizeKey.
|
||||
*/
|
||||
function _parseModifiers(aEvent, aWindow = window) {
|
||||
var navigator = _getNavigator(aWindow);
|
||||
var nsIDOMWindowUtils = _EU_Ci.nsIDOMWindowUtils;
|
||||
var mval = 0;
|
||||
if (aEvent.shiftKey) {
|
||||
|
@ -700,7 +705,6 @@ function synthesizeWheelAtPoint(aLeft, aTop, aEvent, aWindow = window) {
|
|||
options |= utils.WHEEL_EVENT_EXPECTED_OVERFLOW_DELTA_Y_NEGATIVE;
|
||||
}
|
||||
}
|
||||
var isNoLineOrPageDelta = aEvent.isNoLineOrPageDelta;
|
||||
|
||||
// Avoid the JS warnings "reference to undefined property"
|
||||
if (!aEvent.deltaX) {
|
||||
|
@ -714,12 +718,14 @@ function synthesizeWheelAtPoint(aLeft, aTop, aEvent, aWindow = window) {
|
|||
}
|
||||
|
||||
var lineOrPageDeltaX =
|
||||
// eslint-disable-next-line no-nested-ternary
|
||||
aEvent.lineOrPageDeltaX != null
|
||||
? aEvent.lineOrPageDeltaX
|
||||
: aEvent.deltaX > 0
|
||||
? Math.floor(aEvent.deltaX)
|
||||
: Math.ceil(aEvent.deltaX);
|
||||
var lineOrPageDeltaY =
|
||||
// eslint-disable-next-line no-nested-ternary
|
||||
aEvent.lineOrPageDeltaY != null
|
||||
? aEvent.lineOrPageDeltaY
|
||||
: aEvent.deltaY > 0
|
||||
|
@ -1135,6 +1141,7 @@ function synthesizeAndWaitKey(
|
|||
resolve();
|
||||
});
|
||||
});
|
||||
// eslint-disable-next-line no-shadow
|
||||
let keyReceivedPromise = ContentTask.spawn(browser, keyCode, keyCode => {
|
||||
return new Promise(resolve => {
|
||||
addEventListener("keyup", function onKeyEvent(e) {
|
||||
|
@ -1159,7 +1166,6 @@ function synthesizeAndWaitKey(
|
|||
}
|
||||
|
||||
function _parseNativeModifiers(aModifiers, aWindow = window) {
|
||||
var navigator = _getNavigator(aWindow);
|
||||
var modifiers;
|
||||
if (aModifiers.capsLockKey) {
|
||||
modifiers |= 0x00000001;
|
||||
|
@ -1361,7 +1367,6 @@ function synthesizeNativeKey(
|
|||
if (!utils) {
|
||||
return false;
|
||||
}
|
||||
var navigator = _getNavigator(aWindow);
|
||||
var nativeKeyboardLayout = null;
|
||||
if (_EU_isMac(aWindow)) {
|
||||
nativeKeyboardLayout = aKeyboardLayout.Mac;
|
||||
|
@ -1604,13 +1609,7 @@ function _getKeyboardEvent(aWindow = window) {
|
|||
return aWindow.KeyboardEvent;
|
||||
}
|
||||
|
||||
function _getNavigator(aWindow = window) {
|
||||
if (typeof navigator != "undefined") {
|
||||
return navigator;
|
||||
}
|
||||
return aWindow.navigator;
|
||||
}
|
||||
|
||||
// eslint-disable-next-line complexity
|
||||
function _guessKeyNameFromKeyCode(aKeyCode, aWindow = window) {
|
||||
var KeyboardEvent = _getKeyboardEvent(aWindow);
|
||||
switch (aKeyCode) {
|
||||
|
@ -1788,7 +1787,7 @@ function _createKeyboardEventDictionary(
|
|||
} else if (aKey.indexOf("VK_") == 0) {
|
||||
keyCode = _getKeyboardEvent(aWindow)["DOM_" + aKey];
|
||||
if (!keyCode) {
|
||||
throw "Unknown key: " + aKey;
|
||||
throw new Error("Unknown key: " + aKey);
|
||||
}
|
||||
keyName = _guessKeyNameFromKeyCode(keyCode, aWindow);
|
||||
result.flags |= _EU_Ci.nsITextInputProcessor.KEY_NON_PRINTABLE_KEY;
|
||||
|
@ -1843,7 +1842,6 @@ function _emulateToActivateModifiers(aTIP, aKeyEvent, aWindow = window) {
|
|||
return null;
|
||||
}
|
||||
var KeyboardEvent = _getKeyboardEvent(aWindow);
|
||||
var navigator = _getNavigator(aWindow);
|
||||
|
||||
var modifiers = {
|
||||
normal: [
|
||||
|
@ -1866,28 +1864,28 @@ function _emulateToActivateModifiers(aTIP, aKeyEvent, aWindow = window) {
|
|||
],
|
||||
};
|
||||
|
||||
for (var i = 0; i < modifiers.normal.length; i++) {
|
||||
for (let i = 0; i < modifiers.normal.length; i++) {
|
||||
if (!aKeyEvent[modifiers.normal[i].attr]) {
|
||||
continue;
|
||||
}
|
||||
if (aTIP.getModifierState(modifiers.normal[i].key)) {
|
||||
continue; // already activated.
|
||||
}
|
||||
var event = new KeyboardEvent("", { key: modifiers.normal[i].key });
|
||||
let event = new KeyboardEvent("", { key: modifiers.normal[i].key });
|
||||
aTIP.keydown(
|
||||
event,
|
||||
aTIP.KEY_NON_PRINTABLE_KEY | aTIP.KEY_DONT_DISPATCH_MODIFIER_KEY_EVENT
|
||||
);
|
||||
modifiers.normal[i].activated = true;
|
||||
}
|
||||
for (var i = 0; i < modifiers.lockable.length; i++) {
|
||||
for (let i = 0; i < modifiers.lockable.length; i++) {
|
||||
if (!aKeyEvent[modifiers.lockable[i].attr]) {
|
||||
continue;
|
||||
}
|
||||
if (aTIP.getModifierState(modifiers.lockable[i].key)) {
|
||||
continue; // already activated.
|
||||
}
|
||||
var event = new KeyboardEvent("", { key: modifiers.lockable[i].key });
|
||||
let event = new KeyboardEvent("", { key: modifiers.lockable[i].key });
|
||||
aTIP.keydown(
|
||||
event,
|
||||
aTIP.KEY_NON_PRINTABLE_KEY | aTIP.KEY_DONT_DISPATCH_MODIFIER_KEY_EVENT
|
||||
|
@ -1906,24 +1904,24 @@ function _emulateToInactivateModifiers(aTIP, aModifiers, aWindow = window) {
|
|||
return;
|
||||
}
|
||||
var KeyboardEvent = _getKeyboardEvent(aWindow);
|
||||
for (var i = 0; i < aModifiers.normal.length; i++) {
|
||||
for (let i = 0; i < aModifiers.normal.length; i++) {
|
||||
if (!aModifiers.normal[i].activated) {
|
||||
continue;
|
||||
}
|
||||
var event = new KeyboardEvent("", { key: aModifiers.normal[i].key });
|
||||
let event = new KeyboardEvent("", { key: aModifiers.normal[i].key });
|
||||
aTIP.keyup(
|
||||
event,
|
||||
aTIP.KEY_NON_PRINTABLE_KEY | aTIP.KEY_DONT_DISPATCH_MODIFIER_KEY_EVENT
|
||||
);
|
||||
}
|
||||
for (var i = 0; i < aModifiers.lockable.length; i++) {
|
||||
for (let i = 0; i < aModifiers.lockable.length; i++) {
|
||||
if (!aModifiers.lockable[i].activated) {
|
||||
continue;
|
||||
}
|
||||
if (!aTIP.getModifierState(aModifiers.lockable[i].key)) {
|
||||
continue; // who already inactivated this?
|
||||
}
|
||||
var event = new KeyboardEvent("", { key: aModifiers.lockable[i].key });
|
||||
let event = new KeyboardEvent("", { key: aModifiers.lockable[i].key });
|
||||
aTIP.keydown(
|
||||
event,
|
||||
aTIP.KEY_NON_PRINTABLE_KEY | aTIP.KEY_DONT_DISPATCH_MODIFIER_KEY_EVENT
|
||||
|
@ -1984,11 +1982,10 @@ function _emulateToInactivateModifiers(aTIP, aModifiers, aWindow = window) {
|
|||
function synthesizeComposition(aEvent, aWindow = window, aCallback) {
|
||||
var TIP = _getTIP(aWindow, aCallback);
|
||||
if (!TIP) {
|
||||
return false;
|
||||
return;
|
||||
}
|
||||
var KeyboardEvent = _getKeyboardEvent(aWindow);
|
||||
var modifiers = _emulateToActivateModifiers(TIP, aEvent.key, aWindow);
|
||||
var ret = false;
|
||||
var keyEventDict = { dictionary: null, flags: 0 };
|
||||
var keyEvent = null;
|
||||
if (aEvent.key && typeof aEvent.key.key === "string") {
|
||||
|
@ -1999,6 +1996,7 @@ function synthesizeComposition(aEvent, aWindow = window, aCallback) {
|
|||
aWindow
|
||||
);
|
||||
keyEvent = new KeyboardEvent(
|
||||
// eslint-disable-next-line no-nested-ternary
|
||||
aEvent.key.type === "keydown"
|
||||
? "keydown"
|
||||
: aEvent.key.type === "keyup"
|
||||
|
@ -2018,17 +2016,13 @@ function synthesizeComposition(aEvent, aWindow = window, aCallback) {
|
|||
try {
|
||||
switch (aEvent.type) {
|
||||
case "compositionstart":
|
||||
ret = TIP.startComposition(keyEvent, keyEventDict.flags);
|
||||
TIP.startComposition(keyEvent, keyEventDict.flags);
|
||||
break;
|
||||
case "compositioncommitasis":
|
||||
ret = TIP.commitComposition(keyEvent, keyEventDict.flags);
|
||||
TIP.commitComposition(keyEvent, keyEventDict.flags);
|
||||
break;
|
||||
case "compositioncommit":
|
||||
ret = TIP.commitCompositionWith(
|
||||
aEvent.data,
|
||||
keyEvent,
|
||||
keyEventDict.flags
|
||||
);
|
||||
TIP.commitCompositionWith(aEvent.data, keyEvent, keyEventDict.flags);
|
||||
break;
|
||||
}
|
||||
} finally {
|
||||
|
@ -2132,7 +2126,6 @@ function synthesizeCompositionChange(aEvent, aWindow = window, aCallback) {
|
|||
break;
|
||||
default:
|
||||
throw new Error("invalid clause attribute specified");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2153,6 +2146,7 @@ function synthesizeCompositionChange(aEvent, aWindow = window, aCallback) {
|
|||
aWindow
|
||||
);
|
||||
keyEvent = new KeyboardEvent(
|
||||
// eslint-disable-next-line no-nested-ternary
|
||||
aEvent.key.type === "keydown"
|
||||
? "keydown"
|
||||
: aEvent.key.type === "keyup"
|
||||
|
@ -2212,7 +2206,7 @@ const SELECTION_SET_FLAG_REVERSE = 0x0002;
|
|||
function synthesizeQueryTextContent(aOffset, aLength, aIsRelative, aWindow) {
|
||||
var utils = _getDOMWindowUtils(aWindow);
|
||||
if (!utils) {
|
||||
return nullptr;
|
||||
return null;
|
||||
}
|
||||
var flags = QUERY_CONTENT_FLAG_USE_NATIVE_LINE_BREAK;
|
||||
if (aIsRelative === true) {
|
||||
|
@ -2240,10 +2234,6 @@ function synthesizeQueryTextContent(aOffset, aLength, aIsRelative, aWindow) {
|
|||
*/
|
||||
function synthesizeQuerySelectedText(aSelectionType, aWindow) {
|
||||
var utils = _getDOMWindowUtils(aWindow);
|
||||
if (!utils) {
|
||||
return null;
|
||||
}
|
||||
|
||||
var flags = QUERY_CONTENT_FLAG_USE_NATIVE_LINE_BREAK;
|
||||
if (aSelectionType) {
|
||||
flags |= aSelectionType;
|
||||
|
@ -2444,9 +2434,6 @@ function synthesizeNativeOSXClick(x, y) {
|
|||
*/
|
||||
function synthesizeQueryTextRect(aOffset, aLength, aWindow) {
|
||||
var utils = _getDOMWindowUtils(aWindow);
|
||||
if (!utils) {
|
||||
return nullptr;
|
||||
}
|
||||
return utils.sendQueryContentEvent(
|
||||
utils.QUERY_TEXT_RECT,
|
||||
aOffset,
|
||||
|
@ -2470,9 +2457,6 @@ function synthesizeQueryTextRect(aOffset, aLength, aWindow) {
|
|||
*/
|
||||
function synthesizeQueryTextRectArray(aOffset, aLength, aWindow) {
|
||||
var utils = _getDOMWindowUtils(aWindow);
|
||||
if (!utils) {
|
||||
return nullptr;
|
||||
}
|
||||
return utils.sendQueryContentEvent(
|
||||
utils.QUERY_TEXT_RECT_ARRAY,
|
||||
aOffset,
|
||||
|
@ -2492,9 +2476,6 @@ function synthesizeQueryTextRectArray(aOffset, aLength, aWindow) {
|
|||
*/
|
||||
function synthesizeQueryEditorRect(aWindow) {
|
||||
var utils = _getDOMWindowUtils(aWindow);
|
||||
if (!utils) {
|
||||
return nullptr;
|
||||
}
|
||||
return utils.sendQueryContentEvent(
|
||||
utils.QUERY_EDITOR_RECT,
|
||||
0,
|
||||
|
@ -2515,9 +2496,6 @@ function synthesizeQueryEditorRect(aWindow) {
|
|||
*/
|
||||
function synthesizeCharAtPoint(aX, aY, aWindow) {
|
||||
var utils = _getDOMWindowUtils(aWindow);
|
||||
if (!utils) {
|
||||
return nullptr;
|
||||
}
|
||||
return utils.sendQueryContentEvent(
|
||||
utils.QUERY_CHARACTER_AT_POINT,
|
||||
0,
|
||||
|
@ -2625,6 +2603,7 @@ function synthesizeDragOver(
|
|||
aDestWindow = aWindow;
|
||||
}
|
||||
|
||||
// eslint-disable-next-line mozilla/use-services
|
||||
const obs = _EU_Cc["@mozilla.org/observer-service;1"].getService(
|
||||
_EU_Ci.nsIObserverService
|
||||
);
|
||||
|
@ -2867,6 +2846,7 @@ function _computeSrcElementFromSrcSelection(aSrcSelection) {
|
|||
* to log rect of target. E.g., `console.log`.
|
||||
* }
|
||||
*/
|
||||
// eslint-disable-next-line complexity
|
||||
async function synthesizePlainDragAndDrop(aParams) {
|
||||
let {
|
||||
dragEvent = {},
|
||||
|
|
|
@ -9,6 +9,7 @@ ExtensionTestUtils.loadExtension = function(ext) {
|
|||
// Cleanup functions need to be registered differently depending on
|
||||
// whether we're in browser chrome or plain mochitests.
|
||||
var registerCleanup;
|
||||
/* global registerCleanupFunction */
|
||||
if (typeof registerCleanupFunction != "undefined") {
|
||||
registerCleanup = registerCleanupFunction;
|
||||
} else {
|
||||
|
@ -73,18 +74,18 @@ ExtensionTestUtils.loadExtension = function(ext) {
|
|||
}
|
||||
|
||||
var handler = {
|
||||
testResult(kind, pass, msg, ...args) {
|
||||
async testResult(kind, pass, msg, ...args) {
|
||||
if (kind == "test-done") {
|
||||
SimpleTest.ok(pass, msg);
|
||||
return testResolve(msg);
|
||||
await testResolve(msg);
|
||||
}
|
||||
testHandler(kind, pass, msg, ...args);
|
||||
},
|
||||
|
||||
testMessage(msg, ...args) {
|
||||
var handler = messageHandler.get(msg);
|
||||
if (handler) {
|
||||
handler(...args);
|
||||
var msgHandler = messageHandler.get(msg);
|
||||
if (msgHandler) {
|
||||
msgHandler(...args);
|
||||
} else {
|
||||
messageQueue.add([msg, ...args]);
|
||||
checkMessages();
|
||||
|
@ -111,10 +112,10 @@ ExtensionTestUtils.loadExtension = function(ext) {
|
|||
|
||||
var extension = SpecialPowers.loadExtension(ext, handler);
|
||||
|
||||
registerCleanup(() => {
|
||||
registerCleanup(async () => {
|
||||
if (extension.state == "pending" || extension.state == "running") {
|
||||
SimpleTest.ok(false, "Extension left running at test shutdown");
|
||||
return extension.unload();
|
||||
await extension.unload();
|
||||
} else if (extension.state == "unloading") {
|
||||
SimpleTest.ok(false, "Extension not fully unloaded at test shutdown");
|
||||
}
|
||||
|
|
|
@ -78,7 +78,7 @@ MemoryStats.dump = function(
|
|||
if (supported == MEM_STAT_UNKNOWN) {
|
||||
firstAccess = true;
|
||||
try {
|
||||
var value = mrm[stat];
|
||||
void mrm[stat];
|
||||
supported = MEM_STAT_SUPPORTED;
|
||||
} catch (e) {
|
||||
supported = MEM_STAT_UNSUPPORTED;
|
||||
|
@ -102,7 +102,7 @@ MemoryStats.dump = function(
|
|||
var basename = "about-memory-" + testNumber + ".json.gz";
|
||||
var dumpfile = MemoryStats.constructPathname(dumpOutputDirectory, basename);
|
||||
info(testURL + " | MEMDUMP-START " + dumpfile);
|
||||
var md = MemoryStats._getService(
|
||||
let md = MemoryStats._getService(
|
||||
"@mozilla.org/memory-info-dumper;1",
|
||||
"nsIMemoryInfoDumper"
|
||||
);
|
||||
|
@ -117,7 +117,7 @@ MemoryStats.dump = function(
|
|||
}
|
||||
|
||||
if (dumpDMD) {
|
||||
var md = MemoryStats._getService(
|
||||
let md = MemoryStats._getService(
|
||||
"@mozilla.org/memory-info-dumper;1",
|
||||
"nsIMemoryInfoDumper"
|
||||
);
|
||||
|
|
|
@ -34,7 +34,7 @@ MockObjectRegisterer.prototype = {
|
|||
*/
|
||||
register: function MOR_register() {
|
||||
if (this._originalCID) {
|
||||
throw new Exception("Invalid object state when calling register()");
|
||||
throw new Error("Invalid object state when calling register()");
|
||||
}
|
||||
|
||||
// Define a factory that creates a new object using the given constructor.
|
||||
|
@ -64,7 +64,7 @@ MockObjectRegisterer.prototype = {
|
|||
this._mockFactory
|
||||
);
|
||||
if ("error" in retVal) {
|
||||
throw new Exception("ERROR: " + retVal.error);
|
||||
throw new Error("ERROR: " + retVal.error);
|
||||
} else {
|
||||
this._originalCID = retVal.originalCID;
|
||||
}
|
||||
|
@ -75,7 +75,7 @@ MockObjectRegisterer.prototype = {
|
|||
*/
|
||||
unregister: function MOR_unregister() {
|
||||
if (!this._originalCID) {
|
||||
throw new Exception("Invalid object state when calling unregister()");
|
||||
throw new Error("Invalid object state when calling unregister()");
|
||||
}
|
||||
|
||||
// Free references to the mock factory.
|
||||
|
|
|
@ -16,6 +16,12 @@
|
|||
*
|
||||
**/
|
||||
|
||||
// Generally gTestPath should be set by the harness.
|
||||
/* global gTestPath */
|
||||
|
||||
// This can be loaded into a child process.
|
||||
/* eslint-env mozilla/frame-script */
|
||||
|
||||
var SimpleTest = {};
|
||||
var parentRunner = null;
|
||||
|
||||
|
@ -75,7 +81,7 @@ try {
|
|||
|
||||
/* Helper functions pulled out of various MochiKit modules */
|
||||
if (typeof repr == "undefined") {
|
||||
this.repr = function(o) {
|
||||
this.repr = function repr(o) {
|
||||
if (typeof o == "undefined") {
|
||||
return "undefined";
|
||||
} else if (o === null) {
|
||||
|
@ -84,7 +90,7 @@ if (typeof repr == "undefined") {
|
|||
try {
|
||||
if (typeof o.__repr__ == "function") {
|
||||
return o.__repr__();
|
||||
} else if (typeof o.repr == "function" && o.repr != arguments.callee) {
|
||||
} else if (typeof o.repr == "function" && o.repr != repr) {
|
||||
return o.repr();
|
||||
}
|
||||
} catch (e) {}
|
||||
|
@ -128,12 +134,12 @@ if (typeof repr == "undefined") {
|
|||
if (typeof partial == "undefined") {
|
||||
this.partial = function(func) {
|
||||
var args = [];
|
||||
for (var i = 1; i < arguments.length; i++) {
|
||||
for (let i = 1; i < arguments.length; i++) {
|
||||
args.push(arguments[i]);
|
||||
}
|
||||
return function() {
|
||||
if (arguments.length > 0) {
|
||||
for (var i = 1; i < arguments.length; i++) {
|
||||
for (let i = 1; i < arguments.length; i++) {
|
||||
args.push(arguments[i]);
|
||||
}
|
||||
}
|
||||
|
@ -150,8 +156,8 @@ if (typeof getElement == "undefined") {
|
|||
}
|
||||
|
||||
SimpleTest._newCallStack = function(path) {
|
||||
var rval = function() {
|
||||
var callStack = arguments.callee.callStack;
|
||||
var rval = function callStackHandler() {
|
||||
var callStack = callStackHandler.callStack;
|
||||
for (var i = 0; i < callStack.length; i++) {
|
||||
if (callStack[i].apply(this, arguments) === false) {
|
||||
break;
|
||||
|
@ -296,17 +302,19 @@ SimpleTest.ok = function(condition, name) {
|
|||
|
||||
SimpleTest.record = function(condition, name, diag, stack, expected) {
|
||||
var test = { result: !!condition, name, diag };
|
||||
let successInfo;
|
||||
let failureInfo;
|
||||
if (SimpleTest.expected == "fail") {
|
||||
if (!test.result) {
|
||||
SimpleTest.num_failed++;
|
||||
test.result = !test.result;
|
||||
}
|
||||
var successInfo = {
|
||||
successInfo = {
|
||||
status: "PASS",
|
||||
expected: "PASS",
|
||||
message: "TEST-PASS",
|
||||
};
|
||||
var failureInfo = {
|
||||
failureInfo = {
|
||||
status: "FAIL",
|
||||
expected: "FAIL",
|
||||
message: "TEST-KNOWN-FAIL",
|
||||
|
@ -317,34 +325,34 @@ SimpleTest.record = function(condition, name, diag, stack, expected) {
|
|||
// Add a mark for unexpected failures suppressed by failure pattern.
|
||||
name = "[suppressed] " + name;
|
||||
}
|
||||
var successInfo = {
|
||||
successInfo = {
|
||||
status: "FAIL",
|
||||
expected: "FAIL",
|
||||
message: "TEST-KNOWN-FAIL",
|
||||
};
|
||||
var failureInfo = {
|
||||
failureInfo = {
|
||||
status: "FAIL",
|
||||
expected: "PASS",
|
||||
message: "TEST-UNEXPECTED-FAIL",
|
||||
};
|
||||
} else if (expected == "fail") {
|
||||
var successInfo = {
|
||||
successInfo = {
|
||||
status: "PASS",
|
||||
expected: "FAIL",
|
||||
message: "TEST-UNEXPECTED-PASS",
|
||||
};
|
||||
var failureInfo = {
|
||||
failureInfo = {
|
||||
status: "FAIL",
|
||||
expected: "FAIL",
|
||||
message: "TEST-KNOWN-FAIL",
|
||||
};
|
||||
} else {
|
||||
var successInfo = {
|
||||
successInfo = {
|
||||
status: "PASS",
|
||||
expected: "PASS",
|
||||
message: "TEST-PASS",
|
||||
};
|
||||
var failureInfo = {
|
||||
failureInfo = {
|
||||
status: "FAIL",
|
||||
expected: "PASS",
|
||||
message: "TEST-UNEXPECTED-FAIL",
|
||||
|
@ -447,8 +455,6 @@ SimpleTest.todo = function(condition, name, diag) {
|
|||
* slave)
|
||||
*/
|
||||
SimpleTest.getTestFileURL = function(path) {
|
||||
var lastSlashIdx = path.lastIndexOf("/") + 1;
|
||||
var filename = path.substr(lastSlashIdx);
|
||||
var location = window.location;
|
||||
// Remove mochitest html file name from the path
|
||||
var remotePath = location.pathname.replace(/\/[^\/]+?$/, "");
|
||||
|
@ -582,6 +588,7 @@ SimpleTest.report = function() {
|
|||
}
|
||||
|
||||
var summary_class =
|
||||
// eslint-disable-next-line no-nested-ternary
|
||||
failed != 0 ? "some_fail" : passed == 0 ? "todo_only" : "all_pass";
|
||||
|
||||
var div1 = createEl("div", { class: "tests_report" });
|
||||
|
@ -846,7 +853,8 @@ SimpleTest.waitForFocus = function(callback, targetWindow, expectBlankPage) {
|
|||
// If a child frame in a child process must be focused, a
|
||||
// WaitForFocus:FocusChild message is then sent to the child to focus that
|
||||
// child. This message is used so that the child frame can be passed to it.
|
||||
function waitForFocusInner(targetWindow, isChildProcess, expectBlankPage) {
|
||||
/* eslint-disable mozilla/use-services */
|
||||
function waitForFocusInner(targetWin, isChildProcess, expectBlank) {
|
||||
/* Indicates whether the desired targetWindow has loaded or focused. The
|
||||
finished flag is set when the callback has been called and is used to
|
||||
reject extraneous events from invoking the callback again. */
|
||||
|
@ -880,7 +888,7 @@ SimpleTest.waitForFocus = function(callback, targetWindow, expectBlankPage) {
|
|||
try {
|
||||
if (event) {
|
||||
if (event.type == "load") {
|
||||
if (expectBlankPage != (event.target.location == "about:blank")) {
|
||||
if (expectBlank != (event.target.location == "about:blank")) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -903,7 +911,7 @@ SimpleTest.waitForFocus = function(callback, targetWindow, expectBlankPage) {
|
|||
} else {
|
||||
SimpleTest._pendingWaitForFocusCount--;
|
||||
SimpleTest.executeSoon(function() {
|
||||
callback(targetWindow);
|
||||
callback(targetWin);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -929,7 +937,7 @@ SimpleTest.waitForFocus = function(callback, targetWindow, expectBlankPage) {
|
|||
page to load. A common situation is to wait for a newly opened window
|
||||
to load its content, and we want to skip over any intermediate blank
|
||||
pages that load. This issue is described in bug 554873. */
|
||||
loaded = expectBlankPage
|
||||
loaded = expectBlank
|
||||
? getHref(desiredWindow) == "about:blank"
|
||||
: getHref(desiredWindow) != "about:blank" &&
|
||||
desiredWindow.document.readyState == "complete";
|
||||
|
@ -976,7 +984,7 @@ SimpleTest.waitForFocus = function(callback, targetWindow, expectBlankPage) {
|
|||
});
|
||||
}
|
||||
|
||||
waitForLoadAndFocusOnWindow(targetWindow);
|
||||
waitForLoadAndFocusOnWindow(targetWin);
|
||||
}
|
||||
|
||||
SimpleTest._pendingWaitForFocusCount++;
|
||||
|
@ -996,7 +1004,9 @@ SimpleTest.waitForFocus = function(callback, targetWindow, expectBlankPage) {
|
|||
var c = Object.getOwnPropertyDescriptor(window, "Components");
|
||||
var Cu, Ci;
|
||||
if (c && c.value && !c.writable) {
|
||||
// eslint-disable-next-line mozilla/use-cc-etc
|
||||
Cu = Components.utils;
|
||||
// eslint-disable-next-line mozilla/use-cc-etc
|
||||
Ci = Components.interfaces;
|
||||
} else {
|
||||
Cu = SpecialPowers.Cu;
|
||||
|
@ -1051,6 +1061,7 @@ SimpleTest.waitForFocus = function(callback, targetWindow, expectBlankPage) {
|
|||
waitForFocusInner(targetWindow, false, expectBlankPage);
|
||||
}
|
||||
};
|
||||
/* eslint-enable mozilla/use-services */
|
||||
|
||||
/*
|
||||
* Polls the clipboard waiting for the expected value. A known value different than
|
||||
|
@ -1138,32 +1149,27 @@ SimpleTest.promiseClipboardChange = async function(
|
|||
inputValidatorFn = function(aData) {
|
||||
return aData != initialVal;
|
||||
};
|
||||
} else {
|
||||
// Build a default validator function for common string input.
|
||||
if (typeof aExpectedStringOrValidatorFn == "string") {
|
||||
if (aExpectedStringOrValidatorFn.includes("\r")) {
|
||||
throw new Error(
|
||||
"Use function instead of string to compare raw line breakers in clipboard"
|
||||
);
|
||||
}
|
||||
if (
|
||||
requestedFlavor === "text/html" &&
|
||||
navigator.platform.includes("Win")
|
||||
) {
|
||||
inputValidatorFn = function(aData) {
|
||||
return (
|
||||
aData.replace(/\r\n?/g, "\n") ===
|
||||
`<html><body>\n<!--StartFragment-->${aExpectedStringOrValidatorFn}<!--EndFragment-->\n</body>\n</html>`
|
||||
);
|
||||
};
|
||||
} else {
|
||||
inputValidatorFn = function(aData) {
|
||||
return aData.replace(/\r\n?/g, "\n") === aExpectedStringOrValidatorFn;
|
||||
};
|
||||
}
|
||||
} else {
|
||||
inputValidatorFn = aExpectedStringOrValidatorFn;
|
||||
} else if (typeof aExpectedStringOrValidatorFn == "string") {
|
||||
if (aExpectedStringOrValidatorFn.includes("\r")) {
|
||||
throw new Error(
|
||||
"Use function instead of string to compare raw line breakers in clipboard"
|
||||
);
|
||||
}
|
||||
if (requestedFlavor === "text/html" && navigator.platform.includes("Win")) {
|
||||
inputValidatorFn = function(aData) {
|
||||
return (
|
||||
aData.replace(/\r\n?/g, "\n") ===
|
||||
`<html><body>\n<!--StartFragment-->${aExpectedStringOrValidatorFn}<!--EndFragment-->\n</body>\n</html>`
|
||||
);
|
||||
};
|
||||
} else {
|
||||
inputValidatorFn = function(aData) {
|
||||
return aData.replace(/\r\n?/g, "\n") === aExpectedStringOrValidatorFn;
|
||||
};
|
||||
}
|
||||
} else {
|
||||
inputValidatorFn = aExpectedStringOrValidatorFn;
|
||||
}
|
||||
|
||||
let maxPolls = aTimeout ? aTimeout / 100 : 50;
|
||||
|
@ -1199,8 +1205,9 @@ SimpleTest.promiseClipboardChange = async function(
|
|||
"Timed out while polling clipboard for pasted data, got: " + data
|
||||
);
|
||||
if (!aExpectFailure) {
|
||||
throw "failed";
|
||||
throw new Error("failed");
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
// First we wait for a known value different from the expected one.
|
||||
|
@ -1214,7 +1221,7 @@ SimpleTest.promiseClipboardChange = async function(
|
|||
"text/unicode"
|
||||
);
|
||||
|
||||
return await putAndVerify(aSetupFn, inputValidatorFn, requestedFlavor);
|
||||
return putAndVerify(aSetupFn, inputValidatorFn, requestedFlavor);
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -1310,18 +1317,18 @@ SimpleTest.finish = function() {
|
|||
}
|
||||
|
||||
if (SimpleTest.expected == "fail" && SimpleTest.num_failed <= 0) {
|
||||
msg = "We expected at least one failure";
|
||||
var test = {
|
||||
let msg = "We expected at least one failure";
|
||||
let test = {
|
||||
result: false,
|
||||
name: "fail-if condition in manifest",
|
||||
diag: msg,
|
||||
};
|
||||
var successInfo = {
|
||||
let successInfo = {
|
||||
status: "FAIL",
|
||||
expected: "FAIL",
|
||||
message: "TEST-KNOWN-FAIL",
|
||||
};
|
||||
var failureInfo = {
|
||||
let failureInfo = {
|
||||
status: "PASS",
|
||||
expected: "FAIL",
|
||||
message: "TEST-UNEXPECTED-PASS",
|
||||
|
@ -1340,16 +1347,16 @@ SimpleTest.finish = function() {
|
|||
} else {
|
||||
return;
|
||||
}
|
||||
var name = pat
|
||||
let name = pat
|
||||
? `failure pattern \`${pat}\` in this test`
|
||||
: "failures in this test";
|
||||
var test = { result: false, name, diag };
|
||||
var successInfo = {
|
||||
let test = { result: false, name, diag };
|
||||
let successInfo = {
|
||||
status: "PASS",
|
||||
expected: "PASS",
|
||||
message: "TEST-PASS",
|
||||
};
|
||||
var failureInfo = {
|
||||
let failureInfo = {
|
||||
status: "FAIL",
|
||||
expected: "PASS",
|
||||
message: "TEST-UNEXPECTED-FAIL",
|
||||
|
@ -1539,7 +1546,7 @@ SimpleTest.monitorConsole = function(continuation, msgs, forbidUnexpectedMsgs) {
|
|||
var forbiddenMsgs = [];
|
||||
var i = 0;
|
||||
while (i < msgs.length) {
|
||||
var pat = msgs[i];
|
||||
let pat = msgs[i];
|
||||
if ("forbid" in pat) {
|
||||
var forbid = pat.forbid;
|
||||
delete pat.forbid;
|
||||
|
@ -1564,7 +1571,7 @@ SimpleTest.monitorConsole = function(continuation, msgs, forbidUnexpectedMsgs) {
|
|||
SimpleTest.executeSoon(continuation);
|
||||
return;
|
||||
}
|
||||
for (var pat of forbiddenMsgs) {
|
||||
for (let pat of forbiddenMsgs) {
|
||||
if (msgMatches(msg, pat)) {
|
||||
ok(
|
||||
false,
|
||||
|
@ -1792,7 +1799,7 @@ SimpleTest._eqAssoc = function(o1, o2, stack, seen) {
|
|||
// confusing a reference seen more than once (such as [a, a]) for a
|
||||
// circular reference.
|
||||
seen = seen.slice(0);
|
||||
for (var j = 0; j < seen.length; j++) {
|
||||
for (let j = 0; j < seen.length; j++) {
|
||||
if (seen[j][0] == o1) {
|
||||
return seen[j][1] == o2;
|
||||
}
|
||||
|
@ -1807,15 +1814,17 @@ SimpleTest._eqAssoc = function(o1, o2, stack, seen) {
|
|||
var ok = true;
|
||||
// Only examines enumerable attributes.
|
||||
var o1Size = 0;
|
||||
for (var i in o1) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
for (let i in o1) {
|
||||
o1Size++;
|
||||
}
|
||||
var o2Size = 0;
|
||||
for (var i in o2) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
for (let i in o2) {
|
||||
o2Size++;
|
||||
}
|
||||
var bigger = o1Size > o2Size ? o1 : o2;
|
||||
for (var i in bigger) {
|
||||
for (let i in bigger) {
|
||||
var e1 = i in o1 ? o1[i] : SimpleTest.DNE;
|
||||
var e2 = i in o2 ? o2[i] : SimpleTest.DNE;
|
||||
stack.push({ type: "Object", idx: i, vals: [e1, e2] });
|
||||
|
@ -1831,7 +1840,7 @@ SimpleTest._eqAssoc = function(o1, o2, stack, seen) {
|
|||
|
||||
SimpleTest._formatStack = function(stack) {
|
||||
var variable = "$Foo";
|
||||
for (var i = 0; i < stack.length; i++) {
|
||||
for (let i = 0; i < stack.length; i++) {
|
||||
var entry = stack[i];
|
||||
var type = entry.type;
|
||||
var idx = entry.idx;
|
||||
|
@ -1854,7 +1863,7 @@ SimpleTest._formatStack = function(stack) {
|
|||
];
|
||||
|
||||
var out = "Structures begin differing at:" + SimpleTest.LF;
|
||||
for (var i = 0; i < vals.length; i++) {
|
||||
for (let i = 0; i < vals.length; i++) {
|
||||
var val = vals[i];
|
||||
if (val === SimpleTest.DNE) {
|
||||
val = "Does not exist";
|
||||
|
|
|
@ -6,6 +6,14 @@
|
|||
* data = json object {"filename":filename} <- for LoggerInit
|
||||
*/
|
||||
|
||||
// This file expects the following files to be loaded.
|
||||
/* import-globals-from ../../../modules/StructuredLog.jsm */
|
||||
/* import-globals-from LogController.js */
|
||||
/* import-globals-from MemoryStats.js */
|
||||
/* import-globals-from MozillaLogger.js */
|
||||
|
||||
/* eslint-disable no-unsanitized/property */
|
||||
|
||||
"use strict";
|
||||
|
||||
function getElement(id) {
|
||||
|
@ -197,7 +205,7 @@ TestRunner.expectAssertions = function(min, max) {
|
|||
min < 0 ||
|
||||
max < min
|
||||
) {
|
||||
throw "bad parameter to expectAssertions";
|
||||
throw new Error("bad parameter to expectAssertions");
|
||||
}
|
||||
TestRunner._expectedMinAsserts = min;
|
||||
TestRunner._expectedMaxAsserts = max;
|
||||
|
@ -237,11 +245,7 @@ TestRunner.generateFailureList = function() {
|
|||
**/
|
||||
|
||||
// This delimiter is used to avoid interleaving Mochitest/Gecko logs.
|
||||
var LOG_DELIMITER =
|
||||
String.fromCharCode(0xe175) +
|
||||
String.fromCharCode(0xee31) +
|
||||
String.fromCharCode(0x2c32) +
|
||||
String.fromCharCode(0xacbf);
|
||||
var LOG_DELIMITER = "\ue175\uee31\u2c32\uacbf";
|
||||
|
||||
// A log callback for StructuredLog.jsm
|
||||
TestRunner._dumpMessage = function(message) {
|
||||
|
@ -308,6 +312,7 @@ TestRunner.failureHandler = function() {
|
|||
if (TestRunner.debugOnFailure) {
|
||||
// You've hit this line because you requested to break into the
|
||||
// debugger upon a testcase failure on your test run.
|
||||
// eslint-disable-next-line no-debugger
|
||||
debugger;
|
||||
}
|
||||
};
|
||||
|
@ -354,7 +359,6 @@ TestRunner._makeIframe = function(url, retry) {
|
|||
iframe.src = url;
|
||||
iframe.name = url;
|
||||
iframe.width = "500";
|
||||
return iframe;
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -608,7 +612,7 @@ TestRunner.testFinished = function(tests) {
|
|||
TestRunner._expectingProcessCrash
|
||||
))
|
||||
) {
|
||||
var subtest = "expected-crash-dump-missing";
|
||||
let subtest = "expected-crash-dump-missing";
|
||||
TestRunner.structuredLogger.testStatus(
|
||||
TestRunner.currentTestURL,
|
||||
subtest,
|
||||
|
@ -623,7 +627,7 @@ TestRunner.testFinished = function(tests) {
|
|||
var unexpectedCrashDumpFiles = await SpecialPowers.findUnexpectedCrashDumpFiles();
|
||||
TestRunner._expectingProcessCrash = false;
|
||||
if (unexpectedCrashDumpFiles.length) {
|
||||
var subtest = "unexpected-crash-dump-found";
|
||||
let subtest = "unexpected-crash-dump-found";
|
||||
TestRunner.structuredLogger.testStatus(
|
||||
TestRunner.currentTestURL,
|
||||
subtest,
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
(function() {
|
||||
var accumulatedRect = null;
|
||||
var onpaint = new Array();
|
||||
var onpaint = [];
|
||||
var debug = SpecialPowers.getBoolPref("testing.paint_listener.debug", false);
|
||||
const FlushModes = {
|
||||
FLUSH: 0,
|
||||
|
|
|
@ -6,6 +6,17 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
// This file expects the following files to be loaded.
|
||||
/* import-globals-from TestRunner.js */
|
||||
|
||||
// From the harness:
|
||||
/* import-globals-from ../../chrome-harness.js */
|
||||
/* import-globals-from ../../chunkifyTests.js */
|
||||
|
||||
// It appears we expect these from one of the MochiKit scripts.
|
||||
/* global toggleElementClass, removeElementClass, addElementClass,
|
||||
hasElementClass */
|
||||
|
||||
TestRunner.logEnabled = true;
|
||||
TestRunner.logger = LogController;
|
||||
|
||||
|
@ -210,9 +221,9 @@ RunSet.runtests = function(e) {
|
|||
RunSet.reloadAndRunAll = function(e) {
|
||||
e.preventDefault();
|
||||
//window.location.hash = "";
|
||||
var addParam = "";
|
||||
if (params.autorun) {
|
||||
window.location.search += "";
|
||||
// eslint-disable-next-line no-self-assign
|
||||
window.location.href = window.location.href;
|
||||
} else if (window.location.search) {
|
||||
window.location.href += "&autorun=1";
|
||||
|
|
Загрузка…
Ссылка в новой задаче