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:
Mark Banner 2020-02-11 17:33:15 +00:00
parent 32182ed29c
commit 053da90c15
11 changed files with 151 additions and 142 deletions

View file

@ -180,7 +180,6 @@ servo/
# third party modules # third party modules
testing/mochitest/tests/Harness_sanity/ testing/mochitest/tests/Harness_sanity/
testing/mochitest/tests/SimpleTest/
# Test files that we don't want to lint (preprocessed, minified etc) # Test files that we don't want to lint (preprocessed, minified etc)
testing/marionette/atom.js testing/marionette/atom.js

View file

@ -27,7 +27,11 @@ const browserTestPaths = [
]; ];
const mochitestTestPaths = [ 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 = [ const chromeTestPaths = [
@ -108,7 +112,6 @@ module.exports = {
"excludedFiles": [ "excludedFiles": [
"devtools/**", "devtools/**",
"security/manager/ssl/tests/mochitest/browser/**", "security/manager/ssl/tests/mochitest/browser/**",
"testing/mochitest/**",
], ],
}, { }, {
...removeOverrides(chromeTestConfig), ...removeOverrides(chromeTestConfig),

View file

@ -6,17 +6,19 @@
"use strict"; "use strict";
/* eslint-env mozilla/frame-script */
function ChromeTask_ChromeScript() { function ChromeTask_ChromeScript() {
"use strict"; "use strict";
const { Task } = ChromeUtils.import("resource://testing-common/Task.jsm"); const { Task } = ChromeUtils.import("resource://testing-common/Task.jsm");
// eslint-disable-next-line no-unused-vars
const { Services } = ChromeUtils.import( const { Services } = ChromeUtils.import(
"resource://gre/modules/Services.jsm" "resource://gre/modules/Services.jsm"
); );
const AssertCls = ChromeUtils.import( const { Assert: AssertCls } = ChromeUtils.import(
"resource://testing-common/Assert.jsm", "resource://testing-common/Assert.jsm"
null );
).Assert;
addMessageListener("chrome-task:spawn", function(aData) { addMessageListener("chrome-task:spawn", function(aData) {
let id = aData.id; let id = aData.id;

View file

@ -26,6 +26,10 @@
* When adding methods to this file, please add a performance test for it. * 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 // 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 // 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 // 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 // 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 whether the property is read-only or not. The real |Components| property
// is read-only. // is read-only.
/* global _EU_Ci, _EU_Cc, _EU_Cu, _EU_OS */
window.__defineGetter__("_EU_Ci", function() { window.__defineGetter__("_EU_Ci", function() {
var c = Object.getOwnPropertyDescriptor(window, "Components"); var c = Object.getOwnPropertyDescriptor(window, "Components");
return c && c.value && !c.writable ? Ci : SpecialPowers.Ci; return c && c.value && !c.writable ? Ci : SpecialPowers.Ci;
@ -189,6 +194,7 @@ function sendMouseEvent(aEvent, aTarget, aWindow) {
var viewArg = aWindow; var viewArg = aWindow;
var detailArg = var detailArg =
aEvent.detail || aEvent.detail ||
// eslint-disable-next-line no-nested-ternary
(aEvent.type == "click" || (aEvent.type == "click" ||
aEvent.type == "mousedown" || aEvent.type == "mousedown" ||
aEvent.type == "mouseup" aEvent.type == "mouseup"
@ -394,7 +400,6 @@ function sendKey(aKey, aWindow) {
* synthesizeMouse and synthesizeKey. * synthesizeMouse and synthesizeKey.
*/ */
function _parseModifiers(aEvent, aWindow = window) { function _parseModifiers(aEvent, aWindow = window) {
var navigator = _getNavigator(aWindow);
var nsIDOMWindowUtils = _EU_Ci.nsIDOMWindowUtils; var nsIDOMWindowUtils = _EU_Ci.nsIDOMWindowUtils;
var mval = 0; var mval = 0;
if (aEvent.shiftKey) { if (aEvent.shiftKey) {
@ -700,7 +705,6 @@ function synthesizeWheelAtPoint(aLeft, aTop, aEvent, aWindow = window) {
options |= utils.WHEEL_EVENT_EXPECTED_OVERFLOW_DELTA_Y_NEGATIVE; options |= utils.WHEEL_EVENT_EXPECTED_OVERFLOW_DELTA_Y_NEGATIVE;
} }
} }
var isNoLineOrPageDelta = aEvent.isNoLineOrPageDelta;
// Avoid the JS warnings "reference to undefined property" // Avoid the JS warnings "reference to undefined property"
if (!aEvent.deltaX) { if (!aEvent.deltaX) {
@ -714,12 +718,14 @@ function synthesizeWheelAtPoint(aLeft, aTop, aEvent, aWindow = window) {
} }
var lineOrPageDeltaX = var lineOrPageDeltaX =
// eslint-disable-next-line no-nested-ternary
aEvent.lineOrPageDeltaX != null aEvent.lineOrPageDeltaX != null
? aEvent.lineOrPageDeltaX ? aEvent.lineOrPageDeltaX
: aEvent.deltaX > 0 : aEvent.deltaX > 0
? Math.floor(aEvent.deltaX) ? Math.floor(aEvent.deltaX)
: Math.ceil(aEvent.deltaX); : Math.ceil(aEvent.deltaX);
var lineOrPageDeltaY = var lineOrPageDeltaY =
// eslint-disable-next-line no-nested-ternary
aEvent.lineOrPageDeltaY != null aEvent.lineOrPageDeltaY != null
? aEvent.lineOrPageDeltaY ? aEvent.lineOrPageDeltaY
: aEvent.deltaY > 0 : aEvent.deltaY > 0
@ -1135,6 +1141,7 @@ function synthesizeAndWaitKey(
resolve(); resolve();
}); });
}); });
// eslint-disable-next-line no-shadow
let keyReceivedPromise = ContentTask.spawn(browser, keyCode, keyCode => { let keyReceivedPromise = ContentTask.spawn(browser, keyCode, keyCode => {
return new Promise(resolve => { return new Promise(resolve => {
addEventListener("keyup", function onKeyEvent(e) { addEventListener("keyup", function onKeyEvent(e) {
@ -1159,7 +1166,6 @@ function synthesizeAndWaitKey(
} }
function _parseNativeModifiers(aModifiers, aWindow = window) { function _parseNativeModifiers(aModifiers, aWindow = window) {
var navigator = _getNavigator(aWindow);
var modifiers; var modifiers;
if (aModifiers.capsLockKey) { if (aModifiers.capsLockKey) {
modifiers |= 0x00000001; modifiers |= 0x00000001;
@ -1361,7 +1367,6 @@ function synthesizeNativeKey(
if (!utils) { if (!utils) {
return false; return false;
} }
var navigator = _getNavigator(aWindow);
var nativeKeyboardLayout = null; var nativeKeyboardLayout = null;
if (_EU_isMac(aWindow)) { if (_EU_isMac(aWindow)) {
nativeKeyboardLayout = aKeyboardLayout.Mac; nativeKeyboardLayout = aKeyboardLayout.Mac;
@ -1604,13 +1609,7 @@ function _getKeyboardEvent(aWindow = window) {
return aWindow.KeyboardEvent; return aWindow.KeyboardEvent;
} }
function _getNavigator(aWindow = window) { // eslint-disable-next-line complexity
if (typeof navigator != "undefined") {
return navigator;
}
return aWindow.navigator;
}
function _guessKeyNameFromKeyCode(aKeyCode, aWindow = window) { function _guessKeyNameFromKeyCode(aKeyCode, aWindow = window) {
var KeyboardEvent = _getKeyboardEvent(aWindow); var KeyboardEvent = _getKeyboardEvent(aWindow);
switch (aKeyCode) { switch (aKeyCode) {
@ -1788,7 +1787,7 @@ function _createKeyboardEventDictionary(
} else if (aKey.indexOf("VK_") == 0) { } else if (aKey.indexOf("VK_") == 0) {
keyCode = _getKeyboardEvent(aWindow)["DOM_" + aKey]; keyCode = _getKeyboardEvent(aWindow)["DOM_" + aKey];
if (!keyCode) { if (!keyCode) {
throw "Unknown key: " + aKey; throw new Error("Unknown key: " + aKey);
} }
keyName = _guessKeyNameFromKeyCode(keyCode, aWindow); keyName = _guessKeyNameFromKeyCode(keyCode, aWindow);
result.flags |= _EU_Ci.nsITextInputProcessor.KEY_NON_PRINTABLE_KEY; result.flags |= _EU_Ci.nsITextInputProcessor.KEY_NON_PRINTABLE_KEY;
@ -1843,7 +1842,6 @@ function _emulateToActivateModifiers(aTIP, aKeyEvent, aWindow = window) {
return null; return null;
} }
var KeyboardEvent = _getKeyboardEvent(aWindow); var KeyboardEvent = _getKeyboardEvent(aWindow);
var navigator = _getNavigator(aWindow);
var modifiers = { var modifiers = {
normal: [ 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]) { if (!aKeyEvent[modifiers.normal[i].attr]) {
continue; continue;
} }
if (aTIP.getModifierState(modifiers.normal[i].key)) { if (aTIP.getModifierState(modifiers.normal[i].key)) {
continue; // already activated. continue; // already activated.
} }
var event = new KeyboardEvent("", { key: modifiers.normal[i].key }); let event = new KeyboardEvent("", { key: modifiers.normal[i].key });
aTIP.keydown( aTIP.keydown(
event, event,
aTIP.KEY_NON_PRINTABLE_KEY | aTIP.KEY_DONT_DISPATCH_MODIFIER_KEY_EVENT aTIP.KEY_NON_PRINTABLE_KEY | aTIP.KEY_DONT_DISPATCH_MODIFIER_KEY_EVENT
); );
modifiers.normal[i].activated = true; 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]) { if (!aKeyEvent[modifiers.lockable[i].attr]) {
continue; continue;
} }
if (aTIP.getModifierState(modifiers.lockable[i].key)) { if (aTIP.getModifierState(modifiers.lockable[i].key)) {
continue; // already activated. continue; // already activated.
} }
var event = new KeyboardEvent("", { key: modifiers.lockable[i].key }); let event = new KeyboardEvent("", { key: modifiers.lockable[i].key });
aTIP.keydown( aTIP.keydown(
event, event,
aTIP.KEY_NON_PRINTABLE_KEY | aTIP.KEY_DONT_DISPATCH_MODIFIER_KEY_EVENT aTIP.KEY_NON_PRINTABLE_KEY | aTIP.KEY_DONT_DISPATCH_MODIFIER_KEY_EVENT
@ -1906,24 +1904,24 @@ function _emulateToInactivateModifiers(aTIP, aModifiers, aWindow = window) {
return; return;
} }
var KeyboardEvent = _getKeyboardEvent(aWindow); 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) { if (!aModifiers.normal[i].activated) {
continue; continue;
} }
var event = new KeyboardEvent("", { key: aModifiers.normal[i].key }); let event = new KeyboardEvent("", { key: aModifiers.normal[i].key });
aTIP.keyup( aTIP.keyup(
event, event,
aTIP.KEY_NON_PRINTABLE_KEY | aTIP.KEY_DONT_DISPATCH_MODIFIER_KEY_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) { if (!aModifiers.lockable[i].activated) {
continue; continue;
} }
if (!aTIP.getModifierState(aModifiers.lockable[i].key)) { if (!aTIP.getModifierState(aModifiers.lockable[i].key)) {
continue; // who already inactivated this? 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( aTIP.keydown(
event, event,
aTIP.KEY_NON_PRINTABLE_KEY | aTIP.KEY_DONT_DISPATCH_MODIFIER_KEY_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) { function synthesizeComposition(aEvent, aWindow = window, aCallback) {
var TIP = _getTIP(aWindow, aCallback); var TIP = _getTIP(aWindow, aCallback);
if (!TIP) { if (!TIP) {
return false; return;
} }
var KeyboardEvent = _getKeyboardEvent(aWindow); var KeyboardEvent = _getKeyboardEvent(aWindow);
var modifiers = _emulateToActivateModifiers(TIP, aEvent.key, aWindow); var modifiers = _emulateToActivateModifiers(TIP, aEvent.key, aWindow);
var ret = false;
var keyEventDict = { dictionary: null, flags: 0 }; var keyEventDict = { dictionary: null, flags: 0 };
var keyEvent = null; var keyEvent = null;
if (aEvent.key && typeof aEvent.key.key === "string") { if (aEvent.key && typeof aEvent.key.key === "string") {
@ -1999,6 +1996,7 @@ function synthesizeComposition(aEvent, aWindow = window, aCallback) {
aWindow aWindow
); );
keyEvent = new KeyboardEvent( keyEvent = new KeyboardEvent(
// eslint-disable-next-line no-nested-ternary
aEvent.key.type === "keydown" aEvent.key.type === "keydown"
? "keydown" ? "keydown"
: aEvent.key.type === "keyup" : aEvent.key.type === "keyup"
@ -2018,17 +2016,13 @@ function synthesizeComposition(aEvent, aWindow = window, aCallback) {
try { try {
switch (aEvent.type) { switch (aEvent.type) {
case "compositionstart": case "compositionstart":
ret = TIP.startComposition(keyEvent, keyEventDict.flags); TIP.startComposition(keyEvent, keyEventDict.flags);
break; break;
case "compositioncommitasis": case "compositioncommitasis":
ret = TIP.commitComposition(keyEvent, keyEventDict.flags); TIP.commitComposition(keyEvent, keyEventDict.flags);
break; break;
case "compositioncommit": case "compositioncommit":
ret = TIP.commitCompositionWith( TIP.commitCompositionWith(aEvent.data, keyEvent, keyEventDict.flags);
aEvent.data,
keyEvent,
keyEventDict.flags
);
break; break;
} }
} finally { } finally {
@ -2132,7 +2126,6 @@ function synthesizeCompositionChange(aEvent, aWindow = window, aCallback) {
break; break;
default: default:
throw new Error("invalid clause attribute specified"); throw new Error("invalid clause attribute specified");
break;
} }
} }
} }
@ -2153,6 +2146,7 @@ function synthesizeCompositionChange(aEvent, aWindow = window, aCallback) {
aWindow aWindow
); );
keyEvent = new KeyboardEvent( keyEvent = new KeyboardEvent(
// eslint-disable-next-line no-nested-ternary
aEvent.key.type === "keydown" aEvent.key.type === "keydown"
? "keydown" ? "keydown"
: aEvent.key.type === "keyup" : aEvent.key.type === "keyup"
@ -2212,7 +2206,7 @@ const SELECTION_SET_FLAG_REVERSE = 0x0002;
function synthesizeQueryTextContent(aOffset, aLength, aIsRelative, aWindow) { function synthesizeQueryTextContent(aOffset, aLength, aIsRelative, aWindow) {
var utils = _getDOMWindowUtils(aWindow); var utils = _getDOMWindowUtils(aWindow);
if (!utils) { if (!utils) {
return nullptr; return null;
} }
var flags = QUERY_CONTENT_FLAG_USE_NATIVE_LINE_BREAK; var flags = QUERY_CONTENT_FLAG_USE_NATIVE_LINE_BREAK;
if (aIsRelative === true) { if (aIsRelative === true) {
@ -2240,10 +2234,6 @@ function synthesizeQueryTextContent(aOffset, aLength, aIsRelative, aWindow) {
*/ */
function synthesizeQuerySelectedText(aSelectionType, aWindow) { function synthesizeQuerySelectedText(aSelectionType, aWindow) {
var utils = _getDOMWindowUtils(aWindow); var utils = _getDOMWindowUtils(aWindow);
if (!utils) {
return null;
}
var flags = QUERY_CONTENT_FLAG_USE_NATIVE_LINE_BREAK; var flags = QUERY_CONTENT_FLAG_USE_NATIVE_LINE_BREAK;
if (aSelectionType) { if (aSelectionType) {
flags |= aSelectionType; flags |= aSelectionType;
@ -2444,9 +2434,6 @@ function synthesizeNativeOSXClick(x, y) {
*/ */
function synthesizeQueryTextRect(aOffset, aLength, aWindow) { function synthesizeQueryTextRect(aOffset, aLength, aWindow) {
var utils = _getDOMWindowUtils(aWindow); var utils = _getDOMWindowUtils(aWindow);
if (!utils) {
return nullptr;
}
return utils.sendQueryContentEvent( return utils.sendQueryContentEvent(
utils.QUERY_TEXT_RECT, utils.QUERY_TEXT_RECT,
aOffset, aOffset,
@ -2470,9 +2457,6 @@ function synthesizeQueryTextRect(aOffset, aLength, aWindow) {
*/ */
function synthesizeQueryTextRectArray(aOffset, aLength, aWindow) { function synthesizeQueryTextRectArray(aOffset, aLength, aWindow) {
var utils = _getDOMWindowUtils(aWindow); var utils = _getDOMWindowUtils(aWindow);
if (!utils) {
return nullptr;
}
return utils.sendQueryContentEvent( return utils.sendQueryContentEvent(
utils.QUERY_TEXT_RECT_ARRAY, utils.QUERY_TEXT_RECT_ARRAY,
aOffset, aOffset,
@ -2492,9 +2476,6 @@ function synthesizeQueryTextRectArray(aOffset, aLength, aWindow) {
*/ */
function synthesizeQueryEditorRect(aWindow) { function synthesizeQueryEditorRect(aWindow) {
var utils = _getDOMWindowUtils(aWindow); var utils = _getDOMWindowUtils(aWindow);
if (!utils) {
return nullptr;
}
return utils.sendQueryContentEvent( return utils.sendQueryContentEvent(
utils.QUERY_EDITOR_RECT, utils.QUERY_EDITOR_RECT,
0, 0,
@ -2515,9 +2496,6 @@ function synthesizeQueryEditorRect(aWindow) {
*/ */
function synthesizeCharAtPoint(aX, aY, aWindow) { function synthesizeCharAtPoint(aX, aY, aWindow) {
var utils = _getDOMWindowUtils(aWindow); var utils = _getDOMWindowUtils(aWindow);
if (!utils) {
return nullptr;
}
return utils.sendQueryContentEvent( return utils.sendQueryContentEvent(
utils.QUERY_CHARACTER_AT_POINT, utils.QUERY_CHARACTER_AT_POINT,
0, 0,
@ -2625,6 +2603,7 @@ function synthesizeDragOver(
aDestWindow = aWindow; aDestWindow = aWindow;
} }
// eslint-disable-next-line mozilla/use-services
const obs = _EU_Cc["@mozilla.org/observer-service;1"].getService( const obs = _EU_Cc["@mozilla.org/observer-service;1"].getService(
_EU_Ci.nsIObserverService _EU_Ci.nsIObserverService
); );
@ -2867,6 +2846,7 @@ function _computeSrcElementFromSrcSelection(aSrcSelection) {
* to log rect of target. E.g., `console.log`. * to log rect of target. E.g., `console.log`.
* } * }
*/ */
// eslint-disable-next-line complexity
async function synthesizePlainDragAndDrop(aParams) { async function synthesizePlainDragAndDrop(aParams) {
let { let {
dragEvent = {}, dragEvent = {},

View file

@ -9,6 +9,7 @@ ExtensionTestUtils.loadExtension = function(ext) {
// Cleanup functions need to be registered differently depending on // Cleanup functions need to be registered differently depending on
// whether we're in browser chrome or plain mochitests. // whether we're in browser chrome or plain mochitests.
var registerCleanup; var registerCleanup;
/* global registerCleanupFunction */
if (typeof registerCleanupFunction != "undefined") { if (typeof registerCleanupFunction != "undefined") {
registerCleanup = registerCleanupFunction; registerCleanup = registerCleanupFunction;
} else { } else {
@ -73,18 +74,18 @@ ExtensionTestUtils.loadExtension = function(ext) {
} }
var handler = { var handler = {
testResult(kind, pass, msg, ...args) { async testResult(kind, pass, msg, ...args) {
if (kind == "test-done") { if (kind == "test-done") {
SimpleTest.ok(pass, msg); SimpleTest.ok(pass, msg);
return testResolve(msg); await testResolve(msg);
} }
testHandler(kind, pass, msg, ...args); testHandler(kind, pass, msg, ...args);
}, },
testMessage(msg, ...args) { testMessage(msg, ...args) {
var handler = messageHandler.get(msg); var msgHandler = messageHandler.get(msg);
if (handler) { if (msgHandler) {
handler(...args); msgHandler(...args);
} else { } else {
messageQueue.add([msg, ...args]); messageQueue.add([msg, ...args]);
checkMessages(); checkMessages();
@ -111,10 +112,10 @@ ExtensionTestUtils.loadExtension = function(ext) {
var extension = SpecialPowers.loadExtension(ext, handler); var extension = SpecialPowers.loadExtension(ext, handler);
registerCleanup(() => { registerCleanup(async () => {
if (extension.state == "pending" || extension.state == "running") { if (extension.state == "pending" || extension.state == "running") {
SimpleTest.ok(false, "Extension left running at test shutdown"); SimpleTest.ok(false, "Extension left running at test shutdown");
return extension.unload(); await extension.unload();
} else if (extension.state == "unloading") { } else if (extension.state == "unloading") {
SimpleTest.ok(false, "Extension not fully unloaded at test shutdown"); SimpleTest.ok(false, "Extension not fully unloaded at test shutdown");
} }

View file

@ -78,7 +78,7 @@ MemoryStats.dump = function(
if (supported == MEM_STAT_UNKNOWN) { if (supported == MEM_STAT_UNKNOWN) {
firstAccess = true; firstAccess = true;
try { try {
var value = mrm[stat]; void mrm[stat];
supported = MEM_STAT_SUPPORTED; supported = MEM_STAT_SUPPORTED;
} catch (e) { } catch (e) {
supported = MEM_STAT_UNSUPPORTED; supported = MEM_STAT_UNSUPPORTED;
@ -102,7 +102,7 @@ MemoryStats.dump = function(
var basename = "about-memory-" + testNumber + ".json.gz"; var basename = "about-memory-" + testNumber + ".json.gz";
var dumpfile = MemoryStats.constructPathname(dumpOutputDirectory, basename); var dumpfile = MemoryStats.constructPathname(dumpOutputDirectory, basename);
info(testURL + " | MEMDUMP-START " + dumpfile); info(testURL + " | MEMDUMP-START " + dumpfile);
var md = MemoryStats._getService( let md = MemoryStats._getService(
"@mozilla.org/memory-info-dumper;1", "@mozilla.org/memory-info-dumper;1",
"nsIMemoryInfoDumper" "nsIMemoryInfoDumper"
); );
@ -117,7 +117,7 @@ MemoryStats.dump = function(
} }
if (dumpDMD) { if (dumpDMD) {
var md = MemoryStats._getService( let md = MemoryStats._getService(
"@mozilla.org/memory-info-dumper;1", "@mozilla.org/memory-info-dumper;1",
"nsIMemoryInfoDumper" "nsIMemoryInfoDumper"
); );

View file

@ -34,7 +34,7 @@ MockObjectRegisterer.prototype = {
*/ */
register: function MOR_register() { register: function MOR_register() {
if (this._originalCID) { 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. // Define a factory that creates a new object using the given constructor.
@ -64,7 +64,7 @@ MockObjectRegisterer.prototype = {
this._mockFactory this._mockFactory
); );
if ("error" in retVal) { if ("error" in retVal) {
throw new Exception("ERROR: " + retVal.error); throw new Error("ERROR: " + retVal.error);
} else { } else {
this._originalCID = retVal.originalCID; this._originalCID = retVal.originalCID;
} }
@ -75,7 +75,7 @@ MockObjectRegisterer.prototype = {
*/ */
unregister: function MOR_unregister() { unregister: function MOR_unregister() {
if (!this._originalCID) { 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. // Free references to the mock factory.

View file

@ -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 SimpleTest = {};
var parentRunner = null; var parentRunner = null;
@ -75,7 +81,7 @@ try {
/* Helper functions pulled out of various MochiKit modules */ /* Helper functions pulled out of various MochiKit modules */
if (typeof repr == "undefined") { if (typeof repr == "undefined") {
this.repr = function(o) { this.repr = function repr(o) {
if (typeof o == "undefined") { if (typeof o == "undefined") {
return "undefined"; return "undefined";
} else if (o === null) { } else if (o === null) {
@ -84,7 +90,7 @@ if (typeof repr == "undefined") {
try { try {
if (typeof o.__repr__ == "function") { if (typeof o.__repr__ == "function") {
return o.__repr__(); 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(); return o.repr();
} }
} catch (e) {} } catch (e) {}
@ -128,12 +134,12 @@ if (typeof repr == "undefined") {
if (typeof partial == "undefined") { if (typeof partial == "undefined") {
this.partial = function(func) { this.partial = function(func) {
var args = []; var args = [];
for (var i = 1; i < arguments.length; i++) { for (let i = 1; i < arguments.length; i++) {
args.push(arguments[i]); args.push(arguments[i]);
} }
return function() { return function() {
if (arguments.length > 0) { if (arguments.length > 0) {
for (var i = 1; i < arguments.length; i++) { for (let i = 1; i < arguments.length; i++) {
args.push(arguments[i]); args.push(arguments[i]);
} }
} }
@ -150,8 +156,8 @@ if (typeof getElement == "undefined") {
} }
SimpleTest._newCallStack = function(path) { SimpleTest._newCallStack = function(path) {
var rval = function() { var rval = function callStackHandler() {
var callStack = arguments.callee.callStack; var callStack = callStackHandler.callStack;
for (var i = 0; i < callStack.length; i++) { for (var i = 0; i < callStack.length; i++) {
if (callStack[i].apply(this, arguments) === false) { if (callStack[i].apply(this, arguments) === false) {
break; break;
@ -296,17 +302,19 @@ SimpleTest.ok = function(condition, name) {
SimpleTest.record = function(condition, name, diag, stack, expected) { SimpleTest.record = function(condition, name, diag, stack, expected) {
var test = { result: !!condition, name, diag }; var test = { result: !!condition, name, diag };
let successInfo;
let failureInfo;
if (SimpleTest.expected == "fail") { if (SimpleTest.expected == "fail") {
if (!test.result) { if (!test.result) {
SimpleTest.num_failed++; SimpleTest.num_failed++;
test.result = !test.result; test.result = !test.result;
} }
var successInfo = { successInfo = {
status: "PASS", status: "PASS",
expected: "PASS", expected: "PASS",
message: "TEST-PASS", message: "TEST-PASS",
}; };
var failureInfo = { failureInfo = {
status: "FAIL", status: "FAIL",
expected: "FAIL", expected: "FAIL",
message: "TEST-KNOWN-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. // Add a mark for unexpected failures suppressed by failure pattern.
name = "[suppressed] " + name; name = "[suppressed] " + name;
} }
var successInfo = { successInfo = {
status: "FAIL", status: "FAIL",
expected: "FAIL", expected: "FAIL",
message: "TEST-KNOWN-FAIL", message: "TEST-KNOWN-FAIL",
}; };
var failureInfo = { failureInfo = {
status: "FAIL", status: "FAIL",
expected: "PASS", expected: "PASS",
message: "TEST-UNEXPECTED-FAIL", message: "TEST-UNEXPECTED-FAIL",
}; };
} else if (expected == "fail") { } else if (expected == "fail") {
var successInfo = { successInfo = {
status: "PASS", status: "PASS",
expected: "FAIL", expected: "FAIL",
message: "TEST-UNEXPECTED-PASS", message: "TEST-UNEXPECTED-PASS",
}; };
var failureInfo = { failureInfo = {
status: "FAIL", status: "FAIL",
expected: "FAIL", expected: "FAIL",
message: "TEST-KNOWN-FAIL", message: "TEST-KNOWN-FAIL",
}; };
} else { } else {
var successInfo = { successInfo = {
status: "PASS", status: "PASS",
expected: "PASS", expected: "PASS",
message: "TEST-PASS", message: "TEST-PASS",
}; };
var failureInfo = { failureInfo = {
status: "FAIL", status: "FAIL",
expected: "PASS", expected: "PASS",
message: "TEST-UNEXPECTED-FAIL", message: "TEST-UNEXPECTED-FAIL",
@ -447,8 +455,6 @@ SimpleTest.todo = function(condition, name, diag) {
* slave) * slave)
*/ */
SimpleTest.getTestFileURL = function(path) { SimpleTest.getTestFileURL = function(path) {
var lastSlashIdx = path.lastIndexOf("/") + 1;
var filename = path.substr(lastSlashIdx);
var location = window.location; var location = window.location;
// Remove mochitest html file name from the path // Remove mochitest html file name from the path
var remotePath = location.pathname.replace(/\/[^\/]+?$/, ""); var remotePath = location.pathname.replace(/\/[^\/]+?$/, "");
@ -582,6 +588,7 @@ SimpleTest.report = function() {
} }
var summary_class = var summary_class =
// eslint-disable-next-line no-nested-ternary
failed != 0 ? "some_fail" : passed == 0 ? "todo_only" : "all_pass"; failed != 0 ? "some_fail" : passed == 0 ? "todo_only" : "all_pass";
var div1 = createEl("div", { class: "tests_report" }); 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 // If a child frame in a child process must be focused, a
// WaitForFocus:FocusChild message is then sent to the child to focus that // 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. // 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 /* Indicates whether the desired targetWindow has loaded or focused. The
finished flag is set when the callback has been called and is used to finished flag is set when the callback has been called and is used to
reject extraneous events from invoking the callback again. */ reject extraneous events from invoking the callback again. */
@ -880,7 +888,7 @@ SimpleTest.waitForFocus = function(callback, targetWindow, expectBlankPage) {
try { try {
if (event) { if (event) {
if (event.type == "load") { if (event.type == "load") {
if (expectBlankPage != (event.target.location == "about:blank")) { if (expectBlank != (event.target.location == "about:blank")) {
return; return;
} }
@ -903,7 +911,7 @@ SimpleTest.waitForFocus = function(callback, targetWindow, expectBlankPage) {
} else { } else {
SimpleTest._pendingWaitForFocusCount--; SimpleTest._pendingWaitForFocusCount--;
SimpleTest.executeSoon(function() { 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 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 to load its content, and we want to skip over any intermediate blank
pages that load. This issue is described in bug 554873. */ pages that load. This issue is described in bug 554873. */
loaded = expectBlankPage loaded = expectBlank
? getHref(desiredWindow) == "about:blank" ? getHref(desiredWindow) == "about:blank"
: getHref(desiredWindow) != "about:blank" && : getHref(desiredWindow) != "about:blank" &&
desiredWindow.document.readyState == "complete"; desiredWindow.document.readyState == "complete";
@ -976,7 +984,7 @@ SimpleTest.waitForFocus = function(callback, targetWindow, expectBlankPage) {
}); });
} }
waitForLoadAndFocusOnWindow(targetWindow); waitForLoadAndFocusOnWindow(targetWin);
} }
SimpleTest._pendingWaitForFocusCount++; SimpleTest._pendingWaitForFocusCount++;
@ -996,7 +1004,9 @@ SimpleTest.waitForFocus = function(callback, targetWindow, expectBlankPage) {
var c = Object.getOwnPropertyDescriptor(window, "Components"); var c = Object.getOwnPropertyDescriptor(window, "Components");
var Cu, Ci; var Cu, Ci;
if (c && c.value && !c.writable) { if (c && c.value && !c.writable) {
// eslint-disable-next-line mozilla/use-cc-etc
Cu = Components.utils; Cu = Components.utils;
// eslint-disable-next-line mozilla/use-cc-etc
Ci = Components.interfaces; Ci = Components.interfaces;
} else { } else {
Cu = SpecialPowers.Cu; Cu = SpecialPowers.Cu;
@ -1051,6 +1061,7 @@ SimpleTest.waitForFocus = function(callback, targetWindow, expectBlankPage) {
waitForFocusInner(targetWindow, false, expectBlankPage); waitForFocusInner(targetWindow, false, expectBlankPage);
} }
}; };
/* eslint-enable mozilla/use-services */
/* /*
* Polls the clipboard waiting for the expected value. A known value different than * Polls the clipboard waiting for the expected value. A known value different than
@ -1138,32 +1149,27 @@ SimpleTest.promiseClipboardChange = async function(
inputValidatorFn = function(aData) { inputValidatorFn = function(aData) {
return aData != initialVal; return aData != initialVal;
}; };
} else {
// Build a default validator function for common string input. // Build a default validator function for common string input.
if (typeof aExpectedStringOrValidatorFn == "string") { } else if (typeof aExpectedStringOrValidatorFn == "string") {
if (aExpectedStringOrValidatorFn.includes("\r")) { if (aExpectedStringOrValidatorFn.includes("\r")) {
throw new Error( throw new Error(
"Use function instead of string to compare raw line breakers in clipboard" "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;
} }
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; let maxPolls = aTimeout ? aTimeout / 100 : 50;
@ -1199,8 +1205,9 @@ SimpleTest.promiseClipboardChange = async function(
"Timed out while polling clipboard for pasted data, got: " + data "Timed out while polling clipboard for pasted data, got: " + data
); );
if (!aExpectFailure) { if (!aExpectFailure) {
throw "failed"; throw new Error("failed");
} }
return data;
} }
// First we wait for a known value different from the expected one. // First we wait for a known value different from the expected one.
@ -1214,7 +1221,7 @@ SimpleTest.promiseClipboardChange = async function(
"text/unicode" "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) { if (SimpleTest.expected == "fail" && SimpleTest.num_failed <= 0) {
msg = "We expected at least one failure"; let msg = "We expected at least one failure";
var test = { let test = {
result: false, result: false,
name: "fail-if condition in manifest", name: "fail-if condition in manifest",
diag: msg, diag: msg,
}; };
var successInfo = { let successInfo = {
status: "FAIL", status: "FAIL",
expected: "FAIL", expected: "FAIL",
message: "TEST-KNOWN-FAIL", message: "TEST-KNOWN-FAIL",
}; };
var failureInfo = { let failureInfo = {
status: "PASS", status: "PASS",
expected: "FAIL", expected: "FAIL",
message: "TEST-UNEXPECTED-PASS", message: "TEST-UNEXPECTED-PASS",
@ -1340,16 +1347,16 @@ SimpleTest.finish = function() {
} else { } else {
return; return;
} }
var name = pat let name = pat
? `failure pattern \`${pat}\` in this test` ? `failure pattern \`${pat}\` in this test`
: "failures in this test"; : "failures in this test";
var test = { result: false, name, diag }; let test = { result: false, name, diag };
var successInfo = { let successInfo = {
status: "PASS", status: "PASS",
expected: "PASS", expected: "PASS",
message: "TEST-PASS", message: "TEST-PASS",
}; };
var failureInfo = { let failureInfo = {
status: "FAIL", status: "FAIL",
expected: "PASS", expected: "PASS",
message: "TEST-UNEXPECTED-FAIL", message: "TEST-UNEXPECTED-FAIL",
@ -1539,7 +1546,7 @@ SimpleTest.monitorConsole = function(continuation, msgs, forbidUnexpectedMsgs) {
var forbiddenMsgs = []; var forbiddenMsgs = [];
var i = 0; var i = 0;
while (i < msgs.length) { while (i < msgs.length) {
var pat = msgs[i]; let pat = msgs[i];
if ("forbid" in pat) { if ("forbid" in pat) {
var forbid = pat.forbid; var forbid = pat.forbid;
delete pat.forbid; delete pat.forbid;
@ -1564,7 +1571,7 @@ SimpleTest.monitorConsole = function(continuation, msgs, forbidUnexpectedMsgs) {
SimpleTest.executeSoon(continuation); SimpleTest.executeSoon(continuation);
return; return;
} }
for (var pat of forbiddenMsgs) { for (let pat of forbiddenMsgs) {
if (msgMatches(msg, pat)) { if (msgMatches(msg, pat)) {
ok( ok(
false, 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 // confusing a reference seen more than once (such as [a, a]) for a
// circular reference. // circular reference.
seen = seen.slice(0); 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) { if (seen[j][0] == o1) {
return seen[j][1] == o2; return seen[j][1] == o2;
} }
@ -1807,15 +1814,17 @@ SimpleTest._eqAssoc = function(o1, o2, stack, seen) {
var ok = true; var ok = true;
// Only examines enumerable attributes. // Only examines enumerable attributes.
var o1Size = 0; var o1Size = 0;
for (var i in o1) { // eslint-disable-next-line no-unused-vars
for (let i in o1) {
o1Size++; o1Size++;
} }
var o2Size = 0; var o2Size = 0;
for (var i in o2) { // eslint-disable-next-line no-unused-vars
for (let i in o2) {
o2Size++; o2Size++;
} }
var bigger = o1Size > o2Size ? o1 : o2; 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 e1 = i in o1 ? o1[i] : SimpleTest.DNE;
var e2 = i in o2 ? o2[i] : SimpleTest.DNE; var e2 = i in o2 ? o2[i] : SimpleTest.DNE;
stack.push({ type: "Object", idx: i, vals: [e1, e2] }); stack.push({ type: "Object", idx: i, vals: [e1, e2] });
@ -1831,7 +1840,7 @@ SimpleTest._eqAssoc = function(o1, o2, stack, seen) {
SimpleTest._formatStack = function(stack) { SimpleTest._formatStack = function(stack) {
var variable = "$Foo"; var variable = "$Foo";
for (var i = 0; i < stack.length; i++) { for (let i = 0; i < stack.length; i++) {
var entry = stack[i]; var entry = stack[i];
var type = entry.type; var type = entry.type;
var idx = entry.idx; var idx = entry.idx;
@ -1854,7 +1863,7 @@ SimpleTest._formatStack = function(stack) {
]; ];
var out = "Structures begin differing at:" + SimpleTest.LF; 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]; var val = vals[i];
if (val === SimpleTest.DNE) { if (val === SimpleTest.DNE) {
val = "Does not exist"; val = "Does not exist";

View file

@ -6,6 +6,14 @@
* data = json object {"filename":filename} <- for LoggerInit * 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"; "use strict";
function getElement(id) { function getElement(id) {
@ -197,7 +205,7 @@ TestRunner.expectAssertions = function(min, max) {
min < 0 || min < 0 ||
max < min max < min
) { ) {
throw "bad parameter to expectAssertions"; throw new Error("bad parameter to expectAssertions");
} }
TestRunner._expectedMinAsserts = min; TestRunner._expectedMinAsserts = min;
TestRunner._expectedMaxAsserts = max; TestRunner._expectedMaxAsserts = max;
@ -237,11 +245,7 @@ TestRunner.generateFailureList = function() {
**/ **/
// This delimiter is used to avoid interleaving Mochitest/Gecko logs. // This delimiter is used to avoid interleaving Mochitest/Gecko logs.
var LOG_DELIMITER = var LOG_DELIMITER = "\ue175\uee31\u2c32\uacbf";
String.fromCharCode(0xe175) +
String.fromCharCode(0xee31) +
String.fromCharCode(0x2c32) +
String.fromCharCode(0xacbf);
// A log callback for StructuredLog.jsm // A log callback for StructuredLog.jsm
TestRunner._dumpMessage = function(message) { TestRunner._dumpMessage = function(message) {
@ -308,6 +312,7 @@ TestRunner.failureHandler = function() {
if (TestRunner.debugOnFailure) { if (TestRunner.debugOnFailure) {
// You've hit this line because you requested to break into the // You've hit this line because you requested to break into the
// debugger upon a testcase failure on your test run. // debugger upon a testcase failure on your test run.
// eslint-disable-next-line no-debugger
debugger; debugger;
} }
}; };
@ -354,7 +359,6 @@ TestRunner._makeIframe = function(url, retry) {
iframe.src = url; iframe.src = url;
iframe.name = url; iframe.name = url;
iframe.width = "500"; iframe.width = "500";
return iframe;
}; };
/** /**
@ -608,7 +612,7 @@ TestRunner.testFinished = function(tests) {
TestRunner._expectingProcessCrash TestRunner._expectingProcessCrash
)) ))
) { ) {
var subtest = "expected-crash-dump-missing"; let subtest = "expected-crash-dump-missing";
TestRunner.structuredLogger.testStatus( TestRunner.structuredLogger.testStatus(
TestRunner.currentTestURL, TestRunner.currentTestURL,
subtest, subtest,
@ -623,7 +627,7 @@ TestRunner.testFinished = function(tests) {
var unexpectedCrashDumpFiles = await SpecialPowers.findUnexpectedCrashDumpFiles(); var unexpectedCrashDumpFiles = await SpecialPowers.findUnexpectedCrashDumpFiles();
TestRunner._expectingProcessCrash = false; TestRunner._expectingProcessCrash = false;
if (unexpectedCrashDumpFiles.length) { if (unexpectedCrashDumpFiles.length) {
var subtest = "unexpected-crash-dump-found"; let subtest = "unexpected-crash-dump-found";
TestRunner.structuredLogger.testStatus( TestRunner.structuredLogger.testStatus(
TestRunner.currentTestURL, TestRunner.currentTestURL,
subtest, subtest,

View file

@ -1,6 +1,6 @@
(function() { (function() {
var accumulatedRect = null; var accumulatedRect = null;
var onpaint = new Array(); var onpaint = [];
var debug = SpecialPowers.getBoolPref("testing.paint_listener.debug", false); var debug = SpecialPowers.getBoolPref("testing.paint_listener.debug", false);
const FlushModes = { const FlushModes = {
FLUSH: 0, FLUSH: 0,

View file

@ -6,6 +6,17 @@
"use strict"; "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.logEnabled = true;
TestRunner.logger = LogController; TestRunner.logger = LogController;
@ -210,9 +221,9 @@ RunSet.runtests = function(e) {
RunSet.reloadAndRunAll = function(e) { RunSet.reloadAndRunAll = function(e) {
e.preventDefault(); e.preventDefault();
//window.location.hash = ""; //window.location.hash = "";
var addParam = "";
if (params.autorun) { if (params.autorun) {
window.location.search += ""; window.location.search += "";
// eslint-disable-next-line no-self-assign
window.location.href = window.location.href; window.location.href = window.location.href;
} else if (window.location.search) { } else if (window.location.search) {
window.location.href += "&autorun=1"; window.location.href += "&autorun=1";