Bug 1788037 - Turn on ESLint rule for prefer-boolean-length-check for dom. r=asuth,karlt

Differential Revision: https://phabricator.services.mozilla.com/D155965
This commit is contained in:
Mark Banner 2022-09-02 11:05:17 +00:00
parent e035e3994d
commit 783a2f2187
163 changed files with 254 additions and 259 deletions

View File

@ -477,7 +477,7 @@ module.exports = {
},
},
{
files: ["dom/**", "netwerk/**"],
files: ["netwerk/**"],
rules: {
"mozilla/prefer-boolean-length-check": "off",
},

View File

@ -410,7 +410,7 @@ waitForAllPaints(() => {
now = document.timeline.currentTime;
elapsed = (now - timeAtStart);
markers = await observeStyling(1);
if (markers.length > 0) {
if (markers.length) {
break;
}
}
@ -437,7 +437,7 @@ waitForAllPaints(() => {
else if (elapsed.toPrecision(10) > 200)
expectedMarkersLengthValid = markers.length == 1;
else
expectedMarkersLengthValid = markers.length == 0;
expectedMarkersLengthValid = !markers.length;
ok(expectedMarkersLengthValid,
'Transform animation running on the element which is scrolled out ' +
'should be unthrottled after around 200ms have elapsed. now: ' +
@ -472,7 +472,7 @@ waitForAllPaints(() => {
now = document.timeline.currentTime;
elapsed = (now - timeAtStart);
markers = await observeStyling(1);
if (markers.length > 0) {
if (markers.length) {
break;
}
}
@ -495,7 +495,7 @@ waitForAllPaints(() => {
else if (elapsed.toPrecision(10) > 200)
expectedMarkersLengthValid = markers.length == 1;
else
expectedMarkersLengthValid = markers.length == 0;
expectedMarkersLengthValid = !markers.length;
ok(expectedMarkersLengthValid,
'Transform animation running on out of view element ' +
'should be unthrottled after around 200ms have elapsed. now: ' +

View File

@ -39,7 +39,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=990812
var next = order.shift();
window.arguments[0].is(msg.data, next, "received test:" + next);
if (order.length == 0) {
if (!order.length) {
window.arguments[0].setTimeout(function() { this.next(); });
window.close();
}

View File

@ -28,7 +28,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=990812
mm.addMessageListener("test", function onMessage(msg) {
is(msg.data, order.shift(), "correct message " + msg.data);
if (order.length == 0) {
if (!order.length) {
mm.removeMessageListener("test", onMessage);
resolve();
}

View File

@ -33,7 +33,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=990812
var next = order.shift();
opener.wrappedJSObject.is(msg.data, next, "received test:" + next);
if (order.length == 0) {
if (!order.length) {
opener.setTimeout("next()");
window.close();
}

View File

@ -43,7 +43,7 @@ window.onload = function() {
var scripts = dbg.findScripts({
url: "http://mochi.test:8888/tests/dom/base/test/chrome/nochrome_bug1346936.js",
});
ok(scripts.length > 0, "Should be able to find script");
ok(scripts.length, "Should be able to find script");
is(scripts[0].source.sourceMapURL, "foo.js.map");
SimpleTest.finish();

View File

@ -43,7 +43,7 @@ window.onload = function() {
var scripts = dbg.findScripts({
url: "http://mochi.test:8888/tests/dom/base/test/chrome/nochrome_bug765993.js",
});
ok(scripts.length > 0, "Should be able to find script");
ok(scripts.length, "Should be able to find script");
is(scripts[0].source.sourceMapURL, "foo.js.map");
SimpleTest.finish();

View File

@ -41,7 +41,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=884693
msg.category.includes("chrome javascript") &&
msg.message.includes("Unknown event")));
if (messages.length > 0) {
if (messages.length) {
info(`Got console messages ${messages}`);
}
is(messages.length, expectedMessages.length, "Got expected message count");

View File

@ -28,7 +28,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=990812
];
function next() {
if (tests.length > 0) {
if (tests.length) {
var file = tests.shift();
info("-- running " + file);
window.openDialog(file, "_blank", "chrome,noopener", window);

View File

@ -4134,7 +4134,7 @@ async function runCallbackTests(aForTests)
function waitUntilNotificationsReceived()
{
return new Promise(resolve => {
if (notifications.length > 0) {
if (notifications.length) {
SimpleTest.executeSoon(resolve);
} else {
waitingNextNotification = resolve;
@ -4167,8 +4167,8 @@ async function runCallbackTests(aForTests)
is(aNotification.reversed, aExpected.reversed || false,
`${aDescription} should cause selection change notification whose reversed is ${aExpected.reversed || false}`);
}
is(aNotification.collapsed, aExpected.hasRange === false || aExpected.text.length == 0,
`${aDescription} should cause selection change notification whose collapsed is ${aExpected.hasRange === false || aExpected.text.length == 0}`);
is(aNotification.collapsed, aExpected.hasRange === false || !aExpected.text.length,
`${aDescription} should cause selection change notification whose collapsed is ${aExpected.hasRange === false || !aExpected.text.length}`);
is(aNotification.writingMode, aExpected.writingMode || "horizontal-tb",
`${aDescription} should cause selection change notification whose writingMode is ${aExpected.writingMode || "horizontal-tb"}`);
is(aNotification.causedByComposition, aExpected.causedByComposition || false,
@ -4391,7 +4391,7 @@ async function runFocusNotificationTestAfterDrop() {
notifications.length > 1,
"runFocusNotificationTestAfterDrop: At least two notifications should be fired"
);
if (notifications.length > 0) {
if (notifications.length) {
is(
notifications[notifications.length - 1],
"notify-focus",

View File

@ -16,7 +16,7 @@ var strings_to_send = [
var resp = null;
function sendNextString() {
if (strings_to_send.length == 0) {
if (!strings_to_send.length) {
timer.cancel();
resp.finish();
timer = null;

View File

@ -437,7 +437,7 @@
try {
var single = root.querySelector(query);
var pass = found.length == 0 && single === null ||
var pass = !found.length && single === null ||
found.length && found[0] == single;
assert(expect, type + ".querySelector: " + query);

View File

@ -62,7 +62,7 @@ function doAbort2() {
/* Utility functions */
function runNextTest() {
if (tests.length > 0) {
if (tests.length) {
var test = tests.shift();
// Initialize state variables

View File

@ -103,7 +103,7 @@ async function onWindowLoad() {
async function runTest(test) {
if (test.cleanEnableCertOnPreflight) {
await SpecialPowers.pushPrefEnv({"set": [["network.cors_preflight.allow_client_cert", false]]});
if (alltests.length == 0) {
if (!alltests.length) {
SimpleTest.finish();
} else {
runTest(alltests.shift());
@ -131,7 +131,7 @@ async function onWindowLoad() {
var success = eval(xhr.status + test.status_check);
ok(success, test.error);
if (alltests.length == 0) {
if (!alltests.length) {
SimpleTest.finish();
} else {
runTest(alltests.shift());

View File

@ -285,7 +285,7 @@ function drive(test)
}
if (this.readyState == 4) {
test.done(this);
if (tests.length == 0)
if (!tests.length)
SimpleTest.finish();
else
drive(tests.shift());

View File

@ -45,9 +45,9 @@ function checkHeaders(xhrInner) {
ok(contentType == true, "Content-type is part of the headers!");
var ct = xhrInner.getResponseHeader('content-type');
ok(ct.length > 0, 'Get Response Header - content type: ' + ct);
ok(ct.length, 'Get Response Header - content type: ' + ct);
var cl = xhrInner.getResponseHeader('content-length');
ok(cl.length > 0, 'Get Response Header - content length: ' + cl);
ok(cl.length, 'Get Response Header - content length: ' + cl);
}
xhr.addEventListener("load", function () {

View File

@ -456,7 +456,7 @@ SimpleTest.waitForFocus(function () {
* Basic tests with complicated tree.
*/
function check(aIter, aExpectedResult, aDescription) {
if (aExpectedResult.length > 0) {
if (aExpectedResult.length) {
is(SpecialPowers.unwrap(aIter.currentNode), aExpectedResult[0],
`${aDescription}: currentNode should be the text node immediately after initialization (got: ${getNodeDescription(aIter.currentNode)}, expected: ${getNodeDescription(aExpectedResult[0])})`);
ok(!aIter.isDone, `${aDescription}: isDone shouldn't be true immediately after initialization`);

View File

@ -456,7 +456,7 @@ SimpleTest.waitForFocus(function () {
* Basic tests with complicated tree.
*/
function check(aIter, aExpectedResult, aDescription) {
if (aExpectedResult.length > 0) {
if (aExpectedResult.length) {
is(SpecialPowers.unwrap(aIter.currentNode), aExpectedResult[0],
`${aDescription}: currentNode should be the text node immediately after initialization (got: ${getNodeDescription(aIter.currentNode)}, expected: ${getNodeDescription(aExpectedResult[0])})`);
ok(!aIter.isDone, `${aDescription}: isDone shouldn't be true immediately after initialization`);

View File

@ -381,7 +381,7 @@ SimpleTest.waitForFocus(function () {
* Basic tests with complicated tree.
*/
function check(aIter, aExpectedResult, aDescription) {
if (aExpectedResult.length > 0) {
if (aExpectedResult.length) {
is(SpecialPowers.unwrap(aIter.currentNode), aExpectedResult[0],
`${aDescription}: currentNode should be the text node immediately after initialization (got: ${getNodeDescription(aIter.currentNode)}, expected: ${getNodeDescription(aExpectedResult[0])})`);
ok(!aIter.isDone, `${aDescription}: isDone shouldn't be true immediately after initialization`);

View File

@ -131,7 +131,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=889335
is(navigator.language, data.language);
is(navigator.languages.length, data.languages.length);
if (navigator.languages.length > 0) {
if (navigator.languages.length) {
is(navigator.languages[0], navigator.language)
}
for (var j = 0; j < navigator.languages.length; ++j) {

View File

@ -45,7 +45,7 @@ const parser = getParser();
*/
function evalXPathInDocumentFragment(aContextNode, aPath) {
Assert.equal(ChromeUtils.getClassName(aContextNode), "DocumentFragment");
Assert.ok(aContextNode.childNodes.length > 0);
Assert.ok(aContextNode.childNodes.length);
if (aPath == ".") {
return aContextNode;
}

View File

@ -16,7 +16,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1186696
function doTest() {
var values = [ function() {}, 5, null, undefined, "some string", {} ];
while (values.length != 0) {
while (values.length) {
var value = values.pop();
var t = new TestInterfaceJS();
t.onsomething = value;

View File

@ -14,7 +14,7 @@ add_task(async function testSteps() {
const requestList = await cache.keys();
ok(requestList.length > 0, "should have at least one request in cache");
ok(requestList.length, "should have at least one request in cache");
for (const request of requestList) {
ok(request, "each request in list should be non-null");
ok(
@ -41,7 +41,7 @@ add_task(async function testSteps() {
})
);
ok(responseList.length > 0, "should have at least one response in cache");
ok(responseList.length, "should have at least one response in cache");
for (const response of responseList) {
ok(response, "each response should be non-null");
// reponse.url is a empty string in current test file. It should test for

View File

@ -152,7 +152,7 @@ function testExceptions() {
tempWorker.postMessage(imageData.data.buffer, [imageData.data.buffer]);
tempWorker.terminate();
ok(imageData.data.length == 0, "Get a neutured ImageData.");
ok(!imageData.data.length, "Get a neutured ImageData.");
resolve(createImageBitmap(imageData));
}
});

View File

@ -68,7 +68,7 @@ let tests = [
];
function next() {
if (tests.length == 0) {
if (!tests.length) {
SimpleTest.finish();
return;
}

View File

@ -35,7 +35,7 @@ TestArray.addTest(
(x.publicKey.algorithm.namedCurve == alg.namedCurve) &&
(x.publicKey.type == "public") &&
x.publicKey.extractable &&
(x.publicKey.usages.length == 0) &&
(!x.publicKey.usages.length) &&
exists(x.privateKey) &&
(x.privateKey.algorithm.name == alg.name) &&
(x.privateKey.algorithm.namedCurve == alg.namedCurve) &&

View File

@ -43,8 +43,8 @@ function withoutImplicitlyPointerCaptureForTouch() {
});
done.addEventListener("mouseup", () => {
ok(target0_events.length == 0, " should receive " + target0_events + " on target0");
ok(target1_events.length == 0, " should receive " + target1_events + " on target1");
ok(!target0_events.length, " should receive " + target0_events + " on target0");
ok(!target1_events.length, " should receive " + target1_events + " on target1");
SpecialPowers.pushPrefEnv({"set": [["dom.w3c_pointer_events.implicit_capture", true]]},
withImplicitlyPointerCaptureForTouch);
}, {once : true});
@ -68,7 +68,7 @@ function withImplicitlyPointerCaptureForTouch() {
});
done.addEventListener("mouseup", () => {
ok(target0_events.length == 0, " should receive " + target0_events + " on target0");
ok(!target0_events.length, " should receive " + target0_events + " on target0");
SimpleTest.finish();
}, {once : true});

View File

@ -63,7 +63,7 @@ function withoutImplicitlyPointerCaptureForTouch() {
ok(expectedEvents.includes(e.data), " don't expect " + e.data);
expectedEvents = expectedEvents.filter(item => item !== e.data);
if (e.data == "iframe2 touchend") {
ok(expectedEvents.length == 0, " expect " + expectedEvents);
ok(!expectedEvents.length, " expect " + expectedEvents);
SimpleTest.finish();
}
})

View File

@ -66,7 +66,7 @@ function withoutImplicitlyPointerCaptureForTouch() {
ok(expectedEvents.includes(e.data), " don't expect " + e.data);
expectedEvents = expectedEvents.filter(item => item !== e.data);
if (e.data == "div1 touchend") {
ok(expectedEvents.length == 0, " expect " + expectedEvents);
ok(!expectedEvents.length, " expect " + expectedEvents);
SimpleTest.finish();
}
})

View File

@ -59,7 +59,7 @@ function withoutImplicitlyPointerCaptureForTouch() {
ok(expectedEvents.includes(e.data), " don't expect " + e.data);
expectedEvents = expectedEvents.filter(item => item !== e.data);
if (e.data == "iframe1 touchend") {
ok(expectedEvents.length == 0, " expect " + expectedEvents);
ok(!expectedEvents.length, " expect " + expectedEvents);
SimpleTest.finish();
}
})

View File

@ -72,7 +72,7 @@ function startTest() {
synthesizeMouseAtCenter(div2, {type: "mousemove"}, iframe.contentWindow);
synthesizeMouseAtCenter(div2, {type: "mouseup"}, iframe.contentWindow);
ok(divEvents.length == 0, " expect " + divEvents);
ok(!divEvents.length, " expect " + divEvents);
divEvents = [
"pointerdown",
@ -113,7 +113,7 @@ function startTest() {
synthesizeTouch(div2, 5, 5, { type: "touchmove" }, iframe.contentWindow);
synthesizeTouch(div2, 5, 5, { type: "touchend" }, iframe.contentWindow);
ok(divEvents.length == 0, " expect " + divEvents);
ok(!divEvents.length, " expect " + divEvents);
divEvents = [
"pointerdown",
@ -154,7 +154,7 @@ function startTest() {
synthesizeTouch(div2, 5, 5, { type: "touchmove" }, iframe.contentWindow);
synthesizeTouch(div2, 5, 5, { type: "touchcancel" }, iframe.contentWindow);
ok(divEvents.length == 0, " expect " + divEvents);
ok(!divEvents.length, " expect " + divEvents);
SimpleTest.finish();
}

View File

@ -130,7 +130,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=409604
var accessChar = String.fromCharCode(code).toUpperCase();
pressAccessKey({key: accessChar});
}
ok(focusArray.length == 0, "(focus) unhandled elements remaining: " + focusArray.join(","));
ok(!focusArray.length, "(focus) unhandled elements remaining: " + focusArray.join(","));
}
function createUnfocusableElement(elem, accesskey) {

View File

@ -107,7 +107,7 @@ function runTests()
if (test.check) {
test.check();
}
if (tests.length == 0) {
if (!tests.length) {
SimpleTest.finish();
return;
}

View File

@ -560,7 +560,7 @@ function doDragOverSynthetic(event)
function onDragStartDraggable(event)
{
var dt = event.dataTransfer;
ok(SpecialPowers.wrap(dt).mozItemCount == 0 && dt.types.length == 0 && event.originalTarget == gDragInfo.target, gDragInfo.testid);
ok(SpecialPowers.wrap(dt).mozItemCount == 0 && !dt.types.length && event.originalTarget == gDragInfo.target, gDragInfo.testid);
event.preventDefault();
gExtraDragTests++;

View File

@ -17,7 +17,7 @@
}
function weak_ref_dead(r) {
return SpecialPowers.nondeterministicGetWeakMapKeys(r).length == 0;
return !SpecialPowers.nondeterministicGetWeakMapKeys(r).length;
}
function setupTarget1() {

View File

@ -125,7 +125,7 @@ function waitForEnterLeaveEvents(aEnterTarget, aLeaveTarget) {
return;
}
if (expectedEvents.length == 0) {
if (!expectedEvents.length) {
// Trigger a reflow which will generate synthesized mouse move event.
reflow();
// Now wait a bit to see if there is any unexpected event fired.

View File

@ -118,7 +118,7 @@
"Getting @items twice should return the same object");
var haveFiles = false;
ok(items instanceof DataTransferItemList, "@items implements DataTransferItemList");
ok(items.length > 0, "@items is not empty");
ok(items.length, "@items is not empty");
for (var i = 0; i < items.length; i++) {
var item = items[i];
ok(item instanceof DataTransferItem, "each element of @items must implement DataTransferItem");
@ -136,7 +136,7 @@
is(files, e.clipboardData.files,
"Getting the files array twice should return the same array");
ok(files.length > 0, "There should be at least one file in the clipboard");
ok(files.length, "There should be at least one file in the clipboard");
for (var i = 0; i < files.length; i++) {
var file = files[i];
ok(file instanceof File, ".files should contain only File objects");

View File

@ -206,7 +206,7 @@ function testSlice(file, size, type, contents, fileType, range) {
}
function runNextTest() {
if (indexes.length == 0) {
if (!indexes.length) {
return Promise.resolve(true);
}

View File

@ -200,8 +200,8 @@ let currentTest = null;
let testCounter = 0;
function runTests() {
if (!currentTest || currentTest[2].length == 0) {
if (testData.length == 0) {
if (!currentTest || !currentTest[2].length) {
if (!testData.length) {
SimpleTest.finish();
return;
}

View File

@ -54,7 +54,7 @@ function runTests() {
);
// test that the grid has cols and rows properties
if (gridFragments.length > 0) {
if (gridFragments.length) {
let grid = gridFragments[0];
isnot(typeof(grid.cols), "undefined", id + ": Grid.cols property exists.");
isnot(typeof(grid.rows), "undefined", id + ": Grid.rows property exists.");

View File

@ -39,7 +39,7 @@ var tests = [
];
async function nextTest() {
if (tests.length == 0) {
if (!tests.length) {
opener.nextTest();
return;
}

View File

@ -149,7 +149,7 @@ function secondClick(evt) {
}
function exitFullscreen() {
if (tests.length > 0) {
if (tests.length) {
nextTest();
} else {
opener.nextTest();

View File

@ -172,13 +172,13 @@ SimpleTest.waitForFocus(async () => {
`Only one "input" event should be dispatched when setUserInput("${test.input.before}") is called before ${tag} gets focus`);
}
}
if (inputEvents.length > 0) {
if (inputEvents.length) {
if (SpecialPowers.wrap(target).isInputEventTarget) {
if (test.type === "time") {
todo(inputEvents[0] instanceof InputEvent,
`"input" event should be dispatched with InputEvent interface when setUserInput("${test.input.before}") is called before ${tag} gets focus`);
} else {
if (beforeInputEvents.length > 0 && test.result.fireBeforeInputEvent) {
if (beforeInputEvents.length && test.result.fireBeforeInputEvent) {
is(beforeInputEvents[0].cancelable, kSetUserInputCancelable,
`"beforeinput" event for "insertReplacementText" should be cancelable when setUserInput("${test.input.before}") is called before ${tag} gets focus unless it's suppressed by the pref`);
is(beforeInputEvents[0].inputType, "insertReplacementText",
@ -258,13 +258,13 @@ SimpleTest.waitForFocus(async () => {
`Only one "input" event should be dispatched when setUserInput("${test.input.after}") is called after ${tag} gets focus`);
}
}
if (inputEvents.length > 0) {
if (inputEvents.length) {
if (SpecialPowers.wrap(target).isInputEventTarget) {
if (test.type === "time") {
todo(inputEvents[0] instanceof InputEvent,
`"input" event should be dispatched with InputEvent interface when setUserInput("${test.input.after}") is called after ${tag} gets focus`);
} else {
if (beforeInputEvents.length > 0 && test.result.fireBeforeInputEvent) {
if (beforeInputEvents.length && test.result.fireBeforeInputEvent) {
is(beforeInputEvents[0].cancelable, kSetUserInputCancelable,
`"beforeinput" event should be cancelable when setUserInput("${test.input.after}") is called after ${tag} gets focus unless it's suppressed by the pref`);
is(beforeInputEvents[0].inputType, "insertReplacementText",
@ -407,12 +407,12 @@ SimpleTest.waitForFocus(async () => {
reset();
SpecialPowers.wrap(target).setUserInput(aValidValue);
is(beforeInputEvents.length, 1, `Calling ${tag}.setUserInput(${aValidValue}) should cause a "beforeinput" event (before gets focus)`);
if (beforeInputEvents.length > 0) {
if (beforeInputEvents.length) {
is(beforeInputEvents[0].validity, false,
`The ${tag} should be invalid at "beforeinput" event (before gets focus)`);
}
is(inputEvents.length, 1, `Calling ${tag}.setUserInput(${aValidValue}) should cause a "input" event (before gets focus)`);
if (inputEvents.length > 0) {
if (inputEvents.length) {
is(inputEvents[0].validity, true,
`The ${tag} should be valid at "input" event (before gets focus)`);
}
@ -433,12 +433,12 @@ SimpleTest.waitForFocus(async () => {
reset();
SpecialPowers.wrap(target).setUserInput(aValidValue);
is(beforeInputEvents.length, 1, `Calling ${tag}.setUserInput(${aValidValue}) should cause a "beforeinput" event (after gets focus)`);
if (beforeInputEvents.length > 0) {
if (beforeInputEvents.length) {
is(beforeInputEvents[0].validity, false,
`The ${tag} should be invalid at "beforeinput" event (after gets focus)`);
}
is(inputEvents.length, 1, `Calling ${tag}.setUserInput(${aValidValue}) should cause a "input" event (after gets focus)`);
if (inputEvents.length > 0) {
if (inputEvents.length) {
is(inputEvents[0].validity, true,
`The ${tag} should be valid at "input" event (after gets focus)`);
}

View File

@ -58,7 +58,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=885996
return "";
};
while (testData.length != 0) {
while (testData.length) {
currentTest = testData.shift();
element = document.getElementById(currentTest.id);

View File

@ -471,7 +471,7 @@ SimpleTest.waitForFocus(() => {
is(input.value, "hig",
`${description}The value should be set to the specified value in "beforeinput" event listener since the event target was already modified`);
is(inputEvents.length, 1, `${description}"input" event should be fired`);
if (inputEvents.length > 0) {
if (inputEvents.length) {
is(inputEvents[0].inputType,
"insertReplacementText", `${description}inputType of "input" event should be "insertReplacementText"`);
is(inputEvents[0].data, "def",
@ -550,7 +550,7 @@ SimpleTest.waitForFocus(() => {
// Different from Chrome
is(inputEvents.length, 1,
`${description}"input" event should be fired even if the frame of target is destroyed`);
if (inputEvents.length > 0) {
if (inputEvents.length) {
is(inputEvents[0].inputType,
"insertReplacementText", `${description}inputType of "input" event should be "insertReplacementText"`);
is(inputEvents[0].data, "def",
@ -597,7 +597,7 @@ SimpleTest.waitForFocus(() => {
is(input.value, "hig",
`${description}The value should be set to the specified value in "beforeinput" event listener since the event target was already modified`);
is(inputEvents.length, 1, `${description}"input" event should be fired`);
if (inputEvents.length > 0) {
if (inputEvents.length) {
is(inputEvents[0].inputType,
"insertReplacementText", `${description}inputType of "input" event should be "insertReplacementText"`);
is(inputEvents[0].data, "def",

View File

@ -596,7 +596,7 @@ function reflectLimitedEnumerated(aParameters) {
null,
"Missing default value should be null for nullable attributes"
);
ok(validValues.length > 0, "We better have at least one valid value");
ok(validValues.length, "We better have at least one valid value");
element.setAttribute(contentAttr, validValues[0]);
ok(
element.hasAttribute(contentAttr),

View File

@ -66,12 +66,12 @@ function testSubmitResetEvents() {
expectedCurrentTargets = new Array(document, outerForm, outerForm, document);
outerSubmit.click();
ok(expectedCurrentTargets.length == 0,
ok(!expectedCurrentTargets.length,
"(1) expectedCurrentTargets isn't empty!");
expectedCurrentTargets = new Array(document, outerForm, outerForm, document);
outerReset.click();
ok(expectedCurrentTargets.length == 0,
ok(!expectedCurrentTargets.length,
"(2) expectedCurrentTargets isn't empty!");
// Because of bug 428135, submit shouldn't propagate
@ -79,7 +79,7 @@ function testSubmitResetEvents() {
expectedCurrentTargets =
new Array(document, outerForm, outerSubmitDispatcher, outerSubmitDispatcher);
outerSubmitDispatcher.click();
ok(expectedCurrentTargets.length == 0,
ok(!expectedCurrentTargets.length,
"(3) expectedCurrentTargets isn't empty!");
// Because of bug 428135, reset shouldn't propagate
@ -87,7 +87,7 @@ function testSubmitResetEvents() {
expectedCurrentTargets =
new Array(document, outerForm, outerResetDispatcher, outerResetDispatcher);
outerResetDispatcher.click();
ok(expectedCurrentTargets.length == 0,
ok(!expectedCurrentTargets.length,
"(4) expectedCurrentTargets isn't empty!");
// Because of bug 428135, submit shouldn't propagate
@ -95,7 +95,7 @@ function testSubmitResetEvents() {
expectedCurrentTargets =
new Array(document, outerForm, outerChild, innerForm, innerForm, outerChild);
innerSubmit.click();
ok(expectedCurrentTargets.length == 0,
ok(!expectedCurrentTargets.length,
"(5) expectedCurrentTargets isn't empty!");
// Because of bug 428135, reset shouldn't propagate
@ -103,7 +103,7 @@ function testSubmitResetEvents() {
expectedCurrentTargets =
new Array(document, outerForm, outerChild, innerForm, innerForm, outerChild);
innerReset.click();
ok(expectedCurrentTargets.length == 0,
ok(!expectedCurrentTargets.length,
"(6) expectedCurrentTargets isn't empty!");
// Because of bug 428135, submit shouldn't propagate
@ -112,7 +112,7 @@ function testSubmitResetEvents() {
new Array(document, outerForm, outerChild, innerForm, innerSubmitDispatcher,
innerSubmitDispatcher);
innerSubmitDispatcher.click();
ok(expectedCurrentTargets.length == 0,
ok(!expectedCurrentTargets.length,
"(7) expectedCurrentTargets isn't empty!");
// Because of bug 428135, reset shouldn't propagate
@ -121,7 +121,7 @@ function testSubmitResetEvents() {
new Array(document, outerForm, outerChild, innerForm, innerResetDispatcher,
innerResetDispatcher);
innerResetDispatcher.click();
ok(expectedCurrentTargets.length == 0,
ok(!expectedCurrentTargets.length,
"(8) expectedCurrentTargets isn't empty!");
}

View File

@ -34,7 +34,7 @@ var tests = [
]
function next() {
if (tests.length > 0) {
if (tests.length) {
var t = tests.shift();
loc = t.substring(t.indexOf("test"));
media.setAttribute("src",t);

View File

@ -60,7 +60,7 @@ let tests = [
];
function next() {
if (tests.length == 0) {
if (!tests.length) {
SimpleTest.finish();
return;
}

View File

@ -9,7 +9,7 @@
SimpleTest.waitForExplicitFinish();
function getWindowLength() {
setTimeout(function() {
if (window.length > 0) {
if (window.length) {
ok(false, "Synthetic document shouldn't be exposed");
}

View File

@ -38,7 +38,7 @@ function popupLoad(win)
function next()
{
if (TESTS.length == 0) {
if (!TESTS.length) {
SimpleTest.finish();
} else {
var test = TESTS.shift();

View File

@ -56,7 +56,7 @@ function unregisterAllPopupEventHandlers(win) {
function triggerMainCommand(popup) {
info("triggering main command");
let notifications = popup.childNodes;
ok(notifications.length > 0, "at least one notification displayed");
ok(notifications.length, "at least one notification displayed");
let notification = notifications[0];
info("triggering command: " + notification.getAttribute("buttonlabel"));
@ -69,7 +69,7 @@ function triggerSecondaryCommand(popup, win) {
}
info("triggering secondary command");
let notifications = popup.childNodes;
ok(notifications.length > 0, "at least one notification displayed");
ok(notifications.length, "at least one notification displayed");
let notification = notifications[0];
EventUtils.synthesizeMouseAtCenter(notification.secondaryButton, {}, win);
}

View File

@ -85,7 +85,7 @@
ok(false, 'Test has already received a message from ${message.source}');
}
if (testFrames.length > 0) {
if (testFrames.length) {
return;
}

View File

@ -39,7 +39,7 @@
let label = this.shadowRoot.getElementById("label");
let verifyL10n = () => {
if (label.textContent.length > 0) {
if (label.textContent.length) {
window.removeEventListener("MozAfterPaint", verifyL10n);
is(label.textContent, "Learn more", "localization content applied to element");
firstWidgetTranslated = true;

View File

@ -18,15 +18,15 @@
// Test for initial localization applied.
let desc = document.getElementById("main-desc");
is(desc.textContent.length > 0, true);
is(!!desc.textContent.length, true);
// Test for manual value formatting.
let msg = await document.l10n.formatValue("id-heading");
is(msg.length > 0, true);
is(!!msg.length, true);
// Test for mutations applied.
let verifyL10n = () => {
if (label.textContent.length > 0) {
if (label.textContent.length) {
window.removeEventListener("MozAfterPaint", verifyL10n);
SimpleTest.finish();
}

View File

@ -21,15 +21,15 @@
// Test for initial localization applied.
let desc = document.getElementById("main-desc");
is(desc.textContent.length > 0, true);
is(!!desc.textContent.length, true);
// Test for manual value formatting
let msg = await document.l10n.formatValue("id-heading");
is(msg.length > 0, true);
is(!!msg.length, true);
// Test for mutations applied.
let verifyL10n = () => {
if (label.textContent.length > 0) {
if (label.textContent.length) {
window.removeEventListener("MozAfterPaint", verifyL10n);
SimpleTest.finish();
}

View File

@ -26,7 +26,7 @@
await document.l10n.ready;
// Lazy initialized localization should translate the document.
is(desc.textContent.length > 0, true, "main-desc is translated");
is(!!desc.textContent.length, true, "main-desc is translated");
document.head.removeChild(link);

View File

@ -17,7 +17,7 @@
{
// 1. An example message from aboutAddons should be available.
let value = await document.l10n.formatValue("shortcuts-browserAction2");
is(value.length > 0, true, "localized value retrieved");
is(!!value.length, true, "localized value retrieved");
}
{
@ -29,7 +29,7 @@
{
// 3. An example message from aboutSupport should still be available.
let value = await document.l10n.formatValue("features-version");
is(value.length > 0, true, "localized value retrieved");
is(!!value.length, true, "localized value retrieved");
// 4. An example message from aboutAddons should not be available.
await document.l10n.formatValue("shortcuts-browserAction").then(

View File

@ -15,15 +15,15 @@
// Test for initial localization applied.
let desc = document.getElementById("main-desc");
is(desc.textContent.length > 0, true);
is(!!desc.textContent.length, true);
// Test for manual value formatting.
let msg = await document.l10n.formatValue("id-heading");
is(msg.length > 0, true);
is(!!msg.length, true);
// Test for mutations applied.
let verifyL10n = () => {
if (label.textContent.length > 0) {
if (label.textContent.length) {
window.removeEventListener("MozAfterPaint", verifyL10n);
SimpleTest.finish();
}

View File

@ -29,11 +29,11 @@ key1 = Value for Key 1
);
await domLoc.translateRoots();
is(p1.textContent.length == 0, true);
is(!p1.textContent.length, true);
const body = document.body;
domLoc.connectRoot(body);
await domLoc.translateRoots();
is(p1.textContent.length > 0, true);
is(!!p1.textContent.length, true);
SimpleTest.finish();
};

View File

@ -24,7 +24,7 @@
// Test for mutations applied.
let verifyL10n = () => {
if (label.textContent.length > 0) {
if (label.textContent.length) {
window.removeEventListener("MozAfterPaint", verifyL10n);
// Notice: In normal tests we do not want to test against any particular
// value as per https://firefox-source-docs.mozilla.org/intl/l10n/l10n/fluent_tutorial.html#testing

View File

@ -30,7 +30,7 @@ key2 = Value for Key 2
);
await domLoc.translateRoots();
is(p1.textContent.length == 0, true);
is(!p1.textContent.length, true);
const body = document.body;

View File

@ -15,7 +15,7 @@
document.l10n.setAttributes(elem, "crash-reports-title");
is(elem.textContent.length, 0);
let verifyL10n = () => {
if (elem.textContent.length > 0) {
if (elem.textContent.length) {
window.removeEventListener("MozAfterPaint", verifyL10n);
SimpleTest.finish();
}

View File

@ -16,7 +16,7 @@
document.l10n.setAttributes(elem, "crash-reports-title");
is(elem.textContent.length, 0);
let verifyL10n = () => {
if (elem.textContent.length > 0) {
if (elem.textContent.length) {
window.removeEventListener("MozAfterPaint", verifyL10n);
SimpleTest.finish();
}

View File

@ -24,7 +24,7 @@
is(elem2.textContent.length, 0);
let verifyL10n = () => {
if (elem.textContent.length > 0 && elem2.textContent.length > 0) {
if (elem.textContent.length && elem2.textContent.length) {
window.removeEventListener("MozAfterPaint", verifyL10n);
SimpleTest.finish();
}

View File

@ -23,9 +23,9 @@
document.l10n.setAttributes(elem3, "crash-reports-title");
let verifyL10n = () => {
if (elem1.textContent.length > 0 &&
elem2.textContent.length == 0 &&
elem3.textContent.length > 0) {
if (elem1.textContent.length &&
!elem2.textContent.length &&
elem3.textContent.length) {
window.removeEventListener("MozAfterPaint", verifyL10n);
SimpleTest.finish();
}

View File

@ -48,17 +48,17 @@
document.body.appendChild(elem3);
// 1. `elem` should be localized since it is in DOM.
await SimpleTest.waitForCondition(() => elem.textContent.length > 0);
await SimpleTest.waitForCondition(() => elem.textContent.length);
// 2. `elem2` was removed before l10n frame, so it should remain not localized.
is(elem2.textContent.length, 0);
// 3. `elem3` was added/removed/re-added so it should become localized.
await SimpleTest.waitForCondition(() => elem3.textContent.length > 0);
await SimpleTest.waitForCondition(() => elem3.textContent.length);
// 4. `elem4` was not re-added, so it shouldn't be localized.
is(elem4.textContent.length, 0);
document.body.appendChild(elem4);
// 5. Now we re-added `elem4` to DOM so it should get localized.
await SimpleTest.waitForCondition(() => elem4.textContent.length > 0);
await SimpleTest.waitForCondition(() => elem4.textContent.length);
SimpleTest.finish();
});
</script>

View File

@ -44,20 +44,20 @@
document.body.appendChild(div2);
// 1. `elem` should be localized since it is in DOM.
await SimpleTest.waitForCondition(() => elem.textContent.length > 0);
await SimpleTest.waitForCondition(() => !!elem.textContent.length);
// 2. `elem2` was removed before l10n frame, so it should remain not localized.
is(elem2.textContent.length, 0);
// 3. `elem3` was added/removed/re-added so it should become localized.
await SimpleTest.waitForCondition(() => elem3.textContent.length > 0);
await SimpleTest.waitForCondition(() => !!elem3.textContent.length);
// 4. `elem4` was not re-added, so it shouldn't be localized.
is(elem4.textContent.length, 0);
document.body.appendChild(div);
// 5. Now we re-added `elem4` to DOM so it should get localized.
await SimpleTest.waitForCondition(() => elem4.textContent.length > 0);
await SimpleTest.waitForCondition(() => !!elem4.textContent.length);
SimpleTest.finish();
});
</script>

View File

@ -21,7 +21,7 @@
elem2.setAttribute("data-l10n-args", JSON.stringify({bug: "New string"}));
let verifyL10n = () => {
if (elem.textContent.length > 0 && elem2.textContent.includes("New string")) {
if (elem.textContent.length && elem2.textContent.includes("New string")) {
window.removeEventListener("MozAfterPaint", verifyL10n);
SimpleTest.finish();
}

View File

@ -20,7 +20,7 @@
document.body.appendChild(clone);
let verifyL10n = () => {
if (span.textContent.length > 0) {
if (span.textContent.length) {
window.removeEventListener("MozAfterPaint", verifyL10n);
SimpleTest.finish();
}

View File

@ -26,7 +26,7 @@
let inputElem = document.getElementById("search-input");
// Test for initial localization applied.
is(inputElem.getAttribute("placeholder").length > 0, true);
is(!!inputElem.getAttribute("placeholder").length, true);
let observer = new MutationObserver((mutations) => {
for (let mutation of mutations) {

View File

@ -26,7 +26,7 @@
let inputElem = document.getElementById("search-input");
// Test for initial localization applied.
is(inputElem.getAttribute("placeholder").length > 0, true);
is(!!inputElem.getAttribute("placeholder").length, true);
let observer = new MutationObserver((mutations) => {
for (let mutation of mutations) {

View File

@ -732,7 +732,7 @@ class RTCPeerConnection {
"Missing required 'urls' member of RTCIceServer"
);
}
if (urls.length == 0) {
if (!urls.length) {
throw new this._win.DOMException(
`${msg} - urls is empty`,
"SyntaxError"
@ -1524,7 +1524,7 @@ class RTCPeerConnection {
get currentLocalDescription() {
this._checkClosed();
const sdp = this._pc.currentLocalDescription;
if (sdp.length == 0) {
if (!sdp.length) {
return null;
}
const type = this._pc.currentOfferer ? "offer" : "answer";
@ -1534,7 +1534,7 @@ class RTCPeerConnection {
get pendingLocalDescription() {
this._checkClosed();
const sdp = this._pc.pendingLocalDescription;
if (sdp.length == 0) {
if (!sdp.length) {
return null;
}
const type = this._pc.pendingOfferer ? "offer" : "answer";
@ -1548,7 +1548,7 @@ class RTCPeerConnection {
get currentRemoteDescription() {
this._checkClosed();
const sdp = this._pc.currentRemoteDescription;
if (sdp.length == 0) {
if (!sdp.length) {
return null;
}
const type = this._pc.currentOfferer ? "answer" : "offer";
@ -1558,7 +1558,7 @@ class RTCPeerConnection {
get pendingRemoteDescription() {
this._checkClosed();
const sdp = this._pc.pendingRemoteDescription;
if (sdp.length == 0) {
if (!sdp.length) {
return null;
}
const type = this._pc.pendingOfferer ? "answer" : "offer";

View File

@ -299,7 +299,7 @@ async function isGivenTabUsingDefaultMetadata(tab, options = {}) {
const fallbackTitle = await localization.formatValue(
"mediastatus-fallback-title"
);
ok(fallbackTitle.length > 0, "l10n fallback title is not empty");
ok(fallbackTitle.length, "l10n fallback title is not empty");
const metadata = tab.linkedBrowser.browsingContext.mediaController.getMetadata();

View File

@ -15,12 +15,12 @@ SimpleTest.waitForExplicitFinish();
runWithMSE(async (ms, el) => {
el.controls = true;
el.addEventListener("loadeddata", () => {
ok(el.buffered.length > 0, "data is buffered");
ok(el.buffered.length, "data is buffered");
is(el.buffered.start(0), 0, "must fire loadeddata when data has been loaded");
is(el.currentTime, 0, "must fire loadeddata at start");
});
el.addEventListener("playing", () => {
ok(el.buffered.length > 0, "data is buffered");
ok(el.buffered.length, "data is buffered");
is(el.buffered.start(0), 0, "must fire playing when data has been loaded");
ok(el.currentTime >= 0, "must have started playback");
});

View File

@ -567,7 +567,7 @@ async function checkReportedTelemetry(media, reportExpected, hasVideo, hasAudio,
* }
*/
const items = Object.entries(hist.snapshot());
if (items.length > 0) {
if (items.length) {
for (const [key, value] of items) {
const entriesNums = Object.entries(value.values).length;
ok(reportExpected && entriesNums > 0, `Reported ${key} for ${name}`);
@ -590,7 +590,7 @@ async function checkReportedTelemetry(media, reportExpected, hasVideo, hasAudio,
const hist =
SpecialPowers.Services.telemetry.getKeyedHistogramById("MEDIA_PLAY_TIME_MS");
const items = Object.entries(hist.snapshot());
if (items.length > 0) {
if (items.length) {
for (const item of items) {
ok(item[0].includes("V") != -1 || !hasVideo, "Video time is reported if video was present");
}
@ -604,7 +604,7 @@ async function checkReportedTelemetry(media, reportExpected, hasVideo, hasAudio,
try {
const hist = SpecialPowers.Services.telemetry.getKeyedHistogramById(name);
const items = Object.entries(hist.snapshot());
if (items.length > 0) {
if (items.length) {
for (const [key, value] of items) {
const entriesNums = Object.entries(value.values).length;
ok(reportExpected && entriesNums > 0, `Reported ${key} for ${name}`);

View File

@ -241,10 +241,7 @@ var EmeHelper = class EmeHelper {
if (!this._initDataTypes) {
throw new Error("EmeHelper needs _initDataTypes to configure media");
}
if (
this._audioCapabilities.length == 0 &&
this._videoCapabilities.length == 0
) {
if (!this._audioCapabilities.length && !this._videoCapabilities.length) {
throw new Error(
"EmeHelper needs _audioCapabilities or _videoCapabilities to configure media"
);

View File

@ -2168,7 +2168,7 @@ function checkMetadata(msg, e, test) {
// installed video backends.
function getPlayableVideo(candidates) {
var resources = getPlayableVideos(candidates);
if (resources.length > 0) {
if (resources.length) {
return resources[0];
}
return null;
@ -2186,7 +2186,7 @@ function getPlayableAudio(candidates) {
var resources = candidates.filter(function(x) {
return /^audio/.test(x.type) && v.canPlayType(x.type);
});
if (resources.length > 0) {
if (resources.length) {
return resources[0];
}
return null;
@ -2341,7 +2341,7 @@ function MediaTestManager() {
});
SimpleTest.registerCleanupFunction(() => {
if (this.tokens.length > 0) {
if (this.tokens.length) {
info("Test timed out. Remaining tests=" + this.tokens);
}
for (var token of this.tokens) {
@ -2448,7 +2448,7 @@ function MediaTestManager() {
if (
this.testNum == this.tests.length &&
!DEBUG_TEST_LOOP_FOREVER &&
this.tokens.length == 0 &&
!this.tokens.length &&
!this.isShutdown
) {
this.isShutdown = true;

View File

@ -56,7 +56,7 @@ add_task(async function testMozDebugReaderData() {
"Audio track should have demuxed some samples"
);
ok(
debugData.demuxer.audioTrack.ranges.length > 0,
debugData.demuxer.audioTrack.ranges.length,
"Audio track should have some buffered range"
);
ok(
@ -64,7 +64,7 @@ add_task(async function testMozDebugReaderData() {
"Video track should have demuxed some samples"
);
ok(
debugData.demuxer.videoTrack.ranges.length > 0,
debugData.demuxer.videoTrack.ranges.length,
"Video track should have some buffered range"
);
removeNodeAndSource(video);

View File

@ -32,7 +32,7 @@ function startTest(test, token) {
is(el.error.code, MediaError.MEDIA_ERR_DECODE, "Expected a decode error");
}
ok(typeof el.error.message === 'string' || el.error.message instanceof String, "Element 'message' attr expected to be a string");
ok(el.error.message.length > 0, "Element 'message' attr has content");
ok(el.error.message.length, "Element 'message' attr has content");
el._sawError = true;
manager.finished(token);
});

View File

@ -96,7 +96,7 @@ v.onloadstart = function(e) {
v.load(); // load started while in this document, this doc's load will block until
// the video's finished loading (in the other document).
if (gRegisteredElements.length > 0) {
if (gRegisteredElements.length) {
SimpleTest.waitForExplicitFinish();
} else {
todo(false, "No types supported");

View File

@ -21,7 +21,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=476731
var videos = [];
function FinishedLoads() {
if (videos.length == 0)
if (!videos.length)
return false;
for (var i=0; i<videos.length; ++i) {
if (videos[i]._loadedData) {
@ -73,7 +73,7 @@ for (var i=0; i<g404Tests.length; ++i) {
videos.push(v);
}
if (videos.length == 0) {
if (!videos.length) {
todo(false, "No types supported");
} else {
SimpleTest.waitForExplicitFinish();

View File

@ -75,7 +75,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=778077
v.target = 0;
v.keyframes = test.keyframes;
v.keyframeIndex = 0;
ok(v.keyframes.length > 0, v.name + " - video should have at least one sync point");
ok(v.keyframes.length, v.name + " - video should have at least one sync point");
v.addEventListener("loadedmetadata", onloadedmetadata);
v.addEventListener("seeked", onseeked);
document.body.appendChild(v);

View File

@ -76,7 +76,7 @@ for (var i=0; i<gSmallTests.length; ++i) {
media.push(v);
}
if (media.length == 0) {
if (!media.length) {
todo(false, "No types supported");
} else {
SimpleTest.waitForExplicitFinish();

View File

@ -25,7 +25,7 @@ is(a1.childNodes.length, 0, "should have no children");
function newSource(filter) {
var candidates = gSmallTests.filter(function(x){return filter.test(x.type);});
if (candidates.length > 0) {
if (candidates.length) {
var e = document.createElement("source");
e.type = candidates[0].type;
e.src = candidates[0].name;

View File

@ -49,7 +49,7 @@ function doTest()
SimpleTest.finish();
}
if (iframes.length == 0) {
if (!iframes.length) {
todo(false, "No types supported");
} else {
SimpleTest.waitForExplicitFinish();

View File

@ -84,7 +84,7 @@ async function startTest(test, token) {
`${token} checking readyState`);
ok(vout.ended, `${token} checking playback has ended`);
isnot(stream.getTracks().length, 0, `${token} results in some tracks`);
if (stream.getVideoTracks().length > 0) {
if (stream.getVideoTracks().length) {
ok(test.type.match(/^video/), `${token} is a video resource`);
checkDrawImage(vout, `${token} checking video frame pixel has been drawn`);
}

View File

@ -85,7 +85,7 @@ function startTest(test, token) {
function canPlay(candidates) {
var v = document.createElement("video");
var resources = candidates.filter(function(x){return v.canPlayType(x.type);});
return (resources.length > 0);
return (resources.length);
}
if (canPlay(gUnseekableTests)) {

View File

@ -33,7 +33,7 @@
if (index != -1) {
info("Dropping id " + id + " at index " + index);
ids.splice(index, 1);
if (ids.length == 0) {
if (!ids.length) {
SimpleTest.executeSoon(function() {
is(weak.get(), null, "The weak reference must be dropped now");
SpecialPowers.removeObserver(observer, "webaudio-node-demise");

View File

@ -54,7 +54,7 @@ testProcessor.onaudioprocess = function(event) {
SpecialPowers.removeObserver(observer, "webaudio-node-demise");
observer = null;
event.target.onaudioprocess = null;
ok(ids.length == 0, "All expected nodes should be collected");
ok(!ids.length, "All expected nodes should be collected");
SimpleTest.finish();
});
break;

View File

@ -17,7 +17,7 @@ function observer(subject, topic, data) {
if (index != -1) {
ok(true, "Dropping id " + id + " at index " + index);
ids.splice(index, 1);
if (ids.length == 0) {
if (!ids.length) {
SimpleTest.executeSoon(function() {
SimpleTest.finish();
});

View File

@ -253,7 +253,7 @@ function runTest() {
var expectedBuffer = expectedBuffers.shift();
testLength += expectedBuffer.length;
compareBuffers(e.inputBuffer, expectedBuffer);
if (expectedBuffers.length == 0) {
if (!expectedBuffers.length) {
sp.onaudioprocess = null;
callback();
}

View File

@ -1626,9 +1626,9 @@ PeerConnectionWrapper.prototype = {
info(
this.label + ": iceCandidate = " + JSON.stringify(anEvent.candidate)
);
ok(anEvent.candidate.sdpMid.length > 0, "SDP mid not empty");
ok(anEvent.candidate.sdpMid.length, "SDP mid not empty");
ok(
anEvent.candidate.usernameFragment.length > 0,
anEvent.candidate.usernameFragment.length,
"usernameFragment not empty"
);

View File

@ -138,7 +138,7 @@ var sdputils = {
).filter(hasOwnTransport);
ok(
msectionsWithOwnTransports.length > 0,
msectionsWithOwnTransports.length,
"SDP should contain at least one msection with a transport"
);
msectionsWithOwnTransports.forEach(checkForTransportAttributes);

View File

@ -131,7 +131,7 @@ function dumpSdp(test) {
// We need to verify that at least one candidate has been (or will be) gathered.
function waitForAnIceCandidate(pc) {
return new Promise(resolve => {
if (!pc.localRequiresTrickleIce || pc._local_ice_candidates.length > 0) {
if (!pc.localRequiresTrickleIce || pc._local_ice_candidates.length) {
resolve();
} else {
// In some circumstances, especially when both PCs are on the same
@ -142,7 +142,7 @@ function waitForAnIceCandidate(pc) {
}
}).then(() => {
ok(
pc._local_ice_candidates.length > 0,
pc._local_ice_candidates.length,
pc + " received local trickle ICE candidates"
);
isnot(

View File

@ -47,7 +47,7 @@ runTest(async () => {
// Validate enumerated devices.
let devices = await navigator.mediaDevices.enumerateDevices();
ok(devices.length > 0, "At least one device found");
ok(devices.length, "At least one device found");
let jsoned = JSON.parse(JSON.stringify(devices));
is(jsoned[0].kind, devices[0].kind, "kind survived serializer");
is(jsoned[0].deviceId, devices[0].deviceId, "deviceId survived serializer");

View File

@ -17,8 +17,8 @@
is(receivers.length, 2, "Expected number of receivers");
// Wait for sync sources
while (true) {
if (receivers[0].getSynchronizationSources().length > 0 &&
receivers[1].getSynchronizationSources().length > 0) {
if (receivers[0].getSynchronizationSources().length &&
receivers[1].getSynchronizationSources().length) {
break;
}
await wait(250);

View File

@ -15,7 +15,7 @@
let receiver = test.pcRemote.getReceivers()[0];
ok(receiver, "Remote has a receiver");
// Wait for remote sync source
while (receiver.getSynchronizationSources().length == 0) {
while (!receiver.getSynchronizationSources().length) {
await wait(250);
}
is(receiver.getSynchronizationSources().length, 1,
@ -32,7 +32,7 @@
await waitForSyncSources(test);
let receiver = test.pcRemote.getReceivers()[0];
let syncSources = receiver.getSynchronizationSources();
ok(syncSources.length > 0,
ok(syncSources.length,
"Receiver has Synchronization sources " + JSON.stringify(syncSources));
is(syncSources.length, 1, "Receiver has only a single sync source");
let syncSource = syncSources[0];

View File

@ -55,8 +55,8 @@
offerToReceiveAudio: false,
}
);
const hasVideo = stream.getVideoTracks().length > 0;
const hasAudio = stream.getAudioTracks().length > 0;
const hasVideo = !!stream.getVideoTracks().length;
const hasAudio = !!stream.getAudioTracks().length;
test.setMediaConstraints([{ video: hasVideo, audio: hasAudio }], []);
test.chain.replace("PC_LOCAL_GUM", [
function PC_LOCAL_CAPTUREVIDEO(test) {

View File

@ -13,7 +13,7 @@ createHTML({
});
function insertdtmftest(pc) {
ok(pc.getSenders().length > 0, "have senders");
ok(pc.getSenders().length, "have senders");
var sender = pc.getSenders()[0];
ok(sender.dtmf, "sender has dtmf object");

Some files were not shown because too many files have changed in this diff Show More