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: { rules: {
"mozilla/prefer-boolean-length-check": "off", "mozilla/prefer-boolean-length-check": "off",
}, },

View File

@ -410,7 +410,7 @@ waitForAllPaints(() => {
now = document.timeline.currentTime; now = document.timeline.currentTime;
elapsed = (now - timeAtStart); elapsed = (now - timeAtStart);
markers = await observeStyling(1); markers = await observeStyling(1);
if (markers.length > 0) { if (markers.length) {
break; break;
} }
} }
@ -437,7 +437,7 @@ waitForAllPaints(() => {
else if (elapsed.toPrecision(10) > 200) else if (elapsed.toPrecision(10) > 200)
expectedMarkersLengthValid = markers.length == 1; expectedMarkersLengthValid = markers.length == 1;
else else
expectedMarkersLengthValid = markers.length == 0; expectedMarkersLengthValid = !markers.length;
ok(expectedMarkersLengthValid, ok(expectedMarkersLengthValid,
'Transform animation running on the element which is scrolled out ' + 'Transform animation running on the element which is scrolled out ' +
'should be unthrottled after around 200ms have elapsed. now: ' + 'should be unthrottled after around 200ms have elapsed. now: ' +
@ -472,7 +472,7 @@ waitForAllPaints(() => {
now = document.timeline.currentTime; now = document.timeline.currentTime;
elapsed = (now - timeAtStart); elapsed = (now - timeAtStart);
markers = await observeStyling(1); markers = await observeStyling(1);
if (markers.length > 0) { if (markers.length) {
break; break;
} }
} }
@ -495,7 +495,7 @@ waitForAllPaints(() => {
else if (elapsed.toPrecision(10) > 200) else if (elapsed.toPrecision(10) > 200)
expectedMarkersLengthValid = markers.length == 1; expectedMarkersLengthValid = markers.length == 1;
else else
expectedMarkersLengthValid = markers.length == 0; expectedMarkersLengthValid = !markers.length;
ok(expectedMarkersLengthValid, ok(expectedMarkersLengthValid,
'Transform animation running on out of view element ' + 'Transform animation running on out of view element ' +
'should be unthrottled after around 200ms have elapsed. now: ' + '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(); var next = order.shift();
window.arguments[0].is(msg.data, next, "received test:" + next); 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.arguments[0].setTimeout(function() { this.next(); });
window.close(); window.close();
} }

View File

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

View File

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

View File

@ -43,7 +43,7 @@ window.onload = function() {
var scripts = dbg.findScripts({ var scripts = dbg.findScripts({
url: "http://mochi.test:8888/tests/dom/base/test/chrome/nochrome_bug1346936.js", 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"); is(scripts[0].source.sourceMapURL, "foo.js.map");
SimpleTest.finish(); SimpleTest.finish();

View File

@ -43,7 +43,7 @@ window.onload = function() {
var scripts = dbg.findScripts({ var scripts = dbg.findScripts({
url: "http://mochi.test:8888/tests/dom/base/test/chrome/nochrome_bug765993.js", 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"); is(scripts[0].source.sourceMapURL, "foo.js.map");
SimpleTest.finish(); SimpleTest.finish();

View File

@ -41,7 +41,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=884693
msg.category.includes("chrome javascript") && msg.category.includes("chrome javascript") &&
msg.message.includes("Unknown event"))); msg.message.includes("Unknown event")));
if (messages.length > 0) { if (messages.length) {
info(`Got console messages ${messages}`); info(`Got console messages ${messages}`);
} }
is(messages.length, expectedMessages.length, "Got expected message count"); 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() { function next() {
if (tests.length > 0) { if (tests.length) {
var file = tests.shift(); var file = tests.shift();
info("-- running " + file); info("-- running " + file);
window.openDialog(file, "_blank", "chrome,noopener", window); window.openDialog(file, "_blank", "chrome,noopener", window);

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -45,9 +45,9 @@ function checkHeaders(xhrInner) {
ok(contentType == true, "Content-type is part of the headers!"); ok(contentType == true, "Content-type is part of the headers!");
var ct = xhrInner.getResponseHeader('content-type'); 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'); 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 () { xhr.addEventListener("load", function () {

View File

@ -456,7 +456,7 @@ SimpleTest.waitForFocus(function () {
* Basic tests with complicated tree. * Basic tests with complicated tree.
*/ */
function check(aIter, aExpectedResult, aDescription) { function check(aIter, aExpectedResult, aDescription) {
if (aExpectedResult.length > 0) { if (aExpectedResult.length) {
is(SpecialPowers.unwrap(aIter.currentNode), aExpectedResult[0], 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])})`); `${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`); 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. * Basic tests with complicated tree.
*/ */
function check(aIter, aExpectedResult, aDescription) { function check(aIter, aExpectedResult, aDescription) {
if (aExpectedResult.length > 0) { if (aExpectedResult.length) {
is(SpecialPowers.unwrap(aIter.currentNode), aExpectedResult[0], 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])})`); `${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`); 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. * Basic tests with complicated tree.
*/ */
function check(aIter, aExpectedResult, aDescription) { function check(aIter, aExpectedResult, aDescription) {
if (aExpectedResult.length > 0) { if (aExpectedResult.length) {
is(SpecialPowers.unwrap(aIter.currentNode), aExpectedResult[0], 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])})`); `${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`); 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.language, data.language);
is(navigator.languages.length, data.languages.length); is(navigator.languages.length, data.languages.length);
if (navigator.languages.length > 0) { if (navigator.languages.length) {
is(navigator.languages[0], navigator.language) is(navigator.languages[0], navigator.language)
} }
for (var j = 0; j < navigator.languages.length; ++j) { for (var j = 0; j < navigator.languages.length; ++j) {

View File

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

View File

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

View File

@ -14,7 +14,7 @@ add_task(async function testSteps() {
const requestList = await cache.keys(); 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) { for (const request of requestList) {
ok(request, "each request in list should be non-null"); ok(request, "each request in list should be non-null");
ok( 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) { for (const response of responseList) {
ok(response, "each response should be non-null"); ok(response, "each response should be non-null");
// reponse.url is a empty string in current test file. It should test for // 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.postMessage(imageData.data.buffer, [imageData.data.buffer]);
tempWorker.terminate(); tempWorker.terminate();
ok(imageData.data.length == 0, "Get a neutured ImageData."); ok(!imageData.data.length, "Get a neutured ImageData.");
resolve(createImageBitmap(imageData)); resolve(createImageBitmap(imageData));
} }
}); });

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -130,7 +130,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=409604
var accessChar = String.fromCharCode(code).toUpperCase(); var accessChar = String.fromCharCode(code).toUpperCase();
pressAccessKey({key: accessChar}); 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) { function createUnfocusableElement(elem, accesskey) {

View File

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

View File

@ -560,7 +560,7 @@ function doDragOverSynthetic(event)
function onDragStartDraggable(event) function onDragStartDraggable(event)
{ {
var dt = event.dataTransfer; 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(); event.preventDefault();
gExtraDragTests++; gExtraDragTests++;

View File

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

View File

@ -125,7 +125,7 @@ function waitForEnterLeaveEvents(aEnterTarget, aLeaveTarget) {
return; return;
} }
if (expectedEvents.length == 0) { if (!expectedEvents.length) {
// Trigger a reflow which will generate synthesized mouse move event. // Trigger a reflow which will generate synthesized mouse move event.
reflow(); reflow();
// Now wait a bit to see if there is any unexpected event fired. // 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"); "Getting @items twice should return the same object");
var haveFiles = false; var haveFiles = false;
ok(items instanceof DataTransferItemList, "@items implements DataTransferItemList"); 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++) { for (var i = 0; i < items.length; i++) {
var item = items[i]; var item = items[i];
ok(item instanceof DataTransferItem, "each element of @items must implement DataTransferItem"); ok(item instanceof DataTransferItem, "each element of @items must implement DataTransferItem");
@ -136,7 +136,7 @@
is(files, e.clipboardData.files, is(files, e.clipboardData.files,
"Getting the files array twice should return the same array"); "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++) { for (var i = 0; i < files.length; i++) {
var file = files[i]; var file = files[i];
ok(file instanceof File, ".files should contain only File objects"); 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() { function runNextTest() {
if (indexes.length == 0) { if (!indexes.length) {
return Promise.resolve(true); return Promise.resolve(true);
} }

View File

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

View File

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

View File

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

View File

@ -149,7 +149,7 @@ function secondClick(evt) {
} }
function exitFullscreen() { function exitFullscreen() {
if (tests.length > 0) { if (tests.length) {
nextTest(); nextTest();
} else { } else {
opener.nextTest(); 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`); `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 (SpecialPowers.wrap(target).isInputEventTarget) {
if (test.type === "time") { if (test.type === "time") {
todo(inputEvents[0] instanceof InputEvent, todo(inputEvents[0] instanceof InputEvent,
`"input" event should be dispatched with InputEvent interface when setUserInput("${test.input.before}") is called before ${tag} gets focus`); `"input" event should be dispatched with InputEvent interface when setUserInput("${test.input.before}") is called before ${tag} gets focus`);
} else { } else {
if (beforeInputEvents.length > 0 && test.result.fireBeforeInputEvent) { if (beforeInputEvents.length && test.result.fireBeforeInputEvent) {
is(beforeInputEvents[0].cancelable, kSetUserInputCancelable, 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`); `"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", 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`); `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 (SpecialPowers.wrap(target).isInputEventTarget) {
if (test.type === "time") { if (test.type === "time") {
todo(inputEvents[0] instanceof InputEvent, todo(inputEvents[0] instanceof InputEvent,
`"input" event should be dispatched with InputEvent interface when setUserInput("${test.input.after}") is called after ${tag} gets focus`); `"input" event should be dispatched with InputEvent interface when setUserInput("${test.input.after}") is called after ${tag} gets focus`);
} else { } else {
if (beforeInputEvents.length > 0 && test.result.fireBeforeInputEvent) { if (beforeInputEvents.length && test.result.fireBeforeInputEvent) {
is(beforeInputEvents[0].cancelable, kSetUserInputCancelable, 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`); `"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", is(beforeInputEvents[0].inputType, "insertReplacementText",
@ -407,12 +407,12 @@ SimpleTest.waitForFocus(async () => {
reset(); reset();
SpecialPowers.wrap(target).setUserInput(aValidValue); SpecialPowers.wrap(target).setUserInput(aValidValue);
is(beforeInputEvents.length, 1, `Calling ${tag}.setUserInput(${aValidValue}) should cause a "beforeinput" event (before gets focus)`); 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, is(beforeInputEvents[0].validity, false,
`The ${tag} should be invalid at "beforeinput" event (before gets focus)`); `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)`); 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, is(inputEvents[0].validity, true,
`The ${tag} should be valid at "input" event (before gets focus)`); `The ${tag} should be valid at "input" event (before gets focus)`);
} }
@ -433,12 +433,12 @@ SimpleTest.waitForFocus(async () => {
reset(); reset();
SpecialPowers.wrap(target).setUserInput(aValidValue); SpecialPowers.wrap(target).setUserInput(aValidValue);
is(beforeInputEvents.length, 1, `Calling ${tag}.setUserInput(${aValidValue}) should cause a "beforeinput" event (after gets focus)`); 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, is(beforeInputEvents[0].validity, false,
`The ${tag} should be invalid at "beforeinput" event (after gets focus)`); `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)`); 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, is(inputEvents[0].validity, true,
`The ${tag} should be valid at "input" event (after gets focus)`); `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 ""; return "";
}; };
while (testData.length != 0) { while (testData.length) {
currentTest = testData.shift(); currentTest = testData.shift();
element = document.getElementById(currentTest.id); element = document.getElementById(currentTest.id);

View File

@ -471,7 +471,7 @@ SimpleTest.waitForFocus(() => {
is(input.value, "hig", 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`); `${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`); is(inputEvents.length, 1, `${description}"input" event should be fired`);
if (inputEvents.length > 0) { if (inputEvents.length) {
is(inputEvents[0].inputType, is(inputEvents[0].inputType,
"insertReplacementText", `${description}inputType of "input" event should be "insertReplacementText"`); "insertReplacementText", `${description}inputType of "input" event should be "insertReplacementText"`);
is(inputEvents[0].data, "def", is(inputEvents[0].data, "def",
@ -550,7 +550,7 @@ SimpleTest.waitForFocus(() => {
// Different from Chrome // Different from Chrome
is(inputEvents.length, 1, is(inputEvents.length, 1,
`${description}"input" event should be fired even if the frame of target is destroyed`); `${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, is(inputEvents[0].inputType,
"insertReplacementText", `${description}inputType of "input" event should be "insertReplacementText"`); "insertReplacementText", `${description}inputType of "input" event should be "insertReplacementText"`);
is(inputEvents[0].data, "def", is(inputEvents[0].data, "def",
@ -597,7 +597,7 @@ SimpleTest.waitForFocus(() => {
is(input.value, "hig", 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`); `${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`); is(inputEvents.length, 1, `${description}"input" event should be fired`);
if (inputEvents.length > 0) { if (inputEvents.length) {
is(inputEvents[0].inputType, is(inputEvents[0].inputType,
"insertReplacementText", `${description}inputType of "input" event should be "insertReplacementText"`); "insertReplacementText", `${description}inputType of "input" event should be "insertReplacementText"`);
is(inputEvents[0].data, "def", is(inputEvents[0].data, "def",

View File

@ -596,7 +596,7 @@ function reflectLimitedEnumerated(aParameters) {
null, null,
"Missing default value should be null for nullable attributes" "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]); element.setAttribute(contentAttr, validValues[0]);
ok( ok(
element.hasAttribute(contentAttr), element.hasAttribute(contentAttr),

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -56,7 +56,7 @@ function unregisterAllPopupEventHandlers(win) {
function triggerMainCommand(popup) { function triggerMainCommand(popup) {
info("triggering main command"); info("triggering main command");
let notifications = popup.childNodes; 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]; let notification = notifications[0];
info("triggering command: " + notification.getAttribute("buttonlabel")); info("triggering command: " + notification.getAttribute("buttonlabel"));
@ -69,7 +69,7 @@ function triggerSecondaryCommand(popup, win) {
} }
info("triggering secondary command"); info("triggering secondary command");
let notifications = popup.childNodes; 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]; let notification = notifications[0];
EventUtils.synthesizeMouseAtCenter(notification.secondaryButton, {}, win); EventUtils.synthesizeMouseAtCenter(notification.secondaryButton, {}, win);
} }

View File

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

View File

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

View File

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

View File

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

View File

@ -26,7 +26,7 @@
await document.l10n.ready; await document.l10n.ready;
// Lazy initialized localization should translate the document. // 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); document.head.removeChild(link);

View File

@ -17,7 +17,7 @@
{ {
// 1. An example message from aboutAddons should be available. // 1. An example message from aboutAddons should be available.
let value = await document.l10n.formatValue("shortcuts-browserAction2"); 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. // 3. An example message from aboutSupport should still be available.
let value = await document.l10n.formatValue("features-version"); 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. // 4. An example message from aboutAddons should not be available.
await document.l10n.formatValue("shortcuts-browserAction").then( await document.l10n.formatValue("shortcuts-browserAction").then(

View File

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

View File

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

View File

@ -24,7 +24,7 @@
// Test for mutations applied. // Test for mutations applied.
let verifyL10n = () => { let verifyL10n = () => {
if (label.textContent.length > 0) { if (label.textContent.length) {
window.removeEventListener("MozAfterPaint", verifyL10n); window.removeEventListener("MozAfterPaint", verifyL10n);
// Notice: In normal tests we do not want to test against any particular // 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 // 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(); await domLoc.translateRoots();
is(p1.textContent.length == 0, true); is(!p1.textContent.length, true);
const body = document.body; const body = document.body;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -21,7 +21,7 @@
elem2.setAttribute("data-l10n-args", JSON.stringify({bug: "New string"})); elem2.setAttribute("data-l10n-args", JSON.stringify({bug: "New string"}));
let verifyL10n = () => { 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); window.removeEventListener("MozAfterPaint", verifyL10n);
SimpleTest.finish(); SimpleTest.finish();
} }

View File

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

View File

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

View File

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

View File

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

View File

@ -299,7 +299,7 @@ async function isGivenTabUsingDefaultMetadata(tab, options = {}) {
const fallbackTitle = await localization.formatValue( const fallbackTitle = await localization.formatValue(
"mediastatus-fallback-title" "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(); const metadata = tab.linkedBrowser.browsingContext.mediaController.getMetadata();

View File

@ -15,12 +15,12 @@ SimpleTest.waitForExplicitFinish();
runWithMSE(async (ms, el) => { runWithMSE(async (ms, el) => {
el.controls = true; el.controls = true;
el.addEventListener("loadeddata", () => { 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.buffered.start(0), 0, "must fire loadeddata when data has been loaded");
is(el.currentTime, 0, "must fire loadeddata at start"); is(el.currentTime, 0, "must fire loadeddata at start");
}); });
el.addEventListener("playing", () => { 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"); is(el.buffered.start(0), 0, "must fire playing when data has been loaded");
ok(el.currentTime >= 0, "must have started playback"); 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()); const items = Object.entries(hist.snapshot());
if (items.length > 0) { if (items.length) {
for (const [key, value] of items) { for (const [key, value] of items) {
const entriesNums = Object.entries(value.values).length; const entriesNums = Object.entries(value.values).length;
ok(reportExpected && entriesNums > 0, `Reported ${key} for ${name}`); ok(reportExpected && entriesNums > 0, `Reported ${key} for ${name}`);
@ -590,7 +590,7 @@ async function checkReportedTelemetry(media, reportExpected, hasVideo, hasAudio,
const hist = const hist =
SpecialPowers.Services.telemetry.getKeyedHistogramById("MEDIA_PLAY_TIME_MS"); SpecialPowers.Services.telemetry.getKeyedHistogramById("MEDIA_PLAY_TIME_MS");
const items = Object.entries(hist.snapshot()); const items = Object.entries(hist.snapshot());
if (items.length > 0) { if (items.length) {
for (const item of items) { for (const item of items) {
ok(item[0].includes("V") != -1 || !hasVideo, "Video time is reported if video was present"); 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 { try {
const hist = SpecialPowers.Services.telemetry.getKeyedHistogramById(name); const hist = SpecialPowers.Services.telemetry.getKeyedHistogramById(name);
const items = Object.entries(hist.snapshot()); const items = Object.entries(hist.snapshot());
if (items.length > 0) { if (items.length) {
for (const [key, value] of items) { for (const [key, value] of items) {
const entriesNums = Object.entries(value.values).length; const entriesNums = Object.entries(value.values).length;
ok(reportExpected && entriesNums > 0, `Reported ${key} for ${name}`); ok(reportExpected && entriesNums > 0, `Reported ${key} for ${name}`);

View File

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

View File

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

View File

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

View File

@ -32,7 +32,7 @@ function startTest(test, token) {
is(el.error.code, MediaError.MEDIA_ERR_DECODE, "Expected a decode error"); 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(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; el._sawError = true;
manager.finished(token); 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 v.load(); // load started while in this document, this doc's load will block until
// the video's finished loading (in the other document). // the video's finished loading (in the other document).
if (gRegisteredElements.length > 0) { if (gRegisteredElements.length) {
SimpleTest.waitForExplicitFinish(); SimpleTest.waitForExplicitFinish();
} else { } else {
todo(false, "No types supported"); todo(false, "No types supported");

View File

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

View File

@ -75,7 +75,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=778077
v.target = 0; v.target = 0;
v.keyframes = test.keyframes; v.keyframes = test.keyframes;
v.keyframeIndex = 0; 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("loadedmetadata", onloadedmetadata);
v.addEventListener("seeked", onseeked); v.addEventListener("seeked", onseeked);
document.body.appendChild(v); document.body.appendChild(v);

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -54,7 +54,7 @@ testProcessor.onaudioprocess = function(event) {
SpecialPowers.removeObserver(observer, "webaudio-node-demise"); SpecialPowers.removeObserver(observer, "webaudio-node-demise");
observer = null; observer = null;
event.target.onaudioprocess = 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(); SimpleTest.finish();
}); });
break; break;

View File

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

View File

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

View File

@ -1626,9 +1626,9 @@ PeerConnectionWrapper.prototype = {
info( info(
this.label + ": iceCandidate = " + JSON.stringify(anEvent.candidate) 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( ok(
anEvent.candidate.usernameFragment.length > 0, anEvent.candidate.usernameFragment.length,
"usernameFragment not empty" "usernameFragment not empty"
); );

View File

@ -138,7 +138,7 @@ var sdputils = {
).filter(hasOwnTransport); ).filter(hasOwnTransport);
ok( ok(
msectionsWithOwnTransports.length > 0, msectionsWithOwnTransports.length,
"SDP should contain at least one msection with a transport" "SDP should contain at least one msection with a transport"
); );
msectionsWithOwnTransports.forEach(checkForTransportAttributes); 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. // We need to verify that at least one candidate has been (or will be) gathered.
function waitForAnIceCandidate(pc) { function waitForAnIceCandidate(pc) {
return new Promise(resolve => { return new Promise(resolve => {
if (!pc.localRequiresTrickleIce || pc._local_ice_candidates.length > 0) { if (!pc.localRequiresTrickleIce || pc._local_ice_candidates.length) {
resolve(); resolve();
} else { } else {
// In some circumstances, especially when both PCs are on the same // In some circumstances, especially when both PCs are on the same
@ -142,7 +142,7 @@ function waitForAnIceCandidate(pc) {
} }
}).then(() => { }).then(() => {
ok( ok(
pc._local_ice_candidates.length > 0, pc._local_ice_candidates.length,
pc + " received local trickle ICE candidates" pc + " received local trickle ICE candidates"
); );
isnot( isnot(

View File

@ -47,7 +47,7 @@ runTest(async () => {
// Validate enumerated devices. // Validate enumerated devices.
let devices = await navigator.mediaDevices.enumerateDevices(); 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)); let jsoned = JSON.parse(JSON.stringify(devices));
is(jsoned[0].kind, devices[0].kind, "kind survived serializer"); is(jsoned[0].kind, devices[0].kind, "kind survived serializer");
is(jsoned[0].deviceId, devices[0].deviceId, "deviceId 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"); is(receivers.length, 2, "Expected number of receivers");
// Wait for sync sources // Wait for sync sources
while (true) { while (true) {
if (receivers[0].getSynchronizationSources().length > 0 && if (receivers[0].getSynchronizationSources().length &&
receivers[1].getSynchronizationSources().length > 0) { receivers[1].getSynchronizationSources().length) {
break; break;
} }
await wait(250); await wait(250);

View File

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

View File

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

View File

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

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