/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/** * Predicates used when sorting items. * * @param object first * The first item used in the comparison. * @param object second * The second item used in the comparison. * @return number * <0 to sort first to a lower index than second * =0 to leave first and second unchanged with respect to each other * >0 to sort second to a lower index than first
*/
function compareValues(first, second) { if (first === second) { return 0;
} return first > second ? 1 : -1;
}
function waterfall(first, second) { const result = compareValues(first.startedMs, second.startedMs); return result || compareValues(first.id, second.id);
}
function priority(first, second) { const result = compareValues(first.priority, second.priority); return result || waterfall(first, second);
}
function status(first, second) { const result = compareValues(getStatusValue(first), getStatusValue(second)); return result || waterfall(first, second);
}
function method(first, second) { const result = compareValues(first.method, second.method); return result || waterfall(first, second);
}
function file(first, second) { const firstUrl = first.urlDetails.baseNameWithQuery.toLowerCase(); const secondUrl = second.urlDetails.baseNameWithQuery.toLowerCase(); const result = compareValues(firstUrl, secondUrl); return result || waterfall(first, second);
}
function url(first, second) { const firstUrl = first.url.toLowerCase(); const secondUrl = second.url.toLowerCase(); const result = compareValues(firstUrl, secondUrl); return result || waterfall(first, second);
}
function protocol(first, second) { const result = compareValues(first.httpVersion, second.httpVersion); return result || waterfall(first, second);
}
function scheme(first, second) { const result = compareValues(
first.urlDetails.scheme,
second.urlDetails.scheme
); return result || waterfall(first, second);
}
function startTime(first, second) { const result = compareValues(getStartTime(first), getStartTime(second)); return result || waterfall(first, second);
}
function endTime(first, second) { const result = compareValues(getEndTime(first), getEndTime(second)); return result || waterfall(first, second);
}
function responseTime(first, second) { const result = compareValues(getResponseTime(first), getResponseTime(second)); return result || waterfall(first, second);
}
function duration(first, second) { const result = compareValues(first.totalTime, second.totalTime); return result || waterfall(first, second);
}
let firstInitiator = "";
let firstInitiatorLineNumber = 0;
if (first.cause.lastFrame) {
firstInitiator = getUrlBaseName(first.cause.lastFrame.filename);
firstInitiatorLineNumber = first.cause.lastFrame.lineNumber;
}
let secondInitiator = "";
let secondInitiatorLineNumber = 0;
if (second.cause.lastFrame) {
secondInitiator = getUrlBaseName(second.cause.lastFrame.filename);
secondInitiatorLineNumber = second.cause.lastFrame.lineNumber;
}
let result; // if both initiators don't have a stack trace, compare their causes if (!firstInitiator && !secondInitiator) {
result = compareValues(firstCause, secondCause);
} elseif (!firstInitiator || !secondInitiator) { // if one initiator doesn't have a stack trace but the other does, former should precede the latter
result = compareValues(firstInitiatorLineNumber, secondInitiatorLineNumber);
} else {
result = compareValues(firstInitiator, secondInitiator); if (result === 0) {
result = compareValues(
firstInitiatorLineNumber,
secondInitiatorLineNumber
);
}
}
function type(first, second) { const firstType = getAbbreviatedMimeType(first.mimeType).toLowerCase(); const secondType = getAbbreviatedMimeType(second.mimeType).toLowerCase(); const result = compareValues(firstType, secondType); return result || waterfall(first, second);
}
function getStatusValue(item) {
let value; if (item.blockedReason) {
value = typeof item.blockedReason == "number" ? -item.blockedReason : -1000;
} elseif (item.status == null) {
value = -2;
} else {
value = item.status;
} return value;
}
function getTransferedSizeValue(item) {
let value; if (item.blockedReason) { // Also properly group/sort various blocked reasons.
value = typeof item.blockedReason == "number" ? -item.blockedReason : -1000;
} elseif (item.fromCache || item.status === "304") {
value = -2;
} elseif (item.fromServiceWorker) {
value = -3;
} elseif (typeof item.transferredSize == "number") {
value = item.transferredSize; if (item.isRacing && typeof item.isRacing == "boolean") {
value = -4;
}
} elseif (item.transferredSize === null) {
value = -5;
} return value;
}
function transferred(first, second) { const result = compareValues(
getTransferedSizeValue(first),
getTransferedSizeValue(second)
); return result || waterfall(first, second);
}
function contentSize(first, second) { const result = compareValues(first.contentSize, second.contentSize); return result || waterfall(first, second);
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.