--- a/browser/base/content/browser-gestureSupport.js
+++ b/browser/base/content/browser-gestureSupport.js
@@ -421,19 +421,22 @@ var gGestureSupport = {
*/
_getPref: function GS__getPref(aPref, aDef) {
// Preferences branch under which all gestures preferences are stored
const branch = "browser.gesture.";
try {
// Determine what type of data to load based on default value's type
let type = typeof aDef;
- let getFunc = "get" + (type == "boolean" ? "Bool" :
- type == "number" ? "Int" : "Char") + "Pref";
- return gPrefService[getFunc](branch + aPref);
+ let getFunc = "Char";
+ if (type == "boolean")
+ getFunc = "Bool";
+ else if (type == "number")
+ getFunc = "Int";
+ return gPrefService["get" + getFunc + "Pref"](branch + aPref);
}
catch (e) {
return aDef;
}
},
/**
* Perform rotation for ImageDocuments
--- a/browser/base/content/contentSearchUI.js
+++ b/browser/base/content/contentSearchUI.js
@@ -272,19 +272,23 @@ ContentSearchUIController.prototype = {
altKey: aEvent.altKey,
button: aEvent.button,
},
};
if (this.suggestionAtIndex(this.selectedIndex)) {
eventData.selection = {
index: this.selectedIndex,
- kind: aEvent instanceof MouseEvent ? "mouse" :
- aEvent instanceof KeyboardEvent ? "key" : undefined,
+ kind: undefined,
};
+ if (aEvent instanceof MouseEvent) {
+ eventData.selection.kind = "mouse";
+ } else if (aEvent instanceof KeyboardEvent) {
+ eventData.selection.kind = "key";
+ }
}
this._sendMsg("Search", eventData);
this.addInputValueToFormHistory();
},
_onInput: function () {
if (!this.input.value) {
--- a/browser/base/content/pageinfo/permissions.js
+++ b/browser/base/content/pageinfo/permissions.js
@@ -295,17 +295,17 @@ function initPluginsRow() {
permissionMap.set(permString, name);
}
}
}
let entries = Array.from(permissionMap, item => ({ name: item[1], permission: item[0] }));
entries.sort(function(a, b) {
- return a.name < b.name ? -1 : (a.name == b.name ? 0 : 1);
+ return a.name.localeCompare(b.name);
});
let permissionEntries = entries.map(p => fillInPluginPermissionTemplate(p.name, p.permission));
let permPluginsRow = document.getElementById("perm-plugins-row");
clearPluginPermissionTemplate();
if (permissionEntries.length < 1) {
permPluginsRow.hidden = true;
--- a/browser/components/customizableui/CustomizeMode.jsm
+++ b/browser/components/customizableui/CustomizeMode.jsm
@@ -911,18 +911,22 @@ CustomizeMode.prototype = {
} else if (wrapper.hasAttribute("haswideitem")) {
wrapper.removeAttribute("haswideitem");
}
}
let removable = aPlace == "palette" || CustomizableUI.isWidgetRemovable(aNode);
wrapper.setAttribute("removable", removable);
- let contextMenuAttrName = aNode.getAttribute("context") ? "context" :
- aNode.getAttribute("contextmenu") ? "contextmenu" : "";
+ let contextMenuAttrName = "";
+ if (aNode.getAttribute("context")) {
+ contextMenuAttrName = "context";
+ } else if (aNode.getAttribute("contextmenu")) {
+ contextMenuAttrName = "contextmenu";
+ }
let currentContextMenu = aNode.getAttribute(contextMenuAttrName);
let contextMenuForPlace = aPlace == "panel" ?
kPanelItemContextMenu :
kPaletteItemContextMenu;
if (aPlace != "toolbar") {
wrapper.setAttribute("context", contextMenuForPlace);
}
// Only keep track of the menu if it is non-default.
--- a/browser/components/places/content/menu.xml
+++ b/browser/components/places/content/menu.xml
@@ -412,18 +412,22 @@
else {
// We are not dragging over a folder.
// Clear out old _overFolder information.
this._overFolder.clear();
}
// Autoscroll the popup strip if we drag over the scroll buttons.
let anonid = event.originalTarget.getAttribute('anonid');
- let scrollDir = anonid == "scrollbutton-up" ? -1 :
- anonid == "scrollbutton-down" ? 1 : 0;
+ let scrollDir = 0;
+ if (anonid == "scrollbutton-up") {
+ scrollDir = -1;
+ } else if (anonid == "scrollbutton-down") {
+ scrollDir = 1;
+ }
if (scrollDir != 0) {
this._scrollBox.scrollByIndex(scrollDir, false);
}
// Check if we should hide the drop indicator for this target.
if (dropPoint.folderElt || this._hideDropIndicator(event)) {
this._indicatorBar.hidden = true;
event.preventDefault();
--- a/browser/extensions/pocket/content/pktApi.jsm
+++ b/browser/extensions/pocket/content/pktApi.jsm
@@ -537,17 +537,17 @@ var pktApi = (function() {
for (var tagKey in usedTagsObject) {
usedTagsObjectArray.push(usedTagsObject[tagKey]);
}
// Sort usedTagsObjectArray based on timestamp
usedTagsObjectArray.sort(function(usedTagA, usedTagB) {
var a = usedTagA.timestamp;
var b = usedTagB.timestamp;
- return a < b ? -1 : a > b ? 1 : 0;
+ return a - b;
});
// Get all keys tags
for (var j = 0; j < usedTagsObjectArray.length; j++) {
usedTags.push(usedTagsObjectArray[j].tag);
}
// Reverse to set the last recent used tags to the front
--- a/toolkit/.eslintrc
+++ b/toolkit/.eslintrc
@@ -105,17 +105,17 @@
// No reassigning native JS objects
"no-native-reassign": 2,
// No (!foo in bar)
"no-negated-in-lhs": 2,
// Nested ternary statements are confusing
- // "no-nested-ternary": 2,
+ "no-nested-ternary": 2,
// Use {} instead of new Object()
// "no-new-object": 2,
// No Math() or JSON()
"no-obj-calls": 2,
// No octal literals
--- a/toolkit/components/aboutmemory/content/aboutMemory.js
+++ b/toolkit/components/aboutmemory/content/aboutMemory.js
@@ -1188,19 +1188,17 @@ TreeNode.compareAmounts = function(aA, a
}
if (a < b) {
return 1;
}
return TreeNode.compareUnsafeNames(aA, aB);
};
TreeNode.compareUnsafeNames = function(aA, aB) {
- return aA._unsafeName < aB._unsafeName ? -1 :
- aA._unsafeName > aB._unsafeName ? 1 :
- 0;
+ return aA._unsafeName.localeCompare(aB._unsafeName);
};
/**
* Fill in the remaining properties for the specified tree in a bottom-up
* fashion.
*
* @param aRoot
--- a/toolkit/components/microformats/test/static/javascript/chai.js
+++ b/toolkit/components/microformats/test/static/javascript/chai.js
@@ -1588,22 +1588,23 @@ module.exports = function (chai, _) {
flag(this, 'object', err);
return this;
} else {
thrown = true;
thrownError = err;
}
}
- var actuallyGot = ''
- , expectedThrown = name !== null
- ? name
- : desiredError
- ? '#{exp}' //_.inspect(desiredError)
- : 'an error';
+ var actuallyGot = '';
+ var expectedThrown = 'an error';
+ if (name !== null) {
+ expectedThrown = name;
+ } else if (desiredError) {
+ expectedThrown = '#{exp}'; //_.inspect(desiredError)
+ }
if (thrown) {
actuallyGot = ' but #{act} was thrown'
}
this.assert(
thrown === true
, 'expected #{this} to throw ' + expectedThrown + actuallyGot
--- a/toolkit/components/microformats/test/static/javascript/mocha.js
+++ b/toolkit/components/microformats/test/static/javascript/mocha.js
@@ -410,17 +410,23 @@ var JsDiff = (function() {
return ret.join('');
},
// See: http://code.google.com/p/google-diff-match-patch/wiki/API
convertChangesToDMP: function(changes){
var ret = [], change;
for ( var i = 0; i < changes.length; i++) {
change = changes[i];
- ret.push([(change.added ? 1 : change.removed ? -1 : 0), change.value]);
+ var order = 0;
+ if (change.added) {
+ order = 1;
+ } else if (change.removed) {
+ order = -1;
+ }
+ ret.push([order, change.value]);
}
return ret;
}
};
})();
if (typeof module !== 'undefined') {
module.exports = JsDiff;
@@ -2092,22 +2098,23 @@ var color = exports.color = function(typ
};
/**
* Expose term window size, with some
* defaults for when stderr is not a tty.
*/
exports.window = {
- width: isatty
- ? process.stdout.getWindowSize
- ? process.stdout.getWindowSize(1)[0]
- : tty.getWindowSize()[1]
- : 75
+ width: 75
};
+if (isatty) {
+ exports.window.width = process.stdout.getWindowSize
+ ? process.stdout.getWindowSize(1)[0]
+ : tty.getWindowSize()[1];
+}
/**
* Expose some basic cursor interactions
* that are common among reporters.
*/
exports.cursor = {
hide: function(){
@@ -2235,21 +2242,23 @@ function Base(runner) {
stats.tests = stats.tests || 0;
stats.tests++;
});
runner.on('pass', function(test){
stats.passes = stats.passes || 0;
var medium = test.slow() / 2;
- test.speed = test.duration > test.slow()
- ? 'slow'
- : test.duration > medium
- ? 'medium'
- : 'fast';
+ if (test.duration > test.slow()) {
+ test.speed = 'slow';
+ } else if (test.duration > medium) {
+ test.speed = 'medium';
+ } else {
+ test.speed = 'fast';
+ }
stats.passes++;
});
runner.on('fail', function(test, err){
stats.failures = stats.failures || 0;
stats.failures++;
test.err = err;
--- a/toolkit/components/microformats/test/static/javascript/prettify.js
+++ b/toolkit/components/microformats/test/static/javascript/prettify.js
@@ -576,21 +576,21 @@ var REGEXP_PRECEDER_PATTERN = '(?:^^\\.?
* content, but not to return anything where there are multiple child elements
* as in {@code <pre><code>...</code><code>...</code></pre>} or when there
* is textual content.
*/
function childContentWrapper(element) {
var wrapper = undefined;
for (var c = element.firstChild; c; c = c.nextSibling) {
var type = c.nodeType;
- wrapper = (type === 1) // Element Node
- ? (wrapper ? element : c)
- : (type === 3) // Text Node
- ? (notWs.test(c.nodeValue) ? element : wrapper)
- : wrapper;
+ if (type === 1) {
+ wrapper = wrapper ? element : c;
+ } else if (type === 3) {
+ wrapper = notWs.test(c.nodeValue) ? element : wrapper;
+ }
}
return wrapper === element ? undefined : wrapper;
}
/** Given triples of [style, pattern, context] returns a lexing function,
* The lexing function interprets the patterns to find token boundaries and
* returns a decoration list of the form
* [index_0, style_0, index_1, style_1, ..., index_n, style_n]
@@ -1406,19 +1406,21 @@ var REGEXP_PRECEDER_PATTERN = '(?:^^\\.?
nested = true;
break;
}
}
if (!nested) {
// Look for a class like linenums or linenums:<n> where <n> is the
// 1-indexed number of the first line.
var lineNums = cs.className.match(/\blinenums\b(?::(\d+))?/);
- lineNums = lineNums
- ? lineNums[1] && lineNums[1].length ? +lineNums[1] : true
- : false;
+ if (lineNums) {
+ lineNums = lineNums[1] && lineNums[1].length ? +lineNums[1] : true;
+ } else {
+ lineNums = false;
+ }
if (lineNums) { numberLines(cs, lineNums); }
// do the pretty printing
prettyPrintingJob = {
langExtension: langExtension,
sourceNode: cs,
numberLines: lineNums
};
--- a/toolkit/components/places/BookmarkJSONUtils.jsm
+++ b/toolkit/components/places/BookmarkJSONUtils.jsm
@@ -251,18 +251,21 @@ BookmarkImporter.prototype = {
PlacesUtils.unwrapNodes(aString, PlacesUtils.TYPE_X_MOZ_PLACE_CONTAINER);
if (nodes.length == 0 || !nodes[0].children ||
nodes[0].children.length == 0) {
deferred.resolve(); // Nothing to restore
} else {
// Ensure tag folder gets processed last
nodes[0].children.sort(function sortRoots(aNode, bNode) {
- return (aNode.root && aNode.root == "tagsFolder") ? 1 :
- (bNode.root && bNode.root == "tagsFolder") ? -1 : 0;
+ if (aNode.root && aNode.root == "tagsFolder")
+ return 1;
+ if (bNode.root && bNode.root == "tagsFolder")
+ return -1;
+ return 0;
});
let batch = {
nodes: nodes[0].children,
runBatched: function runBatched() {
if (this._replace) {
// Get roots excluded from the backup, we will not remove them
// before restoring.
--- a/toolkit/components/places/Bookmarks.jsm
+++ b/toolkit/components/places/Bookmarks.jsm
@@ -972,18 +972,19 @@ function reorderChildren(parent, ordered
return undefined;
// Reorder the children array according to the specified order, provided
// GUIDs come first, others are appended in somehow random order.
children.sort((a, b) => {
let i = orderedChildrenGuids.indexOf(a.guid);
let j = orderedChildrenGuids.indexOf(b.guid);
// This works provided fetchBookmarksByParent returns sorted children.
- return (i == -1 && j == -1) ? 0 :
- (i != -1 && j != -1 && i < j) || (i != -1 && j == -1) ? -1 : 1;
+ if (i == -1 && j == -1)
+ return 0;
+ return (i != -1 && j != -1 && i < j) || (i != -1 && j == -1) ? -1 : 1;
});
// Update the bookmarks position now. If any unknown guid have been
// inserted meanwhile, its position will be set to -position, and we'll
// handle it later.
// To do the update in a single step, we build a VALUES (guid, position)
// table. We then use count() in the sorting table to avoid skipping values
// when no more existing GUIDs have been provided.
--- a/toolkit/components/places/PlacesBackups.jsm
+++ b/toolkit/components/places/PlacesBackups.jsm
@@ -168,17 +168,17 @@ this.PlacesBackups = {
continue;
}
this._entries.push(entry);
}
}
this._entries.sort((a, b) => {
let aDate = this.getDateForFile(a);
let bDate = this.getDateForFile(b);
- return aDate < bDate ? 1 : aDate > bDate ? -1 : 0;
+ return bDate.getTime() - aDate.getTime();
});
return this._entries;
},
/**
* Cache current backups in a sorted (by date DESC) array.
* @return {Promise}
* @resolve a sorted array of string paths.
@@ -210,17 +210,17 @@ this.PlacesBackups = {
}
}
}.bind(this));
iterator.close();
this._backupFiles.sort((a, b) => {
let aDate = this.getDateForFile(a);
let bDate = this.getDateForFile(b);
- return aDate < bDate ? 1 : aDate > bDate ? -1 : 0;
+ return bDate.getTime() - aDate.getTime();
});
return this._backupFiles;
}.bind(this));
},
/**
* Generates a ISO date string (YYYY-MM-DD) from a Date object.
--- a/toolkit/components/places/UnifiedComplete.js
+++ b/toolkit/components/places/UnifiedComplete.js
@@ -1746,26 +1746,31 @@ Search.prototype = {
*
* @return an array consisting of the correctly optimized query to search the
* database with and an object containing the params to bound.
*/
get _hostQuery() {
let typed = Prefs.autofillTyped || this.hasBehavior("typed");
let bookmarked = this.hasBehavior("bookmark") && !this.hasBehavior("history");
- return [
- bookmarked ? typed ? SQL_BOOKMARKED_TYPED_HOST_QUERY
- : SQL_BOOKMARKED_HOST_QUERY
- : typed ? SQL_TYPED_HOST_QUERY
- : SQL_HOST_QUERY,
- {
- query_type: QUERYTYPE_AUTOFILL_HOST,
- searchString: this._searchString.toLowerCase()
- }
- ];
+ let query = [];
+ if (bookmarked) {
+ query.push(typed ? SQL_BOOKMARKED_TYPED_HOST_QUERY
+ : SQL_BOOKMARKED_HOST_QUERY);
+ } else {
+ query.push(typed ? SQL_TYPED_HOST_QUERY
+ : SQL_HOST_QUERY);
+ }
+
+ query.push({
+ query_type: QUERYTYPE_AUTOFILL_HOST,
+ searchString: this._searchString.toLowerCase()
+ });
+
+ return query;
},
/**
* Obtains the query to search for autoFill url results.
*
* @return an array consisting of the correctly optimized query to search the
* database with and an object containing the params to bound.
*/
@@ -1775,27 +1780,32 @@ Search.prototype = {
// query.
let slashIndex = this._autofillUrlSearchString.indexOf("/");
let revHost = this._autofillUrlSearchString.substring(0, slashIndex).toLowerCase()
.split("").reverse().join("") + ".";
let typed = Prefs.autofillTyped || this.hasBehavior("typed");
let bookmarked = this.hasBehavior("bookmark") && !this.hasBehavior("history");
- return [
- bookmarked ? typed ? SQL_BOOKMARKED_TYPED_URL_QUERY
- : SQL_BOOKMARKED_URL_QUERY
- : typed ? SQL_TYPED_URL_QUERY
- : SQL_URL_QUERY,
- {
- query_type: QUERYTYPE_AUTOFILL_URL,
- searchString: this._autofillUrlSearchString,
- revHost
- }
- ];
+ let query = [];
+ if (bookmarked) {
+ query.push(typed ? SQL_BOOKMARKED_TYPED_URL_QUERY
+ : SQL_BOOKMARKED_URL_QUERY);
+ } else {
+ query.push(typed ? SQL_TYPED_URL_QUERY
+ : SQL_URL_QUERY);
+ }
+
+ query.push({
+ query_type: QUERYTYPE_AUTOFILL_URL,
+ searchString: this._autofillUrlSearchString,
+ revHost
+ });
+
+ return query;
},
/**
* Notifies the listener about results.
*
* @param searchOngoing
* Indicates whether the search is ongoing.
*/
--- a/toolkit/components/places/tests/head_common.js
+++ b/toolkit/components/places/tests/head_common.js
@@ -529,19 +529,22 @@ function check_JSON_backup(aIsAutomaticB
* Returns the frecency of a url.
*
* @param aURI
* The URI or spec to get frecency for.
* @return the frecency value.
*/
function frecencyForUrl(aURI)
{
- let url = aURI instanceof Ci.nsIURI ? aURI.spec
- : aURI instanceof URL ? aURI.href
- : aURI;
+ let url = aURI;
+ if (aURI instanceof Ci.nsIURI) {
+ url = aURI.spec;
+ } else if (aURI instanceof URL) {
+ url = aURI.href;
+ }
let stmt = DBConn().createStatement(
"SELECT frecency FROM moz_places WHERE url = ?1"
);
stmt.bindByIndex(0, url);
try {
if (!stmt.executeStep()) {
throw new Error("No result for frecency.");
}
--- a/toolkit/components/reader/Readability.js
+++ b/toolkit/components/reader/Readability.js
@@ -67,18 +67,22 @@ var Readability = function(uri, doc, opt
// Control whether log messages are sent to the console
if (this._debug) {
function logEl(e) {
var rv = e.nodeName + " ";
if (e.nodeType == e.TEXT_NODE) {
return rv + '("' + e.textContent + '")';
}
var classDesc = e.className && ("." + e.className.replace(/ /g, "."));
- var elDesc = e.id ? "(#" + e.id + classDesc + ")" :
- (classDesc ? "(" + classDesc + ")" : "");
+ var elDesc = "";
+ if (e.id) {
+ elDesc = "(#" + e.id + classDesc + ")";
+ } else if (classDesc) {
+ elDesc = "(" + classDesc + ")";
+ }
return rv + elDesc;
}
this.log = function () {
if ("dump" in root) {
var msg = Array.prototype.map.call(arguments, function(x) {
return (x && x.nodeName) ? logEl(x) : x;
}).join(" ");
dump("Reader: (Readability) " + msg + "\n");
@@ -738,17 +742,17 @@ Readability.prototype = {
this._initializeNode(ancestor);
candidates.push(ancestor);
}
// Node score divider:
// - parent: 1 (no division)
// - grandparent: 2
// - great grandparent+: ancestor level * 3
- var scoreDivider = level === 0 ? 1 : level === 1 ? 2 : level * 3;
+ var scoreDivider = level < 2 ? level + 1 : level * 3;
ancestor.readability.contentScore += contentScore / scoreDivider;
});
});
// After we've calculated scores, loop through all of the possible
// candidate nodes we found and find the one with the highest score.
var topCandidates = [];
for (var c = 0, cl = candidates.length; c < cl; c += 1) {
--- a/toolkit/components/timermanager/tests/unit/consumerNotifications.js
+++ b/toolkit/components/timermanager/tests/unit/consumerNotifications.js
@@ -476,18 +476,24 @@ function logTestInfo(aText, aCaller) {
let caller = aCaller ? aCaller : Components.stack.caller;
let now = new Date;
let hh = now.getHours();
let mm = now.getMinutes();
let ss = now.getSeconds();
let ms = now.getMilliseconds();
let time = (hh < 10 ? "0" + hh : hh) + ":" +
(mm < 10 ? "0" + mm : mm) + ":" +
- (ss < 10 ? "0" + ss : ss) + ":" +
- (ms < 10 ? "00" + ms : ms < 100 ? "0" + ms : ms);
+ (ss < 10 ? "0" + ss : ss) + ":";
+ if (ms < 10) {
+ time += "00";
+ }
+ else if (ms < 100) {
+ time += "0";
+ }
+ time += ms;
let msg = time + " | TEST-INFO | " + caller.filename + " | [" + caller.name +
" : " + caller.lineNumber + "] " + aText;
do_print(msg);
}
/**
* Logs TEST-INFO messages when DEBUG_TEST evaluates to true.
*
--- a/toolkit/content/aboutTelemetry.js
+++ b/toolkit/content/aboutTelemetry.js
@@ -1236,17 +1236,20 @@ var Histogram = {
// - see toolkit/components/telemetry/Telemetry.cpp
// (CreateJSTimeHistogram, CreateJSThreadHangStats, CreateJSHangHistogram)
// - see toolkit/components/telemetry/ThreadHangStats.h
// Fix BHR labels to the "standard" format for about:telemetry as follows:
// - The dummy 0 label+bucket will be filtered before arriving here
// - If it's 1 -> manually correct it to 0 (the 0..1 anomaly)
// - For the rest, set the label as the bottom value instead of the upper.
// --> so we'll end with the following (non dummy) labels: 0, 2, 4, 8, 16, ...
- return !aIsBHR ? k : k == 1 ? 0 : (k + 1) / 2;
+ if (!aIsBHR) {
+ return k;
+ }
+ return k == 1 ? 0 : (k + 1) / 2;
}
const labelledValues = Object.keys(aHgram.values)
.filter(label => !aIsBHR || Number(label) != 0) // remove dummy 0 label for BHR
.map(k => [labelFunc(Number(k)), aHgram.values[k]]);
let result = {
values: labelledValues,
--- a/toolkit/content/tests/widgets/tree_shared.js
+++ b/toolkit/content/tests/widgets/tree_shared.js
@@ -388,17 +388,21 @@ function testtag_tree_TreeSelection_UI(t
synthesizeKeyExpectEvent("VK_UP", { accelKey: true }, tree, "!select", "key up with accel");
testtag_tree_TreeSelection_State(tree, testid + "key up with accel", multiple ? 3 : 4, [4]);
if (!multiple)
is(tree.treeBoxObject.getFirstVisibleRow(), 3, testid + "key up with accel and scroll");
// do this three times, one for each state of pageUpOrDownMovesSelection,
// and then once with the accel key pressed
for (let t = 0; t < 3; t++) {
- let testidmod = (t == 2) ? " with accel" : (t == 1) ? " rev" : "";
+ let testidmod = "";
+ if (t == 2)
+ testidmod = " with accel"
+ else if (t == 1)
+ testidmod = " rev";
var keymod = (t == 2) ? { accelKey: true } : { };
var moveselection = tree.pageUpOrDownMovesSelection;
if (t == 2)
moveselection = !moveselection;
tree.treeBoxObject.scrollToRow(4);
selection.currentIndex = 6;
@@ -1159,20 +1163,30 @@ function testtag_tree_wheel(aTree)
const deltaModes = [
WheelEvent.DOM_DELTA_PIXEL, // 0
WheelEvent.DOM_DELTA_LINE, // 1
WheelEvent.DOM_DELTA_PAGE // 2
];
function helper(aStart, aDelta, aIntDelta, aDeltaMode)
{
aTree.treeBoxObject.scrollToRow(aStart);
- var expected = !aIntDelta ? aStart :
- aDeltaMode != WheelEvent.DOM_DELTA_PAGE ? aStart + aIntDelta :
- aIntDelta > 0 ? aStart + aTree.treeBoxObject.getPageLength() :
- aStart - aTree.treeBoxObject.getPageLength();
+ var expected;
+ if (!aIntDelta) {
+ expected = aStart;
+ }
+ else if (aDeltaMode != WheelEvent.DOM_DELTA_PAGE) {
+ expected = aStart + aIntDelta;
+ }
+ else if (aIntDelta > 0) {
+ expected = aStart + aTree.treeBoxObject.getPageLength();
+ }
+ else {
+ expected = aStart - aTree.treeBoxObject.getPageLength();
+ }
+
if (expected < 0) {
expected = 0;
}
if (expected > aTree.view.rowCount - aTree.treeBoxObject.getPageLength()) {
expected = aTree.view.rowCount - aTree.treeBoxObject.getPageLength();
}
synthesizeWheel(aTree.body, 1, 1,
{ deltaMode: aDeltaMode, deltaY: aDelta,
--- a/toolkit/content/widgets/button.xml
+++ b/toolkit/content/widgets/button.xml
@@ -58,18 +58,21 @@
]]></setter>
</property>
<property name="checkState">
<getter><![CDATA[
var state = this.getAttribute("checkState");
if (state == "")
return this.checked ? 1 : 0;
- else
- return state == "0" ? 0 : (state == "2" ? 2 : 1);
+ if (state == "0")
+ return 0;
+ if (state == "2")
+ return 2;
+ return 1;
]]></getter>
<setter><![CDATA[
this.setAttribute("checkState", val);
return val;
]]></setter>
</property>
<property name="autoCheck"
--- a/toolkit/content/widgets/datetimepicker.xml
+++ b/toolkit/content/widgets/datetimepicker.xml
@@ -773,34 +773,39 @@
var dt = new Date(2002,9,4).toLocaleFormat("%x");
var numberFields = dt.match(numberOrder);
if (numberFields) {
this._separatorFirst.value = numberFields[3];
this._separatorSecond.value = numberFields[5];
var yi = 2, mi = 4, di = 6;
+ function fieldForNumber(i) {
+ if (i == 2)
+ return "input-one";
+ if (i == 4)
+ return "input-two";
+ return "input-three";
+ }
+
for (var i = 1; i < numberFields.length; i++) {
switch (Number(numberFields[i])) {
case 2:
twoDigitYear = true; // fall through
case 2002:
yi = i;
- yfield = (i == 2 ? "input-one" :
- (i == 4 ? "input-two" : "input-three"));
+ yfield = fieldForNumber(i);
break;
case 9, 10:
mi = i;
- mfield = (i == 2 ? "input-one" :
- (i == 4 ? "input-two" : "input-three"));
+ mfield = fieldForNumber(i);
break;
case 4:
di = i;
- dfield = (i == 2 ? "input-one" :
- (i == 4 ? "input-two" : "input-three"));
+ dfield = fieldForNumber(i);
break;
}
}
this.yearLeadingZero = (numberFields[yi].length > 1);
this.monthLeadingZero = (numberFields[mi].length > 1);
this.dateLeadingZero = (numberFields[di].length > 1);
}
--- a/toolkit/content/widgets/popup.xml
+++ b/toolkit/content/widgets/popup.xml
@@ -460,20 +460,28 @@
<![CDATA[
this.adjustArrowPosition();
if (this.getAttribute("animate") != "false") {
this.setAttribute("animate", "open");
}
// set fading
var fade = this.getAttribute("fade");
- var fadeDelay = (fade == "fast") ? 1 : fade == "slow" ? 4000 : 0;
- if (fadeDelay) {
- this._fadeTimer = setTimeout(() => this.hidePopup(true), fadeDelay, this);
+ var fadeDelay = 0;
+ if (fade == "fast") {
+ fadeDelay = 1;
}
+ else if (fade == "slow") {
+ fadeDelay = 4000;
+ }
+ else {
+ return;
+ }
+
+ this._fadeTimer = setTimeout(() => this.hidePopup(true), fadeDelay, this);
]]>
</handler>
<handler event="popuphiding" phase="target">
let animate = (this.getAttribute("animate") != "false");
if (this._fadeTimer) {
clearTimeout(this._fadeTimer);
if (animate) {
--- a/toolkit/content/widgets/preferences.xml
+++ b/toolkit/content/widgets/preferences.xml
@@ -438,17 +438,19 @@
var f = new Function ("event",
aElement.getAttribute("onsyncfrompreference"));
rv = f.call(aElement, event);
}
catch (e) {
Components.utils.reportError(e);
}
}
- var val = rv !== undefined ? rv : (this.instantApply ? this.valueFromPreferences : this.value);
+ var val = rv;
+ if (val === undefined)
+ val = this.instantApply ? this.valueFromPreferences : this.value;
// if the preference is marked for reset, show default value in UI
if (val === undefined)
val = this.defaultValue;
/**
* Initialize a UI element property with a value. Handles the case
* where an element has not yet had a XBL binding attached for it and
* the property setter does not yet exist by setting the same attribute
--- a/toolkit/content/widgets/tree.xml
+++ b/toolkit/content/widgets/tree.xml
@@ -1232,17 +1232,20 @@
<implementation>
<constructor>
this.parentNode.parentNode._columnsDirty = true;
</constructor>
<property name="ordinal">
<getter><![CDATA[
var val = this.getAttribute("ordinal");
- return "" + (val == "" ? 1 : (val == "0" ? 0 : parseInt(val)));
+ if (val == "")
+ return "1";
+
+ return "" + (val == "0" ? 0 : parseInt(val));
]]></getter>
<setter><![CDATA[
this.setAttribute("ordinal", val);
return val;
]]></setter>
</property>
<property name="_previousVisibleColumn">
--- a/toolkit/modules/Geometry.jsm
+++ b/toolkit/modules/Geometry.jsm
@@ -257,20 +257,26 @@ Rect.prototype = {
this.top = f.call(this, this.top);
this.right = f.call(this, this.right);
this.bottom = f.call(this, this.bottom);
return this;
},
/** Ensure this rectangle is inside the other, if possible. Preserves w, h. */
translateInside: function translateInside(other) {
- let offsetX = (this.left <= other.left ? other.left - this.left :
- (this.right > other.right ? other.right - this.right : 0));
- let offsetY = (this.top <= other.top ? other.top - this.top :
- (this.bottom > other.bottom ? other.bottom - this.bottom : 0));
+ let offsetX = 0;
+ if (this.left <= other.left)
+ offsetX = other.left - this.left;
+ else if (this.right > other.right)
+ offsetX = other.right - this.right;
+ let offsetY = 0;
+ if (this.top <= other.top)
+ offsetY = other.top - this.top;
+ else if (this.bottom > other.bottom)
+ offsetY = other.bottom - this.bottom;
return this.translate(offsetX, offsetY);
},
/** Subtract other area from this. Returns array of rects whose union is this-other. */
subtract: function subtract(other) {
let r = new Rect(0, 0, 0, 0);
let result = [];
other = other.intersect(this);
--- a/toolkit/modules/sessionstore/XPathGenerator.jsm
+++ b/toolkit/modules/sessionstore/XPathGenerator.jsm
@@ -75,19 +75,21 @@ this.XPathGenerator = {
return /^\w+$/.test(aName) ? aName :
"*[local-name()=" + this.quoteArgument(aName) + "]";
},
/**
* @returns a properly quoted string to insert into an XPath query
*/
quoteArgument: function sss_xph_quoteArgument(aArg) {
- return !/'/.test(aArg) ? "'" + aArg + "'" :
- !/"/.test(aArg) ? '"' + aArg + '"' :
- "concat('" + aArg.replace(/'+/g, "',\"$&\",'") + "')";
+ if (!/'/.test(aArg))
+ return "'" + aArg + "'";
+ if (!/"/.test(aArg))
+ return '"' + aArg + '"';
+ return "concat('" + aArg.replace(/'+/g, "',\"$&\",'") + "')";
},
/**
* @returns an XPath query to all savable form field nodes
*/
get restorableFormNodes() {
// for a comprehensive list of all available <INPUT> types see
// http://mxr.mozilla.org/mozilla-central/search?string=kInputTypeTable
--- a/toolkit/mozapps/extensions/internal/AddonUpdateChecker.jsm
+++ b/toolkit/mozapps/extensions/internal/AddonUpdateChecker.jsm
@@ -315,19 +315,23 @@ function parseRDFManifest(aId, aUpdateKe
let ds = Cc["@mozilla.org/rdf/datasource;1?name=in-memory-datasource"].
createInstance(Ci.nsIRDFDataSource);
rdfParser.parseString(ds, aRequest.channel.URI, aRequest.responseText);
// Differentiating between add-on types is deprecated
let extensionRes = gRDF.GetResource(PREFIX_EXTENSION + aId);
let themeRes = gRDF.GetResource(PREFIX_THEME + aId);
let itemRes = gRDF.GetResource(PREFIX_ITEM + aId);
- let addonRes = ds.ArcLabelsOut(extensionRes).hasMoreElements() ? extensionRes
- : ds.ArcLabelsOut(themeRes).hasMoreElements() ? themeRes
- : itemRes;
+ let addonRes;
+ if (ds.ArcLabelsOut(extensionRes).hasMoreElements())
+ addonRes = extensionRes;
+ else if (ds.ArcLabelsOut(themeRes).hasMoreElements())
+ addonRes = themeRes;
+ else
+ addonRes = itemRes;
// If we have an update key then the update manifest must be signed
if (aUpdateKey) {
let signature = getProperty(ds, addonRes, "signature");
if (!signature)
throw Components.Exception("Update manifest for " + aId + " does not contain a required signature");
let serializer = new RDFSerializer();
let updateString = null;
--- a/toolkit/mozapps/update/tests/data/shared.js
+++ b/toolkit/mozapps/update/tests/data/shared.js
@@ -604,18 +604,23 @@ function logTestInfo(aText, aCaller) {
let caller = aCaller ? aCaller : Components.stack.caller;
let now = new Date;
let hh = now.getHours();
let mm = now.getMinutes();
let ss = now.getSeconds();
let ms = now.getMilliseconds();
let time = (hh < 10 ? "0" + hh : hh) + ":" +
(mm < 10 ? "0" + mm : mm) + ":" +
- (ss < 10 ? "0" + ss : ss) + ":" +
- (ms < 10 ? "00" + ms : ms < 100 ? "0" + ms : ms);
+ (ss < 10 ? "0" + ss : ss) + ":";
+ if (ms < 10) {
+ time += "00";
+ } else if (ms < 100) {
+ time += "0";
+ }
+ time += ms;
let msg = time + " | TEST-INFO | " + caller.filename + " | [" + caller.name +
" : " + caller.lineNumber + "] " + aText;
LOG_FUNCTION(msg);
}
/**
* Logs TEST-INFO messages when DEBUG_AUS_TEST evaluates to true.
*