--- a/browser/base/content/aboutTabCrashed.js
+++ b/browser/base/content/aboutTabCrashed.js
@@ -55,17 +55,17 @@ var AboutTabCrashed = {
init() {
this.MESSAGES.forEach((msg) => addMessageListener(msg, this.receiveMessage.bind(this)));
addEventListener("DOMContentLoaded", this);
document.title = this.pageData.title;
},
receiveMessage(message) {
- switch(message.name) {
+ switch (message.name) {
case "UpdateCount": {
this.showRestoreAll(message.data.count > 1);
break;
}
case "SetCrashReportAvailable": {
this.onSetCrashReportAvailable(message);
break;
}
@@ -105,17 +105,17 @@ var AboutTabCrashed = {
// Error pages are loaded as LOAD_BACKGROUND, so they don't get load events.
let event = new CustomEvent("AboutTabCrashedLoad", {bubbles:true});
document.dispatchEvent(event);
sendAsyncMessage("Load");
},
onClick(event) {
- switch(event.target.id) {
+ switch (event.target.id) {
case "closeTab": {
this.sendMessage("closeTab");
break;
}
case "restoreTab": {
this.sendMessage("restoreTab");
break;
@@ -129,17 +129,17 @@ var AboutTabCrashed = {
case "sendReport": {
this.showCrashReportUI(event.target.checked);
break;
}
}
},
onInput(event) {
- switch(event.target.id) {
+ switch (event.target.id) {
case "email": {
document.getElementById("emailMe").checked = !!event.target.value;
break;
}
}
},
/**
* After this page tells the parent that it has loaded, the parent
--- a/browser/base/content/abouthome/aboutHome.js
+++ b/browser/base/content/abouthome/aboutHome.js
@@ -156,17 +156,17 @@ function ensureSnippetsMapThen(aCallback
invokeCallbacks();
}
let cache = new Map();
let cursorRequest;
try {
cursorRequest = db.transaction(SNIPPETS_OBJECTSTORE_NAME)
.objectStore(SNIPPETS_OBJECTSTORE_NAME).openCursor();
- } catch(ex) {
+ } catch (ex) {
console.error(ex);
invokeCallbacks();
return;
}
cursorRequest.onerror = function (event) {
invokeCallbacks();
}
--- a/browser/base/content/browser-addons.js
+++ b/browser/base/content/browser-addons.js
@@ -628,17 +628,17 @@ var LightWeightThemeWebInstaller = {
this._manager.resetPreview();
},
_isAllowed: function (srcURIString) {
let uri;
try {
uri = makeURI(srcURIString);
}
- catch(e) {
+ catch (e) {
//makeURI fails if srcURIString is a nonsense URI
return false;
}
if (!uri.schemeIs("https")) {
return false;
}
--- a/browser/base/content/browser-customization.js
+++ b/browser/base/content/browser-customization.js
@@ -5,17 +5,17 @@
/**
* Customization handler prepares this browser window for entering and exiting
* customization mode by handling customizationstarting and customizationending
* events.
*/
var CustomizationHandler = {
handleEvent: function(aEvent) {
- switch(aEvent.type) {
+ switch (aEvent.type) {
case "customizationstarting":
this._customizationStarting();
break;
case "customizationchange":
this._customizationChange();
break;
case "customizationending":
this._customizationEnding(aEvent.detail);
--- a/browser/base/content/browser-feeds.js
+++ b/browser/base/content/browser-feeds.js
@@ -263,17 +263,17 @@ var FeedHandler = {
}
// Retrieving the shell service might fail on some systems, most
// notably systems where GNOME is not installed.
try {
let ss = Cc["@mozilla.org/browser/shell-service;1"]
.getService(Ci.nsIShellService);
ss.openApplicationWithURI(clientApp, aSpec);
- } catch(e) {
+ } catch (e) {
// If we couldn't use the shell service, fallback to using a
// nsIProcess instance
let p = Cc["@mozilla.org/process/util;1"]
.createInstance(Ci.nsIProcess);
p.init(clientApp);
p.run(false, [aSpec], 1);
}
},
@@ -306,17 +306,17 @@ var FeedHandler = {
}
let defaultClientApp = null;
try {
// This can sometimes not exist
defaultClientApp = Cc["@mozilla.org/browser/shell-service;1"]
.getService(Ci.nsIShellService)
.defaultFeedReader;
- } catch(ex) {
+ } catch (ex) {
// Just do nothing, then we don't bother populating
}
if (selectedClientApp && selectedClientApp.exists()) {
if (defaultClientApp && selectedClientApp.path != defaultClientApp.path) {
// Only set the default menu item if it differs from the selected one
msg.target.messageManager
.sendAsyncMessage("FeedWriter:SetApplicationLauncherMenuItem",
--- a/browser/base/content/browser-gestureSupport.js
+++ b/browser/base/content/browser-gestureSupport.js
@@ -848,17 +848,17 @@ var gHistorySwipeAnimation = {
* @param aIndex
* The index to check for availability for in the history.
* @return true if the index exists in the browser history, false otherwise.
*/
_doesIndexExistInHistory: function HSA__doesIndexExistInHistory(aIndex) {
try {
return SessionStore.getSessionHistory(gBrowser.selectedTab).entries[aIndex] != null;
}
- catch(ex) {
+ catch (ex) {
return false;
}
return true;
},
/**
* Navigates to the index in history that is currently being tracked by
* |this|.
--- a/browser/base/content/browser-places.js
+++ b/browser/base/content/browser-places.js
@@ -1621,17 +1621,17 @@ var BookmarkingUI = {
this._updateStar();
// Start observing bookmarks if needed.
if (!this._hasBookmarksObserver) {
try {
PlacesUtils.addLazyBookmarkObserver(this);
this._hasBookmarksObserver = true;
- } catch(ex) {
+ } catch (ex) {
Components.utils.reportError("BookmarkingUI failed adding a bookmarks observer: " + ex);
}
}
delete this._pendingStmt;
});
},
--- a/browser/base/content/browser.js
+++ b/browser/base/content/browser.js
@@ -1137,17 +1137,17 @@ var gBrowserInit = {
gBrowser.updateBrowserRemoteness(gBrowser.selectedBrowser, true);
} else if (gBrowser.selectedBrowser.isRemoteBrowser) {
// If the browser is remote, then it's implied that
// gMultiProcessBrowser is true. We need to flip the remoteness
// of this tab to false in order for the tab drag to work.
gBrowser.updateBrowserRemoteness(gBrowser.selectedBrowser, false);
}
gBrowser.swapBrowsersAndCloseOther(gBrowser.selectedTab, tabToOpen);
- } catch(e) {
+ } catch (e) {
Cu.reportError(e);
}
}
// window.arguments[2]: referrer (nsIURI | string)
// [3]: postData (nsIInputStream)
// [4]: allowThirdPartyFixup (bool)
// [5]: referrerPolicy (int)
// [6]: userContextId (int)
@@ -1714,17 +1714,17 @@ function gotoHistoryIndex(aEvent) {
let where = whereToOpenLink(aEvent);
if (where == "current") {
// Normal click. Go there in the current tab and update session history.
try {
gBrowser.gotoIndex(index);
}
- catch(ex) {
+ catch (ex) {
return false;
}
return true;
}
// Modified click. Go there in a new tab/window.
let historyindex = aEvent.target.getAttribute("historyindex");
duplicateTabIn(gBrowser.selectedTab, where, Number(historyindex));
@@ -1733,32 +1733,32 @@ function gotoHistoryIndex(aEvent) {
function BrowserForward(aEvent) {
let where = whereToOpenLink(aEvent, false, true);
if (where == "current") {
try {
gBrowser.goForward();
}
- catch(ex) {
+ catch (ex) {
}
}
else {
duplicateTabIn(gBrowser.selectedTab, where, 1);
}
}
function BrowserBack(aEvent) {
let where = whereToOpenLink(aEvent, false, true);
if (where == "current") {
try {
gBrowser.goBack();
}
- catch(ex) {
+ catch (ex) {
}
}
else {
duplicateTabIn(gBrowser.selectedTab, where, -1);
}
}
function BrowserHandleBackspace()
@@ -1955,25 +1955,25 @@ var gLastOpenDirectory = {
get path() {
if (!this._lastDir || !this._lastDir.exists()) {
try {
this._lastDir = gPrefService.getComplexValue("browser.open.lastDir",
Ci.nsILocalFile);
if (!this._lastDir.exists())
this._lastDir = null;
}
- catch(e) {}
+ catch (e) {}
}
return this._lastDir;
},
set path(val) {
try {
if (!val || !val.isDirectory())
return;
- } catch(e) {
+ } catch (e) {
return;
}
this._lastDir = val.clone();
// Don't save the last open directory pref inside the Private Browsing mode
if (!PrivateBrowsingUtils.isWindowPrivate(window))
gPrefService.setComplexValue("browser.open.lastDir", Ci.nsILocalFile,
this._lastDir);
@@ -3105,17 +3105,17 @@ function getDefaultHomePage() {
var prefs = Services.prefs.getDefaultBranch(null);
var url = BROWSER_NEW_TAB_URL;
try {
url = prefs.getComplexValue("browser.startup.homepage",
Ci.nsIPrefLocalizedString).data;
// If url is a pipe-delimited set of pages, just take the first one.
if (url.includes("|"))
url = url.split("|")[0];
- } catch(e) {
+ } catch (e) {
Components.utils.reportError("Couldn't get homepage pref: " + e);
}
return url;
}
function BrowserFullScreen()
{
window.fullScreen = !window.fullScreen;
@@ -5455,17 +5455,17 @@ function contentAreaClick(event, isPanel
if (linkNode.getAttribute("onclick") ||
href.startsWith("javascript:") ||
href.startsWith("data:"))
return;
try {
urlSecurityCheck(href, linkNode.ownerDocument.nodePrincipal);
}
- catch(ex) {
+ catch (ex) {
// Prevent loading unsecure destinations.
event.preventDefault();
return;
}
loadURI(href, null, null, false);
event.preventDefault();
return;
@@ -6376,17 +6376,17 @@ function convertFromUnicode(charset, str
{
try {
var unicodeConverter = Components
.classes["@mozilla.org/intl/scriptableunicodeconverter"]
.createInstance(Components.interfaces.nsIScriptableUnicodeConverter);
unicodeConverter.charset = charset;
str = unicodeConverter.ConvertFromUnicode(str);
return str + unicodeConverter.Finish();
- } catch(ex) {
+ } catch (ex) {
return null;
}
}
/**
* Re-open a closed tab.
* @param aIndex
* The index of the tab (via SessionStore.getClosedTabData)
--- a/browser/base/content/content.js
+++ b/browser/base/content/content.js
@@ -177,22 +177,22 @@ var showContentContextMenu = function (e
try {
let imageCache =
Cc["@mozilla.org/image/tools;1"].getService(Ci.imgITools)
.getImgCacheForDocument(doc);
let props =
imageCache.findEntryProperties(event.target.currentURI, doc);
try {
contentType = props.get("type", Ci.nsISupportsCString).data;
- } catch(e) {}
+ } catch (e) {}
try {
contentDisposition =
props.get("content-disposition", Ci.nsISupportsCString).data;
- } catch(e) {}
- } catch(e) {}
+ } catch (e) {}
+ } catch (e) {}
}
let selectionInfo = BrowserUtils.getSelectionDetails(content);
if (Services.appinfo.processType == Services.appinfo.PROCESS_TYPE_CONTENT) {
let editFlags = SpellCheckHelper.isEditable(event.target, content);
let spellInfo;
if (editFlags &
@@ -688,17 +688,17 @@ addEventListener("pagehide", function(ev
});
var PageMetadataMessenger = {
init() {
addMessageListener("PageMetadata:GetPageData", this);
addMessageListener("PageMetadata:GetMicroformats", this);
},
receiveMessage(message) {
- switch(message.name) {
+ switch (message.name) {
case "PageMetadata:GetPageData": {
let target = message.objects.target;
let result = PageMetadata.getData(content.document, target);
sendAsyncMessage("PageMetadata:PageDataResult", result);
break;
}
case "PageMetadata:GetMicroformats": {
let target = message.objects.target;
@@ -725,17 +725,17 @@ addEventListener("ActivateSocialFeature"
}
let node = aEvent.target;
let ownerDocument = node.ownerDocument;
let data = node.getAttribute("data-service");
if (data) {
try {
data = JSON.parse(data);
- } catch(e) {
+ } catch (e) {
Cu.reportError("Social Service manifest parse error: " + e);
return;
}
} else {
Cu.reportError("Social Service manifest not available");
return;
}
@@ -1456,17 +1456,17 @@ let OfflineApps = {
if (Services.perms.testExactPermission(currentURI, "offline-app") != Services.perms.UNKNOWN_ACTION)
return;
try {
if (Services.prefs.getBoolPref("offline-apps.allow_by_default")) {
// all pages can use offline capabilities, no need to ask the user
return;
}
- } catch(e) {
+ } catch (e) {
// this pref isn't set by default, ignore failures
}
let docId = ++this._docId;
this._docIdMap.set(docId, Cu.getWeakReference(aContentWindow.document));
sendAsyncMessage("OfflineApps:RequestPermission", {
uri: currentURI.spec,
docId,
});
--- a/browser/base/content/pageinfo/pageInfo.js
+++ b/browser/base/content/pageinfo/pageInfo.js
@@ -257,17 +257,17 @@ const nsIPermissionManager = Components.
const nsICertificateDialogs = Components.interfaces.nsICertificateDialogs;
const CERTIFICATEDIALOGS_CONTRACTID = "@mozilla.org/nsCertificateDialogs;1"
// clipboard helper
function getClipboardHelper() {
try {
return Components.classes["@mozilla.org/widget/clipboardhelper;1"].getService(Components.interfaces.nsIClipboardHelper);
- } catch(e) {
+ } catch (e) {
// do nothing, later code will handle the error
return null;
}
}
const gClipboardHelper = getClipboardHelper();
// Interface for image loading content
const nsIImageLoadingContent = Components.interfaces.nsIImageLoadingContent;
@@ -754,17 +754,17 @@ function saveMedia()
var dir = aDirectory.clone();
var item = gImageView.data[v][COL_IMAGE_NODE];
var uriString = gImageView.data[v][COL_IMAGE_ADDRESS];
var uri = makeURI(uriString);
try {
uri.QueryInterface(Components.interfaces.nsIURL);
dir.append(decodeURIComponent(uri.fileName));
- } catch(ex) {
+ } catch (ex) {
// data:/blob: uris
// Supply a dummy filename, otherwise Download Manager
// will try to delete the base directory on failure.
dir.append(gImageView.data[v][COL_IMAGE_TYPE]);
}
if (i == 0) {
saveAnImage(uriString, new AutoChosen(dir, uri), makeURI(item.baseURI));
--- a/browser/base/content/pageinfo/security.js
+++ b/browser/base/content/pageinfo/security.js
@@ -227,17 +227,17 @@ function securityOnLoad(uri, windowInfo)
var noStr = pageInfoBundle.getString("no");
setText("security-privacy-cookies-value",
hostHasCookies(uri) ? yesStr : noStr);
setText("security-privacy-passwords-value",
realmHasPasswords(uri) ? yesStr : noStr);
var visitCount = previousVisitCount(info.hostName);
- if(visitCount > 1) {
+ if (visitCount > 1) {
setText("security-privacy-history-value",
pageInfoBundle.getFormattedString("securityNVisits", [visitCount.toLocaleString()]));
}
else if (visitCount == 1) {
setText("security-privacy-history-value",
pageInfoBundle.getString("securityOneVisit"));
}
else {
--- a/browser/base/content/socialmarks.xml
+++ b/browser/base/content/socialmarks.xml
@@ -309,17 +309,17 @@
]]></body>
</method>
<method name="handleEvent">
<parameter name="aEvent"/>
<body><![CDATA[
if (aEvent.eventPhase != aEvent.BUBBLING_PHASE)
return;
- switch(aEvent.type) {
+ switch (aEvent.type) {
case "DOMLinkAdded": {
// much of this logic is from DOMLinkHandler in browser.js, this sets
// the presence icon for a chat user, we simply use favicon style
// updating
let link = aEvent.originalTarget;
let rel = link.rel && link.rel.toLowerCase();
if (!link || !link.ownerDocument || !rel || !link.href)
return;
--- a/browser/base/content/sync/setup.js
+++ b/browser/base/content/sync/setup.js
@@ -994,17 +994,17 @@ var gSyncSetup = {
},
// shim
_setFeedbackMessage: function (element, success, string) {
let str = "";
if (string) {
try {
str = this._stringBundle.GetStringFromName(string);
- } catch(e) {}
+ } catch (e) {}
if (!str)
str = Weave.Utils.getErrorString(string);
}
this._setFeedback(element, success, str);
},
loadCaptcha: function loadCaptcha() {
--- a/browser/base/content/tab-content.js
+++ b/browser/base/content/tab-content.js
@@ -536,17 +536,17 @@ var PageStyleHandler = {
let URI;
try {
if (!currentStyleSheet.ownerNode ||
// special-case style nodes, which have no href
currentStyleSheet.ownerNode.nodeName.toLowerCase() != "style") {
URI = Services.io.newURI(currentStyleSheet.href, null, null);
}
- } catch(e) {
+ } catch (e) {
if (e.result != Cr.NS_ERROR_MALFORMED_URI) {
throw e;
}
continue;
}
// We won't send data URIs all of the way up to the parent, as these
// can be arbitrarily large.
@@ -647,17 +647,17 @@ var DOMFullscreenHandler = {
return null;
}
return content.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIDOMWindowUtils);
},
receiveMessage: function(aMessage) {
let windowUtils = this._windowUtils;
- switch(aMessage.name) {
+ switch (aMessage.name) {
case "DOMFullscreen:Entered": {
this._lastTransactionId = windowUtils.lastTransactionId;
if (!windowUtils.handleFullscreenRequests() &&
!content.document.fullscreenElement) {
// If we don't actually have any pending fullscreen request
// to handle, neither we have been in fullscreen, tell the
// parent to just exit.
sendAsyncMessage("DOMFullscreen:Exit");
--- a/browser/base/content/tabbrowser.xml
+++ b/browser/base/content/tabbrowser.xml
@@ -1402,31 +1402,31 @@
var browser = this.getBrowserForTab(aTab);
var crop = "end";
var title = browser.contentTitle;
if (!title) {
if (browser.currentURI.spec) {
try {
title = this.mURIFixup.createExposableURI(browser.currentURI).spec;
- } catch(ex) {
+ } catch (ex) {
title = browser.currentURI.spec;
}
}
if (title && !isBlankPageURL(title)) {
// At this point, we now have a URI.
// Let's try to unescape it using a character set
// in case the URI is not ASCII.
try {
var characterSet = browser.characterSet;
const textToSubURI = Components.classes["@mozilla.org/intl/texttosuburi;1"]
.getService(Components.interfaces.nsITextToSubURI);
title = textToSubURI.unEscapeNonAsciiURI(characterSet, title);
- } catch(ex) { /* Do nothing. */ }
+ } catch (ex) { /* Do nothing. */ }
crop = "center";
} else if (aTab.hasAttribute("customizemode")) {
let brandBundle = document.getElementById("bundle_brand");
let brandShortName = brandBundle.getString("brandShortName");
title = gNavigatorBundle.getFormattedString("customizeMode.tabTitle",
[ brandShortName ]);
@@ -4421,17 +4421,17 @@
</method>
<method name="observe">
<parameter name="aSubject"/>
<parameter name="aTopic"/>
<parameter name="aData"/>
<body><![CDATA[
let browser;
- switch(aTopic) {
+ switch (aTopic) {
case "live-resize-start":
browser = this.mCurrentTab.linkedBrowser;
let fl = browser.QueryInterface(Ci.nsIFrameLoaderOwner).frameLoader;
if (fl && fl.tabParent && !this.mActiveResizeDisplayportSuppression) {
fl.tabParent.suppressDisplayport(true);
this.mActiveResizeDisplayportSuppression = browser;
}
break;
@@ -6091,17 +6091,17 @@
// Load in an existing tab.
try {
let webNav = Ci.nsIWebNavigation;
let flags = webNav.LOAD_FLAGS_ALLOW_THIRD_PARTY_FIXUP |
webNav.LOAD_FLAGS_FIXUP_SCHEME_TYPOS;
this.tabbrowser.getBrowserForTab(tab).loadURIWithFlags(url, flags);
if (!bgLoad)
this.selectedItem = tab;
- } catch(ex) {
+ } catch (ex) {
// Just ignore invalid urls
}
}
}
if (draggedTab) {
delete draggedTab._dragData;
}
--- a/browser/base/content/urlbarBindings.xml
+++ b/browser/base/content/urlbarBindings.xml
@@ -588,17 +588,17 @@ file, You can obtain one at http://mozil
case (shift):
suffix = ".net/";
break;
case (accel):
try {
suffix = gPrefService.getCharPref("browser.fixup.alternate.suffix");
if (suffix.charAt(suffix.length - 1) != "/")
suffix += "/";
- } catch(e) {
+ } catch (e) {
suffix = ".com/";
}
break;
}
if (suffix) {
// trim leading/trailing spaces (bug 233205)
url = url.trim();
--- a/browser/base/content/utilityOverlay.js
+++ b/browser/base/content/utilityOverlay.js
@@ -61,17 +61,17 @@ function openTopWin(url) {
openUILinkIn(url, "current");
}
function getBoolPref(prefname, def)
{
try {
return Services.prefs.getBoolPref(prefname);
}
- catch(er) {
+ catch (er) {
return def;
}
}
/* openUILink handles clicks on UI elements that cause URLs to load.
*
* As the third argument, you may pass an object with the same properties as
* accepted by openUILinkIn, plus "ignoreButton" and "ignoreAlt".
--- a/browser/components/contextualidentity/test/browser/browser_blobUrl.js
+++ b/browser/components/contextualidentity/test/browser/browser_blobUrl.js
@@ -59,17 +59,17 @@ add_task(function* test() {
yield ContentTask.spawn(browser3, blobURL, function(url) {
return new Promise(resolve => {
var xhr = new content.window.XMLHttpRequest();
xhr.open("GET", url);
try {
xhr.send();
resolve("SendSucceeded");
- } catch(e) {
+ } catch (e) {
resolve("SendThrew");
}
});
}).then(status => {
is(status, "SendSucceeded", "Using a blob URI within a single user context id should work");
});
yield BrowserTestUtils.removeTab(tab1);
--- a/browser/components/customizableui/CustomizableUI.jsm
+++ b/browser/components/customizableui/CustomizableUI.jsm
@@ -1439,17 +1439,17 @@ var CustomizableUIInternal = {
def = aDef || "";
}
try {
if (Array.isArray(aFormatArgs) && aFormatArgs.length) {
return gWidgetsBundle.formatStringFromName(name, aFormatArgs,
aFormatArgs.length) || def;
}
return gWidgetsBundle.GetStringFromName(name) || def;
- } catch(ex) {
+ } catch (ex) {
// If an empty string was explicitly passed, treat it as an actual
// value rather than a missing property.
if (!def && (name != "" || kReqStringProps.includes(aProp))) {
log.error("Could not localize property '" + name + "'.");
}
}
return def;
},
@@ -1510,17 +1510,17 @@ var CustomizableUIInternal = {
}
},
handleWidgetClick: function(aWidget, aNode, aEvent) {
log.debug("handleWidgetClick");
if (aWidget.onClick) {
try {
aWidget.onClick.call(null, aEvent);
- } catch(e) {
+ } catch (e) {
Cu.reportError(e);
}
} else {
//XXXunf Need to think this through more, and formalize.
Services.obs.notifyObservers(aNode, "customizedui-widget-click", aWidget.id);
}
},
@@ -1944,17 +1944,17 @@ var CustomizableUIInternal = {
if (!state) {
return;
}
try {
gSavedState = JSON.parse(state);
if (typeof gSavedState != "object" || gSavedState === null) {
throw "Invalid saved state";
}
- } catch(e) {
+ } catch (e) {
Services.prefs.clearUserPref(kPrefCustomizationState);
gSavedState = {};
log.debug("Error loading saved UI customization state, falling back to defaults.");
}
if (!("placements" in gSavedState)) {
gSavedState.placements = {};
}
@@ -2524,17 +2524,17 @@ var CustomizableUIInternal = {
gResetting = false;
},
_resetUIState: function() {
try {
gUIStateBeforeReset.drawInTitlebar = Services.prefs.getBoolPref(kPrefDrawInTitlebar);
gUIStateBeforeReset.uiCustomizationState = Services.prefs.getCharPref(kPrefCustomizationState);
gUIStateBeforeReset.currentTheme = LightweightThemeManager.currentTheme;
- } catch(e) { }
+ } catch (e) { }
this._resetExtraToolbars();
Services.prefs.clearUserPref(kPrefCustomizationState);
Services.prefs.clearUserPref(kPrefDrawInTitlebar);
LightweightThemeManager.currentTheme = null;
log.debug("State reset");
@@ -2786,17 +2786,17 @@ var CustomizableUIInternal = {
}
}
if (Services.prefs.prefHasUserValue(kPrefDrawInTitlebar)) {
log.debug(kPrefDrawInTitlebar + " pref is non-default");
return false;
}
- if(LightweightThemeManager.currentTheme) {
+ if (LightweightThemeManager.currentTheme) {
log.debug(LightweightThemeManager.currentTheme + " theme is non-default");
return false;
}
return true;
},
setToolbarVisibility: function(aToolbarId, aIsVisible) {
@@ -4085,17 +4085,17 @@ OverflowableToolbar.prototype = {
this._chevron.removeEventListener("dragover", this);
this._chevron.removeEventListener("dragend", this);
this._panel.removeEventListener("popuphiding", this);
CustomizableUI.removeListener(this);
CustomizableUIInternal.removePanelCloseListeners(this._panel);
},
handleEvent: function(aEvent) {
- switch(aEvent.type) {
+ switch (aEvent.type) {
case "aftercustomization":
this._enable();
break;
case "command":
if (aEvent.target == this._chevron) {
this._onClickChevron(aEvent);
} else {
this._panel.hidePopup();
--- a/browser/components/customizableui/CustomizeMode.jsm
+++ b/browser/components/customizableui/CustomizeMode.jsm
@@ -1482,17 +1482,17 @@ CustomizeMode.prototype = {
},
_updateUndoResetButton: function() {
let undoResetButton = this.document.getElementById("customization-undo-reset-button");
undoResetButton.hidden = !CustomizableUI.canUndoReset;
},
handleEvent: function(aEvent) {
- switch(aEvent.type) {
+ switch (aEvent.type) {
case "toolbarvisibilitychange":
this._onToolbarVisibilityChange(aEvent);
break;
case "dragstart":
this._onDragStart(aEvent);
break;
case "dragover":
this._onDragOver(aEvent);
--- a/browser/components/customizableui/ScrollbarSampler.jsm
+++ b/browser/components/customizableui/ScrollbarSampler.jsm
@@ -44,17 +44,17 @@ this.ScrollbarSampler = {
.getInterface(Ci.nsIDOMWindowUtils);
return new Promise(resolve => {
cwindow.addEventListener("load", function onLoad(aEvent) {
cwindow.removeEventListener("load", onLoad);
let sbWidth = {};
try {
utils.getScrollbarSize(true, sbWidth, {});
- } catch(e) {
+ } catch (e) {
Cu.reportError("Could not sample scrollbar size: " + e + " -- " +
e.stack);
sbWidth.value = 0;
}
// Minimum width of 10 so that we have enough padding:
sbWidth.value = Math.max(sbWidth.value, 10);
resolve(sbWidth.value);
iframe.remove();
--- a/browser/components/customizableui/test/browser_947914_button_newPrivateWindow.js
+++ b/browser/components/customizableui/test/browser_947914_button_newPrivateWindow.js
@@ -34,15 +34,15 @@ add_task(function*() {
ok(privateBrowsingButton, "Private browsing button exists in Panel Menu");
privateBrowsingButton.click();
try {
yield waitForCondition(() => windowWasHandled);
yield promiseWindowClosed(privateWindow);
info("The new private window was closed");
}
- catch(e) {
+ catch (e) {
ok(false, "The new private browser window was not properly handled");
}
finally {
Services.ww.unregisterNotification(observerWindowOpened);
}
});
--- a/browser/components/customizableui/test/browser_947914_button_newWindow.js
+++ b/browser/components/customizableui/test/browser_947914_button_newWindow.js
@@ -33,15 +33,15 @@ add_task(function*() {
ok(newWindowButton, "New Window button exists in Panel Menu");
newWindowButton.click();
try {
yield waitForCondition(() => windowWasHandled);
yield promiseWindowClosed(newWindow);
info("The new window was closed");
}
- catch(e) {
+ catch (e) {
ok(false, "The new browser window was not properly handled");
}
finally {
Services.ww.unregisterNotification(observerWindowOpened);
}
});
--- a/browser/components/customizableui/test/browser_967000_button_feeds.js
+++ b/browser/components/customizableui/test/browser_967000_button_feeds.js
@@ -37,17 +37,17 @@ add_task(function*() {
ok(!feedButton.hasAttribute("disabled"), "The Subscribe button gets enabled");
feedButton.click();
yield promiseTabLoadEvent(newTab, TEST_FEED);
is(gBrowser.currentURI.spec, TEST_FEED, "Subscribe page opened");
ok(!isPanelUIOpen(), "Panel is closed");
- if(isPanelUIOpen()) {
+ if (isPanelUIOpen()) {
panelHidePromise = promisePanelHidden(window);
PanelUI.hide();
yield panelHidePromise;
}
});
add_task(function* asyncCleanup() {
// reset the panel UI to the default state
--- a/browser/components/customizableui/test/browser_967000_button_sync.js
+++ b/browser/components/customizableui/test/browser_967000_button_sync.js
@@ -92,17 +92,17 @@ function* openPrefsFromMenuPanel(expecte
yield deferred.promise;
newTab = gBrowser.selectedTab;
is(gBrowser.currentURI.spec, "about:preferences?entrypoint=" + entryPoint + "#sync",
"Firefox Sync preference page opened with `menupanel` entrypoint");
ok(!isPanelUIOpen(), "The panel closed");
- if(isPanelUIOpen()) {
+ if (isPanelUIOpen()) {
let panelHidePromise = promisePanelHidden(window);
PanelUI.hide();
yield panelHidePromise;
}
}
function* asyncCleanup() {
Services.prefs.clearUserPref("identity.fxaccounts.remote.signup.uri");
--- a/browser/components/customizableui/test/browser_973641_button_addon.js
+++ b/browser/components/customizableui/test/browser_973641_button_addon.js
@@ -51,17 +51,17 @@ add_task(function* asyncCleanup() {
ok(CustomizableUI.inDefaultState, "The UI is in default state again.");
// destroy the widget
CustomizableUI.destroyWidget(kButton);
});
function resetTabs() {
//close all opened tabs
- while(gBrowser.tabs.length > 1) {
+ while (gBrowser.tabs.length > 1) {
gBrowser.removeTab(gBrowser.selectedTab);
}
//restore the initial tab
gBrowser.addTab(initialLocation);
gBrowser.removeTab(gBrowser.selectedTab);
}
--- a/browser/components/distribution.js
+++ b/browser/components/distribution.js
@@ -20,29 +20,29 @@ XPCOMUtils.defineLazyModuleGetter(this,
"resource://gre/modules/PlacesUtils.jsm");
this.DistributionCustomizer = function DistributionCustomizer() {
// For parallel xpcshell testing purposes allow loading the distribution.ini
// file from the profile folder through an hidden pref.
let loadFromProfile = false;
try {
loadFromProfile = Services.prefs.getBoolPref("distribution.testing.loadFromProfile");
- } catch(ex) {}
+ } catch (ex) {}
let dirSvc = Cc["@mozilla.org/file/directory_service;1"].
getService(Ci.nsIProperties);
try {
let iniFile = loadFromProfile ? dirSvc.get("ProfD", Ci.nsIFile)
: dirSvc.get("XREAppDist", Ci.nsIFile);
if (loadFromProfile) {
iniFile.leafName = "distribution";
}
iniFile.append("distribution.ini");
if (iniFile.exists())
this._iniFile = iniFile;
- } catch(ex) {}
+ } catch (ex) {}
}
DistributionCustomizer.prototype = {
_iniFile: null,
get _ini() {
let ini = null;
try {
@@ -217,26 +217,26 @@ DistributionCustomizer.prototype = {
PlacesUtils.favicons.replaceFaviconDataFromDataURL(
faviconURI, item.iconData, 0,
Services.scriptSecurityManager.getSystemPrincipal());
PlacesUtils.favicons.setAndFetchFaviconForPage(
this._makeURI(item.link), faviconURI, false,
PlacesUtils.favicons.FAVICON_LOAD_NON_PRIVATE, null,
Services.scriptSecurityManager.getSystemPrincipal());
- } catch(e) {
+ } catch (e) {
Cu.reportError(e);
}
}
if (item.keyword) {
try {
yield PlacesUtils.keywords.insert({ keyword: item.keyword,
url: item.link });
- } catch(e) {
+ } catch (e) {
Cu.reportError(e);
}
}
break;
}
}
}),
@@ -454,23 +454,23 @@ DistributionCustomizer.prototype = {
if (this._newProfile) {
let xulStore = Cc["@mozilla.org/xul/xulstore;1"].getService(Ci.nsIXULStore);
try {
var showPersonalToolbar = Services.prefs.getBoolPref("browser.showPersonalToolbar");
if (showPersonalToolbar) {
xulStore.setValue(BROWSER_DOCURL, "PersonalToolbar", "collapsed", "false");
}
- } catch(e) {}
+ } catch (e) {}
try {
var showMenubar = Services.prefs.getBoolPref("browser.showMenubar");
if (showMenubar) {
xulStore.setValue(BROWSER_DOCURL, "toolbar-menubar", "collapsed", "false");
}
- } catch(e) {}
+ } catch (e) {}
}
let prefDefaultsApplied = this._prefDefaultsApplied || !this._ini;
if (this._customizationsApplied && this._bookmarksApplied &&
prefDefaultsApplied) {
let os = Cc["@mozilla.org/observer-service;1"].
getService(Ci.nsIObserverService);
os.notifyObservers(null, DISTRIBUTION_CUSTOMIZATION_COMPLETE_TOPIC, null);
--- a/browser/components/migration/360seProfileMigrator.js
+++ b/browser/components/migration/360seProfileMigrator.js
@@ -226,17 +226,17 @@ Object.defineProperty(Qihoo360seProfileM
if (!loginIni.isReadable()) {
throw new Error("360 Secure Browser's 'login.ini' file could not be read.");
}
let loginIniInUtf8 = copyToTempUTF8File(loginIni, "gbk");
let loginIniObj = parseINIStrings(loginIniInUtf8);
try {
loginIniInUtf8.remove(false);
- } catch(ex) {}
+ } catch (ex) {}
let nowLoginEmail = loginIniObj.NowLogin && loginIniObj.NowLogin.email;
/*
* NowLogin section may:
* 1. be missing or without email, before any user logs in.
* 2. represents the current logged in user
* 3. represents the most recent logged in user
--- a/browser/components/migration/ChromeProfileMigrator.js
+++ b/browser/components/migration/ChromeProfileMigrator.js
@@ -221,17 +221,17 @@ Object.defineProperty(ChromeProfileMigra
createInstance(Ci.nsIFileInputStream);
fstream.init(file, -1, 0, 0);
try {
return JSON.parse(
NetUtil.readInputStreamToString(fstream, fstream.available(),
{ charset: "UTF-8" })
).homepage;
}
- catch(e) {
+ catch (e) {
Cu.reportError("Error parsing Chrome's preferences file: " + e);
}
}
return "";
}
});
Object.defineProperty(ChromeProfileMigrator.prototype, "sourceLocked", {
--- a/browser/components/migration/MigrationUtils.jsm
+++ b/browser/components/migration/MigrationUtils.jsm
@@ -262,17 +262,17 @@ this.MigratorPrototype = {
completeDeferred.resolve();
}
// If migrate throws, an error occurred, and the callback
// (itemMayBeDone) might haven't been called.
try {
resource.migrate(resourceDone);
}
- catch(ex) {
+ catch (ex) {
Cu.reportError(ex);
resourceDone(false);
}
// Certain resources must be ran sequentially or they could fail,
// for example bookmarks and history (See bug 1272652).
if (migrationType == MigrationUtils.resourceTypes.BOOKMARKS ||
migrationType == MigrationUtils.resourceTypes.HISTORY) {
@@ -332,17 +332,17 @@ this.MigratorPrototype = {
let resources = this._getMaybeCachedResources("");
if (resources && resources.length > 0)
exists = true;
}
else {
exists = profiles.length > 0;
}
}
- catch(ex) {
+ catch (ex) {
Cu.reportError(ex);
}
return exists;
},
/*** PRIVATE STUFF - DO NOT OVERRIDE ***/
_getMaybeCachedResources: function PMB__getMaybeCachedResources(aProfile) {
let profileKey = aProfile ? aProfile.id : "";
@@ -406,17 +406,17 @@ this.MigrationUtils = Object.freeze({
*/
wrapMigrateFunction: function MU_wrapMigrateFunction(aFunction, aCallback) {
return function() {
let success = false;
try {
aFunction.apply(null, arguments);
success = true;
}
- catch(ex) {
+ catch (ex) {
Cu.reportError(ex);
}
// Do not change this to call aCallback directly in try try & catch
// blocks, because if aCallback throws, we may end up calling aCallback
// twice.
aCallback(success);
}
},
@@ -534,17 +534,17 @@ this.MigrationUtils = Object.freeze({
if (this._migrators.has(aKey)) {
migrator = this._migrators.get(aKey);
}
else {
try {
migrator = Cc["@mozilla.org/profile/migrator;1?app=browser&type=" +
aKey].createInstance(Ci.nsIBrowserProfileMigrator);
}
- catch(ex) { Cu.reportError(ex) }
+ catch (ex) { Cu.reportError(ex) }
this._migrators.set(aKey, migrator);
}
try {
return migrator && migrator.sourceExists ? migrator : null;
} catch (ex) { Cu.reportError(ex); return null }
},
@@ -572,17 +572,17 @@ this.MigrationUtils = Object.freeze({
let browserDesc = "";
try {
let browserDesc =
Cc["@mozilla.org/uriloader/external-protocol-service;1"].
getService(Ci.nsIExternalProtocolService).
getApplicationDescription("http");
return APP_DESC_TO_KEY[browserDesc] || "";
}
- catch(ex) {
+ catch (ex) {
Cu.reportError("Could not detect default browser: " + ex);
}
return "";
},
// Whether or not we're in the process of startup migration
get isStartupMigration() {
return gProfileStartup != null;
--- a/browser/components/migration/SafariProfileMigrator.js
+++ b/browser/components/migration/SafariProfileMigrator.js
@@ -166,17 +166,17 @@ Bookmarks.prototype = {
let title;
if (entry.has("URIDictionary"))
title = entry.get("URIDictionary").get("title");
try {
yield PlacesUtils.bookmarks.insert({
parentGuid, url: entry.get("URLString"), title
});
- } catch(ex) {
+ } catch (ex) {
Cu.reportError("Invalid Safari bookmark: " + ex);
}
}
}
})
};
function History(aHistoryFile) {
@@ -217,17 +217,17 @@ History.prototype = {
if (entry.has("lastVisitedDate")) {
let visitDate = this._parseCocoaDate(entry.get("lastVisitedDate"));
try {
places.push({ uri: NetUtil.newURI(entry.get("")),
title: entry.get("title"),
visits: [{ transitionType: transType,
visitDate: visitDate }] });
}
- catch(ex) {
+ catch (ex) {
// Safari's History file may contain malformed URIs which
// will be ignored.
Cu.reportError(ex)
}
}
}
if (places.length > 0) {
PlacesUtils.asyncHistory.updatePlaces(places, {
@@ -241,17 +241,17 @@ History.prototype = {
aCallback(this._success);
}
});
}
else {
aCallback(false);
}
}
- catch(ex) {
+ catch (ex) {
Cu.reportError(ex);
aCallback(false);
}
}.bind(this));
}
};
/**
@@ -280,17 +280,17 @@ MainPreferencesPropertyList.prototype =
this._callbacks.push(aCallback);
if (!alreadyReading) {
PropertyListUtils.read(this._file, function readPrefs(aDict) {
this._dict = aDict;
for (let callback of this._callbacks) {
try {
callback(aDict);
}
- catch(ex) {
+ catch (ex) {
Cu.reportError(ex);
}
}
this._callbacks.splice(0);
}.bind(this));
}
},
@@ -475,23 +475,23 @@ Preferences.prototype = {
// See nsLanguageAtomService::GetLanguageGroup
let localeLangGroup = "x-unicode";
let bundle = Services.strings.createBundle(
"resource://gre/res/langGroups.properties");
try {
localeLangGroup = bundle.GetStringFromName(locale);
}
- catch(ex) {
+ catch (ex) {
let hyphenAt = locale.indexOf("-");
if (hyphenAt != -1) {
try {
localeLangGroup = bundle.GetStringFromName(locale.substr(0, hyphenAt));
}
- catch(ex2) { }
+ catch (ex2) { }
}
}
return localeLangGroup;
},
_migrateDownloadsFolder: Task.async(function* () {
// Windows Safari uses DownloadPath while Mac uses DownloadsPath.
// Check both for future compatibility.
--- a/browser/components/migration/content/migration.js
+++ b/browser/components/migration/content/migration.js
@@ -337,17 +337,17 @@ var MigrationWizard = {
onHomePageMigrationPageAdvanced: function ()
{
// we might not have a selectedItem if we're in fallback mode
try {
var radioGroup = document.getElementById("homePageRadiogroup");
this._newHomePage = radioGroup.selectedItem.value;
- } catch(ex) {}
+ } catch (ex) {}
},
// 5 - Migrating
onMigratingPageShow: function ()
{
this._wiz.getButton("cancel").disabled = true;
this._wiz.canRewind = false;
this._wiz.canAdvance = false;
@@ -449,17 +449,17 @@ var MigrationWizard = {
str);
}
var dirSvc = Components.classes["@mozilla.org/file/directory_service;1"]
.getService(Components.interfaces.nsIProperties);
var prefFile = dirSvc.get("ProfDS", Components.interfaces.nsIFile);
prefFile.append("prefs.js");
prefSvc.savePrefFile(prefFile);
- } catch(ex) {
+ } catch (ex) {
dump(ex);
}
}
// We're done now.
this._wiz.canAdvance = true;
this._wiz.advance();
--- a/browser/components/nsBrowserContentHandler.js
+++ b/browser/components/nsBrowserContentHandler.js
@@ -757,17 +757,17 @@ nsDefaultCommandLineHandler.prototype =
// Searches in the Windows 10 task bar searchbox simply open the default browser
// with a URL for a search on Bing. Here we extract the search term and use the
// user's default search engine instead.
var uriScheme = "", uriHost = "", uriPath = "";
try {
uriScheme = uri.scheme;
uriHost = uri.host;
uriPath = uri.path;
- } catch(e) {
+ } catch (e) {
}
// Most Windows searches are "https://www.bing.com/search...", but bug
// 1182308 reports a Chinese edition of Windows 10 using
// "http://cn.bing.com/search...", so be a bit flexible in what we match.
if (redirectWinSearch &&
(uriScheme == "http" || uriScheme == "https") &&
uriHost.endsWith(".bing.com") && uriPath.startsWith("/search")) {
--- a/browser/components/nsBrowserGlue.js
+++ b/browser/components/nsBrowserGlue.js
@@ -731,17 +731,17 @@ BrowserGlue.prototype = {
this._sanitizer.onStartup();
// check if we're in safe mode
if (Services.appinfo.inSafeMode) {
// See https://bugzilla.mozilla.org/show_bug.cgi?id=1231112#c7 . We need to
// register the observer early if we have to migrate tab groups
let currentUIVersion = 0;
try {
currentUIVersion = Services.prefs.getIntPref("browser.migration.version");
- } catch(ex) {}
+ } catch (ex) {}
if (currentUIVersion < 35) {
this._maybeMigrateTabGroups();
}
Services.ww.openWindow(null, "chrome://browser/content/safeMode.xul",
"_blank", "chrome,centerscreen,modal,resizable=no", null);
}
// apply distribution customizations
@@ -1102,17 +1102,17 @@ BrowserGlue.prototype = {
this._trackSlowStartup();
// Offer to reset a user's profile if it hasn't been used for 60 days.
const OFFER_PROFILE_RESET_INTERVAL_MS = 60 * 24 * 60 * 60 * 1000;
let lastUse = Services.appinfo.replacedLockTime;
let disableResetPrompt = false;
try {
disableResetPrompt = Services.prefs.getBoolPref("browser.disableResetPrompt");
- } catch(e) {}
+ } catch (e) {}
if (!disableResetPrompt && lastUse &&
Date.now() - lastUse >= OFFER_PROFILE_RESET_INTERVAL_MS) {
this._resetProfileNotification("unused");
} else if (AppConstants.platform == "win" && !disableResetPrompt) {
// Check if we were just re-installed and offer Firefox Reset
let updateChannel;
try {
@@ -1648,17 +1648,17 @@ BrowserGlue.prototype = {
// Check if user or an extension has required to import bookmarks.html
let importBookmarksHTML = false;
try {
importBookmarksHTML =
Services.prefs.getBoolPref("browser.places.importBookmarksHTML");
if (importBookmarksHTML)
importBookmarks = true;
- } catch(ex) {}
+ } catch (ex) {}
// Support legacy bookmarks.html format for apps that depend on that format.
let autoExportHTML = false;
try {
autoExportHTML = Services.prefs.getBoolPref("browser.bookmarks.autoExportHTML");
} catch (ex) {} // Do not export.
if (autoExportHTML) {
// Sqlite.jsm and Places shutdown happen at profile-before-change, thus,
@@ -1675,17 +1675,17 @@ BrowserGlue.prototype = {
try {
restoreDefaultBookmarks =
Services.prefs.getBoolPref("browser.bookmarks.restore_default_bookmarks");
if (restoreDefaultBookmarks) {
// Ensure that we already have a bookmarks backup for today.
yield this._backupBookmarks();
importBookmarks = true;
}
- } catch(ex) {}
+ } catch (ex) {}
// This may be reused later, check for "=== undefined" to see if it has
// been populated already.
let lastBackupFile;
// If the user did not require to restore default bookmarks, or import
// from bookmarks.html, we will try to restore from JSON
if (importBookmarks && !restoreDefaultBookmarks && !importBookmarksHTML) {
@@ -1723,17 +1723,17 @@ BrowserGlue.prototype = {
}
else {
// An import operation is about to run.
// Don't try to recreate smart bookmarks if autoExportHTML is true or
// smart bookmarks are disabled.
let smartBookmarksVersion = 0;
try {
smartBookmarksVersion = Services.prefs.getIntPref("browser.places.smartBookmarksVersion");
- } catch(ex) {}
+ } catch (ex) {}
if (!autoExportHTML && smartBookmarksVersion != -1)
Services.prefs.setIntPref("browser.places.smartBookmarksVersion", 0);
let bookmarksUrl = null;
if (restoreDefaultBookmarks) {
// User wants to restore bookmarks.html file from default profile folder
bookmarksUrl = "chrome://browser/locale/bookmarks.html";
}
@@ -2144,22 +2144,22 @@ BrowserGlue.prototype = {
if (currentUIVersion < 30) {
// Convert old devedition theme pref to lightweight theme storage
let lightweightThemeSelected = false;
let selectedThemeID = null;
try {
lightweightThemeSelected = Services.prefs.prefHasUserValue("lightweightThemes.selectedThemeID");
selectedThemeID = Services.prefs.getCharPref("lightweightThemes.selectedThemeID");
- } catch(e) {}
+ } catch (e) {}
let defaultThemeSelected = false;
try {
defaultThemeSelected = Services.prefs.getCharPref("general.skins.selectedSkin") == "classic/1.0";
- } catch(e) {}
+ } catch (e) {}
// If we are on the devedition channel, the devedition theme is on by
// default. But we need to handle the case where they didn't want it
// applied, and unapply the theme.
let userChoseToNotUseDeveditionTheme =
!defaultThemeSelected ||
(lightweightThemeSelected && selectedThemeID != "firefox-devedition@mozilla.org");
@@ -2289,17 +2289,17 @@ BrowserGlue.prototype = {
// TODO bug 399268: should this be a pref?
const MAX_RESULTS = 10;
// Get current smart bookmarks version. If not set, create them.
let smartBookmarksCurrentVersion = 0;
try {
smartBookmarksCurrentVersion = Services.prefs.getIntPref(SMART_BOOKMARKS_PREF);
- } catch(ex) {}
+ } catch (ex) {}
// If version is current, or smart bookmarks are disabled, bail out.
if (smartBookmarksCurrentVersion == -1 ||
smartBookmarksCurrentVersion >= SMART_BOOKMARKS_VERSION) {
return;
}
try {
@@ -2394,17 +2394,17 @@ BrowserGlue.prototype = {
index: menuIndex });
// Don't add a separator if the menu was empty or there is one already.
if (bm && bm.type != PlacesUtils.bookmarks.TYPE_SEPARATOR) {
yield PlacesUtils.bookmarks.insert({ type: PlacesUtils.bookmarks.TYPE_SEPARATOR,
parentGuid: PlacesUtils.bookmarks.menuGuid,
index: menuIndex });
}
}
- } catch(ex) {
+ } catch (ex) {
Cu.reportError(ex);
} finally {
Services.prefs.setIntPref(SMART_BOOKMARKS_PREF, SMART_BOOKMARKS_VERSION);
Services.prefs.savePrefFile(null);
}
}),
/**
--- a/browser/components/places/PlacesUIUtils.jsm
+++ b/browser/components/places/PlacesUIUtils.jsm
@@ -1145,26 +1145,26 @@ this.PlacesUIUtils = {
}
// removeItemAnnotation does not check if item exists, nor the anno,
// so this is safe to do.
as.removeItemAnnotation(aItemId, PlacesUIUtils.ORGANIZER_FOLDER_ANNO);
as.removeItemAnnotation(aItemId, PlacesUIUtils.ORGANIZER_QUERY_ANNO);
// This will throw if the annotation is an orphan.
bs.removeItem(aItemId);
}
- catch(e) { /* orphan anno */ }
+ catch (e) { /* orphan anno */ }
}
// Returns true if item really exists, false otherwise.
function itemExists(aItemId) {
try {
bs.getItemIndex(aItemId);
return true;
}
- catch(e) {
+ catch (e) {
return false;
}
}
// Get all items marked as being the left pane folder.
let items = as.getItemsWithAnnotation(this.ORGANIZER_FOLDER_ANNO);
if (items.length > 1) {
// Something went wrong, we cannot have more than one left pane folder,
@@ -1457,17 +1457,17 @@ this.PlacesUIUtils = {
defGetter("title", () => PlacesUtils.bookmarks.getItemTitle(itemId));
if (!("uri" in aNodeLike)) {
defGetter("uri", () => {
let uri = null;
try {
uri = PlacesUtils.bookmarks.getBookmarkURI(itemId);
}
- catch(ex) { }
+ catch (ex) { }
return uri ? uri.spec : "";
});
}
if (!("type" in aNodeLike)) {
defGetter("type", () => {
if (aNodeLike.uri.length > 0) {
if (/^place:/.test(aNodeLike.uri)) {
@@ -1564,17 +1564,17 @@ XPCOMUtils.defineLazyGetter(PlacesUIUtil
return Services.prefs.getComplexValue("intl.ellipsis",
Ci.nsIPrefLocalizedString).data;
});
XPCOMUtils.defineLazyGetter(PlacesUIUtils, "useAsyncTransactions", function() {
try {
return Services.prefs.getBoolPref("browser.places.useAsyncTransactions");
}
- catch(ex) { }
+ catch (ex) { }
return false;
});
XPCOMUtils.defineLazyServiceGetter(this, "URIFixup",
"@mozilla.org/docshell/urifixup;1",
"nsIURIFixup");
XPCOMUtils.defineLazyGetter(this, "bundle", function() {
--- a/browser/components/places/content/controller.js
+++ b/browser/components/places/content/controller.js
@@ -1105,17 +1105,17 @@ PlacesController.prototype = {
let xferable = Cc["@mozilla.org/widget/transferable;1"].
createInstance(Ci.nsITransferable);
xferable.init(null);
xferable.addDataFlavor(PlacesUtils.TYPE_X_MOZ_PLACE_ACTION)
this.clipboard.getData(xferable, Ci.nsIClipboard.kGlobalClipboard);
xferable.getTransferData(PlacesUtils.TYPE_X_MOZ_PLACE_ACTION, action, {});
[action, actionOwner] =
action.value.QueryInterface(Ci.nsISupportsString).data.split(",");
- } catch(ex) {
+ } catch (ex) {
// Paste from external sources don't have any associated action, just
// fallback to a copy action.
return "copy";
}
// For cuts also check who inited the action, since cuts across different
// instances should instead be handled as copies (The sources are not
// available for this instance).
if (action == "cut" && actionOwner != this.profileName)
@@ -1283,17 +1283,17 @@ PlacesController.prototype = {
// Now get the clipboard contents, in the best available flavor.
let data = {}, type = {}, items = [];
try {
xferable.getAnyTransferData(type, data, {});
data = data.value.QueryInterface(Ci.nsISupportsString).data;
type = type.value;
items = PlacesUtils.unwrapNodes(data, type);
- } catch(ex) {
+ } catch (ex) {
// No supported data exists or nodes unwrap failed, just bail out.
return;
}
let itemsToSelect = [];
if (PlacesUIUtils.useAsyncTransactions) {
if (ip.isTag) {
let uris = items.filter(item => "uri" in item).map(item => NetUtil.newURI(item.uri));
@@ -1605,17 +1605,17 @@ var PlacesControllerDragHelper = {
let uri = data.linkedBrowser.currentURI;
let spec = uri ? uri.spec : "about:blank";
let title = data.label;
unwrapped = { uri: spec,
title: data.label,
type: PlacesUtils.TYPE_X_MOZ_URL};
}
else
- throw("bogus data was passed as a tab")
+ throw new Error("bogus data was passed as a tab");
let index = insertionPoint.index;
// Adjust insertion index to prevent reversal of dragged items. When you
// drag multiple elts upward: need to increment index or each successive
// elt will be inserted at the same index, each above the previous.
let dragginUp = insertionPoint.itemId == unwrapped.parent &&
index < PlacesUtils.bookmarks.getItemIndex(unwrapped.id);
--- a/browser/components/places/content/editBookmarkOverlay.js
+++ b/browser/components/places/content/editBookmarkOverlay.js
@@ -596,17 +596,17 @@ var gEditItemOverlay = {
onLocationFieldChange() {
if (this.readOnly || !this._paneInfo.isBookmark)
return;
let newURI;
try {
newURI = PlacesUIUtils.createFixedURI(this._locationField.value);
}
- catch(ex) {
+ catch (ex) {
// TODO: Bug 1089141 - Provide some feedback about the invalid url.
return;
}
if (this._paneInfo.uri.equals(newURI))
return;
if (!PlacesUIUtils.useAsyncTransactions) {
--- a/browser/components/places/content/places.js
+++ b/browser/components/places/content/places.js
@@ -517,17 +517,17 @@ var PlacesOrganizer = {
if (!prompts.confirm(null,
PlacesUIUtils.getString("bookmarksRestoreAlertTitle"),
PlacesUIUtils.getString("bookmarksRestoreAlert")))
return;
Task.spawn(function* () {
try {
yield BookmarkJSONUtils.importFromFile(aFilePath, true);
- } catch(ex) {
+ } catch (ex) {
PlacesOrganizer._showErrorAlert(PlacesUIUtils.getString("bookmarksRestoreParseError"));
}
});
},
_showErrorAlert: function PO__showErrorAlert(aMsg) {
var brandShortName = document.getElementById("brandStrings").
getString("brandShortName");
@@ -1231,17 +1231,17 @@ var ViewMenu = {
lastModified: { key: "LASTMODIFIED", dir: "descending" },
description: { key: "ANNOTATION",
dir: "ascending",
anno: PlacesUIUtils.DESCRIPTION_ANNO }
};
// Make sure we have a valid column.
if (!colLookupTable.hasOwnProperty(columnId))
- throw("Invalid column");
+ throw new Error("Invalid column");
// Use a default sort direction if none has been specified. If aDirection
// is invalid, result.sortingMode will be undefined, which has the effect
// of unsorting the tree.
aDirection = (aDirection || colLookupTable[columnId].dir).toUpperCase();
var sortConst = "SORT_BY_" + colLookupTable[columnId].key + "_" + aDirection;
result.sortingAnnotation = colLookupTable[columnId].anno || "";
@@ -1275,17 +1275,17 @@ var ContentArea = {
let { view, options } = this._specialViews.get(aQueryString);
if (typeof view == "function") {
view = view();
this._specialViews.set(aQueryString, { view: view, options: options });
}
return view;
}
}
- catch(ex) {
+ catch (ex) {
Components.utils.reportError(ex);
}
return ContentTree.view;
},
/**
* Sets a custom view to be used rather than the default places tree
* whenever the given query is selected in the left pane.
--- a/browser/components/places/content/tree.xml
+++ b/browser/components/places/content/tree.xml
@@ -42,17 +42,17 @@
onget="return this._controller"/>
<!-- overriding -->
<property name="view">
<getter><![CDATA[
try {
return this.treeBoxObject.view.wrappedJSObject || null;
}
- catch(e) {
+ catch (e) {
return null;
}
]]></getter>
<setter><![CDATA[
return this.treeBoxObject.view = val;
]]></setter>
</property>
--- a/browser/components/places/content/treeView.js
+++ b/browser/components/places/content/treeView.js
@@ -1106,17 +1106,17 @@ PlacesTreeView.prototype = {
return this._getNodeForRow(aIndex);
},
treeIndexForNode: function PTV_treeNodeForIndex(aNode) {
// The API allows passing invisible nodes.
try {
return this._getRowForNode(aNode, true);
}
- catch(ex) { }
+ catch (ex) { }
return Ci.nsINavHistoryResultTreeViewer.INDEX_INVISIBLE;
},
// nsITreeView
get rowCount() {
return this._rows.length;
},
--- a/browser/components/places/tests/browser/browser_library_middleclick.js
+++ b/browser/components/places/tests/browser/browser_library_middleclick.js
@@ -254,17 +254,17 @@ function runNextTest() {
// Remove tabs listeners.
gBrowser.tabContainer.removeEventListener("TabOpen", gTabsListener, false);
gBrowser.removeTabsProgressListener(gTabsListener);
// Restore history.
try {
gPrefService.clearUserPref(ENABLE_HISTORY_PREF);
- } catch(ex) {}
+ } catch (ex) {}
finish();
}
}
function mouseEventOnCell(aTree, aRowIndex, aColumnIndex, aEventDetails) {
var selection = aTree.view.selection;
selection.select(aRowIndex);
--- a/browser/components/places/tests/unit/head_bookmarks.js
+++ b/browser/components/places/tests/unit/head_bookmarks.js
@@ -120,10 +120,10 @@ var waitForResolvedPromise = Task.async(
let tries = 0;
do {
try {
let value = yield promiseFn();
return value;
} catch (ex) {}
yield new Promise(resolve => do_timeout(SINGLE_TRY_TIMEOUT, resolve));
} while (++tries <= tryCount);
- throw(timeoutMsg);
+ throw new Error(timeoutMsg);
});
--- a/browser/components/places/tests/unit/test_PUIU_makeTransaction.js
+++ b/browser/components/places/tests/unit/test_PUIU_makeTransaction.js
@@ -157,17 +157,17 @@ add_test(function test_container()
let txn = PlacesUIUtils.makeTransaction(
wrapNodeByIdAndParent(aData.id, PlacesUtils.unfiledBookmarksFolderId),
0, // Unused for real nodes.
PlacesUtils.unfiledBookmarksFolderId,
PlacesUtils.bookmarks.DEFAULT_INDEX,
true
);
PlacesUtils.transactionManager.doTransaction(txn);
- } catch(ex) {
+ } catch (ex) {
do_throw(ex);
}
}, "random-anno");
let id = PlacesUtils.bookmarks.createFolder(PlacesUtils.unfiledBookmarksFolderId,
TEST_TITLE,
PlacesUtils.bookmarks.DEFAULT_INDEX);
PlacesUtils.annotations.setItemAnnotation(id, PlacesUIUtils.DESCRIPTION_ANNO,
@@ -215,17 +215,17 @@ add_test(function test_separator()
let txn = PlacesUIUtils.makeTransaction(
wrapNodeByIdAndParent(aData.id, PlacesUtils.unfiledBookmarksFolderId),
0, // Unused for real nodes.
PlacesUtils.unfiledBookmarksFolderId,
PlacesUtils.bookmarks.DEFAULT_INDEX,
true
);
PlacesUtils.transactionManager.doTransaction(txn);
- } catch(ex) {
+ } catch (ex) {
do_throw(ex);
}
}, "random-anno");
let id = PlacesUtils.bookmarks.insertSeparator(PlacesUtils.unfiledBookmarksFolderId,
PlacesUtils.bookmarks.DEFAULT_INDEX);
PlacesUtils.annotations.setItemAnnotation(id, "random-anno",
"random-value", 0,
@@ -275,17 +275,17 @@ add_test(function test_bookmark()
let txn = PlacesUIUtils.makeTransaction(
wrapNodeByIdAndParent(aData.id, PlacesUtils.unfiledBookmarksFolderId),
0, // Unused for real nodes.
PlacesUtils.unfiledBookmarksFolderId,
PlacesUtils.bookmarks.DEFAULT_INDEX,
true
);
PlacesUtils.transactionManager.doTransaction(txn);
- } catch(ex) {
+ } catch (ex) {
do_throw(ex);
}
}, "random-anno");
let id = PlacesUtils.bookmarks.insertBookmark(PlacesUtils.unfiledBookmarksFolderId,
NetUtil.newURI(TEST_URL),
PlacesUtils.bookmarks.DEFAULT_INDEX,
TEST_TITLE);
@@ -325,17 +325,17 @@ add_test(function test_visit()
let txn = PlacesUIUtils.makeTransaction(
node,
0, // Unused for real nodes.
PlacesUtils.unfiledBookmarksFolderId,
PlacesUtils.bookmarks.DEFAULT_INDEX,
true
);
PlacesUtils.transactionManager.doTransaction(txn);
- } catch(ex) {
+ } catch (ex) {
do_throw(ex);
}
});
PlacesUtils.bookmarks.insertBookmark(PlacesUtils.unfiledBookmarksFolderId,
NetUtil.newURI(TEST_URL),
PlacesUtils.bookmarks.DEFAULT_INDEX,
TEST_TITLE);
--- a/browser/components/syncedtabs/SyncedTabsListStore.js
+++ b/browser/components/syncedtabs/SyncedTabsListStore.js
@@ -113,17 +113,17 @@ Object.assign(SyncedTabsListStore.protot
this.selectRow(branchRow + 1);
return;
}
if (branchRow < 0) {
this.selectRow(0, -1);
} else if ((!branch.tabs.length || childRow >= branch.tabs.length - 1 || !this._isOpen(branch)) && branchRow < this.data.length) {
this.selectRow(branchRow + 1, -1);
- } else if(childRow < branch.tabs.length) {
+ } else if (childRow < branch.tabs.length) {
this.selectRow(branchRow, childRow + 1);
}
},
moveSelectionUp() {
let branchRow = this._selectedRow[0];
let childRow = this._selectedRow[1];
let branch = this.data[branchRow];
--- a/browser/components/uitour/UITour.jsm
+++ b/browser/components/uitour/UITour.jsm
@@ -1807,17 +1807,17 @@ this.UITour = {
props.forEach(property => appinfo[property] = Services.appinfo[property]);
// Identifier of the partner repack, as stored in preference "distribution.id"
// and included in Firefox and other update pings. Note this is not the same as
// Services.appinfo.distributionID (value of MOZ_DISTRIBUTION_ID is set at build time).
let distribution = "default";
try {
distribution = Services.prefs.getDefaultBranch("distribution.").getCharPref("id");
- } catch(e) {}
+ } catch (e) {}
appinfo["distribution"] = distribution;
let isDefaultBrowser = null;
try {
let shell = aWindow.getShellService();
if (shell) {
isDefaultBrowser = shell.isDefaultBrowser(false);
}
--- a/browser/experiments/Experiments.jsm
+++ b/browser/experiments/Experiments.jsm
@@ -2169,17 +2169,17 @@ this.Experiments.PreviousExperimentProvi
this._log.trace("startup()");
Services.obs.addObserver(this, EXPERIMENTS_CHANGED_TOPIC, false);
},
shutdown: function () {
this._log.trace("shutdown()");
try {
Services.obs.removeObserver(this, EXPERIMENTS_CHANGED_TOPIC);
- } catch(e) {
+ } catch (e) {
// Prevent crash in mochitest-browser3 on Mulet
}
},
observe: function (subject, topic, data) {
switch (topic) {
case EXPERIMENTS_CHANGED_TOPIC:
this._updateExperimentList();
--- a/browser/extensions/pocket/content/main.js
+++ b/browser/extensions/pocket/content/main.js
@@ -462,17 +462,17 @@ var pktUI = (function() {
})
});
var _initL10NMessageId = "initL10N";
pktUIMessaging.addMessageListener(_initL10NMessageId, function(panelId, data) {
var strings = {};
var bundle = Services.strings.createBundle("chrome://pocket/locale/pocket.properties");
var e = bundle.getSimpleEnumeration();
- while(e.hasMoreElements()) {
+ while (e.hasMoreElements()) {
var str = e.getNext().QueryInterface(Components.interfaces.nsIPropertyElement);
strings[str.key] = str.value;
}
pktUIMessaging.sendResponseMessageToPanel(panelId, _initL10NMessageId, { strings: strings });
});
}
--- a/browser/extensions/pocket/content/panels/js/saved.js
+++ b/browser/extensions/pocket/content/panels/js/saved.js
@@ -188,17 +188,17 @@ var PKT_SAVED_OVERLAY = function (option
}
if (!$('.token-input-dropdown-tag').data('init')) {
$('.token-input-dropdown-tag').css('width',inputwrapper.outerWidth()).data('init');
inputwrapper.append($('.token-input-dropdown-tag'));
}
cb(returnlist);
},
textToData: function(text) {
- if($.trim(text).length > 25 || !$.trim(text).length) {
+ if ($.trim(text).length > 25 || !$.trim(text).length) {
if (text.length > 25) {
myself.showTagsError(myself.dictJSON.maxtaglength);
changestamp = Date.now();
setTimeout(function() {
$('.token-input-input-token input').val(text).focus();
},10);
}
return null;
@@ -586,17 +586,17 @@ PKT_SAVED.prototype = {
myself.overlay.showStateSaved(resp);
});
}
}
$(function()
{
- if(!window.thePKT_SAVED) {
+ if (!window.thePKT_SAVED) {
var thePKT_SAVED = new PKT_SAVED();
window.thePKT_SAVED = thePKT_SAVED;
thePKT_SAVED.init();
}
// send an async message to get string data
thePKT_SAVED.sendMessage("initL10N", {}, function(resp) {
window.pocketStrings = resp.strings;
--- a/browser/extensions/pocket/content/panels/js/signup.js
+++ b/browser/extensions/pocket/content/panels/js/signup.js
@@ -162,17 +162,17 @@ PKT_SIGNUP.prototype = {
// tell back end we're ready
thePKT_SIGNUP.sendMessage("show");
}
}
$(function()
{
- if(!window.thePKT_SIGNUP) {
+ if (!window.thePKT_SIGNUP) {
var thePKT_SIGNUP = new PKT_SIGNUP();
window.thePKT_SIGNUP = thePKT_SIGNUP;
thePKT_SIGNUP.init();
}
// send an async message to get string data
thePKT_SIGNUP.sendMessage("initL10N", {}, function(resp) {
window.pocketStrings = resp.strings;
--- a/browser/extensions/pocket/content/pktApi.jsm
+++ b/browser/extensions/pocket/content/pktApi.jsm
@@ -294,17 +294,17 @@ var pktApi = (function() {
};
// Set headers
request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8');
request.setRequestHeader('X-Accept',' application/json');
// Serialize and Fire off the request
var str = [];
- for(var p in data) {
+ for (var p in data) {
if (data.hasOwnProperty(p)) {
str.push(encodeURIComponent(p) + "=" + encodeURIComponent(data[p]));
}
}
request.send(str.join("&"));
return true;
--- a/browser/modules/BrowserUITelemetry.jsm
+++ b/browser/modules/BrowserUITelemetry.jsm
@@ -185,17 +185,17 @@ this.BrowserUITelemetry = {
Services.obs.addObserver(this, "sessionstore-windows-restored", false);
Services.obs.addObserver(this, "browser-delayed-startup-finished", false);
Services.obs.addObserver(this, "autocomplete-did-enter-text", false);
CustomizableUI.addListener(this);
},
observe: function(aSubject, aTopic, aData) {
- switch(aTopic) {
+ switch (aTopic) {
case "sessionstore-windows-restored":
this._gatherFirstWindowMeasurements();
break;
case "browser-delayed-startup-finished":
this._registerWindow(aSubject);
break;
case "autocomplete-did-enter-text":
let input = aSubject.QueryInterface(Ci.nsIAutoCompleteInput);
@@ -345,17 +345,17 @@ this.BrowserUITelemetry = {
let item = document.getElementById(itemID);
if (item) {
item.removeEventListener("mousedown", this);
}
}
},
handleEvent: function(aEvent) {
- switch(aEvent.type) {
+ switch (aEvent.type) {
case "unload":
this._unregisterWindow(aEvent.currentTarget);
break;
case "mouseup":
this._handleMouseUp(aEvent);
break;
case "mousedown":
this._handleMouseDown(aEvent);
--- a/browser/modules/BrowserUsageTelemetry.jsm
+++ b/browser/modules/BrowserUsageTelemetry.jsm
@@ -120,31 +120,31 @@ let BrowserUsageTelemetry = {
uninit() {
Services.obs.removeObserver(this, DOMWINDOW_OPENED_TOPIC, false);
Services.obs.removeObserver(this, TELEMETRY_SUBSESSIONSPLIT_TOPIC, false);
Services.obs.removeObserver(this, WINDOWS_RESTORED_TOPIC, false);
},
observe(subject, topic, data) {
- switch(topic) {
+ switch (topic) {
case WINDOWS_RESTORED_TOPIC:
this._setupAfterRestore();
break;
case DOMWINDOW_OPENED_TOPIC:
this._onWindowOpen(subject);
break;
case TELEMETRY_SUBSESSIONSPLIT_TOPIC:
this.afterSubsessionSplit();
break;
}
},
handleEvent(event) {
- switch(event.type) {
+ switch (event.type) {
case "TabOpen":
this._onTabOpen();
break;
case "unload":
this._unregisterWindow(event.target);
break;
}
},
--- a/browser/modules/CaptivePortalWatcher.jsm
+++ b/browser/modules/CaptivePortalWatcher.jsm
@@ -58,17 +58,17 @@ this.CaptivePortalWatcher = {
return;
}
Services.obs.removeObserver(this, "captive-portal-login");
Services.obs.removeObserver(this, "captive-portal-login-abort");
Services.obs.removeObserver(this, "captive-portal-login-success");
},
observe(subject, topic, data) {
- switch(topic) {
+ switch (topic) {
case "captive-portal-login":
this._addCaptivePortalTab();
break;
case "captive-portal-login-abort":
case "captive-portal-login-success":
this._captivePortalGone();
break;
case "xul-window-visible":
--- a/browser/modules/ContentCrashHandlers.jsm
+++ b/browser/modules/ContentCrashHandlers.jsm
@@ -77,17 +77,17 @@ this.TabCrashHandler = {
}
},
receiveMessage: function(message) {
let browser = message.target.browser;
let gBrowser = browser.ownerGlobal.gBrowser;
let tab = gBrowser.getTabForBrowser(browser);
- switch(message.name) {
+ switch (message.name) {
case "Load": {
this.onAboutTabCrashedLoad(message);
break;
}
case "RemotePage:Unload": {
this.onAboutTabCrashedUnload(message);
break;
@@ -340,17 +340,17 @@ this.PluginCrashReporter = {
uninit() {
Services.obs.removeObserver(this, "plugin-crashed", false);
Services.obs.removeObserver(this, "gmp-plugin-crash", false);
Services.obs.removeObserver(this, "profile-after-change", false);
this.initialized = false;
},
observe(subject, topic, data) {
- switch(topic) {
+ switch (topic) {
case "plugin-crashed": {
let propertyBag = subject;
if (!(propertyBag instanceof Ci.nsIPropertyBag2) ||
!(propertyBag instanceof Ci.nsIWritablePropertyBag2) ||
!propertyBag.hasKey("runID") ||
!propertyBag.hasKey("pluginDumpID")) {
Cu.reportError("PluginCrashReporter can not read plugin information.");
return;
--- a/browser/modules/ContentLinkHandler.jsm
+++ b/browser/modules/ContentLinkHandler.jsm
@@ -134,14 +134,14 @@ this.ContentLinkHandler = {
}
},
getLinkIconURI: function(aLink) {
let targetDoc = aLink.ownerDocument;
var uri = BrowserUtils.makeURI(aLink.href, targetDoc.characterSet);
try {
uri.userPass = "";
- } catch(e) {
+ } catch (e) {
// some URIs are immutable
}
return uri;
},
};
--- a/browser/modules/ContentObservers.jsm
+++ b/browser/modules/ContentObservers.jsm
@@ -38,17 +38,17 @@ var gDecoderDoctorObserver = function(su
function getMessageManagerForWindow(aContentWindow) {
let ir = aContentWindow.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIDocShell)
.sameTypeRootTreeItem
.QueryInterface(Ci.nsIInterfaceRequestor);
try {
// If e10s is disabled, this throws NS_NOINTERFACE for closed tabs.
return ir.getInterface(Ci.nsIContentFrameMessageManager);
- } catch(e) {
+ } catch (e) {
if (e.result == Cr.NS_NOINTERFACE) {
return null;
}
throw e;
}
}
Services.obs.addObserver(gEMEUIObserver, "mediakeys-request", false);
--- a/browser/modules/ContentWebRTC.jsm
+++ b/browser/modules/ContentWebRTC.jsm
@@ -353,17 +353,17 @@ function getInnerWindowIDForWindow(aCont
function getMessageManagerForWindow(aContentWindow) {
let ir = aContentWindow.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIDocShell)
.sameTypeRootTreeItem
.QueryInterface(Ci.nsIInterfaceRequestor);
try {
// If e10s is disabled, this throws NS_NOINTERFACE for closed tabs.
return ir.getInterface(Ci.nsIContentFrameMessageManager);
- } catch(e) {
+ } catch (e) {
if (e.result == Cr.NS_NOINTERFACE) {
return null;
}
throw e;
}
}
function processShutdown() {
--- a/browser/modules/DirectoryLinksProvider.jsm
+++ b/browser/modules/DirectoryLinksProvider.jsm
@@ -223,17 +223,17 @@ var DirectoryLinksProvider = {
if (!Services.prefs.prefHasUserValue(PREF_NEWTAB_ENHANCED)) {
let enhanced = Services.prefs.getBoolPref(PREF_NEWTAB_ENHANCED);
try {
// Default to not enhanced if DNT is set to tell websites to not track
if (Services.prefs.getBoolPref("privacy.donottrackheader.enabled")) {
enhanced = false;
}
}
- catch(ex) {}
+ catch (ex) {}
Services.prefs.setBoolPref(PREF_NEWTAB_ENHANCED, enhanced);
}
},
observe: function DirectoryLinksProvider_observe(aSubject, aTopic, aData) {
if (aTopic == "nsPref:changed") {
switch (aData) {
// Re-set the default in case the user clears the pref
@@ -604,17 +604,17 @@ var DirectoryLinksProvider = {
try {
// A malformed url will not be allowed
let uri = Services.io.newURI(url, null, null);
scheme = uri.scheme;
// URIs without base domains will be allowed
base = Services.eTLD.getBaseDomain(uri);
}
- catch(ex) {}
+ catch (ex) {}
// Require a scheme match and the base only if desired
return allowed.has(scheme) && (!checkBase || ALLOWED_URL_BASE.has(base));
},
_escapeChars(text) {
let charMap = {
'&': '&',
'<': '<',
--- a/browser/modules/Feeds.jsm
+++ b/browser/modules/Feeds.jsm
@@ -89,16 +89,16 @@ this.Feeds = {
let principalURI = BrowserUtils.makeURIFromCPOW(aPrincipal.URI);
let principalToCheck =
Services.scriptSecurityManager.createCodebasePrincipal(principalURI, aPrincipal.originAttributes);
try {
BrowserUtils.urlSecurityCheck(aLink.href, principalToCheck,
Ci.nsIScriptSecurityManager.DISALLOW_INHERIT_PRINCIPAL);
return type || "application/rss+xml";
}
- catch(ex) {
+ catch (ex) {
}
}
return null;
},
};
--- a/browser/modules/Social.jsm
+++ b/browser/modules/Social.jsm
@@ -41,17 +41,17 @@ function promiseSetAnnotation(aURI, prov
try {
if (providerList && providerList.length > 0) {
PlacesUtils.annotations.setPageAnnotation(
aURI, "social/mark", JSON.stringify(providerList), 0,
PlacesUtils.annotations.EXPIRE_WITH_HISTORY);
} else {
PlacesUtils.annotations.removePageAnnotation(aURI, "social/mark");
}
- } catch(e) {
+ } catch (e) {
Cu.reportError("SocialAnnotation failed: " + e);
}
deferred.resolve();
}, Ci.nsIThread.DISPATCH_NORMAL);
return deferred.promise;
}
--- a/browser/modules/offlineAppCache.jsm
+++ b/browser/modules/offlineAppCache.jsm
@@ -10,11 +10,11 @@ const Cc = Components.classes;
const Ci = Components.interfaces;
this.OfflineAppCacheHelper = {
clear: function() {
var cacheService = Cc["@mozilla.org/netwerk/cache-storage-service;1"].getService(Ci.nsICacheStorageService);
var appCacheStorage = cacheService.appCacheStorage(LoadContextInfo.default, null);
try {
appCacheStorage.asyncEvictStorage(null);
- } catch(er) {}
+ } catch (er) {}
}
};
--- a/toolkit/.eslintrc
+++ b/toolkit/.eslintrc
@@ -39,17 +39,17 @@
// Two space indent
// "indent": [2, 2, { "SwitchCase": 1 }],
// Space after colon not before in property declarations
// "key-spacing": [2, { "beforeColon": false, "afterColon": true, "mode": "minimum" }],
// Require spaces before and after keywords
- // "keyword-spacing": 2,
+ "keyword-spacing": 2,
// Unix linebreaks
"linebreak-style": [2, "unix"],
// Always require parenthesis for new calls
// "new-parens": 2,
// Use [] instead of Array()
--- a/toolkit/components/aboutmemory/content/aboutMemory.js
+++ b/toolkit/components/aboutmemory/content/aboutMemory.js
@@ -2022,17 +2022,17 @@ function saveReportsToFile()
if (aResult == Ci.nsIFilePicker.returnOK ||
aResult == Ci.nsIFilePicker.returnReplace) {
fpFinish(fp.file);
}
};
try {
fp.init(window, "Save Memory Reports", Ci.nsIFilePicker.modeSave);
- } catch(ex) {
+ } catch (ex) {
// This will fail on Android, since there is no Save as file picker there.
// Just save to the default downloads dir if it does.
Downloads.getSystemDownloadsDirectory().then(function(dirPath) {
let file = FileUtils.File(dirPath);
file.append(fp.defaultString);
fpFinish(file);
});
--- a/toolkit/components/aboutperformance/tests/browser/browser_aboutperformance.js
+++ b/toolkit/components/aboutperformance/tests/browser/browser_aboutperformance.js
@@ -267,17 +267,17 @@ add_task(function* test_close_tab() {
yield promiseContentResponse(tab.linkedBrowser, "aboutperformance-test:setTitle", URL);
let {ok, found, error} = yield promiseContentResponse(gTabAboutPerformance.linkedBrowser, "aboutperformance-test:closeTab", {url: URL, autoRefresh: true, mode, displayRecent});
Assert.ok(ok, `Message aboutperformance-test:closeTab was handled correctly ${JSON.stringify(error)}`);
info(`URL ${URL} ${found?"found":"hasn't been found yet"}`);
if (found) {
break;
}
- } while(true);
+ } while (true);
if (mode == "close") {
info(`Waiting for close`);
yield promiseClosed;
} else {
info(`Waiting for reload`);
yield promiseReloaded;
yield BrowserTestUtils.removeTab(tab);
--- a/toolkit/components/addoncompat/RemoteAddonsChild.jsm
+++ b/toolkit/components/addoncompat/RemoteAddonsChild.jsm
@@ -261,23 +261,23 @@ AboutProtocolChannel.prototype = {
// Return the data via an nsIStringInputStream.
let stream = Cc["@mozilla.org/io/string-input-stream;1"].createInstance(Ci.nsIStringInputStream);
stream.setData(data, data.length);
let runnable = {
run: () => {
try {
listener.onStartRequest(this, context);
- } catch(e) {}
+ } catch (e) {}
try {
listener.onDataAvailable(this, context, stream, 0, stream.available());
- } catch(e) {}
+ } catch (e) {}
try {
listener.onStopRequest(this, context, Cr.NS_OK);
- } catch(e) {}
+ } catch (e) {}
}
};
Services.tm.currentThread.dispatch(runnable, Ci.nsIEventTarget.DISPATCH_NORMAL);
},
asyncOpen2: function(listener) {
// throws an error if security checks fail
var outListener = contentSecManager.performSecurityCheck(this, listener);
@@ -530,17 +530,17 @@ var RemoteAddonsChild = {
ContentPolicyChild,
AboutProtocolChild,
ObserverChild,
];
for (let shim of shims) {
try {
shim.init();
- } catch(e) {
+ } catch (e) {
Cu.reportError(e);
}
}
},
init: function(global) {
if (!this._ready) {
@@ -560,17 +560,17 @@ var RemoteAddonsChild = {
// Return this so it gets rooted in the content script.
return [new EventTargetChild(global), sandboxChild];
},
uninit: function(perTabShims) {
for (let shim of perTabShims) {
try {
shim.uninit();
- } catch(e) {
+ } catch (e) {
Cu.reportError(e);
}
}
},
get useSyncWebProgress() {
return NotificationTracker.getCount("web-progress") > 0;
},
--- a/toolkit/components/addoncompat/tests/addon/bootstrap.js
+++ b/toolkit/components/addoncompat/tests/addon/bootstrap.js
@@ -284,23 +284,23 @@ function testAboutModuleRegistration()
TestChannel.prototype = {
asyncOpen: function(listener, context) {
let stream = this.open();
let runnable = {
run: () => {
try {
listener.onStartRequest(this, context);
- } catch(e) {}
+ } catch (e) {}
try {
listener.onDataAvailable(this, context, stream, 0, stream.available());
- } catch(e) {}
+ } catch (e) {}
try {
listener.onStopRequest(this, context, Cr.NS_OK);
- } catch(e) {}
+ } catch (e) {}
}
};
Services.tm.currentThread.dispatch(runnable, Ci.nsIEventTarget.DISPATCH_NORMAL);
},
asyncOpen2: function(listener) {
// throws an error if security checks fail
var outListener = contentSecManager.performSecurityCheck(this, listener);
@@ -308,23 +308,23 @@ function testAboutModuleRegistration()
},
open: function() {
function getWindow(channel) {
try
{
if (channel.notificationCallbacks)
return channel.notificationCallbacks.getInterface(Ci.nsILoadContext).associatedWindow;
- } catch(e) {}
+ } catch (e) {}
try
{
if (channel.loadGroup && channel.loadGroup.notificationCallbacks)
return channel.loadGroup.notificationCallbacks.getInterface(Ci.nsILoadContext).associatedWindow;
- } catch(e) {}
+ } catch (e) {}
return null;
}
let data = `<html><h1>${this.aboutName}</h1></html>`;
let wnd = getWindow(this);
if (!wnd)
throw Cr.NS_ERROR_UNEXPECTED;
@@ -441,37 +441,37 @@ function testAboutModuleRegistration()
*/
let testAboutModulesWork = (browser) => {
let testConnection = () => {
let request = new content.XMLHttpRequest();
try {
request.open("GET", "about:test1", false);
request.send(null);
if (request.status != 200) {
- throw(`about:test1 response had status ${request.status} - expected 200`);
+ throw (`about:test1 response had status ${request.status} - expected 200`);
}
if (request.responseText.indexOf("test1") == -1) {
- throw(`about:test1 response had result ${request.responseText}`);
+ throw (`about:test1 response had result ${request.responseText}`);
}
request = new content.XMLHttpRequest();
request.open("GET", "about:test2", false);
request.send(null);
if (request.status != 200) {
- throw(`about:test2 response had status ${request.status} - expected 200`);
+ throw (`about:test2 response had status ${request.status} - expected 200`);
}
if (request.responseText.indexOf("test2") == -1) {
- throw(`about:test2 response had result ${request.responseText}`);
+ throw (`about:test2 response had result ${request.responseText}`);
}
sendAsyncMessage("test:result", {
pass: true,
});
- } catch(e) {
+ } catch (e) {
sendAsyncMessage("test:result", {
pass: false,
errorMsg: e.toString(),
});
}
};
return new Promise((resolve, reject) => {
--- a/toolkit/components/captivedetect/captivedetect.js
+++ b/toolkit/components/captivedetect/captivedetect.js
@@ -169,17 +169,17 @@ function LoginObserver(captivePortalDete
}
}
},
/*
* Check if login activity is finished according to HTTP burst.
*/
notify : function notify() {
- switch(state) {
+ switch (state) {
case LOGIN_OBSERVER_STATE_BURST:
// Wait while network stays idle for a short period
state = LOGIN_OBSERVER_STATE_VERIFY_NEEDED;
// Fall though to start polling timer
case LOGIN_OBSERVER_STATE_IDLE:
if (waitForNetworkActivity) {
timer.initWithCallback(this,
captivePortalDetector._pollingTime,
@@ -208,17 +208,17 @@ function CaptivePortalDetector() {
this._canonicalSiteURL = null;
this._canonicalSiteExpectedContent = null;
try {
this._canonicalSiteURL =
Services.prefs.getCharPref('captivedetect.canonicalURL');
this._canonicalSiteExpectedContent =
Services.prefs.getCharPref('captivedetect.canonicalContent');
- } catch(e) {
+ } catch (e) {
debug('canonicalURL or canonicalContent not set.')
}
this._maxWaitingTime =
Services.prefs.getIntPref('captivedetect.maxWaitingTime');
this._pollingTime =
Services.prefs.getIntPref('captivedetect.pollingTime');
this._maxRetryCount =
--- a/toolkit/components/commandlines/test/unit/test_bug666224.js
+++ b/toolkit/components/commandlines/test/unit/test_bug666224.js
@@ -1,6 +1,6 @@
function run_test() {
var cmdLine=Components.classes["@mozilla.org/toolkit/command-line;1"].createInstance(Components.interfaces.nsICommandLine);
try {
cmdLine.getArgument(cmdLine.length);
- } catch(e) {}
+ } catch (e) {}
}
--- a/toolkit/components/contentprefs/nsContentPrefService.js
+++ b/toolkit/components/contentprefs/nsContentPrefService.js
@@ -151,21 +151,21 @@ ContentPrefService.prototype = {
if (this.__stmtSelectPrefsByName) {
this.__stmtSelectPrefsByName.finalize();
this.__stmtSelectPrefsByName = null;
}
if (this.__stmtDeleteSettingIfUnused) {
this.__stmtDeleteSettingIfUnused.finalize();
this.__stmtDeleteSettingIfUnused = null;
}
- if(this.__stmtSelectPrefs) {
+ if (this.__stmtSelectPrefs) {
this.__stmtSelectPrefs.finalize();
this.__stmtSelectPrefs = null;
}
- if(this.__stmtDeleteGroupIfUnused) {
+ if (this.__stmtDeleteGroupIfUnused) {
this.__stmtDeleteGroupIfUnused.finalize();
this.__stmtDeleteGroupIfUnused = null;
}
if (this.__stmtDeletePref) {
this.__stmtDeletePref.finalize();
this.__stmtDeletePref = null;
}
if (this.__stmtUpdatePref) {
@@ -354,17 +354,17 @@ ContentPrefService.prototype = {
this._dbConnection.executeSimpleSQL("DELETE FROM prefs WHERE groupID IS NOT NULL");
this._dbConnection.executeSimpleSQL("DELETE FROM groups");
this._dbConnection.executeSimpleSQL(`
DELETE FROM settings
WHERE id NOT IN (SELECT DISTINCT settingID FROM prefs)
`);
this._dbConnection.commitTransaction();
}
- catch(ex) {
+ catch (ex) {
this._dbConnection.rollbackTransaction();
throw ex;
}
},
removePrefsByName: function ContentPrefService_removePrefsByName(aName, aContext) {
warnDeprecated();
@@ -526,31 +526,31 @@ ContentPrefService.prototype = {
/**
* Notify all observers about the removal of a preference.
*/
_notifyPrefRemoved: function ContentPrefService__notifyPrefRemoved(aGroup, aName, aIsPrivate) {
for (var observer of this._getObservers(aName)) {
try {
observer.onContentPrefRemoved(aGroup, aName, aIsPrivate);
}
- catch(ex) {
+ catch (ex) {
Cu.reportError(ex);
}
}
},
/**
* Notify all observers about a preference change.
*/
_notifyPrefSet: function ContentPrefService__notifyPrefSet(aGroup, aName, aValue, aIsPrivate) {
for (var observer of this._getObservers(aName)) {
try {
observer.onContentPrefSet(aGroup, aName, aValue, aIsPrivate);
}
- catch(ex) {
+ catch (ex) {
Cu.reportError(ex);
}
}
},
get grouper() {
warnDeprecated();
return this._grouper;
@@ -1033,17 +1033,17 @@ ContentPrefService.prototype = {
},
_dbConnection: null,
_dbCreateStatement: function ContentPrefService__dbCreateStatement(aSQLString) {
try {
var statement = this._dbConnection.createStatement(aSQLString);
}
- catch(ex) {
+ catch (ex) {
Cu.reportError("error creating statement " + aSQLString + ": " +
this._dbConnection.lastError + " - " +
this._dbConnection.lastErrorString);
throw ex;
}
return statement;
},
@@ -1083,17 +1083,17 @@ ContentPrefService.prototype = {
var version = dbConnection.schemaVersion;
// Try to migrate the schema in the database to the current schema used by
// the service. If migration fails, back up the database and recreate it.
if (version != this._dbVersion) {
try {
this._dbMigrate(dbConnection, version, this._dbVersion);
}
- catch(ex) {
+ catch (ex) {
Cu.reportError("error migrating DB: " + ex + "; backing up and recreating");
dbConnection = this._dbBackUpAndRecreate(dbService, dbFile, dbConnection);
}
}
}
// Turn off disk synchronization checking to reduce disk churn and speed up
// operations when prefs are changed rapidly (such as when a user repeatedly
@@ -1115,17 +1115,17 @@ ContentPrefService.prototype = {
_dbCreate: function ContentPrefService__dbCreate(aDBService, aDBFile) {
var dbConnection = aDBService.openDatabase(aDBFile);
try {
this._dbCreateSchema(dbConnection);
dbConnection.schemaVersion = this._dbVersion;
}
- catch(ex) {
+ catch (ex) {
// If we failed to create the database (perhaps because the disk ran out
// of space), then remove the database file so we don't leave it in some
// half-created state from which we won't know how to recover.
dbConnection.close();
aDBFile.remove(false);
throw ex;
}
@@ -1156,17 +1156,17 @@ ContentPrefService.prototype = {
_dbBackUpAndRecreate: function ContentPrefService__dbBackUpAndRecreate(aDBService,
aDBFile,
aDBConnection) {
aDBService.backupDatabaseFile(aDBFile, "content-prefs.sqlite.corrupt");
// Close the database, ignoring the "already closed" exception, if any.
// It'll be open if we're here because of a migration failure but closed
// if we're here because of database corruption.
- try { aDBConnection.close() } catch(ex) {}
+ try { aDBConnection.close() } catch (ex) {}
aDBFile.remove(false);
let dbConnection = this._dbCreate(aDBService, aDBFile);
return dbConnection;
},
@@ -1189,17 +1189,17 @@ ContentPrefService.prototype = {
* applying the schema. In any case, recover by simply reapplying the schema.
*/
if (aOldVersion == 0) {
this._dbCreateSchema(aDBConnection);
} else {
for (let i = aOldVersion; i < aNewVersion; i++) {
let migrationName = "_dbMigrate" + i + "To" + (i + 1);
if (typeof this[migrationName] != 'function') {
- throw("no migrator function from version " + aOldVersion + " to version " + aNewVersion);
+ throw ("no migrator function from version " + aOldVersion + " to version " + aNewVersion);
}
this[migrationName](aDBConnection);
}
}
aDBConnection.schemaVersion = aNewVersion;
aDBConnection.commitTransaction();
} catch (ex) {
aDBConnection.rollbackTransaction();
@@ -1276,36 +1276,36 @@ HostnameGrouper.prototype = {
try {
// Accessing the host property of the URI will throw an exception
// if the URI is of a type that doesn't have a host property.
// Otherwise, we manually throw an exception if the host is empty,
// since the effect is the same (we can't derive a group from it).
group = aURI.host;
if (!group)
- throw("can't derive group from host; no host in URI");
+ throw ("can't derive group from host; no host in URI");
}
- catch(ex) {
+ catch (ex) {
// If we don't have a host, then use the entire URI (minus the query,
// reference, and hash, if possible) as the group. This means that URIs
// like about:mozilla and about:blank will be considered separate groups,
// but at least they'll be grouped somehow.
// This also means that each individual file: URL will be considered
// its own group. This seems suboptimal, but so does treating the entire
// file: URL space as a single group (especially if folks start setting
// group-specific capabilities prefs).
// XXX Is there something better we can do here?
try {
var url = aURI.QueryInterface(Ci.nsIURL);
group = aURI.prePath + url.filePath;
}
- catch(ex) {
+ catch (ex) {
group = aURI.spec;
}
}
return group;
}
};
--- a/toolkit/components/contentprefs/tests/unit/head_contentPrefs.js
+++ b/toolkit/components/contentprefs/tests/unit/head_contentPrefs.js
@@ -103,17 +103,17 @@ var ContentPrefTest = {
* Delete the content pref service's persistent datastore. We do this before
* and after running tests to make sure we start from scratch each time. We
* also do it during the database creation, schema migration, and backup tests.
*/
deleteDatabase: function ContentPrefTest_deleteDatabase() {
var file = this.getProfileDir();
file.append(CONTENT_PREFS_DB_FILENAME);
if (file.exists())
- try { file.remove(false); } catch(e) { /* stupid windows box */ }
+ try { file.remove(false); } catch (e) { /* stupid windows box */ }
return file;
},
/**
* Delete the backup of the content pref service's persistent datastore.
* We do this during the database creation, schema migration, and backup tests.
*/
deleteBackupDatabase: function ContentPrefTest_deleteBackupDatabase() {
--- a/toolkit/components/contextualidentity/ContextualIdentityService.jsm
+++ b/toolkit/components/contextualidentity/ContextualIdentityService.jsm
@@ -111,17 +111,17 @@ function _ContextualIdentityService(path
this.loadError(null);
return;
}
this._identities = data.identities;
this._lastUserContextId = data.lastUserContextId;
this._dataReady = true;
- } catch(error) {
+ } catch (error) {
this.loadError(error);
}
}, (error) => {
this.loadError(error);
});
},
loadError(error) {
--- a/toolkit/components/cookie/content/cookieAcceptDialog.js
+++ b/toolkit/components/cookie/content/cookieAcceptDialog.js
@@ -189,15 +189,15 @@ function GetExpiresString(secondsUntilEx
// see bug 238045 for details
var expiry = "";
try {
expiry = gDateService.FormatDateTime("", gDateService.dateFormatLong,
gDateService.timeFormatSeconds,
date.getFullYear(), date.getMonth()+1,
date.getDate(), date.getHours(),
date.getMinutes(), date.getSeconds());
- } catch(ex) {
+ } catch (ex) {
// do nothing
}
return expiry;
}
return cookieBundle.getString("expireAtEndOfSession");
}
--- a/toolkit/components/crashes/CrashManager.jsm
+++ b/toolkit/components/crashes/CrashManager.jsm
@@ -531,17 +531,17 @@ this.CrashManager.prototype = Object.fre
// If we have a saved environment, use it. Otherwise report
// the current environment.
let crashEnvironment = null;
let sessionId = null;
let reportMeta = Cu.cloneInto(metadata, myScope);
if ('TelemetryEnvironment' in reportMeta) {
try {
crashEnvironment = JSON.parse(reportMeta.TelemetryEnvironment);
- } catch(e) {
+ } catch (e) {
Cu.reportError(e);
}
delete reportMeta.TelemetryEnvironment;
}
if ('TelemetrySessionId' in reportMeta) {
sessionId = reportMeta.TelemetrySessionId;
delete reportMeta.TelemetrySessionId;
}
--- a/toolkit/components/ctypes/tests/unit/head.js
+++ b/toolkit/components/ctypes/tests/unit/head.js
@@ -1,13 +1,13 @@
try {
// We might be running without privileges, in which case it's up to the
// harness to give us the 'ctypes' object.
Components.utils.import("resource://gre/modules/ctypes.jsm");
-} catch(e) {
+} catch (e) {
}
function open_ctypes_test_lib()
{
return ctypes.open(do_get_file(ctypes.libraryName("jsctypes-test")).path);
}
/**
--- a/toolkit/components/ctypes/tests/unit/test_finalizer_shouldaccept.js
+++ b/toolkit/components/ctypes/tests/unit/test_finalizer_shouldaccept.js
@@ -1,13 +1,13 @@
try {
// We might be running without privileges, in which case it's up to the
// harness to give us the 'ctypes' object.
Components.utils.import("resource://gre/modules/ctypes.jsm");
-} catch(e) {
+} catch (e) {
}
var acquire, dispose, reset_errno, dispose_errno,
acquire_ptr, dispose_ptr,
acquire_void_ptr, dispose_void_ptr,
acquire_string, dispose_string;
function run_test()
--- a/toolkit/components/ctypes/tests/unit/test_finalizer_shouldfail.js
+++ b/toolkit/components/ctypes/tests/unit/test_finalizer_shouldfail.js
@@ -1,13 +1,13 @@
try {
// We might be running without privileges, in which case it's up to the
// harness to give us the 'ctypes' object.
Components.utils.import("resource://gre/modules/ctypes.jsm");
-} catch(e) {
+} catch (e) {
}
var acquire, dispose, null_dispose, compare, dispose_64;
function run_test()
{
let library = open_ctypes_test_lib();
--- a/toolkit/components/ctypes/tests/unit/test_jsctypes.js
+++ b/toolkit/components/ctypes/tests/unit/test_jsctypes.js
@@ -2,17 +2,17 @@
/* 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/. */
try {
// We might be running without privileges, in which case it's up to the
// harness to give us the 'ctypes' object.
Components.utils.import("resource://gre/modules/ctypes.jsm");
-} catch(e) {
+} catch (e) {
}
CTYPES_TEST_LIB = ctypes.libraryName("jsctypes-test");
CTYPES_UNICODE_LIB = ctypes.libraryName("jsctyp\u00E8s-t\u00EB\u00DFt");
function do_check_throws(f, type, stack)
{
if (!stack) {
@@ -656,17 +656,17 @@ function run_basic_abi_tests(library, t,
check_struct_stats(library, t);
// Check the ToSource functions defined in the namespace ABI
do_check_eq(ctypes.default_abi.toSource(), "ctypes.default_abi");
let exn;
try {
ctypes.default_abi.toSource.call(null);
- } catch(x) {
+ } catch (x) {
exn = x;
}
do_check_true(!!exn); // Check that some exception was raised
}
function run_single_abi_tests(decl, abi, t, toprimitive,
get_test, set_tests, sum_tests, sum_many_tests) {
let getter_t = ctypes.FunctionType(abi, t).ptr;
@@ -2655,17 +2655,17 @@ function run_single_closure_tests(librar
sb.fn = fn_v_t(function() {sb.foo = {};});
Components.utils.evalInSandbox("fn();", sb);
} catch (e) {} // Components not available in workers.
// Make sure that a void callback can't return an error sentinel.
var sentinelThrew = false;
try {
fn_v_t(function() {}, null, -1);
- } catch(e) {
+ } catch (e) {
sentinelThrew = true;
}
do_check_true(sentinelThrew);
}
function run_variadic_tests(library) {
let sum_va_type = ctypes.FunctionType(ctypes.default_abi,
ctypes.int32_t,
--- a/toolkit/components/exthelper/extApplication.js
+++ b/toolkit/components/exthelper/extApplication.js
@@ -289,17 +289,17 @@ PreferenceBranch.prototype = {
break;
case "Boolean":
this._prefs.setBoolPref(aName, aValue);
break;
case "Number":
this._prefs.setIntPref(aName, aValue);
break;
default:
- throw("Unknown preference value specified.");
+ throw ("Unknown preference value specified.");
}
},
reset: function prefs_reset() {
this._prefs.resetBranch("");
},
QueryInterface: XPCOMUtils.generateQI([Ci.extIPreferenceBranch])
--- a/toolkit/components/feeds/FeedProcessor.js
+++ b/toolkit/components/feeds/FeedProcessor.js
@@ -51,17 +51,17 @@ const RSS090NS = "http://my.netscape.com
/***** Some general utils *****/
function strToURI(link, base) {
base = base || null;
if (!gIoService)
gIoService = Cc[IO_CONTRACTID].getService(Ci.nsIIOService);
try {
return gIoService.newURI(link, null, base);
}
- catch(e) {
+ catch (e) {
return null;
}
}
function isArray(a) {
return isObject(a) && a.constructor == Array;
}
@@ -74,17 +74,17 @@ function isFunction(a) {
}
function isIID(a, iid) {
var rv = false;
try {
a.QueryInterface(iid);
rv = true;
}
- catch(e) {
+ catch (e) {
}
return rv;
}
function isIArray(a) {
return isIID(a, Ci.nsIArray);
}
@@ -152,17 +152,17 @@ function bagHasKey(bag, key) {
}
}
function makePropGetter(key) {
return function FeedPropGetter(bag) {
try {
return value = bag.getProperty(key);
}
- catch(e) {
+ catch (e) {
}
return null;
}
}
const RDF_NS = "http://www.w3.org/1999/02/22-rdf-syntax-ns#";
// namespace map
var gNamespaces = {
@@ -354,17 +354,17 @@ Feed.prototype = {
},
_resolveURI: function Feed_resolveURI(linkSpec, baseSpec) {
var uri = null;
try {
var base = baseSpec ? strToURI(baseSpec, this.baseURI) : this.baseURI;
uri = strToURI(linkSpec, base);
}
- catch(e) {
+ catch (e) {
LOG(e);
}
return uri;
},
// reset the bag to raw contents, not text constructs
_resetBagMembersToRawText: function Feed_resetBagMembers(fieldLists) {
@@ -711,17 +711,17 @@ function fieldsToObj(container, fields)
searchList = fields[key];
for (var i=0; i < searchList.length; ++i) {
props = searchList[i];
prop = null;
field = isArray(props) ? props[0] : props;
try {
prop = container.fields.getProperty(field);
}
- catch(e) {
+ catch (e) {
}
if (prop) {
prop = isArray(props) ? props[1](prop) : prop;
container[key] = prop;
}
}
}
}
@@ -1525,17 +1525,17 @@ FeedProcessor.prototype = {
// First we'll see what's on top of the stack.
var container = this._stack[this._stack.length - 1][0];
// Check to see if it has the property
var prop;
try {
prop = container.getProperty(elementInfo.fieldName);
}
- catch(e) {
+ catch (e) {
}
if (elementInfo.isArray) {
if (!prop) {
container.setPropertyAsInterface(elementInfo.fieldName,
Cc[ARRAY_CONTRACTID].
createInstance(Ci.nsIMutableArray));
}
@@ -1685,17 +1685,17 @@ FeedProcessor.prototype = {
// convert URI-bearing values to an nsIURI
if (propName == "uri") {
var base = this._xmlBaseStack[this._xmlBaseStack.length - 1];
propValue = strToURI(chars, base);
}
el[propName] = propValue;
}
}
- catch(e) {
+ catch (e) {
// ignore XPConnect errors
}
// the rest of the function deals with entry- and feed-level stuff
return;
}
container = container.queryElementAt(container.length - 1,
Ci.nsIWritablePropertyBag2);
}
--- a/toolkit/components/feeds/test/head.js
+++ b/toolkit/components/feeds/test/head.js
@@ -37,17 +37,17 @@ function readTestData(testFile) {
if (testcase.expect && testcase.desc) {
testcase.path = 'xml/' + testFile.parent.leafName + '/' + testFile.leafName;
testcase.file = testFile;
break;
}
} while (hasmore);
- } catch(e) {
+ } catch (e) {
Assert.ok(false, "FAILED! Error reading testFile case in file " + testFile.leafName + " ---- " + e);
} finally {
istream.close();
}
return testcase;
}
@@ -69,12 +69,12 @@ function iterateDir(dir, recurse, callba
}
}
}
function isIID(a, iid) {
try {
a.QueryInterface(iid);
return true;
- } catch(e) { }
+ } catch (e) { }
return false;
}
--- a/toolkit/components/feeds/test/test_xml.js
+++ b/toolkit/components/feeds/test/test_xml.js
@@ -38,17 +38,17 @@ FeedListener.prototype = {
do_print("Testing feed " + this.testcase.file.path);
Assert.ok(isIID(feed, Ci.nsIFeed), "Has feed interface");
if (!eval(this.testcase.expect)) {
Assert.ok(false, "expect failed for " + this.testcase.desc);
} else {
Assert.ok(true, "expect passed for " + this.testcase.desc);
}
- } catch(e) {
+ } catch (e) {
Assert.ok(false, "expect failed for " + this.testcase.desc + " ---- " + e.message);
}
run_next_test();
}
}
function createTest(data) {
@@ -65,17 +65,17 @@ function createTest(data) {
var parser = Cc["@mozilla.org/feed-processor;1"].createInstance(Ci.nsIFeedProcessor);
var stream = Cc["@mozilla.org/network/file-input-stream;1"].createInstance(Ci.nsIFileInputStream);
stream.init(data.file, 0x01, parseInt("0444", 8), 0);
parser.listener = new FeedListener(data);
try {
parser.parseFromStream(stream, uri);
- } catch(e) {
+ } catch (e) {
Assert.ok(false, "parse failed for " + data.file.leafName + " ---- " + e.message);
// If the parser failed, the listener won't be notified, run the next test here.
run_next_test();
} finally {
stream.close();
}
}
}
--- a/toolkit/components/filepicker/content/filepicker.js
+++ b/toolkit/components/filepicker/content/filepicker.js
@@ -230,19 +230,19 @@ function selectOnOK()
var curFileIndex;
for (curFileIndex = 0; curFileIndex < fileList.length &&
ret != nsIFilePicker.returnCancel; ++curFileIndex) {
var file = fileList[curFileIndex].QueryInterface(nsIFile);
// try to normalize - if this fails we will ignore the error
// because we will notice the
// error later and show a fitting error alert.
- try{
+ try {
file.normalize();
- } catch(e) {
+ } catch (e) {
//promptService.alert(window, "Problem", "normalize failed, continuing");
}
var fileExists = file.exists();
if (!fileExists && (filePickerMode == nsIFilePicker.modeOpen ||
filePickerMode == nsIFilePicker.modeOpenMultiple)) {
showErrorDialog("errorOpenFileDoesntExistTitle",
@@ -258,17 +258,17 @@ function selectOnOK()
return false;
}
if (fileExists) {
isDir = file.isDirectory();
isFile = file.isFile();
}
- switch(filePickerMode) {
+ switch (filePickerMode) {
case nsIFilePicker.modeOpen:
case nsIFilePicker.modeOpenMultiple:
if (isFile) {
if (file.isReadable()) {
retvals.directory = file.parent.path;
} else {
showErrorDialog("errorOpeningFileTitle",
"openWithoutPermissionMessage_file",
@@ -486,17 +486,17 @@ function setOKAction(file) {
var buttonIcon = "open"; // used in all but one case
if (file && file.isDirectory()) {
document.documentElement.setAttribute("ondialogaccept", "return openOnOK();");
buttonLabel = gFilePickerBundle.getString("openButtonLabel");
}
else {
document.documentElement.setAttribute("ondialogaccept", "return selectOnOK();");
- switch(filePickerMode) {
+ switch (filePickerMode) {
case nsIFilePicker.modeGetFolder:
buttonLabel = gFilePickerBundle.getString("selectFolderButtonLabel");
break;
case nsIFilePicker.modeOpen:
case nsIFilePicker.modeOpenMultiple:
buttonLabel = gFilePickerBundle.getString("openButtonLabel");
break;
case nsIFilePicker.modeSave:
@@ -616,17 +616,17 @@ function populateAncestorList(directory)
var menuList = document.getElementById("lookInMenuList");
menuList.selectedIndex = 0;
}
function goUp() {
try {
var parent = sfile.parent;
- } catch(ex) { dump("can't get parent directory\n"); }
+ } catch (ex) { dump("can't get parent directory\n"); }
if (parent) {
gotoDirectory(parent);
}
}
function goHome() {
gotoDirectory(homeDir);
@@ -699,17 +699,17 @@ function newDir() {
}
function gotoDirectory(directory) {
window.setCursor("wait");
try {
populateAncestorList(directory);
treeView.setDirectory(directory);
document.getElementById("errorShower").selectedIndex = 0;
- } catch(ex) {
+ } catch (ex) {
document.getElementById("errorShower").selectedIndex = 1;
}
window.setCursor("auto");
if (filePickerMode == nsIFilePicker.modeGetFolder) {
textInput.value = "";
}
@@ -786,17 +786,17 @@ function processPath(path)
function processPathEntry(path, fileArray)
{
var filePath;
var file;
try {
file = sfile.clone().QueryInterface(nsILocalFile);
- } catch(e) {
+ } catch (e) {
dump("Couldn't clone\n"+e);
return false;
}
var tilde_file = file.clone();
tilde_file.append("~");
if (path[0] == '~' && // Expand ~ to $HOME, except:
!(path == "~" && tilde_file.exists()) && // If ~ was entered and such a file exists, don't expand
@@ -810,17 +810,17 @@ function processPathEntry(path, fileArra
if (filePath[0] == '/') /* an absolute path was entered */
file.initWithPath(filePath);
else if ((filePath.indexOf("/../") > 0) ||
(filePath.substr(-3) == "/..") ||
(filePath.substr(0,3) == "../") ||
(filePath == "..")) {
/* appendRelativePath doesn't allow .. */
- try{
+ try {
file.initWithPath(file.path + "/" + filePath);
} catch (e) {
dump("Couldn't init path\n"+e);
return false;
}
}
else {
try {
--- a/toolkit/components/filepicker/nsFilePicker.js
+++ b/toolkit/components/filepicker/nsFilePicker.js
@@ -229,17 +229,17 @@ nsFilePicker.prototype = {
open: function(aFilePickerShownCallback) {
var tm = Components.classes["@mozilla.org/thread-manager;1"]
.getService(Components.interfaces.nsIThreadManager);
tm.mainThread.dispatch(function() {
let result = Components.interfaces.nsIFilePicker.returnCancel;
try {
result = this.show();
- } catch(ex) {
+ } catch (ex) {
}
if (aFilePickerShownCallback) {
aFilePickerShownCallback.done(result);
}
}.bind(this), Components.interfaces.nsIThread.DISPATCH_NORMAL);
},
show: function() {
@@ -259,45 +259,45 @@ nsFilePicker.prototype = {
if (this.mParentWindow) {
parent = this.mParentWindow;
} else if (typeof(window) == "object" && window != null) {
parent = window;
} else {
try {
var appShellService = Components.classes[APPSHELL_SERV_CONTRACTID].getService(nsIAppShellService);
parent = appShellService.hiddenDOMWindow;
- } catch(ex) {
+ } catch (ex) {
debug("Can't get parent. xpconnect hates me so we can't get one from the appShellService.\n");
debug(ex + "\n");
}
}
var parentWin = null;
try {
parentWin = parent.QueryInterface(nsIInterfaceRequestor)
.getInterface(nsIWebNavigation)
.QueryInterface(nsIDocShellTreeItem)
.treeOwner
.QueryInterface(nsIInterfaceRequestor)
.getInterface(nsIBaseWindow);
- } catch(ex) {
+ } catch (ex) {
dump("file picker couldn't get base window\n"+ex+"\n");
}
try {
parent.openDialog("chrome://global/content/filepicker.xul",
"",
"chrome,modal,titlebar,resizable=yes,dependent=yes",
o);
this.mFilterIndex = o.retvals.filterIndex;
this.mFilesEnumerator = o.retvals.files;
this.mFileURL = o.retvals.fileURL;
lastDirectory = o.retvals.directory;
return o.retvals.buttonStatus;
- } catch(ex) { dump("unable to open file picker\n" + ex + "\n"); }
+ } catch (ex) { dump("unable to open file picker\n" + ex + "\n"); }
return null;
}
}
if (DEBUG)
debug = function (s) { dump("-*- filepicker: " + s + "\n"); };
else
--- a/toolkit/components/jsdownloads/src/DownloadCore.jsm
+++ b/toolkit/components/jsdownloads/src/DownloadCore.jsm
@@ -1753,17 +1753,17 @@ this.DownloadSaver.prototype = {
// The start time is always available when we reach this point.
let startPRTime = this.download.startTime.getTime() * 1000;
try {
gDownloadHistory.addDownload(sourceUri, referrerUri, startPRTime,
targetUri);
}
- catch(ex) {
+ catch (ex) {
if (!(ex instanceof Components.Exception) ||
ex.result != Cr.NS_ERROR_NOT_AVAILABLE) {
throw ex;
}
//
// Under normal operation the download history service may not
// be available. We don't want all downloads that are public to fail
// when this happens so we'll ignore this error and this error only!
--- a/toolkit/components/jsdownloads/test/unit/test_DownloadIntegration.js
+++ b/toolkit/components/jsdownloads/test/unit/test_DownloadIntegration.js
@@ -86,17 +86,17 @@ add_task(function* test_getSystemDownloa
let info = yield OS.File.stat(downloadDir);
do_check_true(info.isDir);
} else {
let targetPath = OS.Path.join(tempDir.path,
gStringBundle.GetStringFromName("downloadsFolder"));
try {
yield OS.File.removeEmptyDir(targetPath);
- } catch(e) {}
+ } catch (e) {}
downloadDir = yield DownloadIntegration.getSystemDownloadsDirectory();
do_check_eq(downloadDir, targetPath);
do_check_true(yield OS.File.exists(downloadDir));
let info = yield OS.File.stat(downloadDir);
do_check_true(info.isDir);
yield OS.File.removeEmptyDir(targetPath);
}
--- a/toolkit/components/microformats/microformat-shiv.js
+++ b/toolkit/components/microformats/microformat-shiv.js
@@ -73,51 +73,51 @@ var Microformats; // jshint ignore:line
rels;
this.init();
options = (options)? options : {};
this.mergeOptions(options);
this.getDOMContext( options );
// if we do not have any context create error
- if(!this.rootNode || !this.document) {
+ if (!this.rootNode || !this.document) {
this.errors.push(this.noContentErr);
- }else{
+ } else {
// only parse h-* microformats if we need to
// this is added to speed up parsing
- if(this.hasMicroformats(this.rootNode, options)) {
+ if (this.hasMicroformats(this.rootNode, options)) {
this.prepareDOM( options );
- if(this.options.filters.length > 0) {
+ if (this.options.filters.length > 0) {
// parse flat list of items
var newRootNode = this.findFilterNodes(this.rootNode, this.options.filters);
data = this.walkRoot(newRootNode);
- }else{
+ } else {
// parse whole document from root
data = this.walkRoot(this.rootNode);
}
out.items = data;
// don't clear-up DOM if it was cloned
- if(modules.domUtils.canCloneDocument(this.document) === false) {
+ if (modules.domUtils.canCloneDocument(this.document) === false) {
this.clearUpDom(this.rootNode);
}
}
// find any rels
- if(this.findRels) {
+ if (this.findRels) {
rels = this.findRels(this.rootNode);
out.rels = rels.rels;
out['rel-urls'] = rels['rel-urls'];
}
}
- if(this.errors.length > 0) {
+ if (this.errors.length > 0) {
return this.formatError();
}
return out;
},
/**
* parse to get parent microformat of passed node
@@ -125,17 +125,17 @@ var Microformats; // jshint ignore:line
* @param {DOM Node} node
* @param {Object} options
* @return {Object}
*/
getParent: function(node, options) {
this.init();
options = (options)? options : {};
- if(node) {
+ if (node) {
return this.getParentTreeWalk(node, options);
}
this.errors.push(this.noContentErr);
return this.formatError();
},
/**
@@ -151,40 +151,40 @@ var Microformats; // jshint ignore:line
x,
i;
this.init();
options = (options)? options : {};
this.getDOMContext( options );
// if we do not have any context create error
- if(!this.rootNode || !this.document) {
+ if (!this.rootNode || !this.document) {
return {'errors': [this.noContentErr]};
}
items = this.findRootNodes( this.rootNode, true );
i = items.length;
- while(i--) {
+ while (i--) {
classItems = modules.domUtils.getAttributeList(items[i], 'class');
x = classItems.length;
- while(x--) {
+ while (x--) {
// find v2 names
- if(modules.utils.startWith( classItems[x], 'h-' )) {
+ if (modules.utils.startWith( classItems[x], 'h-' )) {
this.appendCount(classItems[x], 1, out);
}
// find v1 names
- for(var key in modules.maps) {
+ for (var key in modules.maps) {
// dont double count if v1 and v2 roots are present
- if(modules.maps[key].root === classItems[x] && classItems.indexOf(key) === -1) {
+ if (modules.maps[key].root === classItems[x] && classItems.indexOf(key) === -1) {
this.appendCount(key, 1, out);
}
}
}
}
var relCount = this.countRels( this.rootNode );
- if(relCount > 0) {
+ if (relCount > 0) {
out.rels = relCount;
}
return out;
},
/**
@@ -193,29 +193,29 @@ var Microformats; // jshint ignore:line
* @param {DOM Node} node
* @param {Objecte} options
* @return {Boolean}
*/
isMicroformat: function( node, options ) {
var classes,
i;
- if(!node) {
+ if (!node) {
return false;
}
// if documemt gets topmost node
node = modules.domUtils.getTopMostNode( node );
// look for h-* microformats
classes = this.getUfClassNames(node);
- if(options && options.filters && modules.utils.isArray(options.filters)) {
+ if (options && options.filters && modules.utils.isArray(options.filters)) {
i = options.filters.length;
- while(i--) {
- if(classes.root.indexOf(options.filters[i]) > -1) {
+ while (i--) {
+ if (classes.root.indexOf(options.filters[i]) > -1) {
return true;
}
}
return false;
}
return (classes.root.length > 0);
},
@@ -226,46 +226,46 @@ var Microformats; // jshint ignore:line
* @param {DOM Node} node
* @param {Objecte} options
* @return {Boolean}
*/
hasMicroformats: function( node, options ) {
var items,
i;
- if(!node) {
+ if (!node) {
return false;
}
// if browser based documemt get topmost node
node = modules.domUtils.getTopMostNode( node );
// returns all microformat roots
items = this.findRootNodes( node, true );
- if(options && options.filters && modules.utils.isArray(options.filters)) {
+ if (options && options.filters && modules.utils.isArray(options.filters)) {
i = items.length;
- while(i--) {
- if( this.isMicroformat( items[i], options ) ) {
+ while (i--) {
+ if ( this.isMicroformat( items[i], options ) ) {
return true;
}
}
return false;
}
return (items.length > 0);
},
/**
* add a new v1 mapping object to parser
*
* @param {Array} maps
*/
add: function( maps ) {
maps.forEach(function(map) {
- if(map && map.root && map.name && map.properties) {
+ if (map && map.root && map.name && map.properties) {
modules.maps[map.name] = JSON.parse(JSON.stringify(map));
}
});
},
/**
* internal parse to get parent microformats by walking up the tree
@@ -327,42 +327,42 @@ var Microformats; // jshint ignore:line
}
} catch (e) {
// there is no alt action
}
// find base tag to set baseUrl
baseTag = modules.domUtils.querySelector(this.document,'base');
- if(baseTag) {
+ if (baseTag) {
href = modules.domUtils.getAttribute(baseTag, 'href');
- if(href) {
+ if (href) {
this.options.baseUrl = href;
}
}
// get path to rootNode
// then clone document
// then reset the rootNode to its cloned version in a new document
var path,
newDocument,
newRootNode;
path = modules.domUtils.getNodePath(this.rootNode);
newDocument = modules.domUtils.cloneDocument(this.document);
newRootNode = modules.domUtils.getNodeByPath(newDocument, path);
// check results as early IE fails
- if(newDocument && newRootNode) {
+ if (newDocument && newRootNode) {
this.document = newDocument;
this.rootNode = newRootNode;
}
// add includes
- if(this.addIncludes) {
+ if (this.addIncludes) {
this.addIncludes( this.document );
}
return (this.rootNode && this.document);
},
/**
@@ -388,41 +388,41 @@ var Microformats; // jshint ignore:line
'rels': {},
'rel-urls': {}
};
},
// find microformats of a given type and return node structures
findFilterNodes: function(rootNode, filters) {
- if(modules.utils.isString(filters)) {
+ if (modules.utils.isString(filters)) {
filters = [filters];
}
var newRootNode = modules.domUtils.createNode('div'),
items = this.findRootNodes(rootNode, true),
i = 0,
x = 0,
y = 0;
// add v1 names
y = filters.length;
while (y--) {
- if(this.getMapping(filters[y])) {
+ if (this.getMapping(filters[y])) {
var v1Name = this.getMapping(filters[y]).root;
filters.push(v1Name);
}
}
- if(items) {
+ if (items) {
i = items.length;
- while(x < i) {
+ while (x < i) {
// append matching nodes into newRootNode
y = filters.length;
while (y--) {
- if(modules.domUtils.hasAttributeValue(items[x], 'class', filters[y])) {
+ if (modules.domUtils.hasAttributeValue(items[x], 'class', filters[y])) {
var clone = modules.domUtils.clone(items[x]);
modules.domUtils.appendChild(newRootNode, clone);
break;
}
}
x++;
}
}
@@ -434,38 +434,38 @@ var Microformats; // jshint ignore:line
/**
* appends data to output object for count
*
* @param {string} name
* @param {Int} count
* @param {Object}
*/
appendCount: function(name, count, out) {
- if(out[name]) {
+ if (out[name]) {
out[name] = out[name] + count;
- }else{
+ } else {
out[name] = count;
}
},
/**
* is the microformats type in the filter list
*
* @param {Object} uf
* @param {Array} filters
* @return {Boolean}
*/
shouldInclude: function(uf, filters) {
var i;
- if(modules.utils.isArray(filters) && filters.length > 0) {
+ if (modules.utils.isArray(filters) && filters.length > 0) {
i = filters.length;
- while(i--) {
- if(uf.type[0] === filters[i]) {
+ while (i--) {
+ if (uf.type[0] === filters[i]) {
return true;
}
}
return false;
}
return true;
},
@@ -484,48 +484,48 @@ var Microformats; // jshint ignore:line
items,
x,
i,
y,
key;
// build an array of v1 root names
- for(key in modules.maps) {
+ for (key in modules.maps) {
if (modules.maps.hasOwnProperty(key)) {
classList.push(modules.maps[key].root);
}
}
// get all elements that have a class attribute
includeRoot = (includeRoot) ? includeRoot : false;
- if(includeRoot && rootNode.parentNode) {
+ if (includeRoot && rootNode.parentNode) {
arr = modules.domUtils.getNodesByAttribute(rootNode.parentNode, 'class');
} else {
arr = modules.domUtils.getNodesByAttribute(rootNode, 'class');
}
// loop elements that have a class attribute
x = 0;
i = arr.length;
- while(x < i) {
+ while (x < i) {
items = modules.domUtils.getAttributeList(arr[x], 'class');
// loop classes on an element
y = items.length;
- while(y--) {
+ while (y--) {
// match v1 root names
- if(classList.indexOf(items[y]) > -1) {
+ if (classList.indexOf(items[y]) > -1) {
out.push(arr[x]);
break;
}
// match v2 root name prefix
- if(modules.utils.startWith(items[y], 'h-')) {
+ if (modules.utils.startWith(items[y], 'h-')) {
out.push(arr[x]);
break;
}
}
x++;
}
return out;
@@ -543,30 +543,30 @@ var Microformats; // jshint ignore:line
children = [],
child,
classes,
items = [],
out = [];
classes = this.getUfClassNames(node);
// if it is a root microformat node
- if(classes && classes.root.length > 0) {
+ if (classes && classes.root.length > 0) {
items = this.walkTree(node);
- if(items.length > 0) {
+ if (items.length > 0) {
out = out.concat(items);
}
- }else{
+ } else {
// check if there are children and one of the children has a root microformat
children = modules.domUtils.getChildren( node );
- if(children && children.length > 0 && this.findRootNodes(node, true).length > -1) {
+ if (children && children.length > 0 && this.findRootNodes(node, true).length > -1) {
for (var i = 0; i < children.length; i++) {
child = children[i];
items = context.walkRoot(child);
- if(items.length > 0) {
+ if (items.length > 0) {
out = out.concat(items);
}
}
}
}
return out;
},
@@ -580,24 +580,24 @@ var Microformats; // jshint ignore:line
walkTree: function(node) {
var classes,
out = [],
obj,
itemRootID;
// loop roots found on one element
classes = this.getUfClassNames(node);
- if(classes && classes.root.length && classes.root.length > 0) {
+ if (classes && classes.root.length && classes.root.length > 0) {
this.rootID++;
itemRootID = this.rootID;
obj = this.createUfObject(classes.root, classes.typeVersion);
this.walkChildren(node, obj, classes.root, itemRootID, classes);
- if(this.impliedRules) {
+ if (this.impliedRules) {
this.impliedRules(node, obj, classes);
}
out.push( this.cleanUfObject(obj) );
}
return out;
},
@@ -625,139 +625,139 @@ var Microformats; // jshint ignore:line
y,
z,
child;
children = modules.domUtils.getChildren( node );
y = 0;
z = children.length;
- while(y < z) {
+ while (y < z) {
child = children[y];
// get microformat classes for this single element
var classes = context.getUfClassNames(child, ufName);
// a property which is a microformat
- if(classes.root.length > 0 && classes.properties.length > 0 && !child.addedAsRoot) {
+ if (classes.root.length > 0 && classes.properties.length > 0 && !child.addedAsRoot) {
// create object with type, property and value
rootItem = context.createUfObject(
classes.root,
classes.typeVersion,
modules.text.parse(this.document, child, context.options.textFormat)
);
// add the microformat as an array of properties
propertyName = context.removePropPrefix(classes.properties[0][0]);
// modifies value with "implied value rule"
- if(parentClasses && parentClasses.root.length === 1 && parentClasses.properties.length === 1) {
- if(context.impliedValueRule) {
+ if (parentClasses && parentClasses.root.length === 1 && parentClasses.properties.length === 1) {
+ if (context.impliedValueRule) {
out = context.impliedValueRule(out, parentClasses.properties[0][0], classes.properties[0][0], value);
}
}
- if(out.properties[propertyName]) {
+ if (out.properties[propertyName]) {
out.properties[propertyName].push(rootItem);
} else {
out.properties[propertyName] = [rootItem];
}
context.rootID++;
// used to stop duplication in heavily nested structures
child.addedAsRoot = true;
x = 0;
i = rootItem.type.length;
itemRootID = context.rootID;
- while(x < i) {
+ while (x < i) {
context.walkChildren(child, rootItem, rootItem.type, itemRootID, classes);
x++;
}
- if(this.impliedRules) {
+ if (this.impliedRules) {
context.impliedRules(child, rootItem, classes);
}
this.cleanUfObject(rootItem);
}
// a property which is NOT a microformat and has not been used for a given root element
- if(classes.root.length === 0 && classes.properties.length > 0) {
+ if (classes.root.length === 0 && classes.properties.length > 0) {
x = 0;
i = classes.properties.length;
- while(x < i) {
+ while (x < i) {
value = context.getValue(child, classes.properties[x][0], out);
propertyName = context.removePropPrefix(classes.properties[x][0]);
propertyVersion = classes.properties[x][1];
// modifies value with "implied value rule"
- if(parentClasses && parentClasses.root.length === 1 && parentClasses.properties.length === 1) {
- if(context.impliedValueRule) {
+ if (parentClasses && parentClasses.root.length === 1 && parentClasses.properties.length === 1) {
+ if (context.impliedValueRule) {
out = context.impliedValueRule(out, parentClasses.properties[0][0], classes.properties[x][0], value);
}
}
// if we have not added this value into a property with the same name already
- if(!context.hasRootID(child, rootID, propertyName)) {
+ if (!context.hasRootID(child, rootID, propertyName)) {
// check the root and property is the same version or if overlapping versions are allowed
- if( context.isAllowedPropertyVersion( out.typeVersion, propertyVersion ) ) {
+ if ( context.isAllowedPropertyVersion( out.typeVersion, propertyVersion ) ) {
// add the property as an array of properties
- if(out.properties[propertyName]) {
+ if (out.properties[propertyName]) {
out.properties[propertyName].push(value);
} else {
out.properties[propertyName] = [value];
}
// add rootid to node so we can track its use
context.appendRootID(child, rootID, propertyName);
}
}
x++;
}
context.walkChildren(child, out, ufName, rootID, classes);
}
// if the node has no microformat classes, see if its children have
- if(classes.root.length === 0 && classes.properties.length === 0) {
+ if (classes.root.length === 0 && classes.properties.length === 0) {
context.walkChildren(child, out, ufName, rootID, classes);
}
// if the node is a child root add it to the children tree
- if(classes.root.length > 0 && classes.properties.length === 0) {
+ if (classes.root.length > 0 && classes.properties.length === 0) {
// create object with type, property and value
rootItem = context.createUfObject(
classes.root,
classes.typeVersion,
modules.text.parse(this.document, child, context.options.textFormat)
);
// add the microformat as an array of properties
- if(!out.children) {
+ if (!out.children) {
out.children = [];
}
- if(!context.hasRootID(child, rootID, 'child-root')) {
+ if (!context.hasRootID(child, rootID, 'child-root')) {
out.children.push( rootItem );
context.appendRootID(child, rootID, 'child-root');
context.rootID++;
}
x = 0;
i = rootItem.type.length;
itemRootID = context.rootID;
- while(x < i) {
+ while (x < i) {
context.walkChildren(child, rootItem, rootItem.type, itemRootID, classes);
x++;
}
- if(this.impliedRules) {
+ if (this.impliedRules) {
context.impliedRules(child, rootItem, classes);
}
context.cleanUfObject( rootItem );
}
@@ -775,73 +775,73 @@ var Microformats; // jshint ignore:line
* @param {DOM Node} node
* @param {String} className
* @param {Object} uf
* @return {String || Object}
*/
getValue: function(node, className, uf) {
var value = '';
- if(modules.utils.startWith(className, 'p-')) {
+ if (modules.utils.startWith(className, 'p-')) {
value = this.getPValue(node, true);
}
- if(modules.utils.startWith(className, 'e-')) {
+ if (modules.utils.startWith(className, 'e-')) {
value = this.getEValue(node);
}
- if(modules.utils.startWith(className, 'u-')) {
+ if (modules.utils.startWith(className, 'u-')) {
value = this.getUValue(node, true);
}
- if(modules.utils.startWith(className, 'dt-')) {
+ if (modules.utils.startWith(className, 'dt-')) {
value = this.getDTValue(node, className, uf, true);
}
return value;
},
/**
* gets the value of a node which contains a 'p-' property
*
* @param {DOM Node} node
* @param {Boolean} valueParse
* @return {String}
*/
getPValue: function(node, valueParse) {
var out = '';
- if(valueParse) {
+ if (valueParse) {
out = this.getValueClass(node, 'p');
}
- if(!out && valueParse) {
+ if (!out && valueParse) {
out = this.getValueTitle(node);
}
- if(!out) {
+ if (!out) {
out = modules.domUtils.getAttrValFromTagList(node, ['abbr'], 'title');
}
- if(!out) {
+ if (!out) {
out = modules.domUtils.getAttrValFromTagList(node, ['data','input'], 'value');
}
- if(node.name === 'br' || node.name === 'hr') {
+ if (node.name === 'br' || node.name === 'hr') {
out = '';
}
- if(!out) {
+ if (!out) {
out = modules.domUtils.getAttrValFromTagList(node, ['img', 'area'], 'alt');
}
- if(!out) {
+ if (!out) {
out = modules.text.parse(this.document, node, this.options.textFormat);
}
- return(out) ? out : '';
+ return (out) ? out : '';
},
/**
* gets the value of a node which contains the 'e-' property
*
* @param {DOM Node} node
* @return {Object}
@@ -864,125 +864,125 @@ var Microformats; // jshint ignore:line
* gets the value of a node which contains the 'u-' property
*
* @param {DOM Node} node
* @param {Boolean} valueParse
* @return {String}
*/
getUValue: function(node, valueParse) {
var out = '';
- if(valueParse) {
+ if (valueParse) {
out = this.getValueClass(node, 'u');
}
- if(!out && valueParse) {
+ if (!out && valueParse) {
out = this.getValueTitle(node);
}
- if(!out) {
+ if (!out) {
out = modules.domUtils.getAttrValFromTagList(node, ['a', 'area'], 'href');
}
- if(!out) {
+ if (!out) {
out = modules.domUtils.getAttrValFromTagList(node, ['img','audio','video','source'], 'src');
}
- if(!out) {
+ if (!out) {
out = modules.domUtils.getAttrValFromTagList(node, ['object'], 'data');
}
// if we have no protocol separator, turn relative url to absolute url
- if(out && out !== '' && out.indexOf('://') === -1) {
+ if (out && out !== '' && out.indexOf('://') === -1) {
out = modules.url.resolve(out, this.options.baseUrl);
}
- if(!out) {
+ if (!out) {
out = modules.domUtils.getAttrValFromTagList(node, ['abbr'], 'title');
}
- if(!out) {
+ if (!out) {
out = modules.domUtils.getAttrValFromTagList(node, ['data','input'], 'value');
}
- if(!out) {
+ if (!out) {
out = modules.text.parse(this.document, node, this.options.textFormat);
}
- return(out) ? out : '';
+ return (out) ? out : '';
},
/**
* gets the value of a node which contains the 'dt-' property
*
* @param {DOM Node} node
* @param {String} className
* @param {Object} uf
* @param {Boolean} valueParse
* @return {String}
*/
getDTValue: function(node, className, uf, valueParse) {
var out = '';
- if(valueParse) {
+ if (valueParse) {
out = this.getValueClass(node, 'dt');
}
- if(!out && valueParse) {
+ if (!out && valueParse) {
out = this.getValueTitle(node);
}
- if(!out) {
+ if (!out) {
out = modules.domUtils.getAttrValFromTagList(node, ['time', 'ins', 'del'], 'datetime');
}
- if(!out) {
+ if (!out) {
out = modules.domUtils.getAttrValFromTagList(node, ['abbr'], 'title');
}
- if(!out) {
+ if (!out) {
out = modules.domUtils.getAttrValFromTagList(node, ['data', 'input'], 'value');
}
- if(!out) {
+ if (!out) {
out = modules.text.parse(this.document, node, this.options.textFormat);
}
- if(out) {
- if(modules.dates.isDuration(out)) {
+ if (out) {
+ if (modules.dates.isDuration(out)) {
// just duration
return out;
- } else if(modules.dates.isTime(out)) {
+ } else if (modules.dates.isTime(out)) {
// just time or time+timezone
- if(uf) {
+ if (uf) {
uf.times.push([className, modules.dates.parseAmPmTime(out, this.options.dateFormat)]);
}
return modules.dates.parseAmPmTime(out, this.options.dateFormat);
}
// returns a date - microformat profile
- if(uf) {
+ if (uf) {
uf.dates.push([className, new modules.ISODate(out).toString( this.options.dateFormat )]);
}
return new modules.ISODate(out).toString( this.options.dateFormat );
}
return '';
},
/**
* appends a new rootid to a given node
*
* @param {DOM Node} node
* @param {String} id
* @param {String} propertyName
*/
appendRootID: function(node, id, propertyName) {
- if(this.hasRootID(node, id, propertyName) === false) {
+ if (this.hasRootID(node, id, propertyName) === false) {
var rootids = [];
- if(modules.domUtils.hasAttribute(node,'rootids')) {
+ if (modules.domUtils.hasAttribute(node,'rootids')) {
rootids = modules.domUtils.getAttributeList(node,'rootids');
}
rootids.push('id' + id + '-' + propertyName);
modules.domUtils.setAttribute(node, 'rootids', rootids.join(' '));
}
},
@@ -991,17 +991,17 @@ var Microformats; // jshint ignore:line
*
* @param {DOM Node} node
* @param {String} id
* @param {String} propertyName
* @return {Boolean}
*/
hasRootID: function(node, id, propertyName) {
var rootids = [];
- if(!modules.domUtils.hasAttribute(node,'rootids')) {
+ if (!modules.domUtils.hasAttribute(node,'rootids')) {
return false;
}
rootids = modules.domUtils.getAttributeList(node, 'rootids');
return (rootids.indexOf('id' + id + '-' + propertyName) > -1);
},
@@ -1019,45 +1019,45 @@ var Microformats; // jshint ignore:line
child,
x,
i;
children = modules.domUtils.getChildren( node );
x = 0;
i = children.length;
- while(x < i) {
+ while (x < i) {
child = children[x];
var value = null;
- if(modules.domUtils.hasAttributeValue(child, 'class', 'value')) {
- switch(propertyType) {
+ if (modules.domUtils.hasAttributeValue(child, 'class', 'value')) {
+ switch (propertyType) {
case 'p':
value = context.getPValue(child, false);
break;
case 'u':
value = context.getUValue(child, false);
break;
case 'dt':
value = context.getDTValue(child, '', null, false);
break;
}
- if(value) {
+ if (value) {
out.push(modules.utils.trim(value));
}
}
x++;
}
- if(out.length > 0) {
- if(propertyType === 'p') {
+ if (out.length > 0) {
+ if (propertyType === 'p') {
return modules.text.parseText( this.document, out.join(' '), this.options.textFormat);
}
- if(propertyType === 'u') {
+ if (propertyType === 'u') {
return out.join('');
}
- if(propertyType === 'dt') {
+ if (propertyType === 'dt') {
return modules.dates.concatFragments(out,this.options.dateFormat).toString(this.options.dateFormat);
}
return undefined;
}
return null;
},
@@ -1072,35 +1072,35 @@ var Microformats; // jshint ignore:line
var out = [],
items,
i,
x;
items = modules.domUtils.getNodesByAttributeValue(node, 'class', 'value-title');
x = 0;
i = items.length;
- while(x < i) {
- if(modules.domUtils.hasAttribute(items[x], 'title')) {
+ while (x < i) {
+ if (modules.domUtils.hasAttribute(items[x], 'title')) {
out.push(modules.domUtils.getAttribute(items[x], 'title'));
}
x++;
}
return out.join('');
},
/**
* finds out whether a node has h-* class v1 and v2
*
* @param {DOM Node} node
* @return {Boolean}
*/
hasHClass: function(node) {
var classes = this.getUfClassNames(node);
- if(classes.root && classes.root.length > 0) {
+ if (classes.root && classes.root.length > 0) {
return true;
}
return false;
},
/**
* get both the root and property class names from a node
@@ -1126,98 +1126,98 @@ var Microformats; // jshint ignore:line
map,
prop,
propName,
v2Name,
impiedRel,
ufName;
// don't get classes from excluded list of tags
- if(modules.domUtils.hasTagName(node, this.excludeTags) === false) {
+ if (modules.domUtils.hasTagName(node, this.excludeTags) === false) {
// find classes for node
classNames = modules.domUtils.getAttribute(node, 'class');
- if(classNames) {
+ if (classNames) {
items = classNames.split(' ');
x = 0;
i = items.length;
- while(x < i) {
+ while (x < i) {
item = modules.utils.trim(items[x]);
// test for root prefix - v2
- if(modules.utils.startWith(item, context.rootPrefix)) {
- if(out.root.indexOf(item) === -1) {
+ if (modules.utils.startWith(item, context.rootPrefix)) {
+ if (out.root.indexOf(item) === -1) {
out.root.push(item);
}
out.typeVersion = 'v2';
}
// test for property prefix - v2
z = context.propertyPrefixes.length;
- while(z--) {
- if(modules.utils.startWith(item, context.propertyPrefixes[z])) {
+ while (z--) {
+ if (modules.utils.startWith(item, context.propertyPrefixes[z])) {
out.properties.push([item,'v2']);
}
}
// test for mapped root classnames v1
- for(key in modules.maps) {
- if(modules.maps.hasOwnProperty(key)) {
+ for (key in modules.maps) {
+ if (modules.maps.hasOwnProperty(key)) {
// only add a root once
- if(modules.maps[key].root === item && out.root.indexOf(key) === -1) {
+ if (modules.maps[key].root === item && out.root.indexOf(key) === -1) {
// if root map has subTree set to true
// test to see if we should create a property or root
- if(modules.maps[key].subTree) {
+ if (modules.maps[key].subTree) {
out.properties.push(['p-' + modules.maps[key].root, 'v1']);
} else {
out.root.push(key);
- if(!out.typeVersion) {
+ if (!out.typeVersion) {
out.typeVersion = 'v1';
}
}
}
}
}
// test for mapped property classnames v1
- if(ufNameArr) {
+ if (ufNameArr) {
for (var a = 0; a < ufNameArr.length; a++) {
ufName = ufNameArr[a];
// get mapped property v1 microformat
map = context.getMapping(ufName);
- if(map) {
- for(key in map.properties) {
+ if (map) {
+ for (key in map.properties) {
if (map.properties.hasOwnProperty(key)) {
prop = map.properties[key];
propName = (prop.map) ? prop.map : 'p-' + key;
- if(key === item) {
- if(prop.uf) {
+ if (key === item) {
+ if (prop.uf) {
// loop all the classList make sure
// 1. this property is a root
// 2. that there is not already an equivalent v2 property i.e. url and u-url on the same element
y = 0;
- while(y < i) {
+ while (y < i) {
v2Name = context.getV2RootName(items[y]);
// add new root
- if(prop.uf.indexOf(v2Name) > -1 && out.root.indexOf(v2Name) === -1) {
+ if (prop.uf.indexOf(v2Name) > -1 && out.root.indexOf(v2Name) === -1) {
out.root.push(v2Name);
out.typeVersion = 'v1';
}
y++;
}
//only add property once
- if(out.properties.indexOf(propName) === -1) {
+ if (out.properties.indexOf(propName) === -1) {
out.properties.push([propName,'v1']);
}
} else {
- if(out.properties.indexOf(propName) === -1) {
+ if (out.properties.indexOf(propName) === -1) {
out.properties.push([propName,'v1']);
}
}
}
}
}
}
@@ -1228,21 +1228,21 @@ var Microformats; // jshint ignore:line
x++;
}
}
}
// finds any alt rel=* mappings for a given node/microformat
- if(ufNameArr && this.findRelImpied) {
+ if (ufNameArr && this.findRelImpied) {
for (var b = 0; b < ufNameArr.length; b++) {
ufName = ufNameArr[b];
impiedRel = this.findRelImpied(node, ufName);
- if(impiedRel && out.properties.indexOf(impiedRel) === -1) {
+ if (impiedRel && out.properties.indexOf(impiedRel) === -1) {
out.properties.push([impiedRel, 'v1']);
}
}
}
//if(out.root.length === 1 && out.properties.length === 1) {
// if(out.root[0].replace('h-','') === this.removePropPrefix(out.properties[0][0])) {
@@ -1257,51 +1257,51 @@ var Microformats; // jshint ignore:line
/**
* given a v1 or v2 root name, return mapping object
*
* @param {String} name
* @return {Object || null}
*/
getMapping: function(name) {
var key;
- for(key in modules.maps) {
- if(modules.maps[key].root === name || key === name) {
+ for (key in modules.maps) {
+ if (modules.maps[key].root === name || key === name) {
return modules.maps[key];
}
}
return null;
},
/**
* given a v1 root name returns a v2 root name i.e. vcard >>> h-card
*
* @param {String} name
* @return {String || null}
*/
getV2RootName: function(name) {
var key;
- for(key in modules.maps) {
- if(modules.maps[key].root === name) {
+ for (key in modules.maps) {
+ if (modules.maps[key].root === name) {
return key;
}
}
return null;
},
/**
* whether a property is the right microformats version for its root type
*
* @param {String} typeVersion
* @param {String} propertyVersion
* @return {Boolean}
*/
isAllowedPropertyVersion: function(typeVersion, propertyVersion) {
- if(this.options.overlappingVersions === true) {
+ if (this.options.overlappingVersions === true) {
return true;
}
return (typeVersion === propertyVersion);
},
/**
* creates a blank microformats object
@@ -1309,21 +1309,21 @@ var Microformats; // jshint ignore:line
* @param {String} name
* @param {String} value
* @return {Object}
*/
createUfObject: function(names, typeVersion, value) {
var out = {};
// is more than just whitespace
- if(value && modules.utils.isOnlyWhiteSpace(value) === false) {
+ if (value && modules.utils.isOnlyWhiteSpace(value) === false) {
out.value = value;
}
// add type i.e. ["h-card", "h-org"]
- if(modules.utils.isArray(names)) {
+ if (modules.utils.isArray(names)) {
out.type = names;
} else {
out.type = [names];
}
out.properties = {};
// metadata properties for parsing
out.typeVersion = typeVersion;
out.times = [];
@@ -1354,19 +1354,19 @@ var Microformats; // jshint ignore:line
*
* @param {String} text
* @return {String}
*/
removePropPrefix: function(text) {
var i;
i = this.propertyPrefixes.length;
- while(i--) {
+ while (i--) {
var prefix = this.propertyPrefixes[i];
- if(modules.utils.startWith(text, prefix)) {
+ if (modules.utils.startWith(text, prefix)) {
text = text.substr(prefix.length);
}
}
return text;
},
/**
@@ -1379,41 +1379,41 @@ var Microformats; // jshint ignore:line
expandURLs: function(node, attrName, baseUrl) {
var i,
nodes,
attr;
nodes = modules.domUtils.getNodesByAttribute(node, attrName);
i = nodes.length;
while (i--) {
- try{
+ try {
// the url parser can blow up if the format is not right
attr = modules.domUtils.getAttribute(nodes[i], attrName);
- if(attr && attr !== '' && baseUrl !== '' && attr.indexOf('://') === -1) {
+ if (attr && attr !== '' && baseUrl !== '' && attr.indexOf('://') === -1) {
//attr = urlParser.resolve(baseUrl, attr);
attr = modules.url.resolve(attr, baseUrl);
modules.domUtils.setAttribute(nodes[i], attrName, attr);
}
- }catch(err) {
+ } catch (err) {
// do nothing - convert only the urls we can, leave the rest as they are
}
}
},
/**
* merges passed and default options -single level clone of properties
*
* @param {Object} options
*/
mergeOptions: function(options) {
var key;
- for(key in options) {
- if(options.hasOwnProperty(key)) {
+ for (key in options) {
+ if (options.hasOwnProperty(key)) {
this.options[key] = options[key];
}
}
},
/**
* removes all rootid attributes
@@ -1421,74 +1421,74 @@ var Microformats; // jshint ignore:line
* @param {DOM Node} rootNode
*/
removeRootIds: function(rootNode) {
var arr,
i;
arr = modules.domUtils.getNodesByAttribute(rootNode, 'rootids');
i = arr.length;
- while(i--) {
+ while (i--) {
modules.domUtils.removeAttribute(arr[i],'rootids');
}
},
/**
* removes all changes made to the DOM
*
* @param {DOM Node} rootNode
*/
clearUpDom: function(rootNode) {
- if(this.removeIncludes) {
+ if (this.removeIncludes) {
this.removeIncludes(rootNode);
}
this.removeRootIds(rootNode);
}
};
modules.Parser.prototype.constructor = modules.Parser;
// check parser module is loaded
- if(modules.Parser) {
+ if (modules.Parser) {
/**
* applies "implied rules" microformat output structure i.e. feed-title, name, photo, url and date
*
* @param {DOM Node} node
* @param {Object} uf (microformat output structure)
* @param {Object} parentClasses (classes structure)
* @param {Boolean} impliedPropertiesByVersion
* @return {Object}
*/
modules.Parser.prototype.impliedRules = function(node, uf, parentClasses) {
var typeVersion = (uf.typeVersion)? uf.typeVersion: 'v2';
// TEMP: override to allow v1 implied properties while spec changes
- if(this.options.impliedPropertiesByVersion === false) {
+ if (this.options.impliedPropertiesByVersion === false) {
typeVersion = 'v2';
}
- if(node && uf && uf.properties) {
+ if (node && uf && uf.properties) {
uf = this.impliedBackwardComp( node, uf, parentClasses );
- if(typeVersion === 'v2') {
+ if (typeVersion === 'v2') {
uf = this.impliedhFeedTitle( uf );
uf = this.impliedName( node, uf );
uf = this.impliedPhoto( node, uf );
uf = this.impliedUrl( node, uf );
}
uf = this.impliedValue( node, uf, parentClasses );
uf = this.impliedDate( uf );
// TEMP: flagged while spec changes are put forward
- if(this.options.parseLatLonGeo === true) {
+ if (this.options.parseLatLonGeo === true) {
uf = this.impliedGeo( uf );
}
}
return uf;
};
@@ -1512,26 +1512,26 @@ var Microformats; // jshint ignore:line
.h-x>:only-child>img:only-child[alt]:not[.h-*] <div class="h-card"><span><img src="jane.html" alt="Jane Doe"/></span></div>
.h-x>:only-child>area:only-child[alt]:not[.h-*] <div class="h-card"><span><area href="jane.html" alt="Jane Doe"></area></span></div>
.h-x>:only-child>abbr:only-child[title] <div class="h-card"><span><abbr title="Jane Doe">JD</abbr></span></div>
*/
var name,
value;
- if(!uf.properties.name) {
+ if (!uf.properties.name) {
value = this.getImpliedProperty(node, ['img', 'area', 'abbr'], this.getNameAttr);
var textFormat = this.options.textFormat;
// if no value for tags/properties use text
- if(!value) {
+ if (!value) {
name = [modules.text.parse(this.document, node, textFormat)];
- }else{
+ } else {
name = [modules.text.parseText(this.document, value, textFormat)];
}
- if(name && name[0] !== '') {
+ if (name && name[0] !== '') {
uf.properties.name = name;
}
}
return uf;
};
@@ -1548,21 +1548,21 @@ var Microformats; // jshint ignore:line
img.h-x[src] <img class="h-card" alt="Jane Doe" src="jane.jpeg"/>
object.h-x[data] <object class="h-card" data="jane.jpeg"/>Jane Doe</object>
.h-x>img[src]:only-of-type:not[.h-*] <div class="h-card"><img alt="Jane Doe" src="jane.jpeg"/></div>
.h-x>object[data]:only-of-type:not[.h-*] <div class="h-card"><object data="jane.jpeg"/>Jane Doe</object></div>
.h-x>:only-child>img[src]:only-of-type:not[.h-*] <div class="h-card"><span><img alt="Jane Doe" src="jane.jpeg"/></span></div>
.h-x>:only-child>object[data]:only-of-type:not[.h-*] <div class="h-card"><span><object data="jane.jpeg"/>Jane Doe</object></span></div>
*/
var value;
- if(!uf.properties.photo) {
+ if (!uf.properties.photo) {
value = this.getImpliedProperty(node, ['img', 'object'], this.getPhotoAttr);
- if(value) {
+ if (value) {
// relative to absolute URL
- if(value && value !== '' && this.options.baseUrl !== '' && value.indexOf('://') === -1) {
+ if (value && value !== '' && this.options.baseUrl !== '' && value.indexOf('://') === -1) {
value = modules.url.resolve(value, this.options.baseUrl);
}
uf.properties.photo = [modules.utils.trim(value)];
}
}
return uf;
};
@@ -1578,21 +1578,21 @@ var Microformats; // jshint ignore:line
// implied URL rule
/*
a.h-x[href] <a class="h-card" href="glenn.html">Glenn</a>
area.h-x[href] <area class="h-card" href="glenn.html">Glenn</area>
.h-x>a[href]:only-of-type:not[.h-*] <div class="h-card" ><a href="glenn.html">Glenn</a><p>...</p></div>
.h-x>area[href]:only-of-type:not[.h-*] <div class="h-card" ><area href="glenn.html">Glenn</area><p>...</p></div>
*/
var value;
- if(!uf.properties.url) {
+ if (!uf.properties.url) {
value = this.getImpliedProperty(node, ['a', 'area'], this.getURLAttr);
- if(value) {
+ if (value) {
// relative to absolute URL
- if(value && value !== '' && this.options.baseUrl !== '' && value.indexOf('://') === -1) {
+ if (value && value !== '' && this.options.baseUrl !== '' && value.indexOf('://') === -1) {
value = modules.url.resolve(value, this.options.baseUrl);
}
uf.properties.url = [modules.utils.trim(value)];
}
}
return uf;
};
@@ -1604,17 +1604,17 @@ var Microformats; // jshint ignore:line
* @param {Object} uf
* @return {Object}
*/
modules.Parser.prototype.impliedDate = function(uf) {
// implied date rule
// http://microformats.org/wiki/value-class-pattern#microformats2_parsers
// http://microformats.org/wiki/microformats2-parsing-issues#implied_date_for_dt_properties_both_mf2_and_backcompat
var newDate;
- if(uf.times.length > 0 && uf.dates.length > 0) {
+ if (uf.times.length > 0 && uf.dates.length > 0) {
newDate = modules.dates.dateTimeUnion(uf.dates[0][1], uf.times[0][1], this.options.dateFormat);
uf.properties[this.removePropPrefix(uf.times[0][0])][0] = newDate.toString(this.options.dateFormat);
}
// clean-up object
delete uf.times;
delete uf.dates;
return uf;
};
@@ -1629,28 +1629,28 @@ var Microformats; // jshint ignore:line
* @return {String || null}
*/
modules.Parser.prototype.getImpliedProperty = function(node, tagList, getAttrFunction) {
// i.e. img.h-card
var value = getAttrFunction(node),
descendant,
child;
- if(!value) {
+ if (!value) {
// i.e. .h-card>img:only-of-type:not(.h-card)
descendant = modules.domUtils.getSingleDescendantOfType( node, tagList);
- if(descendant && this.hasHClass(descendant) === false) {
+ if (descendant && this.hasHClass(descendant) === false) {
value = getAttrFunction(descendant);
}
- if(node.children.length > 0 ) {
+ if (node.children.length > 0 ) {
// i.e. .h-card>:only-child>img:only-of-type:not(.h-card)
child = modules.domUtils.getSingleDescendant(node);
- if(child && this.hasHClass(child) === false) {
+ if (child && this.hasHClass(child) === false) {
descendant = modules.domUtils.getSingleDescendantOfType(child, tagList);
- if(descendant && this.hasHClass(descendant) === false) {
+ if (descendant && this.hasHClass(descendant) === false) {
value = getAttrFunction(descendant);
}
}
}
}
return value;
};
@@ -1659,50 +1659,50 @@ var Microformats; // jshint ignore:line
/**
* get an implied name value from a node
*
* @param {DOM Node} node
* @return {String || null}
*/
modules.Parser.prototype.getNameAttr = function(node) {
var value = modules.domUtils.getAttrValFromTagList(node, ['img','area'], 'alt');
- if(!value) {
+ if (!value) {
value = modules.domUtils.getAttrValFromTagList(node, ['abbr'], 'title');
}
return value;
};
/**
* get an implied photo value from a node
*
* @param {DOM Node} node
* @return {String || null}
*/
modules.Parser.prototype.getPhotoAttr = function(node) {
var value = modules.domUtils.getAttrValFromTagList(node, ['img'], 'src');
- if(!value && modules.domUtils.hasAttributeValue(node, 'class', 'include') === false) {
+ if (!value && modules.domUtils.hasAttributeValue(node, 'class', 'include') === false) {
value = modules.domUtils.getAttrValFromTagList(node, ['object'], 'data');
}
return value;
};
/**
* get an implied photo value from a node
*
* @param {DOM Node} node
* @return {String || null}
*/
modules.Parser.prototype.getURLAttr = function(node) {
var value = null;
- if(modules.domUtils.hasAttributeValue(node, 'class', 'include') === false) {
+ if (modules.domUtils.hasAttributeValue(node, 'class', 'include') === false) {
value = modules.domUtils.getAttrValFromTagList(node, ['a'], 'href');
- if(!value) {
+ if (!value) {
value = modules.domUtils.getAttrValFromTagList(node, ['area'], 'href');
}
}
return value;
};
@@ -1711,31 +1711,31 @@ var Microformats; // jshint ignore:line
*
* @param {DOM Node} node
* @param {Object} uf
* @return {Object}
*/
modules.Parser.prototype.impliedValue = function(node, uf, parentClasses) {
// intersection of implied name and implied value rules
- if(uf.properties.name) {
- if(uf.value && parentClasses.root.length > 0 && parentClasses.properties.length === 1) {
+ if (uf.properties.name) {
+ if (uf.value && parentClasses.root.length > 0 && parentClasses.properties.length === 1) {
uf = this.getAltValue(uf, parentClasses.properties[0][0], 'p-name', uf.properties.name[0]);
}
}
// intersection of implied URL and implied value rules
- if(uf.properties.url) {
- if(parentClasses && parentClasses.root.length === 1 && parentClasses.properties.length === 1) {
+ if (uf.properties.url) {
+ if (parentClasses && parentClasses.root.length === 1 && parentClasses.properties.length === 1) {
uf = this.getAltValue(uf, parentClasses.properties[0][0], 'u-url', uf.properties.url[0]);
}
}
// apply alt value
- if(uf.altValue !== null) {
+ if (uf.altValue !== null) {
uf.value = uf.altValue.value;
}
delete uf.altValue;
return uf;
};
@@ -1745,47 +1745,47 @@ var Microformats; // jshint ignore:line
*
* @param {Object} uf
* @param {String} parentPropertyName
* @param {String} propertyName
* @param {String} value
* @return {Object}
*/
modules.Parser.prototype.getAltValue = function(uf, parentPropertyName, propertyName, value) {
- if(uf.value && !uf.altValue) {
+ if (uf.value && !uf.altValue) {
// first p-name of the h-* child
- if(modules.utils.startWith(parentPropertyName,'p-') && propertyName === 'p-name') {
+ if (modules.utils.startWith(parentPropertyName,'p-') && propertyName === 'p-name') {
uf.altValue = {name: propertyName, value: value};
}
// if it's an e-* property element
- if(modules.utils.startWith(parentPropertyName,'e-') && modules.utils.startWith(propertyName,'e-')) {
+ if (modules.utils.startWith(parentPropertyName,'e-') && modules.utils.startWith(propertyName,'e-')) {
uf.altValue = {name: propertyName, value: value};
}
// if it's an u-* property element
- if(modules.utils.startWith(parentPropertyName,'u-') && propertyName === 'u-url') {
+ if (modules.utils.startWith(parentPropertyName,'u-') && propertyName === 'u-url') {
uf.altValue = {name: propertyName, value: value};
}
}
return uf;
};
/**
* if a h-feed does not have a title use the title tag of a page
*
* @param {Object} uf
* @return {Object}
*/
modules.Parser.prototype.impliedhFeedTitle = function( uf ) {
- if(uf.type && uf.type.indexOf('h-feed') > -1) {
+ if (uf.type && uf.type.indexOf('h-feed') > -1) {
// has no name property
- if(uf.properties.name === undefined || uf.properties.name[0] === '' ) {
+ if (uf.properties.name === undefined || uf.properties.name[0] === '' ) {
// use the text from the title tag
var title = modules.domUtils.querySelector(this.document, 'title');
- if(title) {
+ if (title) {
uf.properties.name = [modules.domUtils.textContent(title)];
}
}
}
return uf;
};
@@ -1798,48 +1798,48 @@ var Microformats; // jshint ignore:line
*/
modules.Parser.prototype.impliedGeo = function( uf ) {
var geoPair,
parts,
longitude,
latitude,
valid = true;
- if(uf.type && uf.type.indexOf('h-geo') > -1) {
+ if (uf.type && uf.type.indexOf('h-geo') > -1) {
// has no latitude or longitude property
- if(uf.properties.latitude === undefined || uf.properties.longitude === undefined ) {
+ if (uf.properties.latitude === undefined || uf.properties.longitude === undefined ) {
geoPair = (uf.properties.name)? uf.properties.name[0] : null;
geoPair = (!geoPair && uf.properties.value)? uf.properties.value : geoPair;
- if(geoPair) {
+ if (geoPair) {
// allow for the use of a ';' as in microformats and also ',' as in Geo URL
geoPair = geoPair.replace(';',',');
// has sep char
- if(geoPair.indexOf(',') > -1 ) {
+ if (geoPair.indexOf(',') > -1 ) {
parts = geoPair.split(',');
// only correct if we have two or more parts
- if(parts.length > 1) {
+ if (parts.length > 1) {
// latitude no value outside the range -90 or 90
latitude = parseFloat( parts[0] );
- if(modules.utils.isNumber(latitude) && latitude > 90 || latitude < -90) {
+ if (modules.utils.isNumber(latitude) && latitude > 90 || latitude < -90) {
valid = false;
}
// longitude no value outside the range -180 to 180
longitude = parseFloat( parts[1] );
- if(modules.utils.isNumber(longitude) && longitude > 180 || longitude < -180) {
+ if (modules.utils.isNumber(longitude) && longitude > 180 || longitude < -180) {
valid = false;
}
- if(valid) {
+ if (valid) {
uf.properties.latitude = [latitude];
uf.properties.longitude = [longitude];
}
}
}
}
}
@@ -1853,37 +1853,37 @@ var Microformats; // jshint ignore:line
*
* @param {Object} uf
* @return {Object}
*/
modules.Parser.prototype.impliedBackwardComp = function(node, uf, parentClasses) {
// look for pattern in parent classes like "p-geo h-geo"
// these are structures built from backwards compat parsing of geo
- if(parentClasses.root.length === 1 && parentClasses.properties.length === 1) {
- if(parentClasses.root[0].replace('h-','') === this.removePropPrefix(parentClasses.properties[0][0])) {
+ if (parentClasses.root.length === 1 && parentClasses.properties.length === 1) {
+ if (parentClasses.root[0].replace('h-','') === this.removePropPrefix(parentClasses.properties[0][0])) {
// if microformat has no properties apply the impliedName rule to get value from containing node
// this will get value from html such as <abbr class="geo" title="30.267991;-97.739568">Brighton</abbr>
- if( modules.utils.hasProperties(uf.properties) === false ) {
+ if ( modules.utils.hasProperties(uf.properties) === false ) {
uf = this.impliedName( node, uf );
}
}
}
return uf;
};
}
// check parser module is loaded
- if(modules.Parser) {
+ if (modules.Parser) {
/**
* appends clones of include Nodes into the DOM structure
*
* @param {DOM node} rootNode
*/
modules.Parser.prototype.addIncludes = function(rootNode) {
@@ -1905,22 +1905,22 @@ var Microformats; // jshint ignore:line
i,
x,
z,
y;
arr = modules.domUtils.getNodesByAttribute(rootNode, attributeName);
x = 0;
i = arr.length;
- while(x < i) {
+ while (x < i) {
idList = modules.domUtils.getAttributeList(arr[x], attributeName);
- if(idList) {
+ if (idList) {
z = 0;
y = idList.length;
- while(z < y) {
+ while (z < y) {
this.apppendInclude(arr[x], idList[z]);
z++;
}
}
x++;
}
};
@@ -1933,19 +1933,19 @@ var Microformats; // jshint ignore:line
modules.Parser.prototype.addClassIncludes = function(rootNode) {
var id,
arr,
x = 0,
i;
arr = modules.domUtils.getNodesByAttributeValue(rootNode, 'class', 'include');
i = arr.length;
- while(x < i) {
+ while (x < i) {
id = modules.domUtils.getAttrValFromTagList(arr[x], ['a'], 'href');
- if(!id) {
+ if (!id) {
id = modules.domUtils.getAttrValFromTagList(arr[x], ['object'], 'data');
}
this.apppendInclude(arr[x], id);
x++;
}
};
@@ -1956,17 +1956,17 @@ var Microformats; // jshint ignore:line
* @param {Stringe} id
*/
modules.Parser.prototype.apppendInclude = function(node, id) {
var include,
clone;
id = modules.utils.trim(id.replace('#', ''));
include = modules.domUtils.getElementById(this.document, id);
- if(include) {
+ if (include) {
clone = modules.domUtils.clone(include);
this.markIncludeChildren(clone);
modules.domUtils.appendChild(node, clone);
}
};
/**
@@ -1980,17 +1980,17 @@ var Microformats; // jshint ignore:line
i;
// loop the array and add the attribute
arr = this.findRootNodes(rootNode);
x = 0;
i = arr.length;
modules.domUtils.setAttribute(rootNode, 'data-include', 'true');
modules.domUtils.setAttribute(rootNode, 'style', 'display:none');
- while(x < i) {
+ while (x < i) {
modules.domUtils.setAttribute(arr[x], 'data-include', 'true');
x++;
}
};
/**
* removes all appended include clones from DOM
@@ -1999,27 +1999,27 @@ var Microformats; // jshint ignore:line
*/
modules.Parser.prototype.removeIncludes = function(rootNode) {
var arr,
i;
// remove all the items that were added as includes
arr = modules.domUtils.getNodesByAttribute(rootNode, 'data-include');
i = arr.length;
- while(i--) {
+ while (i--) {
modules.domUtils.removeChild(rootNode,arr[i]);
}
};
}
// check parser module is loaded
- if(modules.Parser) {
+ if (modules.Parser) {
/**
* finds rel=* structures
*
* @param {DOM node} rootNode
* @return {Object}
*/
modules.Parser.prototype.findRels = function(rootNode) {
@@ -2036,66 +2036,66 @@ var Microformats; // jshint ignore:line
items,
item,
value,
arr;
arr = modules.domUtils.getNodesByAttribute(rootNode, 'rel');
x = 0;
i = arr.length;
- while(x < i) {
+ while (x < i) {
relList = modules.domUtils.getAttribute(arr[x], 'rel');
- if(relList) {
+ if (relList) {
items = relList.split(' ');
// add rels
z = 0;
y = items.length;
- while(z < y) {
+ while (z < y) {
item = modules.utils.trim(items[z]);
// get rel value
value = modules.domUtils.getAttrValFromTagList(arr[x], ['a', 'area'], 'href');
- if(!value) {
+ if (!value) {
value = modules.domUtils.getAttrValFromTagList(arr[x], ['link'], 'href');
}
// create the key
- if(!out.rels[item]) {
+ if (!out.rels[item]) {
out.rels[item] = [];
}
- if(typeof this.options.baseUrl === 'string' && typeof value === 'string') {
+ if (typeof this.options.baseUrl === 'string' && typeof value === 'string') {
var resolved = modules.url.resolve(value, this.options.baseUrl);
// do not add duplicate rels - based on resolved URLs
- if(out.rels[item].indexOf(resolved) === -1) {
+ if (out.rels[item].indexOf(resolved) === -1) {
out.rels[item].push( resolved );
}
}
z++;
}
var url = null;
- if(modules.domUtils.hasAttribute(arr[x], 'href')) {
+ if (modules.domUtils.hasAttribute(arr[x], 'href')) {
url = modules.domUtils.getAttribute(arr[x], 'href');
- if(url) {
+ if (url) {
url = modules.url.resolve(url, this.options.baseUrl );
}
}
// add to rel-urls
var relUrl = this.getRelProperties(arr[x]);
relUrl.rels = items;
// // do not add duplicate rel-urls - based on resolved URLs
- if(url && out['rel-urls'][url] === undefined) {
+ if (url && out['rel-urls'][url] === undefined) {
out['rel-urls'][url] = relUrl;
}
}
x++;
}
return out;
@@ -2106,29 +2106,29 @@ var Microformats; // jshint ignore:line
* gets the properties of a rel=*
*
* @param {DOM node} node
* @return {Object}
*/
modules.Parser.prototype.getRelProperties = function(node) {
var obj = {};
- if(modules.domUtils.hasAttribute(node, 'media')) {
+ if (modules.domUtils.hasAttribute(node, 'media')) {
obj.media = modules.domUtils.getAttribute(node, 'media');
}
- if(modules.domUtils.hasAttribute(node, 'type')) {
+ if (modules.domUtils.hasAttribute(node, 'type')) {
obj.type = modules.domUtils.getAttribute(node, 'type');
}
- if(modules.domUtils.hasAttribute(node, 'hreflang')) {
+ if (modules.domUtils.hasAttribute(node, 'hreflang')) {
obj.hreflang = modules.domUtils.getAttribute(node, 'hreflang');
}
- if(modules.domUtils.hasAttribute(node, 'title')) {
+ if (modules.domUtils.hasAttribute(node, 'title')) {
obj.title = modules.domUtils.getAttribute(node, 'title');
}
- if(modules.utils.trim(this.getPValue(node, false)) !== '') {
+ if (modules.utils.trim(this.getPValue(node, false)) !== '') {
obj.text = this.getPValue(node, false);
}
return obj;
};
/**
@@ -2139,32 +2139,32 @@ var Microformats; // jshint ignore:line
* @return {String || undefined}
*/
modules.Parser.prototype.findRelImpied = function(node, ufName) {
var out,
map,
i;
map = this.getMapping(ufName);
- if(map) {
- for(var key in map.properties) {
+ if (map) {
+ for (var key in map.properties) {
if (map.properties.hasOwnProperty(key)) {
var prop = map.properties[key],
propName = (prop.map) ? prop.map : 'p-' + key,
relCount = 0;
// is property an alt rel=* mapping
- if(prop.relAlt && modules.domUtils.hasAttribute(node, 'rel')) {
+ if (prop.relAlt && modules.domUtils.hasAttribute(node, 'rel')) {
i = prop.relAlt.length;
- while(i--) {
- if(modules.domUtils.hasAttributeValue(node, 'rel', prop.relAlt[i])) {
+ while (i--) {
+ if (modules.domUtils.hasAttributeValue(node, 'rel', prop.relAlt[i])) {
relCount++;
}
}
- if(relCount === prop.relAlt.length) {
+ if (relCount === prop.relAlt.length) {
out = propName;
}
}
}
}
}
return out;
};
@@ -2183,17 +2183,17 @@ var Microformats; // jshint ignore:line
/**
* returns the number of rel=* microformats
*
* @param {DOM node} node
* @return {Int}
*/
modules.Parser.prototype.countRels = function(node) {
- if(node) {
+ if (node) {
return modules.domUtils.getNodesByAttribute(node, 'rel').length;
}
return 0;
};
}
@@ -2247,76 +2247,76 @@ var Microformats; // jshint ignore:line
/**
* does the text start with a test string
*
* @param {String} text
* @param {String} test
* @return {Boolean}
*/
startWith: function( text, test ) {
- return(text.indexOf(test) === 0);
+ return (text.indexOf(test) === 0);
},
/**
* removes spaces at front and back of text
*
* @param {String} text
* @return {String}
*/
trim: function( text ) {
- if(text && this.isString(text)) {
+ if (text && this.isString(text)) {
return (text.trim())? text.trim() : text.replace(/^\s+|\s+$/g, '');
}
return '';
},
/**
* replaces a character in text
*
* @param {String} text
* @param {Int} index
* @param {String} character
* @return {String}
*/
replaceCharAt: function( text, index, character ) {
- if(text && text.length > index) {
+ if (text && text.length > index) {
return text.substr(0, index) + character + text.substr(index+character.length);
}
return text;
},
/**
* removes whitespace, tabs and returns from start and end of text
*
* @param {String} text
* @return {String}
*/
trimWhitespace: function( text ) {
- if(text && text.length) {
+ if (text && text.length) {
var i = text.length,
x = 0;
// turn all whitespace chars at end into spaces
while (i--) {
- if(this.isOnlyWhiteSpace(text[i])) {
+ if (this.isOnlyWhiteSpace(text[i])) {
text = this.replaceCharAt( text, i, ' ' );
- }else{
+ } else {
break;
}
}
// turn all whitespace chars at start into spaces
i = text.length;
while (x < i) {
- if(this.isOnlyWhiteSpace(text[x])) {
+ if (this.isOnlyWhiteSpace(text[x])) {
text = this.replaceCharAt( text, i, ' ' );
- }else{
+ } else {
break;
}
x++;
}
}
return this.trim(text);
},
@@ -2346,18 +2346,18 @@ var Microformats; // jshint ignore:line
/**
* does an object have any of its own properties
*
* @param {Object} obj
* @return {Boolean}
*/
hasProperties: function( obj ) {
var key;
- for(key in obj) {
- if( obj.hasOwnProperty( key ) ) {
+ for (key in obj) {
+ if ( obj.hasOwnProperty( key ) ) {
return true;
}
}
return false;
},
/**
@@ -2415,49 +2415,49 @@ var Microformats; // jshint ignore:line
* configures what are the base DOM objects for parsing
*
* @param {Object} options
* @return {DOM Node} node
*/
getDOMContext: function( options ) {
// if a node is passed
- if(options.node) {
+ if (options.node) {
this.rootNode = options.node;
}
// if a html string is passed
- if(options.html) {
+ if (options.html) {
//var domParser = new DOMParser();
var domParser = this.getDOMParser();
this.rootNode = domParser.parseFromString( options.html, 'text/html' );
}
// find top level document from rootnode
- if(this.rootNode !== null) {
- if(this.rootNode.nodeType === 9) {
+ if (this.rootNode !== null) {
+ if (this.rootNode.nodeType === 9) {
this.document = this.rootNode;
this.rootNode = modules.domUtils.querySelector(this.rootNode, 'html');
- }else{
+ } else {
// if it's DOM node get parent DOM Document
this.document = modules.domUtils.ownerDocument(this.rootNode);
}
}
// use global document object
- if(!this.rootNode && document) {
+ if (!this.rootNode && document) {
this.rootNode = modules.domUtils.querySelector(document, 'html');
this.document = document;
}
- if(this.rootNode && this.document) {
+ if (this.rootNode && this.document) {
return {document: this.document, rootNode: this.rootNode};
}
return {document: null, rootNode: null};
},
@@ -2490,19 +2490,19 @@ var Microformats; // jshint ignore:line
/**
* abstracts DOM textContent
*
* @param {DOM Node} node
* @return {String}
*/
textContent: function(node) {
- if(node.textContent) {
+ if (node.textContent) {
return node.textContent;
- }else if(node.innerText) {
+ } else if (node.innerText) {
return node.innerText;
}
return '';
},
/**
* abstracts DOM innerHTML
@@ -2606,18 +2606,18 @@ var Microformats; // jshint ignore:line
* @param {String} attributeName
* @return {Array}
*/
getAttributeList: function(node, attributeName) {
var out = [],
attList;
attList = node.getAttribute(attributeName);
- if(attList && attList !== '') {
- if(attList.indexOf(' ') > -1) {
+ if (attList && attList !== '') {
+ if (attList.indexOf(' ') > -1) {
out = attList.split(' ');
} else {
out.push(attList);
}
}
return out;
},
@@ -2644,20 +2644,20 @@ var Microformats; // jshint ignore:line
*/
getNodesByAttributeValue: function(rootNode, name, value) {
var arr = [],
x = 0,
i,
out = [];
arr = this.getNodesByAttribute(rootNode, name);
- if(arr) {
+ if (arr) {
i = arr.length;
- while(x < i) {
- if(this.hasAttributeValue(arr[x], name, value)) {
+ while (x < i) {
+ if (this.hasAttributeValue(arr[x], name, value)) {
out.push(arr[x]);
}
x++;
}
}
return out;
},
@@ -2667,20 +2667,20 @@ var Microformats; // jshint ignore:line
*
* @param {Array} tagNames
* @param {String} attributeName
* @return {String || null}
*/
getAttrValFromTagList: function(node, tagNames, attributeName) {
var i = tagNames.length;
- while(i--) {
- if(node.tagName.toLowerCase() === tagNames[i]) {
+ while (i--) {
+ if (node.tagName.toLowerCase() === tagNames[i]) {
var attrValue = this.getAttribute(node, attributeName);
- if(attrValue && attrValue !== '') {
+ if (attrValue && attrValue !== '') {
return attrValue;
}
}
}
return null;
},
@@ -2717,50 +2717,50 @@ var Microformats; // jshint ignore:line
*/
getDescendant: function( node, tagNames, onlyOfType ) {
var i = node.children.length,
countAll = 0,
countOfType = 0,
child,
out = null;
- while(i--) {
+ while (i--) {
child = node.children[i];
- if(child.nodeType === 1) {
- if(tagNames) {
+ if (child.nodeType === 1) {
+ if (tagNames) {
// count just only-of-type
- if(this.hasTagName(child, tagNames)) {
+ if (this.hasTagName(child, tagNames)) {
out = child;
countOfType++;
}
- }else{
+ } else {
// count all elements
out = child;
countAll++;
}
}
}
- if(onlyOfType === true) {
+ if (onlyOfType === true) {
return (countOfType === 1)? out : null;
}
return (countAll === 1)? out : null;
},
/**
* is a node one of a list of tags
*
* @param {DOM Node} rootNode
* @param {Array} tagNames
* @return {Boolean}
*/
hasTagName: function(node, tagNames) {
var i = tagNames.length;
- while(i--) {
- if(node.tagName.toLowerCase() === tagNames[i]) {
+ while (i--) {
+ if (node.tagName.toLowerCase() === tagNames[i]) {
return true;
}
}
return false;
},
/**
@@ -2804,17 +2804,17 @@ var Microformats; // jshint ignore:line
/**
* gets the text of a node
*
* @param {DOM Node} node
* @return {String}
*/
getElementText: function( node ) {
- if(node && node.data) {
+ if (node && node.data) {
return node.data;
}
return '';
},
/**
* gets the attributes of a node - ordered by sequence in html
@@ -2854,17 +2854,17 @@ var Microformats; // jshint ignore:line
*
* @param {DOM Document} document
* @return {DOM Document}
*/
cloneDocument: function( document ) {
var newNode,
newDocument = null;
- if( this.canCloneDocument( document )) {
+ if ( this.canCloneDocument( document )) {
newDocument = document.implementation.createHTMLDocument('');
newNode = newDocument.importNode( document.documentElement, true );
newDocument.replaceChild(newNode, newDocument.querySelector('html'));
}
return (newNode && newNode.nodeType && newNode.nodeType === 1)? newDocument : document;
},
@@ -2904,18 +2904,18 @@ var Microformats; // jshint ignore:line
* @param {DOM Node} node
* @return {Array}
*/
getNodePath: function (node) {
var parent = node.parentNode,
path = [],
index = this.getChildIndex(node);
- if(parent && (path = this.getNodePath(parent))) {
- if(index > -1) {
+ if (parent && (path = this.getNodePath(parent))) {
+ if (index > -1) {
path.push(index);
}
}
return path;
},
/**
@@ -2997,41 +2997,41 @@ var Microformats; // jshint ignore:line
* resolves url to absolute version using baseUrl
*
* @param {String} url
* @param {String} baseUrl
* @return {String}
*/
resolve: function(url, baseUrl) {
// use modern URL web API where we can
- if(modules.utils.isString(url) && modules.utils.isString(baseUrl) && url.indexOf('://') === -1) {
+ if (modules.utils.isString(url) && modules.utils.isString(baseUrl) && url.indexOf('://') === -1) {
// this try catch is required as IE has an URL object but no constuctor support
// http://glennjones.net/articles/the-problem-with-window-url
try {
var resolved = new URL(url, baseUrl).toString();
// deal with early Webkit not throwing an error - for Safari
- if(resolved === '[object URL]') {
+ if (resolved === '[object URL]') {
resolved = URI.resolve(baseUrl, url);
}
return resolved;
- }catch(e) {
+ } catch (e) {
// otherwise fallback to DOM
- if(this._domParser === undefined) {
+ if (this._domParser === undefined) {
this.init();
}
// do not use setAttribute it does not work with IE9
this._baseNode.href = baseUrl;
this._linkNode.href = url;
// dont use getAttribute as it returns orginal value not resolved
return this._linkNode.href;
}
- }else{
- if(modules.utils.isString(url)) {
+ } else {
+ if (modules.utils.isString(url)) {
return url;
}
return '';
}
},
};
@@ -3046,17 +3046,17 @@ var Microformats; // jshint ignore:line
*/
modules.ISODate = function ( dateString, format ) {
this.clear();
this.format = (format)? format : 'auto'; // auto or W3C or RFC3339 or HTML5
this.setFormatSep();
// optional should be full iso date/time string
- if(arguments[0]) {
+ if (arguments[0]) {
this.parse(dateString, format);
}
};
modules.ISODate.prototype = {
@@ -3135,81 +3135,81 @@ var Microformats; // jshint ignore:line
var parts = [],
tzArray = [],
position = 0,
datePart = '',
timePart = '',
timeZonePart = '';
- if(format) {
+ if (format) {
this.format = format;
}
// discover date time separtor for auto profile
// Set to 'T' by default
- if(dateString.indexOf('t') > -1) {
+ if (dateString.indexOf('t') > -1) {
this.autoProfile.sep = 't';
}
- if(dateString.indexOf('z') > -1) {
+ if (dateString.indexOf('z') > -1) {
this.autoProfile.tzZulu = 'z';
}
- if(dateString.indexOf('Z') > -1) {
+ if (dateString.indexOf('Z') > -1) {
this.autoProfile.tzZulu = 'Z';
}
- if(dateString.toUpperCase().indexOf('T') === -1) {
+ if (dateString.toUpperCase().indexOf('T') === -1) {
this.autoProfile.sep = ' ';
}
dateString = dateString.toUpperCase().replace(' ','T');
// break on 'T' divider or space
- if(dateString.indexOf('T') > -1) {
+ if (dateString.indexOf('T') > -1) {
parts = dateString.split('T');
datePart = parts[0];
timePart = parts[1];
// zulu UTC
- if(timePart.indexOf( 'Z' ) > -1) {
+ if (timePart.indexOf( 'Z' ) > -1) {
this.z = true;
}
// timezone
- if(timePart.indexOf( '+' ) > -1 || timePart.indexOf( '-' ) > -1) {
+ if (timePart.indexOf( '+' ) > -1 || timePart.indexOf( '-' ) > -1) {
tzArray = timePart.split( 'Z' ); // incase of incorrect use of Z
timePart = tzArray[0];
timeZonePart = tzArray[1];
// timezone
- if(timePart.indexOf( '+' ) > -1 || timePart.indexOf( '-' ) > -1) {
+ if (timePart.indexOf( '+' ) > -1 || timePart.indexOf( '-' ) > -1) {
position = 0;
- if(timePart.indexOf( '+' ) > -1) {
+ if (timePart.indexOf( '+' ) > -1) {
position = timePart.indexOf( '+' );
} else {
position = timePart.indexOf( '-' );
}
timeZonePart = timePart.substring( position, timePart.length );
timePart = timePart.substring( 0, position );
}
}
} else {
datePart = dateString;
}
- if(datePart !== '') {
+ if (datePart !== '') {
this.parseDate( datePart );
- if(timePart !== '') {
+ if (timePart !== '') {
this.parseTime( timePart );
- if(timeZonePart !== '') {
+ if (timeZonePart !== '') {
this.parseTimeZone( timeZonePart );
}
}
}
return this.toString( format );
},
@@ -3221,41 +3221,41 @@ var Microformats; // jshint ignore:line
* @return {String}
*/
parseDate: function( dateString, format ) {
this.clearDate();
var parts = [];
// discover timezone separtor for auto profile // default is ':'
- if(dateString.indexOf('-') === -1) {
+ if (dateString.indexOf('-') === -1) {
this.autoProfile.tsep = '';
}
// YYYY-DDD
parts = dateString.match( /(\d\d\d\d)-(\d\d\d)/ );
- if(parts) {
- if(parts[1]) {
+ if (parts) {
+ if (parts[1]) {
this.dY = parts[1];
}
- if(parts[2]) {
+ if (parts[2]) {
this.dDDD = parts[2];
}
}
- if(this.dDDD === -1) {
+ if (this.dDDD === -1) {
// YYYY-MM-DD ie 2008-05-01 and YYYYMMDD ie 20080501
parts = dateString.match( /(\d\d\d\d)?-?(\d\d)?-?(\d\d)?/ );
- if(parts[1]) {
+ if (parts[1]) {
this.dY = parts[1];
}
- if(parts[2]) {
+ if (parts[2]) {
this.dM = parts[2];
}
- if(parts[3]) {
+ if (parts[3]) {
this.dD = parts[3];
}
}
return this.toString(format);
},
/**
@@ -3265,32 +3265,32 @@ var Microformats; // jshint ignore:line
* @param {String} format
* @return {String}
*/
parseTime: function( timeString, format ) {
this.clearTime();
var parts = [];
// discover date separtor for auto profile // default is ':'
- if(timeString.indexOf(':') === -1) {
+ if (timeString.indexOf(':') === -1) {
this.autoProfile.tsep = '';
}
// finds timezone HH:MM:SS and HHMMSS ie 13:30:45, 133045 and 13:30:45.0135
parts = timeString.match( /(\d\d)?:?(\d\d)?:?(\d\d)?.?([0-9]+)?/ );
- if(parts[1]) {
+ if (parts[1]) {
this.tH = parts[1];
}
- if(parts[2]) {
+ if (parts[2]) {
this.tM = parts[2];
}
- if(parts[3]) {
+ if (parts[3]) {
this.tS = parts[3];
}
- if(parts[4]) {
+ if (parts[4]) {
this.tD = parts[4];
}
return this.toTimeString(format);
},
/**
* parses text to find just the time element of an ISO date/time string i.e. +08:00
@@ -3298,36 +3298,36 @@ var Microformats; // jshint ignore:line
* @param {String} timeString
* @param {String} format
* @return {String}
*/
parseTimeZone: function( timeString, format ) {
this.clearTimeZone();
var parts = [];
- if(timeString.toLowerCase() === 'z') {
+ if (timeString.toLowerCase() === 'z') {
this.z = true;
// set case for z
this.autoProfile.tzZulu = (timeString === 'z')? 'z' : 'Z';
- }else{
+ } else {
// discover timezone separtor for auto profile // default is ':'
- if(timeString.indexOf(':') === -1) {
+ if (timeString.indexOf(':') === -1) {
this.autoProfile.tzsep = '';
}
// finds timezone +HH:MM and +HHMM ie +13:30 and +1330
parts = timeString.match( /([\-\+]{1})?(\d\d)?:?(\d\d)?/ );
- if(parts[1]) {
+ if (parts[1]) {
this.tzPN = parts[1];
}
- if(parts[2]) {
+ if (parts[2]) {
this.tzH = parts[2];
}
- if(parts[3]) {
+ if (parts[3]) {
this.tzM = parts[3];
}
}
this.tzZulu = 'z';
return this.toTimeString( format );
},
@@ -3337,36 +3337,36 @@ var Microformats; // jshint ignore:line
* returns ISO date/time string in W3C Note, RFC 3339, HTML5, or auto profile
*
* @param {String} format
* @return {String}
*/
toString: function( format ) {
var output = '';
- if(format) {
+ if (format) {
this.format = format;
}
this.setFormatSep();
- if(this.dY > -1) {
+ if (this.dY > -1) {
output = this.dY;
- if(this.dM > 0 && this.dM < 13) {
+ if (this.dM > 0 && this.dM < 13) {
output += this.dsep + this.dM;
- if(this.dD > 0 && this.dD < 32) {
+ if (this.dD > 0 && this.dD < 32) {
output += this.dsep + this.dD;
- if(this.tH > -1 && this.tH < 25) {
+ if (this.tH > -1 && this.tH < 25) {
output += this.sep + this.toTimeString( format );
}
}
}
- if(this.dDDD > -1) {
+ if (this.dDDD > -1) {
output += this.dsep + this.dDDD;
}
- } else if(this.tH > -1) {
+ } else if (this.tH > -1) {
output += this.toTimeString( format );
}
return output;
},
/**
@@ -3374,60 +3374,60 @@ var Microformats; // jshint ignore:line
* in W3C Note, RFC 3339, HTML5, or auto profile
*
* @param {String} format
* @return {String}
*/
toTimeString: function( format ) {
var out = '';
- if(format) {
+ if (format) {
this.format = format;
}
this.setFormatSep();
// time can only be created with a full date
- if(this.tH) {
- if(this.tH > -1 && this.tH < 25) {
+ if (this.tH) {
+ if (this.tH > -1 && this.tH < 25) {
out += this.tH;
- if(this.tM > -1 && this.tM < 61) {
+ if (this.tM > -1 && this.tM < 61) {
out += this.tsep + this.tM;
- if(this.tS > -1 && this.tS < 61) {
+ if (this.tS > -1 && this.tS < 61) {
out += this.tsep + this.tS;
- if(this.tD > -1) {
+ if (this.tD > -1) {
out += '.' + this.tD;
}
}
}
// time zone offset
- if(this.z) {
+ if (this.z) {
out += this.tzZulu;
} else {
- if(this.tzH && this.tzH > -1 && this.tzH < 25) {
+ if (this.tzH && this.tzH > -1 && this.tzH < 25) {
out += this.tzPN + this.tzH;
- if(this.tzM > -1 && this.tzM < 61) {
+ if (this.tzM > -1 && this.tzM < 61) {
out += this.tzsep + this.tzM;
}
}
}
}
}
return out;
},
/**
* set the current profile to W3C Note, RFC 3339, HTML5, or auto profile
*
*/
setFormatSep: function() {
- switch( this.format.toLowerCase() ) {
+ switch ( this.format.toLowerCase() ) {
case 'rfc3339':
this.sep = 'T';
this.dsep = '';
this.tsep = '';
this.tzsep = '';
this.tzZulu = 'Z';
break;
case 'w3c':
@@ -3456,46 +3456,46 @@ var Microformats; // jshint ignore:line
/**
* does current data contain a full date i.e. 2015-03-23
*
* @return {Boolean}
*/
hasFullDate: function() {
- return(this.dY !== -1 && this.dM !== -1 && this.dD !== -1);
+ return (this.dY !== -1 && this.dM !== -1 && this.dD !== -1);
},
/**
* does current data contain a minimum date which is just a year number i.e. 2015
*
* @return {Boolean}
*/
hasDate: function() {
- return(this.dY !== -1);
+ return (this.dY !== -1);
},
/**
* does current data contain a minimum time which is just a hour number i.e. 13
*
* @return {Boolean}
*/
hasTime: function() {
- return(this.tH !== -1);
+ return (this.tH !== -1);
},
/**
* does current data contain a minimum timezone i.e. -1 || +1 || z
*
* @return {Boolean}
*/
hasTimeZone: function() {
- return(this.tzH !== -1);
+ return (this.tzH !== -1);
}
};
modules.ISODate.prototype.constructor = modules.ISODate;
modules.dates = {
@@ -3504,29 +3504,29 @@ var Microformats; // jshint ignore:line
/**
* does text contain am
*
* @param {String} text
* @return {Boolean}
*/
hasAM: function( text ) {
text = text.toLowerCase();
- return(text.indexOf('am') > -1 || text.indexOf('a.m.') > -1);
+ return (text.indexOf('am') > -1 || text.indexOf('a.m.') > -1);
},
/**
* does text contain pm
*
* @param {String} text
* @return {Boolean}
*/
hasPM: function( text ) {
text = text.toLowerCase();
- return(text.indexOf('pm') > -1 || text.indexOf('p.m.') > -1);
+ return (text.indexOf('pm') > -1 || text.indexOf('p.m.') > -1);
},
/**
* remove am and pm from text and return it
*
* @param {String} text
* @return {String}
@@ -3538,54 +3538,54 @@ var Microformats; // jshint ignore:line
/**
* simple test of whether ISO date string is a duration i.e. PY17M or PW12
*
* @param {String} text
* @return {Boolean}
*/
isDuration: function( text ) {
- if(modules.utils.isString( text )) {
+ if (modules.utils.isString( text )) {
text = text.toLowerCase();
- if(modules.utils.startWith(text, 'p') ) {
+ if (modules.utils.startWith(text, 'p') ) {
return true;
}
}
return false;
},
/**
* is text a time or timezone
* i.e. HH-MM-SS or z+-HH-MM-SS 08:43 | 15:23:00:0567 | 10:34pm | 10:34 p.m. | +01:00:00 | -02:00 | z15:00 | 0843
*
* @param {String} text
* @return {Boolean}
*/
isTime: function( text ) {
- if(modules.utils.isString(text)) {
+ if (modules.utils.isString(text)) {
text = text.toLowerCase();
text = modules.utils.trim( text );
// start with timezone char
- if( text.match(':') && ( modules.utils.startWith(text, 'z') || modules.utils.startWith(text, '-') || modules.utils.startWith(text, '+') )) {
+ if ( text.match(':') && ( modules.utils.startWith(text, 'z') || modules.utils.startWith(text, '-') || modules.utils.startWith(text, '+') )) {
return true;
}
// has ante meridiem or post meridiem
- if( text.match(/^[0-9]/) &&
+ if ( text.match(/^[0-9]/) &&
( this.hasAM(text) || this.hasPM(text) )) {
return true;
}
// contains time delimiter but not datetime delimiter
- if( text.match(':') && !text.match(/t|\s/) ) {
+ if ( text.match(':') && !text.match(/t|\s/) ) {
return true;
}
// if it's a number of 2, 4 or 6 chars
- if(modules.utils.isNumber(text)) {
- if(text.length === 2 || text.length === 4 || text.length === 6) {
+ if (modules.utils.isNumber(text)) {
+ if (text.length === 2 || text.length === 4 || text.length === 6) {
return true;
}
}
}
return false;
},
@@ -3596,44 +3596,44 @@ var Microformats; // jshint ignore:line
* @param {String} text
* @return {String}
*/
parseAmPmTime: function( text ) {
var out = text,
times = [];
// if the string has a text : or am or pm
- if(modules.utils.isString(out)) {
+ if (modules.utils.isString(out)) {
//text = text.toLowerCase();
text = text.replace(/[ ]+/g, '');
- if(text.match(':') || this.hasAM(text) || this.hasPM(text)) {
-
- if(text.match(':')) {
+ if (text.match(':') || this.hasAM(text) || this.hasPM(text)) {
+
+ if (text.match(':')) {
times = text.split(':');
} else {
// single number text i.e. 5pm
times[0] = text;
times[0] = this.removeAMPM(times[0]);
}
// change pm hours to 24hr number
- if(this.hasPM(text)) {
- if(times[0] < 12) {
+ if (this.hasPM(text)) {
+ if (times[0] < 12) {
times[0] = parseInt(times[0], 10) + 12;
}
}
// add leading zero's where needed
- if(times[0] && times[0].length === 1) {
+ if (times[0] && times[0].length === 1) {
times[0] = '0' + times[0];
}
// rejoin text elements together
- if(times[0]) {
+ if (times[0]) {
text = times.join(':');
}
}
}
// remove am/pm strings
return this.removeAMPM(text);
},
@@ -3647,24 +3647,24 @@ var Microformats; // jshint ignore:line
* @param {String} format ( Modules.ISODate profile format )
* @return {Object} Modules.ISODate
*/
dateTimeUnion: function(date, time, format) {
var isodate = new modules.ISODate(date, format),
isotime = new modules.ISODate();
isotime.parseTime(this.parseAmPmTime(time), format);
- if(isodate.hasFullDate() && isotime.hasTime()) {
+ if (isodate.hasFullDate() && isotime.hasTime()) {
isodate.tH = isotime.tH;
isodate.tM = isotime.tM;
isodate.tS = isotime.tS;
isodate.tD = isotime.tD;
return isodate;
}
- if(isodate.hasFullDate()) {
+ if (isodate.hasFullDate()) {
return isodate;
}
return new modules.ISODate();
},
/**
* concatenate an array of date and time text fragments to create an ISODate object
@@ -3675,46 +3675,46 @@ var Microformats; // jshint ignore:line
* @return {Object} Modules.ISODate
*/
concatFragments: function (arr, format) {
var out = new modules.ISODate(),
i = 0,
value = '';
// if the fragment already contains a full date just return it once
- if(arr[0].toUpperCase().match('T')) {
+ if (arr[0].toUpperCase().match('T')) {
return new modules.ISODate(arr[0], format);
}
- for(i = 0; i < arr.length; i++) {
+ for (i = 0; i < arr.length; i++) {
value = arr[i];
// date pattern
- if( value.charAt(4) === '-' && out.hasFullDate() === false ) {
+ if ( value.charAt(4) === '-' && out.hasFullDate() === false ) {
out.parseDate(value);
}
// time pattern
- if( (value.indexOf(':') > -1 || modules.utils.isNumber( this.parseAmPmTime(value) )) && out.hasTime() === false ) {
+ if ( (value.indexOf(':') > -1 || modules.utils.isNumber( this.parseAmPmTime(value) )) && out.hasTime() === false ) {
// split time and timezone
var items = this.splitTimeAndZone(value);
value = items[0];
// parse any use of am/pm
value = this.parseAmPmTime(value);
out.parseTime(value);
// parse any timezone
- if(items.length > 1) {
+ if (items.length > 1) {
out.parseTimeZone(items[1], format);
}
}
// timezone pattern
- if(value.charAt(0) === '-' || value.charAt(0) === '+' || value.toUpperCase() === 'Z') {
- if( out.hasTimeZone() === false ) {
+ if (value.charAt(0) === '-' || value.charAt(0) === '+' || value.toUpperCase() === 'Z') {
+ if ( out.hasTimeZone() === false ) {
out.parseTimeZone(value);
}
}
}
return out;
},
@@ -3726,17 +3726,17 @@ var Microformats; // jshint ignore:line
* @return {Array} Modules.ISODate
*/
splitTimeAndZone: function ( text ) {
var out = [text],
chars = ['-','+','z','Z'],
i = chars.length;
while (i--) {
- if(text.indexOf(chars[i]) > -1) {
+ if (text.indexOf(chars[i]) > -1) {
out[0] = text.slice( 0, text.indexOf(chars[i]) );
out.push( text.slice( text.indexOf(chars[i]) ) );
break;
}
}
return out;
}
@@ -3764,19 +3764,19 @@ var Microformats; // jshint ignore:line
*
* @param {DOM Node} node
* @param {String} textFormat
* @return {String}
*/
parse: function(doc, node, textFormat) {
var out;
this.textFormat = (textFormat)? textFormat : this.textFormat;
- if(this.textFormat === 'normalised') {
+ if (this.textFormat === 'normalised') {
out = this.walkTreeForText( node );
- if(out !== undefined) {
+ if (out !== undefined) {
return this.normalise( doc, out );
}
return '';
}
return this.formatText( doc, modules.domUtils.textContent(node), this.textFormat );
},
@@ -3798,22 +3798,22 @@ var Microformats; // jshint ignore:line
* parses the text from a html string - only for whitespace or whitespacetrimmed formats
*
* @param {String} text
* @param {String} textFormat
* @return {String}
*/
formatText: function( doc, text, textFormat ) {
this.textFormat = (textFormat)? textFormat : this.textFormat;
- if(text) {
+ if (text) {
var out = '',
regex = /(<([^>]+)>)/ig;
out = text.replace(regex, '');
- if(this.textFormat === 'whitespacetrimmed') {
+ if (this.textFormat === 'whitespacetrimmed') {
out = modules.utils.trimWhitespace( out );
}
//return entities.decode( out, 2 );
return modules.domUtils.decodeEntities( doc, out );
}
return '';
},
@@ -3839,37 +3839,37 @@ var Microformats; // jshint ignore:line
*
* @param {DOM Node} node
* @return {String}
*/
walkTreeForText: function( node ) {
var out = '',
j = 0;
- if(node.tagName && this.excludeTags.indexOf( node.tagName.toLowerCase() ) > -1) {
+ if (node.tagName && this.excludeTags.indexOf( node.tagName.toLowerCase() ) > -1) {
return out;
}
// if node is a text node get its text
- if(node.nodeType && node.nodeType === 3) {
+ if (node.nodeType && node.nodeType === 3) {
out += modules.domUtils.getElementText( node );
}
// get the text of the child nodes
- if(node.childNodes && node.childNodes.length > 0) {
+ if (node.childNodes && node.childNodes.length > 0) {
for (j = 0; j < node.childNodes.length; j++) {
var text = this.walkTreeForText( node.childNodes[j] );
- if(text !== undefined) {
+ if (text !== undefined) {
out += text;
}
}
}
// if it's a block level tag add an additional space at the end
- if(node.tagName && this.blockLevelTags.indexOf( node.tagName.toLowerCase() ) !== -1) {
+ if (node.tagName && this.blockLevelTags.indexOf( node.tagName.toLowerCase() ) !== -1) {
out += ' ';
}
return (out === '')? undefined : out ;
}
};
@@ -3886,20 +3886,20 @@ var Microformats; // jshint ignore:line
* @param {DOM Node} node
* @return {String}
*/
parse: function( node ) {
var out = '',
j = 0;
// we do not want the outer container
- if(node.childNodes && node.childNodes.length > 0) {
+ if (node.childNodes && node.childNodes.length > 0) {
for (j = 0; j < node.childNodes.length; j++) {
var text = this.walkTreeForHtml( node.childNodes[j] );
- if(text !== undefined) {
+ if (text !== undefined) {
out += text;
}
}
}
return out;
},
@@ -3911,52 +3911,52 @@ var Microformats; // jshint ignore:line
* @param {DOM Node} node
* @return {String}
*/
walkTreeForHtml: function( node ) {
var out = '',
j = 0;
// if node is a text node get its text
- if(node.nodeType && node.nodeType === 3) {
+ if (node.nodeType && node.nodeType === 3) {
out += modules.domUtils.getElementText( node );
}
// exclude text which has been added with include pattern -
- if(node.nodeType && node.nodeType === 1 && modules.domUtils.hasAttribute(node, 'data-include') === false) {
+ if (node.nodeType && node.nodeType === 1 && modules.domUtils.hasAttribute(node, 'data-include') === false) {
// begin tag
out += '<' + node.tagName.toLowerCase();
// add attributes
var attrs = modules.domUtils.getOrderedAttributes(node);
for (j = 0; j < attrs.length; j++) {
out += ' ' + attrs[j].name + '=' + '"' + attrs[j].value + '"';
}
- if(this.selfClosingElt.indexOf(node.tagName.toLowerCase()) === -1) {
+ if (this.selfClosingElt.indexOf(node.tagName.toLowerCase()) === -1) {
out += '>';
}
// get the text of the child nodes
- if(node.childNodes && node.childNodes.length > 0) {
+ if (node.childNodes && node.childNodes.length > 0) {
for (j = 0; j < node.childNodes.length; j++) {
var text = this.walkTreeForHtml( node.childNodes[j] );
- if(text !== undefined) {
+ if (text !== undefined) {
out += text;
}
}
}
// end tag
- if(this.selfClosingElt.indexOf(node.tagName.toLowerCase()) > -1) {
+ if (this.selfClosingElt.indexOf(node.tagName.toLowerCase()) > -1) {
out += ' />';
- }else{
+ } else {
out += '</' + node.tagName.toLowerCase() + '>';
}
}
return (out === '')? undefined : out;
}
@@ -4501,27 +4501,27 @@ var Microformats; // jshint ignore:line
External.hasMicroformats = function( node, options ) {
var parser = new modules.Parser();
addV1(parser, options);
return parser.hasMicroformats( node, options );
};
function addV1(parser, options) {
- if(options && options.maps) {
- if(Array.isArray(options.maps)) {
+ if (options && options.maps) {
+ if (Array.isArray(options.maps)) {
parser.add(options.maps);
- }else{
+ } else {
parser.add([options.maps]);
}
}
}
return External;
}));
try {
// mozilla jsm support
Components.utils.importGlobalProperties(["URL"]);
-} catch(e) {}
+} catch (e) {}
this.EXPORTED_SYMBOLS = ['Microformats'];
--- a/toolkit/components/microformats/update/update.js
+++ b/toolkit/components/microformats/update/update.js
@@ -39,61 +39,61 @@ var repo = 'glennjones/microformat-shiv'
['/test/module-tests','/test/module-tests'],
['/test/standards-tests','/test/standards-tests'],
['/test/static','/test/static']
];
getLastBuildState( repo, function( err, buildState) {
- if(buildState) {
+ if (buildState) {
console.log('last build state:', buildState);
- if(buildState === 'passed') {
+ if (buildState === 'passed') {
console.log('downloading git repo', repo);
getLastCommitDate( repo, function( err, date) {
- if(date) {
+ if (date) {
console.log( 'last commit:', new Date(date).toString() );
}
});
updateFromRepo();
- }else{
+ } else {
console.log('not updating because of build state is failing please contact Glenn Jones glennjones@gmail.com');
}
- }else{
+ } else {
console.log('could not get build state from travis-ci:', err);
}
});
/**
* updates from directories and files from repo
*
*/
function updateFromRepo() {
download(repo, tempDir, function(err, data) {
// the err and data from download-github-repo give false negatives
- if( fs.existsSync( tempDir ) ) {
+ if ( fs.existsSync( tempDir ) ) {
var version = getRepoVersion();
removeCurrentFiles( pathList, deployDirResolved );
addNewFiles( pathList, deployDirResolved );
fs.removeSync(tempDir);
// changes files for firefox
replaceInFile('/test/module-tests/index.html', /..\/..\/lib\//g, '../lib/' );
addExportedSymbol( '/microformat-shiv.js' );
console.log('microformat-shiv is now uptodate to v' + version);
- }else{
+ } else {
console.log('error getting repo', err);
}
});
}
/**
@@ -127,19 +127,19 @@ function addNewFiles( pathList, deployDi
/**
* gets the repo version number
*
* @return {String}
*/
function getRepoVersion() {
var pack = fs.readFileSync(path.resolve(tempDir,'package.json'), {encoding: 'utf8'});
- if(pack) {
+ if (pack) {
pack = JSON.parse(pack)
- if(pack && pack.version) {
+ if (pack && pack.version) {
return pack.version;
}
}
return '';
}
/**
@@ -156,21 +156,21 @@ function getLastCommitDate( repo, callba
'User-Agent': 'request'
}
};
request(options, function (error, response, body) {
if (!error && response.statusCode == 200) {
var date = null,
json = JSON.parse(body);
- if(json && json.length && json[0].commit && json[0].commit.author ) {
+ if (json && json.length && json[0].commit && json[0].commit.author ) {
date = json[0].commit.author.date;
}
callback(null, date);
- }else{
+ } else {
console.log(error, response, body);
callback('fail to get last commit date', null);
}
});
}
/**
@@ -188,70 +188,70 @@ function getLastBuildState( repo, callba
'Accept': 'application/vnd.travis-ci.2+json'
}
};
request(options, function (error, response, body) {
if (!error && response.statusCode == 200) {
var buildState = null,
json = JSON.parse(body);
- if(json && json.repo && json.repo.last_build_state ) {
+ if (json && json.repo && json.repo.last_build_state ) {
buildState = json.repo.last_build_state;
}
callback(null, buildState);
- }else{
+ } else {
console.log(error, response, body);
callback('fail to get last build state', null);
}
});
}
/**
* adds exported symbol to microformat-shiv.js file
*
* @param {String} path
* @param {String} content
*/
function addExportedSymbol( path ) {
- if(path === '/microformat-shiv.js') {
+ if (path === '/microformat-shiv.js') {
fs.appendFileSync(deployDirResolved + '/microformat-shiv.js', '\r\n' + exportedSymbol + '\r\n');
console.log('appended exported symbol to microformat-shiv.js');
}
}
/**
* adds exported symbol to microformat-shiv.js file
*
* @param {String} path
* @param {String} content
*/
function replaceInFile( path, findStr, replaceStr ) {
readFile(deployDirResolved + path, function(err, fileStr) {
- if(fileStr) {
+ if (fileStr) {
fileStr = fileStr.replace(findStr, replaceStr)
writeFile(deployDirResolved + path, fileStr);
console.log('replaced ' + findStr + ' with ' + replaceStr + ' in ' + path);
- }else{
+ } else {
console.log('error replaced strings in ' + path);
}
})
}
/**
* write a file
*
* @param {String} path
* @param {String} content
*/
function writeFile(path, content) {
fs.writeFile(path, content, 'utf8', function(err) {
- if(err) {
+ if (err) {
console.log(err);
} else {
console.log('The file: ' + path + ' was saved');
}
});
}
--- a/toolkit/components/passwordmgr/LoginHelper.jsm
+++ b/toolkit/components/passwordmgr/LoginHelper.jsm
@@ -575,17 +575,17 @@ this.LoginHelper = {
}
// the login is just an update for an old one or the login is older than an existing one
let foundMatchingLogin = false;
for (let existingLogin of existingLogins) {
if (login.username == existingLogin.username) {
// Bug 1187190: Password changes should be propagated depending on timestamps.
// this an old login or a just an update, so make sure not to add it
foundMatchingLogin = true;
- if(login.password != existingLogin.password &
+ if (login.password != existingLogin.password &
login.timePasswordChanged > existingLogin.timePasswordChanged) {
// if a login with the same username and different password already exists and it's older
// than the current one, that login needs to be updated using the current one details
// the existing login password and timestamps should be updated
let propBag = Cc["@mozilla.org/hash-property-bag;1"].
createInstance(Ci.nsIWritablePropertyBag);
propBag.setProperty("password", login.password);
--- a/toolkit/components/passwordmgr/nsLoginManagerPrompter.js
+++ b/toolkit/components/passwordmgr/nsLoginManagerPrompter.js
@@ -896,17 +896,17 @@ LoginManagerPrompter.prototype = {
};
// The main action is the "Remember" or "Update" button.
let mainAction = {
label: this._getLocalizedString(initialMsgNames.buttonLabel),
accessKey: this._getLocalizedString(initialMsgNames.buttonAccessKey),
callback: () => {
histogram.add(PROMPT_ADD_OR_UPDATE);
- if(histogramName == "PWMGR_PROMPT_REMEMBER_ACTION")
+ if (histogramName == "PWMGR_PROMPT_REMEMBER_ACTION")
{
Services.obs.notifyObservers(null, 'LoginStats:NewSavedPassword', null);
}
readDataFromUI();
persistData();
browser.focus();
}
};
--- a/toolkit/components/passwordmgr/storage-mozStorage.js
+++ b/toolkit/components/passwordmgr/storage-mozStorage.js
@@ -22,17 +22,17 @@ XPCOMUtils.defineLazyModuleGetter(this,
function Transaction(aDatabase) {
this._db = aDatabase;
this._hasTransaction = false;
try {
this._db.beginTransaction();
this._hasTransaction = true;
}
- catch(e) { /* om nom nom exceptions */ }
+ catch (e) { /* om nom nom exceptions */ }
}
Transaction.prototype = {
commit : function() {
if (this._hasTransaction)
this._db.commitTransaction();
},
@@ -578,17 +578,17 @@ LoginManagerStorage_mozStorage.prototype
let stmt = null;
try {
this.log("Storing " + aLogin.guid + " in deleted passwords\n");
let query = "INSERT INTO moz_deleted_logins (guid, timeDeleted) VALUES (:guid, :timeDeleted)";
let params = { guid: aLogin.guid,
timeDeleted: Date.now() };
let stmt = this._dbCreateStatement(query, params);
stmt.execute();
- } catch(ex) {
+ } catch (ex) {
throw ex;
} finally {
if (stmt)
stmt.reset();
}
},
--- a/toolkit/components/passwordmgr/test/notification_common.js
+++ b/toolkit/components/passwordmgr/test/notification_common.js
@@ -102,10 +102,10 @@ function dumpNotifications() {
.QueryInterface(Ci.nsIDocShell)
.chromeEventHandler.ownerDocument.defaultView;
var nb = chromeWin.getNotificationBox(window.top);
notes = nb.allNotifications;
ok(true, "Found " + notes.length + " notification bars.");
for (let i = 0; i < notes.length; i++) {
ok(true, "#" + i + ": " + notes[i].getAttribute("value"));
}
- } catch(e) { todo(false, "WOAH! " + e); }
+ } catch (e) { todo(false, "WOAH! " + e); }
}
--- a/toolkit/components/passwordmgr/test/test_master_password.html
+++ b/toolkit/components/passwordmgr/test/test_master_password.html
@@ -76,17 +76,17 @@ addEventListener("message", () => {
function handleDialog(doc, testNum) {
ok(true, "handleDialog running for test " + testNum);
var clickOK = true;
var doNothing = false;
var passfield = doc.getElementById("password1Textbox");
var dialog = doc.getElementById("commonDialog");
- switch(testNum) {
+ switch (testNum) {
case 1:
is(passfield.getAttribute("value"), "", "Checking empty prompt");
passfield.setAttribute("value", masterPassword);
is(passfield.getAttribute("value"), masterPassword, "Checking filled prompt");
break;
case 2:
clickOK = false;
--- a/toolkit/components/passwordmgr/test/test_xhr.html
+++ b/toolkit/components/passwordmgr/test/test_xhr.html
@@ -53,17 +53,17 @@ function handleDialog(doc, testNum) {
var clickOK = true;
var userfield = doc.getElementById("loginTextbox");
var passfield = doc.getElementById("password1Textbox");
var username = userfield.getAttribute("value");
var password = passfield.getAttribute("value");
var dialog = doc.getElementById("commonDialog");
- switch(testNum) {
+ switch (testNum) {
case 1:
is(username, "xhruser1", "Checking provided username");
is(password, "xhrpass1", "Checking provided password");
break;
case 2:
is(username, "xhruser2", "Checking provided username");
is(password, "xhrpass2", "Checking provided password");
@@ -124,17 +124,17 @@ function xhrLoad(xmlDoc) {
ok(true, "xhrLoad running for test " + testNum);
// The server echos back the user/pass it received.
var username = xmlDoc.getElementById("user").textContent;
var password = xmlDoc.getElementById("pass").textContent;
var authok = xmlDoc.getElementById("ok").textContent;
- switch(testNum) {
+ switch (testNum) {
case 1:
is(username, "xhruser1", "Checking provided username");
is(password, "xhrpass1", "Checking provided password");
break;
case 2:
is(username, "xhruser2", "Checking provided username");
is(password, "xhrpass2", "Checking provided password");
@@ -146,17 +146,17 @@ function xhrLoad(xmlDoc) {
ok(false, "Uhh, unhandled switch for testNum #" + testNum);
break;
}
doTest();
}
function doTest() {
- switch(++testNum) {
+ switch (++testNum) {
case 1:
startCallbackTimer();
makeRequest("authenticate.sjs?user=xhruser1&pass=xhrpass1&realm=xhr");
break;
case 2:
// Test correct parenting, by opening another tab in the foreground,
// and making sure the prompt re-focuses the original tab when shown:
--- a/toolkit/components/passwordmgr/test/test_xml_load.html
+++ b/toolkit/components/passwordmgr/test/test_xml_load.html
@@ -45,17 +45,17 @@ function handleDialog(doc, testNum) {
var clickOK = true;
var userfield = doc.getElementById("loginTextbox");
var passfield = doc.getElementById("password1Textbox");
var username = userfield.getAttribute("value");
var password = passfield.getAttribute("value");
var dialog = doc.getElementById("commonDialog");
- switch(testNum) {
+ switch (testNum) {
case 1:
is(username, "xmluser1", "Checking provided username");
is(password, "xmlpass1", "Checking provided password");
break;
case 2:
is(username, "xmluser2", "Checking provided username");
is(password, "xmlpass2", "Checking provided password");
@@ -114,17 +114,17 @@ var newWin;
function xmlLoad(responseDoc) {
ok(true, "xmlLoad running for test " + testNum);
// The server echos back the user/pass it received.
var username = responseDoc.getElementById("user").textContent;
var password = responseDoc.getElementById("pass").textContent;
var authok = responseDoc.getElementById("ok").textContent;
- switch(testNum) {
+ switch (testNum) {
case 1:
is(username, "xmluser1", "Checking provided username");
is(password, "xmlpass1", "Checking provided password");
break;
case 2:
is(username, "xmluser2", "Checking provided username");
is(password, "xmlpass2", "Checking provided password");
@@ -136,17 +136,17 @@ function xmlLoad(responseDoc) {
ok(false, "Uhh, unhandled switch for testNum #" + testNum);
break;
}
doTest();
}
function doTest() {
- switch(++testNum) {
+ switch (++testNum) {
case 1:
startCallbackTimer();
makeRequest("authenticate.sjs?user=xmluser1&pass=xmlpass1&realm=xml");
break;
case 2:
// Test correct parenting, by opening another tab in the foreground,
// and making sure the prompt re-focuses the original tab when shown:
--- a/toolkit/components/passwordmgr/test/unit/test_OSCrypto_win.js
+++ b/toolkit/components/passwordmgr/test/unit/test_OSCrypto_win.js
@@ -66,12 +66,12 @@ add_task(function test_decryptData_encry
for (let key of keys) {
decryptEncryptTest(key);
}
let url = "https://twitter.com/";
let value = [1, 0, 0, 0, 208, 140, 157, 223, 1, 21, 209, 17, 140, 122, 0, 192, 79, 194, 151, 235, 1, 0, 0, 0, 254, 58, 230, 75, 132, 228, 181, 79, 184, 160, 37, 106, 201, 29, 42, 152, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 16, 102, 0, 0, 0, 1, 0, 0, 32, 0, 0, 0, 90, 136, 17, 124, 122, 57, 178, 24, 34, 86, 209, 198, 184, 107, 58, 58, 32, 98, 61, 239, 129, 101, 56, 239, 114, 159, 139, 165, 183, 40, 183, 85, 0, 0, 0, 0, 14, 128, 0, 0, 0, 2, 0, 0, 32, 0, 0, 0, 147, 170, 34, 21, 53, 227, 191, 6, 201, 84, 106, 31, 57, 227, 46, 127, 219, 199, 80, 142, 37, 104, 112, 223, 26, 165, 223, 55, 176, 89, 55, 37, 112, 0, 0, 0, 98, 70, 221, 109, 5, 152, 46, 11, 190, 213, 226, 58, 244, 20, 180, 217, 63, 155, 227, 132, 7, 151, 235, 6, 37, 232, 176, 182, 141, 191, 251, 50, 20, 123, 53, 11, 247, 233, 112, 121, 130, 27, 168, 68, 92, 144, 192, 7, 12, 239, 53, 217, 253, 155, 54, 109, 236, 216, 225, 245, 79, 234, 165, 225, 104, 36, 77, 13, 195, 237, 143, 165, 100, 107, 230, 70, 54, 19, 179, 35, 8, 101, 93, 202, 121, 210, 222, 28, 93, 122, 36, 84, 185, 249, 238, 3, 102, 149, 248, 94, 137, 16, 192, 22, 251, 220, 22, 223, 16, 58, 104, 187, 64, 0, 0, 0, 70, 72, 15, 119, 144, 66, 117, 203, 190, 82, 131, 46, 111, 130, 238, 191, 170, 63, 186, 117, 46, 88, 171, 3, 94, 146, 75, 86, 243, 159, 63, 195, 149, 25, 105, 141, 42, 217, 108, 18, 63, 62, 98, 182, 241, 195, 12, 216, 152, 230, 176, 253, 202, 129, 41, 185, 135, 111, 226, 92, 27, 78, 27, 198];
let arr1 = crypto.arrayToString(value)
let arr2 = crypto.stringToArray(crypto.decryptData(crypto.encryptData(arr1, url), url));
- for(let i = 0; i < arr1.length; i++) {
+ for (let i = 0; i < arr1.length; i++) {
do_check_eq(arr2[i], value[i]);
}
});
--- a/toolkit/components/places/BookmarkHTMLUtils.jsm
+++ b/toolkit/components/places/BookmarkHTMLUtils.jsm
@@ -142,17 +142,17 @@ this.BookmarkHTMLUtils = Object.freeze({
importFromURL: function BHU_importFromURL(aSpec, aInitialImport) {
return Task.spawn(function* () {
notifyObservers(PlacesUtils.TOPIC_BOOKMARKS_RESTORE_BEGIN, aInitialImport);
try {
let importer = new BookmarkImporter(aInitialImport);
yield importer.importFromURL(aSpec);
notifyObservers(PlacesUtils.TOPIC_BOOKMARKS_RESTORE_SUCCESS, aInitialImport);
- } catch(ex) {
+ } catch (ex) {
Cu.reportError("Failed to import bookmarks from " + aSpec + ": " + ex);
notifyObservers(PlacesUtils.TOPIC_BOOKMARKS_RESTORE_FAILED, aInitialImport);
throw ex;
}
});
},
/**
@@ -181,17 +181,17 @@ this.BookmarkHTMLUtils = Object.freeze({
try {
if (!(yield OS.File.exists(aFilePath))) {
throw new Error("Cannot import from nonexisting html file: " + aFilePath);
}
let importer = new BookmarkImporter(aInitialImport);
yield importer.importFromURL(OS.Path.toFileURI(aFilePath));
notifyObservers(PlacesUtils.TOPIC_BOOKMARKS_RESTORE_SUCCESS, aInitialImport);
- } catch(ex) {
+ } catch (ex) {
Cu.reportError("Failed to import bookmarks from " + aFilePath + ": " + ex);
notifyObservers(PlacesUtils.TOPIC_BOOKMARKS_RESTORE_FAILED, aInitialImport);
throw ex;
}
});
},
/**
@@ -366,24 +366,24 @@ BookmarkImporter.prototype = {
default:
// NOT REACHED
throw new Error("Unreached");
}
if (frame.previousDateAdded > 0) {
try {
PlacesUtils.bookmarks.setItemDateAdded(containerId, frame.previousDateAdded);
- } catch(e) {
+ } catch (e) {
}
frame.previousDateAdded = 0;
}
if (frame.previousLastModifiedDate > 0) {
try {
PlacesUtils.bookmarks.setItemLastModified(containerId, frame.previousLastModifiedDate);
- } catch(e) {
+ } catch (e) {
}
// don't clear last-modified, in case there's a description
}
frame.previousId = containerId;
this._frames.push(new Frame(containerId));
},
@@ -397,17 +397,17 @@ BookmarkImporter.prototype = {
* pre-Places bookmarks did not support them.
*/
_handleSeparator: function handleSeparator(aElt) {
let frame = this._curFrame;
try {
frame.previousId =
PlacesUtils.bookmarks.insertSeparator(frame.containerId,
PlacesUtils.bookmarks.DEFAULT_INDEX);
- } catch(e) {}
+ } catch (e) {}
},
/**
* Handles <H1>. We check for the attribute PLACES_ROOT and reset the
* container id if it's found. Otherwise, the default bookmark menu
* root is assumed and imported things will go into the bookmarks menu.
*/
_handleHead1Begin: function handleHead1Begin(aElt) {
@@ -526,17 +526,17 @@ BookmarkImporter.prototype = {
}
// Ignore <a> tags that have no href.
if (href) {
// Save the address if it's valid. Note that we ignore errors if this is a
// feed since href is optional for them.
try {
frame.previousLink = NetUtil.newURI(href);
- } catch(e) {
+ } catch (e) {
if (!frame.previousFeed) {
frame.previousLink = null;
return;
}
}
} else {
frame.previousLink = null;
// The exception is for feeds, where the href is an optional component
@@ -560,49 +560,49 @@ BookmarkImporter.prototype = {
// Create the bookmark. The title is unknown for now, we will set it later.
try {
frame.previousId =
PlacesUtils.bookmarks.insertBookmark(frame.containerId,
frame.previousLink,
PlacesUtils.bookmarks.DEFAULT_INDEX,
"");
- } catch(e) {
+ } catch (e) {
return;
}
// Set the date added value, if we have it.
if (dateAdded) {
try {
PlacesUtils.bookmarks.setItemDateAdded(frame.previousId,
this._convertImportedDateToInternalDate(dateAdded));
- } catch(e) {
+ } catch (e) {
}
}
// Adds tags to the URI, if there are any.
if (tags) {
try {
let tagsArray = tags.split(",");
PlacesUtils.tagging.tagURI(frame.previousLink, tagsArray);
- } catch(e) {
+ } catch (e) {
}
}
// Save the favicon.
if (icon || iconUri) {
let iconUriObject;
try {
iconUriObject = NetUtil.newURI(iconUri);
- } catch(e) {
+ } catch (e) {
}
if (icon || iconUriObject) {
try {
this._setFaviconForURI(frame.previousLink, iconUriObject, icon);
- } catch(e) {
+ } catch (e) {
}
}
}
// Save the keyword.
if (keyword) {
let kwPromise = PlacesUtils.keywords.insert({ keyword,
url: frame.previousLink.spec,
@@ -613,17 +613,17 @@ BookmarkImporter.prototype = {
// Set load-in-sidebar annotation for the bookmark.
if (webPanel && webPanel.toLowerCase() == "true") {
try {
PlacesUtils.annotations.setItemAnnotation(frame.previousId,
LOAD_IN_SIDEBAR_ANNO,
1,
0,
PlacesUtils.annotations.EXPIRE_NEVER);
- } catch(e) {
+ } catch (e) {
}
}
// Import last charset.
if (lastCharset) {
let chPromise = PlacesUtils.setCharsetForURI(frame.previousLink, lastCharset);
this._importPromises.push(chPromise);
}
@@ -682,40 +682,40 @@ BookmarkImporter.prototype = {
"siteURI": frame.previousLink,
});
this._importPromises.push(lmPromise);
} else if (frame.previousLink) {
// This is a common bookmark.
PlacesUtils.bookmarks.setItemTitle(frame.previousId,
frame.previousText);
}
- } catch(e) {
+ } catch (e) {
}
// Set last modified date as the last change.
if (frame.previousId > 0 && frame.previousLastModifiedDate > 0) {
try {
PlacesUtils.bookmarks.setItemLastModified(frame.previousId,
frame.previousLastModifiedDate);
- } catch(e) {
+ } catch (e) {
}
// Note: don't clear previousLastModifiedDate, because if this item has a
// description, we'll need to set it again.
}
frame.previousText = "";
},
_openContainer: function openContainer(aElt) {
if (aElt.namespaceURI != "http://www.w3.org/1999/xhtml") {
return;
}
- switch(aElt.localName) {
+ switch (aElt.localName) {
case "h1":
this._handleHead1Begin(aElt);
break;
case "h2":
case "h3":
case "h4":
case "h5":
case "h6":
@@ -755,17 +755,17 @@ BookmarkImporter.prototype = {
try {
if (!PlacesUtils.annotations.itemHasAnnotation(itemId, DESCRIPTION_ANNO)) {
PlacesUtils.annotations.setItemAnnotation(itemId,
DESCRIPTION_ANNO,
frame.previousText,
0,
PlacesUtils.annotations.EXPIRE_NEVER);
}
- } catch(e) {
+ } catch (e) {
}
frame.previousText = "";
// Set last-modified a 2nd time for all items with descriptions
// we need to set last-modified as the *last* step in processing
// any item type in the bookmarks.html file, so that we do
// not overwrite the imported value. for items without descriptions,
// setting this value after setting the item title is that
@@ -787,17 +787,17 @@ BookmarkImporter.prototype = {
}
}
frame.inDescription = false;
}
if (aElt.namespaceURI != "http://www.w3.org/1999/xhtml") {
return;
}
- switch(aElt.localName) {
+ switch (aElt.localName) {
case "dl":
case "ul":
case "menu":
this._handleContainerEnd();
break;
case "dt":
break;
case "h1":
@@ -938,17 +938,17 @@ BookmarkImporter.prototype = {
this._importPromises = [];
yield new Promise((resolve, reject) => {
let xhr = Cc["@mozilla.org/xmlextras/xmlhttprequest;1"]
.createInstance(Ci.nsIXMLHttpRequest);
xhr.onload = () => {
try {
this._walkTreeForImport(xhr.responseXML);
resolve();
- } catch(e) {
+ } catch (e) {
reject(e);
}
};
xhr.onabort = xhr.onerror = xhr.ontimeout = () => {
reject(new Error("xmlhttprequest failed"));
};
xhr.open("GET", href);
xhr.responseType = "document";
--- a/toolkit/components/places/BookmarkJSONUtils.jsm
+++ b/toolkit/components/places/BookmarkJSONUtils.jsm
@@ -59,17 +59,17 @@ this.BookmarkJSONUtils = Object.freeze({
importFromURL: function BJU_importFromURL(aSpec, aReplace) {
return Task.spawn(function* () {
notifyObservers(PlacesUtils.TOPIC_BOOKMARKS_RESTORE_BEGIN);
try {
let importer = new BookmarkImporter(aReplace);
yield importer.importFromURL(aSpec);
notifyObservers(PlacesUtils.TOPIC_BOOKMARKS_RESTORE_SUCCESS);
- } catch(ex) {
+ } catch (ex) {
Cu.reportError("Failed to restore bookmarks from " + aSpec + ": " + ex);
notifyObservers(PlacesUtils.TOPIC_BOOKMARKS_RESTORE_FAILED);
}
});
},
/**
* Restores bookmarks and tags from a JSON file.
@@ -102,17 +102,17 @@ this.BookmarkJSONUtils = Object.freeze({
let importer = new BookmarkImporter(aReplace);
if (aFilePath.endsWith("jsonlz4")) {
yield importer.importFromCompressedFile(aFilePath);
} else {
yield importer.importFromURL(OS.Path.toFileURI(aFilePath));
}
notifyObservers(PlacesUtils.TOPIC_BOOKMARKS_RESTORE_SUCCESS);
- } catch(ex) {
+ } catch (ex) {
Cu.reportError("Failed to restore bookmarks from " + aFilePath + ": " + ex);
notifyObservers(PlacesUtils.TOPIC_BOOKMARKS_RESTORE_FAILED);
throw ex;
}
});
},
/**
--- a/toolkit/components/places/Bookmarks.jsm
+++ b/toolkit/components/places/Bookmarks.jsm
@@ -1373,17 +1373,17 @@ function validateBookmarkObject(input, b
required.delete(prop);
} else if (input[prop] === undefined) {
// Skip undefined properties that are not required.
continue;
}
if (VALIDATORS.hasOwnProperty(prop)) {
try {
normalizedInput[prop] = VALIDATORS[prop](input[prop], input);
- } catch(ex) {
+ } catch (ex) {
throw new Error(`Invalid value for property '${prop}': ${input[prop]}`);
}
}
}
if (required.size > 0)
throw new Error(`The following properties were expected: ${[...required].join(", ")}`);
return normalizedInput;
}
--- a/toolkit/components/places/PlacesBackups.jsm
+++ b/toolkit/components/places/PlacesBackups.jsm
@@ -107,17 +107,17 @@ this.PlacesBackups = {
* needed to support deprecated methods themselves.
*/
get _folder() {
let bookmarksBackupDir = Services.dirsvc.get("ProfD", Ci.nsILocalFile);
bookmarksBackupDir.append(this.profileRelativeFolderPath);
if (!bookmarksBackupDir.exists()) {
bookmarksBackupDir.create(Ci.nsIFile.DIRECTORY_TYPE, parseInt("0700", 8));
if (!bookmarksBackupDir.exists())
- throw("Unable to create bookmarks backup folder");
+ throw ("Unable to create bookmarks backup folder");
}
delete this._folder;
return this._folder = bookmarksBackupDir;
},
/**
* Gets backup folder asynchronously.
* @return {Promise}
@@ -268,17 +268,17 @@ this.PlacesBackups = {
* nsIFile or string path of the backup.
* @return A Date object for the backup's creation time.
*/
getDateForFile: function PB_getDateForFile(aBackupFile) {
let filename = (aBackupFile instanceof Ci.nsIFile) ? aBackupFile.leafName
: OS.Path.basename(aBackupFile);
let matches = filename.match(filenamesRegex);
if (!matches)
- throw("Invalid backup file name: " + filename);
+ throw ("Invalid backup file name: " + filename);
return new Date(matches[1].replace(/-/g, "/"));
},
/**
* Get the most recent backup file.
*
* @returns nsIFile backup file
*/
--- a/toolkit/components/places/PlacesDBUtils.jsm
+++ b/toolkit/components/places/PlacesDBUtils.jsm
@@ -824,17 +824,17 @@ this.PlacesDBUtils = {
stmt.finalize();
});
// Get maximum number of unique URIs.
try {
let limitURIs = Services.prefs.getIntPref(
"places.history.expiration.transient_current_max_pages");
tasks.log("History can store a maximum of " + limitURIs + " unique pages");
- } catch(ex) {}
+ } catch (ex) {}
let stmt = DBConn.createStatement(
"SELECT name FROM sqlite_master WHERE type = :type");
stmt.params.type = "table";
while (stmt.executeStep()) {
let tableName = stmt.getString(0);
let countStmt = DBConn.createStatement(
`SELECT count(*) FROM ${tableName}`);
@@ -999,17 +999,17 @@ this.PlacesDBUtils = {
stmt.executeAsync({
handleError: reject,
handleResult: function (aResultSet) {
let row = aResultSet.getNextRow();
resolve([probe, row.getResultByIndex(0)]);
},
handleCompletion: function () {}
});
- } finally{
+ } finally {
stmt.finalize();
}
});
// Report the result of the probe through Telemetry.
// The resulting promise cannot reject.
promiseDone.then(
// On success
--- a/toolkit/components/places/PlacesRemoteTabsAutocompleteProvider.jsm
+++ b/toolkit/components/places/PlacesRemoteTabsAutocompleteProvider.jsm
@@ -92,17 +92,17 @@ function observe(subject, topic, data) {
// the cache so we don't supply tabs from a different user.
_items = null;
break;
case "nsPref:changed":
if (data == PREF_SHOW_REMOTE_ICONS) {
try {
showRemoteIcons = Services.prefs.getBoolPref(PREF_SHOW_REMOTE_ICONS);
- } catch(_) {
+ } catch (_) {
showRemoteIcons = true; // no such pref - default is to show the icons.
}
}
break;
default:
break;
}
--- a/toolkit/components/places/PlacesTransactions.jsm
+++ b/toolkit/components/places/PlacesTransactions.jsm
@@ -322,17 +322,17 @@ var PlacesTransactions = {
o => !TransactionsHistory.isProxifiedTransactionObject(o))) {
throw new Error("aToBatch contains non-transaction element");
}
return TransactionsManager.batch(function* () {
for (let txn of aToBatch) {
try {
yield txn.transact();
}
- catch(ex) {
+ catch (ex) {
console.error(ex);
}
}
});
}
if (typeof(aToBatch) == "function") {
return TransactionsManager.batch(aToBatch);
}
@@ -562,17 +562,17 @@ var TransactionsManager = {
let entry = TransactionsHistory.topUndoEntry;
if (!entry)
return;
for (let txnProxy of entry) {
try {
yield TransactionsHistory.getRawTransaction(txnProxy).undo();
}
- catch(ex) {
+ catch (ex) {
// If one transaction is broken, it's not safe to work with any other
// undo entry. Report the error and clear the undo history.
console.error(ex,
"Couldn't undo a transaction, clearing all undo entries.");
TransactionsHistory.clearUndoEntries();
return;
}
}
@@ -595,17 +595,17 @@ var TransactionsManager = {
for (let i = entry.length - 1; i >= 0; i--) {
let transaction = TransactionsHistory.getRawTransaction(entry[i]);
try {
if (transaction.redo)
yield transaction.redo();
else
yield transaction.execute();
}
- catch(ex) {
+ catch (ex) {
// If one transaction is broken, it's not safe to work with any other
// redo entry. Report the error and clear the undo history.
console.error(ex,
"Couldn't redo a transaction, clearing all redo entries.");
TransactionsHistory.clearRedoEntries();
return;
}
}
@@ -637,17 +637,17 @@ var TransactionsManager = {
// Inactive windows commands will be updated on focus.
_updateCommandsOnActiveWindow() {
// Updating "undo" will cause a group update including "redo".
try {
let win = Services.focus.activeWindow;
if (win)
win.updateCommands("undo");
}
- catch(ex) { console.error(ex, "Couldn't update undo commands"); }
+ catch (ex) { console.error(ex, "Couldn't update undo commands"); }
}
};
/**
* Internal helper for defining the standard transactions and their input.
* It takes the required and optional properties, and generates the public
* constructor (which takes the input in the form of a plain object) which,
* when called, creates the argument-less "public" |execute| method by binding
@@ -748,17 +748,17 @@ function (aNames, aValidationFunction, a
let propName = name;
this.inputProps.set(propName, {
validateValue: function (aValue) {
if (aValue === undefined)
return aDefaultValue;
try {
return aValidationFunction(aValue);
}
- catch(ex) {
+ catch (ex) {
throw new Error(`Invalid value for input property ${propName}`);
}
},
validateInput: function (aInput, aRequired) {
if (aRequired && !(propName in aInput))
throw new Error(`Required input property is missing: ${propName}`);
return this.validateValue(aInput[propName]);
@@ -1423,17 +1423,17 @@ PT.SortByName.prototype = {
*/
PT.Remove = DefineTransaction(["guids"]);
PT.Remove.prototype = {
*execute(aGuids) {
function promiseBookmarksTree(guid) {
try {
return PlacesUtils.promiseBookmarksTree(guid);
}
- catch(ex) {
+ catch (ex) {
throw new Error("Failed to get info for the specified item (guid: " +
guid + "). Ex: " + ex);
}
}
let toRestore = [];
for (let guid of aGuids) {
toRestore.push(yield promiseBookmarksTree(guid));
@@ -1582,17 +1582,17 @@ PT.Untag.prototype = {
PT.Copy = DefineTransaction(["guid", "newParentGuid"],
["newIndex", "excludingAnnotations"]);
PT.Copy.prototype = {
execute: function* (aGuid, aNewParentGuid, aNewIndex, aExcludingAnnotations) {
let creationInfo = null;
try {
creationInfo = yield PlacesUtils.promiseBookmarksTree(aGuid);
}
- catch(ex) {
+ catch (ex) {
throw new Error("Failed to get info for the specified item (guid: " +
aGuid + "). Ex: " + ex);
}
creationInfo.parentGuid = aNewParentGuid;
creationInfo.index = aNewIndex;
let newItemId =
yield createItemsFromBookmarksTree(creationInfo, false,
--- a/toolkit/components/places/PlacesUtils.jsm
+++ b/toolkit/components/places/PlacesUtils.jsm
@@ -749,17 +749,17 @@ this.PlacesUtils = {
* to parse.
* @param type
* The content type of the blob.
* @returns An array of objects representing each item contained by the source.
*/
unwrapNodes: function PU_unwrapNodes(blob, type) {
// We split on "\n" because the transferable system converts "\r\n" to "\n"
var nodes = [];
- switch(type) {
+ switch (type) {
case this.TYPE_X_MOZ_PLACE:
case this.TYPE_X_MOZ_PLACE_SEPARATOR:
case this.TYPE_X_MOZ_PLACE_CONTAINER:
nodes = JSON.parse("[" + blob + "]");
break;
case this.TYPE_X_MOZ_URL: {
let parts = blob.split("\n");
// data in this type has 2 parts per entry, so if there are fewer
@@ -1745,17 +1745,17 @@ this.PlacesUtils = {
if (!rootItem) {
try {
// This is the first row.
rootItem = item = yield createItemInfoObject(row, true);
Object.defineProperty(rootItem, "itemsCount", { value: 1
, writable: true
, enumerable: false
, configurable: false });
- } catch(ex) {
+ } catch (ex) {
throw new Error("Failed to fetch the data for the root item " + ex);
}
} else {
try {
// Our query guarantees that we always visit parents ahead of their
// children.
item = yield createItemInfoObject(row, false);
let parentGuid = row.getResultByName("parentGuid");
@@ -1764,17 +1764,17 @@ this.PlacesUtils = {
let parentItem = parentsMap.get(parentGuid);
if ("children" in parentItem)
parentItem.children.push(item);
else
parentItem.children = [item];
rootItem.itemsCount++;
- } catch(ex) {
+ } catch (ex) {
// This is a bogus child, report and skip it.
Cu.reportError("Failed to fetch the data for an item " + ex);
continue;
}
}
if (item.type == this.TYPE_X_MOZ_PLACE_CONTAINER)
parentsMap.set(item.guid, item);
@@ -1928,17 +1928,17 @@ function setupDbForShutdown(conn, name)
});
// Make sure that Sqlite.jsm doesn't close until we are done
// with the high-level connection.
Sqlite.shutdown.addBlocker(`${name} must be closed before Sqlite.jsm`,
() => promiseClosed.catch(Cu.reportError),
() => state
);
- } catch(ex) {
+ } catch (ex) {
// It's too late to block shutdown, just close the connection.
conn.close();
throw ex;
}
}
XPCOMUtils.defineLazyGetter(this, "gAsyncDBConnPromised",
() => Sqlite.cloneStorageConnection({
--- a/toolkit/components/places/nsLivemarkService.js
+++ b/toolkit/components/places/nsLivemarkService.js
@@ -782,17 +782,17 @@ LivemarkLoadListener.prototype = {
continue;
}
try {
Services.scriptSecurityManager
.checkLoadURIWithPrincipal(feedPrincipal, uri,
Ci.nsIScriptSecurityManager.DISALLOW_INHERIT_PRINCIPAL);
}
- catch(ex) {
+ catch (ex) {
continue;
}
let title = entry.title ? entry.title.plainText() : "";
livemarkChildren.push({ uri: uri, title: title, visited: false });
}
this._livemark.children = livemarkChildren;
--- a/toolkit/components/places/nsPlacesExpiration.js
+++ b/toolkit/components/places/nsPlacesExpiration.js
@@ -819,17 +819,17 @@ nsPlacesExpiration.prototype = {
},
_loadPrefs: Task.async(function* () {
// Get the user's limit, if it was set.
try {
// We want to silently fail since getIntPref throws if it does not exist,
// and use a default to fallback to.
this._urisLimit = this._prefBranch.getIntPref(PREF_MAX_URIS);
- } catch(ex) { /* User limit not set */ }
+ } catch (ex) { /* User limit not set */ }
if (this._urisLimit < 0) {
// Some testing code expects a pref change to be synchronous, so
// temporarily set this to a large value, while we asynchronously update
// to the correct value.
this._urisLimit = 300000;
// The user didn't specify a custom limit, so we calculate the number of
--- a/toolkit/components/places/tests/bookmarks/test_388695.js
+++ b/toolkit/components/places/tests/bookmarks/test_388695.js
@@ -3,17 +3,17 @@
/* 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/. */
// Get bookmark service
try {
var bmsvc = Cc["@mozilla.org/browser/nav-bookmarks-service;1"].
getService(Ci.nsINavBookmarksService);
-} catch(ex) {
+} catch (ex) {
do_throw("Could not get nav-bookmarks-service\n");
}
var gTestRoot;
var gURI;
var gItemId1;
var gItemId2;
--- a/toolkit/components/places/tests/bookmarks/test_395101.js
+++ b/toolkit/components/places/tests/bookmarks/test_395101.js
@@ -2,32 +2,32 @@
/* vim:set ts=2 sw=2 sts=2 et: */
/* 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/. */
// Get bookmark service
try {
var bmsvc = Cc["@mozilla.org/browser/nav-bookmarks-service;1"].getService(Ci.nsINavBookmarksService);
-} catch(ex) {
+} catch (ex) {
do_throw("Could not get nav-bookmarks-service\n");
}
// Get history service
try {
var histsvc = Cc["@mozilla.org/browser/nav-history-service;1"].getService(Ci.nsINavHistoryService);
-} catch(ex) {
+} catch (ex) {
do_throw("Could not get history service\n");
}
// Get tagging service
try {
var tagssvc = Cc["@mozilla.org/browser/tagging-service;1"].
getService(Ci.nsITaggingService);
-} catch(ex) {
+} catch (ex) {
do_throw("Could not get tagging service\n");
}
// get bookmarks root id
var root = bmsvc.bookmarksMenuFolder;
// main
function run_test() {
--- a/toolkit/components/places/tests/bookmarks/test_448584.js
+++ b/toolkit/components/places/tests/bookmarks/test_448584.js
@@ -6,17 +6,17 @@
var tests = [];
// Get database connection
try {
var mDBConn = PlacesUtils.history.QueryInterface(Ci.nsPIPlacesDatabase)
.DBConnection;
}
-catch(ex) {
+catch (ex) {
do_throw("Could not get database connection\n");
}
/*
This test is:
- don't try to add invalid uri nodes to a JSON backup
*/
@@ -96,17 +96,17 @@ add_task(function*() {
// clean
tests.forEach(function(aTest) {
aTest.clean();
});
// restore json file
try {
yield BookmarkJSONUtils.importFromFile(jsonFile, true);
- } catch(ex) { do_throw("couldn't import the exported file: " + ex); }
+ } catch (ex) { do_throw("couldn't import the exported file: " + ex); }
// validate
tests.forEach(function(aTest) {
aTest.validate(1);
});
// clean up
yield OS.File.remove(jsonFile);
--- a/toolkit/components/places/tests/bookmarks/test_458683.js
+++ b/toolkit/components/places/tests/bookmarks/test_458683.js
@@ -6,17 +6,17 @@
var tests = [];
// Get database connection
try {
var mDBConn = PlacesUtils.history.QueryInterface(Ci.nsPIPlacesDatabase)
.DBConnection;
}
-catch(ex) {
+catch (ex) {
do_throw("Could not get database connection\n");
}
/*
This test is:
- don't block while doing backup and restore if tag containers contain
bogus items (separators, folders)
*/
--- a/toolkit/components/places/tests/bookmarks/test_bookmarks.js
+++ b/toolkit/components/places/tests/bookmarks/test_bookmarks.js
@@ -89,23 +89,23 @@ add_task(function* test_bookmarks() {
do_check_true(bs.tagsFolder > 0);
do_check_true(bs.toolbarFolder > 0);
do_check_true(bs.unfiledBookmarksFolder > 0);
// test getFolderIdForItem() with bogus item id will throw
try {
let id = bs.getFolderIdForItem(0);
do_throw("getFolderIdForItem accepted bad input");
- } catch(ex) {}
+ } catch (ex) {}
// test getFolderIdForItem() with bogus item id will throw
try {
let id = bs.getFolderIdForItem(-1);
do_throw("getFolderIdForItem accepted bad input");
- } catch(ex) {}
+ } catch (ex) {}
// test root parentage
do_check_eq(bs.getFolderIdForItem(bs.bookmarksMenuFolder), bs.placesRoot);
do_check_eq(bs.getFolderIdForItem(bs.tagsFolder), bs.placesRoot);
do_check_eq(bs.getFolderIdForItem(bs.toolbarFolder), bs.placesRoot);
do_check_eq(bs.getFolderIdForItem(bs.unfiledBookmarksFolder), bs.placesRoot);
// create a folder to hold all the tests
@@ -182,17 +182,17 @@ add_task(function* test_bookmarks() {
// test getItemType for bookmarks
do_check_eq(bs.getItemType(newId), bs.TYPE_BOOKMARK);
// get item title bad input
try {
let title = bs.getItemTitle(-3);
do_throw("getItemTitle accepted bad input");
- } catch(ex) {}
+ } catch (ex) {}
// get the folder that the bookmark is in
let folderId = bs.getFolderIdForItem(newId);
do_check_eq(folderId, testRoot);
// test getItemIndex for bookmarks
do_check_eq(bs.getItemIndex(newId), testStartIndex);
@@ -345,29 +345,29 @@ add_task(function* test_bookmarks() {
let query = hs.getNewQuery();
query.setFolders([tmpFolder], 1);
try {
let result = hs.executeQuery(query, options);
let rootNode = result.root;
rootNode.containerOpen = true;
do_check_eq(rootNode.childCount, 3);
rootNode.containerOpen = false;
- } catch(ex) {
+ } catch (ex) {
do_throw("test removeFolderChildren() - querying for children failed: " + ex);
}
// 3) remove all children
bs.removeFolderChildren(tmpFolder);
// 4) confirm that folder has 0 children
try {
result = hs.executeQuery(query, options);
let rootNode = result.root;
rootNode.containerOpen = true;
do_check_eq(rootNode.childCount, 0);
rootNode.containerOpen = false;
- } catch(ex) {
+ } catch (ex) {
do_throw("removeFolderChildren(): " + ex);
}
// XXX - test folderReadOnly
// test bookmark id in query output
try {
let options = hs.getNewQueryOptions();
@@ -388,17 +388,17 @@ add_task(function* test_bookmarks() {
do_check_true(node.itemId > 0);
}
else {
do_check_eq(node.itemId, -1);
}
}
rootNode.containerOpen = false;
}
- catch(ex) {
+ catch (ex) {
do_throw("bookmarks query: " + ex);
}
// test that multiple bookmarks with same URI show up right in bookmark
// folder queries, todo: also to do for complex folder queries
try {
// test uri
let mURI = uri("http://multiple.uris.in.query");
@@ -416,17 +416,17 @@ add_task(function* test_bookmarks() {
let rootNode = result.root;
rootNode.containerOpen = true;
let cc = rootNode.childCount;
do_check_eq(cc, 2);
do_check_eq(rootNode.getChild(0).title, "title 1");
do_check_eq(rootNode.getChild(1).title, "title 2");
rootNode.containerOpen = false;
}
- catch(ex) {
+ catch (ex) {
do_throw("bookmarks query: " + ex);
}
// test change bookmark uri
let newId10 = bs.insertBookmark(testRoot, uri("http://foo10.com/"),
bs.DEFAULT_INDEX, "");
dateAdded = bs.getItemDateAdded(newId10);
// after just inserting, modified should not be set
@@ -461,17 +461,17 @@ add_task(function* test_bookmarks() {
bs.DEFAULT_INDEX, "");
let bmURI = bs.getBookmarkURI(newId11);
do_check_eq("http://foo11.com/", bmURI.spec);
// test getBookmarkURI with non-bookmark items
try {
bs.getBookmarkURI(testRoot);
do_throw("getBookmarkURI() should throw for non-bookmark items!");
- } catch(ex) {}
+ } catch (ex) {}
// test getItemIndex
let newId12 = bs.insertBookmark(testRoot, uri("http://foo11.com/"), 1, "");
let bmIndex = bs.getItemIndex(newId12);
do_check_eq(1, bmIndex);
// insert a bookmark with title ZZZXXXYYY and then search for it.
// this test confirms that we can find bookmarks that we haven't visited
@@ -509,17 +509,17 @@ add_task(function* test_bookmarks() {
rootNode.containerOpen = true;
let cc = rootNode.childCount;
do_check_eq(cc, 1);
let node = rootNode.getChild(0);
do_check_eq(node.title, "ZZZXXXYYY");
do_check_true(node.itemId > 0);
rootNode.containerOpen = false;
}
- catch(ex) {
+ catch (ex) {
do_throw("bookmarks query: " + ex);
}
// test dateAdded and lastModified properties
// for a search query
try {
let options = hs.getNewQueryOptions();
options.excludeQueries = 1;
@@ -536,17 +536,17 @@ add_task(function* test_bookmarks() {
do_check_eq(typeof node.dateAdded, "number");
do_check_true(node.dateAdded > 0);
do_check_eq(typeof node.lastModified, "number");
do_check_true(node.lastModified > 0);
rootNode.containerOpen = false;
}
- catch(ex) {
+ catch (ex) {
do_throw("bookmarks query: " + ex);
}
// test dateAdded and lastModified properties
// for a folder query
try {
let options = hs.getNewQueryOptions();
let query = hs.getNewQuery();
@@ -565,17 +565,17 @@ add_task(function* test_bookmarks() {
do_check_eq(typeof node.lastModified, "number");
do_check_true(node.lastModified > 0);
break;
}
}
rootNode.containerOpen = false;
}
- catch(ex) {
+ catch (ex) {
do_throw("bookmarks query: " + ex);
}
// check setItemLastModified() and setItemDateAdded()
let newId14 = bs.insertBookmark(testRoot, uri("http://bar.tld/"),
bs.DEFAULT_INDEX, "");
dateAdded = bs.getItemDateAdded(newId14);
lastModified = bs.getItemLastModified(newId14);
@@ -706,13 +706,13 @@ function getChildCount(aFolderId) {
let options = hs.getNewQueryOptions();
let query = hs.getNewQuery();
query.setFolders([aFolderId], 1);
let result = hs.executeQuery(query, options);
let rootNode = result.root;
rootNode.containerOpen = true;
cc = rootNode.childCount;
rootNode.containerOpen = false;
- } catch(ex) {
+ } catch (ex) {
do_throw("getChildCount failed: " + ex);
}
return cc;
}
--- a/toolkit/components/places/tests/bookmarks/test_keywords.js
+++ b/toolkit/components/places/tests/bookmarks/test_keywords.js
@@ -4,17 +4,17 @@ const URI3 = NetUtil.newURI("http://test
function check_keyword(aURI, aKeyword) {
if (aKeyword)
aKeyword = aKeyword.toLowerCase();
for (let bm of PlacesUtils.getBookmarksForURI(aURI)) {
let keyword = PlacesUtils.bookmarks.getKeywordForBookmark(bm);
if (keyword && !aKeyword) {
- throw(`${aURI.spec} should not have a keyword`);
+ throw (`${aURI.spec} should not have a keyword`);
} else if (aKeyword && keyword == aKeyword) {
Assert.equal(keyword, aKeyword);
}
}
if (aKeyword) {
let uri = PlacesUtils.bookmarks.getURIForKeyword(aKeyword);
Assert.equal(uri.spec, aURI.spec);
--- a/toolkit/components/places/tests/bookmarks/test_savedsearches.js
+++ b/toolkit/components/places/tests/bookmarks/test_savedsearches.js
@@ -51,17 +51,17 @@ add_test(function test_savedsearches_boo
// test that queries have valid itemId
do_check_true(node.itemId > 0);
// test that the container is closed
node.QueryInterface(Ci.nsINavHistoryContainerResultNode);
do_check_eq(node.containerOpen, false);
}
rootNode.containerOpen = false;
}
- catch(ex) {
+ catch (ex) {
do_throw("expandQueries=0 query error: " + ex);
}
// bookmark saved search
// query for the test root, expandQueries=1
// the query should show up as a query container, with 1 child
try {
let options = PlacesUtils.history.getNewQueryOptions();
@@ -108,17 +108,17 @@ add_test(function test_savedsearches_boo
// test live-update of query results - add a query that matches the query
PlacesUtils.bookmarks.insertBookmark(
root, uri("place:terms=foo&excludeQueries=1&expandQueries=1&queryType=1"),
PlacesUtils.bookmarks.DEFAULT_INDEX, searchTerm + "blah");
do_check_eq(node.childCount, 1);
}
rootNode.containerOpen = false;
}
- catch(ex) {
+ catch (ex) {
do_throw("expandQueries=1 bookmarks query: " + ex);
}
// delete the bookmark search
PlacesUtils.bookmarks.removeItem(searchId);
run_next_test();
});
@@ -193,17 +193,17 @@ add_task(function* test_savedsearches_hi
PlacesUtils.bookmarks.setItemTitle(searchId, "foo");
do_check_eq(tmpFolderNode.title, "foo");
// test live-update of deleted queries
PlacesUtils.bookmarks.removeItem(searchId);
try {
tmpFolderNode = root.getChild(1);
do_throw("query was not removed");
- } catch(ex) {}
+ } catch (ex) {}
tmpFolderNode.containerOpen = false;
rootNode.containerOpen = false;
}
- catch(ex) {
+ catch (ex) {
do_throw("expandQueries=1 bookmarks query: " + ex);
}
});
--- a/toolkit/components/places/tests/browser/browser_favicon_setAndFetchFaviconForPage_failures.js
+++ b/toolkit/components/places/tests/browser/browser_favicon_setAndFetchFaviconForPage_failures.js
@@ -42,17 +42,17 @@ function test() {
let stmt = DBConn().createAsyncStatement("SELECT url FROM moz_favicons");
stmt.executeAsync({
handleResult: function final_handleResult(aResultSet) {
for (let row; (row = aResultSet.getNextRow()); ) {
favIconsResultCount++;
}
},
handleError: function final_handleError(aError) {
- throw("Unexpected error (" + aError.result + "): " + aError.message);
+ throw ("Unexpected error (" + aError.result + "): " + aError.message);
},
handleCompletion: function final_handleCompletion(aReason) {
//begin testing
info("Previous records in moz_favicons: " + favIconsResultCount);
if (aCallback) {
aCallback();
}
}
@@ -60,34 +60,34 @@ function test() {
stmt.finalize();
}
function testNullPageURI(aWindow, aCallback) {
try {
aWindow.PlacesUtils.favicons.setAndFetchFaviconForPage(null, favIcon16URI,
true, aWindow.PlacesUtils.favicons.FAVICON_LOAD_NON_PRIVATE, null,
Services.scriptSecurityManager.getSystemPrincipal());
- throw("Exception expected because aPageURI is null.");
+ throw ("Exception expected because aPageURI is null.");
} catch (ex) {
// We expected an exception.
ok(true, "Exception expected because aPageURI is null");
}
if (aCallback) {
aCallback();
}
}
function testNullFavIconURI(aWindow, aCallback) {
try {
aWindow.PlacesUtils.favicons.setAndFetchFaviconForPage(
NetUtil.newURI("http://example.com/null_faviconURI"), null,
true, aWindow.PlacesUtils.favicons.FAVICON_LOAD_NON_PRIVATE,
null, Services.scriptSecurityManager.getSystemPrincipal());
- throw("Exception expected because aFaviconURI is null.");
+ throw ("Exception expected because aFaviconURI is null.");
} catch (ex) {
// We expected an exception.
ok(true, "Exception expected because aFaviconURI is null.");
}
if (aCallback) {
aCallback();
}
@@ -194,17 +194,17 @@ function test() {
for (let row; (row = aResultSet.getNextRow()); ) {
is(favIcon32URI.spec, row.getResultByIndex(0),
"Check equal favicons");
resultCount++;
}
}
},
handleError: function final_handleError(aError) {
- throw("Unexpected error (" + aError.result + "): " + aError.message);
+ throw ("Unexpected error (" + aError.result + "): " + aError.message);
},
handleCompletion: function final_handleCompletion(aReason) {
is(Ci.mozIStorageStatementCallback.REASON_FINISHED, aReason,
"Check reasons are equal");
is(1, resultCount, "Check result count");
if (aCallback) {
aCallback();
}
--- a/toolkit/components/places/tests/browser/head.js
+++ b/toolkit/components/places/tests/browser/head.js
@@ -149,17 +149,17 @@ function addVisits(aPlaceInfo, aWindow,
referrerURI: place.referrer
}];
}
aWindow.PlacesUtils.asyncHistory.updatePlaces(
places,
{
handleError: function AAV_handleError() {
- throw("Unexpected error in adding visit.");
+ throw ("Unexpected error in adding visit.");
},
handleResult: function () {},
handleCompletion: function UP_handleCompletion() {
if (aCallback)
aCallback();
}
}
);
--- a/toolkit/components/places/tests/expiration/head_expiration.js
+++ b/toolkit/components/places/tests/expiration/head_expiration.js
@@ -68,45 +68,45 @@ function setInterval(aNewInterval) {
}
function getInterval() {
return Services.prefs.getIntPref("places.history.expiration.interval_seconds");
}
function clearInterval() {
try {
Services.prefs.clearUserPref("places.history.expiration.interval_seconds");
}
- catch(ex) {}
+ catch (ex) {}
}
function setMaxPages(aNewMaxPages) {
Services.prefs.setIntPref("places.history.expiration.max_pages", aNewMaxPages);
}
function getMaxPages() {
return Services.prefs.getIntPref("places.history.expiration.max_pages");
}
function clearMaxPages() {
try {
Services.prefs.clearUserPref("places.history.expiration.max_pages");
}
- catch(ex) {}
+ catch (ex) {}
}
function setHistoryEnabled(aHistoryEnabled) {
Services.prefs.setBoolPref("places.history.enabled", aHistoryEnabled);
}
function getHistoryEnabled() {
return Services.prefs.getBoolPref("places.history.enabled");
}
function clearHistoryEnabled() {
try {
Services.prefs.clearUserPref("places.history.enabled");
}
- catch(ex) {}
+ catch (ex) {}
}
/**
* Returns a PRTime in the past usable to add expirable visits.
*
* param [optional] daysAgo
* Expiration ignores any visit added in the last 7 days, so by default
* this will be set to 7.
--- a/toolkit/components/places/tests/head_common.js
+++ b/toolkit/components/places/tests/head_common.js
@@ -231,17 +231,17 @@ function compareArrays(aArray1, aArray2)
* Deletes a previously created sqlite file from the profile folder.
*/
function clearDB() {
try {
let file = Services.dirsvc.get('ProfD', Ci.nsIFile);
file.append("places.sqlite");
if (file.exists())
file.remove(false);
- } catch(ex) { dump("Exception: " + ex); }
+ } catch (ex) { dump("Exception: " + ex); }
}
/**
* Dumps the rows of a table out to the console.
*
* @param aName
* The name of the table or view to output.
--- a/toolkit/components/places/tests/network/test_history_redirects.js
+++ b/toolkit/components/places/tests/network/test_history_redirects.js
@@ -89,17 +89,17 @@ function continue_test() {
from_visit: 1,
visit_type: Ci.nsINavHistoryService.TRANSITION_REDIRECT_PERMANENT },
{ id: 3,
url: FOUND_URL,
from_visit: 2,
visit_type: Ci.nsINavHistoryService.TRANSITION_REDIRECT_TEMPORARY },
];
try {
- while(stmt.executeStep()) {
+ while (stmt.executeStep()) {
let comparator = EXPECTED.shift();
do_print("Checking that '" + comparator.url +
"' was entered into the DB correctly");
do_check_eq(stmt.row.id, comparator.id);
do_check_eq(stmt.row.url, comparator.url);
do_check_eq(stmt.row.from_visit, comparator.from_visit);
do_check_eq(stmt.row.visit_type, comparator.visit_type);
}
--- a/toolkit/components/places/tests/queries/test_415716.js
+++ b/toolkit/components/places/tests/queries/test_415716.js
@@ -1,16 +1,16 @@
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
/* vim:set ts=2 sw=2 sts=2 et: */
/* 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/. */
function modHistoryTypes(val) {
- switch(val % 8) {
+ switch (val % 8) {
case 0:
case 1:
return TRANSITION_LINK;
case 2:
return TRANSITION_TYPED;
case 3:
return TRANSITION_BOOKMARK;
case 4:
@@ -93,16 +93,16 @@ add_task(function test_execute()
options.sortingMode = options.SORT_BY_DATE_DESCENDING;
options.resultType = options.RESULTS_AS_VISIT;
// Results
let root = PlacesUtils.history.executeQuery(query, options).root;
root.containerOpen = true;
let cc = root.childCount;
dump("----> cc is: " + cc + "\n");
- for(let i = 0; i < root.childCount; ++i) {
+ for (let i = 0; i < root.childCount; ++i) {
let resultNode = root.getChild(i);
let accesstime = Date(resultNode.time / 1000);
dump("----> result: " + resultNode.uri + " Date: " + accesstime.toLocaleString() + "\n");
}
do_check_eq(cc,0);
root.containerOpen = false;
});
--- a/toolkit/components/places/tests/queries/test_containersQueries_sorting.js
+++ b/toolkit/components/places/tests/queries/test_containersQueries_sorting.js
@@ -325,17 +325,17 @@ function check_children_sorting(aRootNod
return -1;
if (aLC > bLC)
return 1;
return 0;
}
// Get a comparator based on expected sortingMode.
var comparator;
- switch(aExpectedSortingMode) {
+ switch (aExpectedSortingMode) {
case Ci.nsINavHistoryQueryOptions.SORT_BY_NONE:
comparator = function (a, b) {
return 0;
}
break;
case Ci.nsINavHistoryQueryOptions.SORT_BY_TITLE_ASCENDING:
comparator = function (a, b) {
return caseInsensitiveStringComparator(a.title, b.title);
--- a/toolkit/components/places/tests/queries/test_queryMultipleFolder.js
+++ b/toolkit/components/places/tests/queries/test_queryMultipleFolder.js
@@ -14,17 +14,17 @@ add_task(function* test_queryMultipleFol
for (let i = 0; i < 3; ++i) {
let folder = yield PlacesUtils.bookmarks.insert({
parentGuid: PlacesUtils.bookmarks.menuGuid,
type: PlacesUtils.bookmarks.TYPE_FOLDER,
title: `Folder${i}`
});
folderIds.push(yield PlacesUtils.promiseItemId(folder.guid));
- for(let j = 0; j < 7; ++j) {
+ for (let j = 0; j < 7; ++j) {
let bm = yield PlacesUtils.bookmarks.insert({
parentGuid: (yield PlacesUtils.promiseItemGuid(folderIds[i])),
url: `http://Bookmark${i}_${j}.com`,
title: ""
});
bookmarkIds.push(yield PlacesUtils.promiseItemId(bm.guid));
}
}
--- a/toolkit/components/places/tests/queries/test_results-as-visit.js
+++ b/toolkit/components/places/tests/queries/test_results-as-visit.js
@@ -50,17 +50,17 @@ add_task(function* test_results_as_visit
options.resultType = options.RESULTS_AS_VISIT;
// Results
var result = PlacesUtils.history.executeQuery(query, options);
var root = result.root;
root.containerOpen = true;
do_print("Number of items in result set: " + root.childCount);
- for(var i=0; i < root.childCount; ++i) {
+ for (var i=0; i < root.childCount; ++i) {
do_print("result: " + root.getChild(i).uri + " Title: " + root.getChild(i).title);
}
// Check our inital result set
compareArrayToResult(testData, root);
// If that passes, check liveupdate
// Add to the query set
--- a/toolkit/components/places/tests/queries/test_searchterms-domain.js
+++ b/toolkit/components/places/tests/queries/test_searchterms-domain.js
@@ -74,17 +74,17 @@ add_task(function* test_searchterms_doma
options.resultType = options.RESULTS_AS_URI;
// Results
var result = PlacesUtils.history.executeQuery(query, options);
var root = result.root;
root.containerOpen = true;
do_print("Number of items in result set: " + root.childCount);
- for(var i=0; i < root.childCount; ++i) {
+ for (var i=0; i < root.childCount; ++i) {
do_print("result: " + root.getChild(i).uri + " Title: " + root.getChild(i).title);
}
// Check our inital result set
compareArrayToResult(testData, root);
// If that passes, check liveupdate
// Add to the query set
--- a/toolkit/components/places/tests/queries/test_searchterms-uri.js
+++ b/toolkit/components/places/tests/queries/test_searchterms-uri.js
@@ -59,17 +59,17 @@ add_task(function* test_searchterms_uri(
options.resultType = options.RESULTS_AS_URI;
// Results
var result = PlacesUtils.history.executeQuery(query, options);
var root = result.root;
root.containerOpen = true;
do_print("Number of items in result set: " + root.childCount);
- for(var i=0; i < root.childCount; ++i) {
+ for (var i=0; i < root.childCount; ++i) {
do_print("result: " + root.getChild(i).uri + " Title: " + root.getChild(i).title);
}
// Check our inital result set
compareArrayToResult(testData, root);
// live update.
do_print("change title");
--- a/toolkit/components/places/tests/unit/test_000_frecency.js
+++ b/toolkit/components/places/tests/unit/test_000_frecency.js
@@ -17,17 +17,17 @@ Autocomplete Frecency Tests
try {
var histsvc = Cc["@mozilla.org/browser/nav-history-service;1"].
getService(Ci.nsINavHistoryService);
var bmsvc = Cc["@mozilla.org/browser/nav-bookmarks-service;1"].
getService(Ci.nsINavBookmarksService);
var prefs = Cc["@mozilla.org/preferences-service;1"].
getService(Ci.nsIPrefBranch);
-} catch(ex) {
+} catch (ex) {
do_throw("Could not get services\n");
}
var bucketPrefs = [
[ "firstBucketCutoff", "firstBucketWeight"],
[ "secondBucketCutoff", "secondBucketWeight"],
[ "thirdBucketCutoff", "thirdBucketWeight"],
[ "fourthBucketCutoff", "fourthBucketWeight"],
@@ -54,20 +54,20 @@ var now = Date.now();
var prefPrefix = "places.frecency.";
function* task_initializeBucket(bucket) {
let [cutoffName, weightName] = bucket;
// get pref values
var weight = 0, cutoff = 0, bonus = 0;
try {
weight = prefs.getIntPref(prefPrefix + weightName);
- } catch(ex) {}
+ } catch (ex) {}
try {
cutoff = prefs.getIntPref(prefPrefix + cutoffName);
- } catch(ex) {}
+ } catch (ex) {}
if (cutoff < 1)
return;
// generate a date within the cutoff period
var dateInPeriod = (now - ((cutoff - 1) * 86400 * 1000)) * 1000;
for (let [bonusName, visitType] in Iterator(bonusPrefs)) {
--- a/toolkit/components/places/tests/unit/test_331487.js
+++ b/toolkit/components/places/tests/unit/test_331487.js
@@ -2,17 +2,17 @@
/* vim:set ts=2 sw=2 sts=2 et: */
/* 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/. */
// Get history service
try {
var histsvc = Cc["@mozilla.org/browser/nav-history-service;1"].getService(Ci.nsINavHistoryService);
-} catch(ex) {
+} catch (ex) {
do_throw("Could not get history service\n");
}
var bmsvc = Cc["@mozilla.org/browser/nav-bookmarks-service;1"].
getService(Ci.nsINavBookmarksService);
// main
function run_test() {
--- a/toolkit/components/places/tests/unit/test_402799.js
+++ b/toolkit/components/places/tests/unit/test_402799.js
@@ -4,34 +4,34 @@
* 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/. */
// Get history services
try {
var histsvc = Cc["@mozilla.org/browser/nav-history-service;1"].
getService(Ci.nsINavHistoryService);
var bhist = histsvc.QueryInterface(Ci.nsIBrowserHistory);
-} catch(ex) {
+} catch (ex) {
do_throw("Could not get history services\n");
}
// Get bookmark service
try {
var bmsvc = Cc["@mozilla.org/browser/nav-bookmarks-service;1"].
getService(Ci.nsINavBookmarksService);
}
-catch(ex) {
+catch (ex) {
do_throw("Could not get the nav-bookmarks-service\n");
}
// Get tagging service
try {
var tagssvc = Cc["@mozilla.org/browser/tagging-service;1"].
getService(Ci.nsITaggingService);
-} catch(ex) {
+} catch (ex) {
do_throw("Could not get tagging service\n");
}
// main
function run_test() {
var uri1 = uri("http://foo.bar/");
--- a/toolkit/components/places/tests/unit/test_408221.js
+++ b/toolkit/components/places/tests/unit/test_408221.js
@@ -57,17 +57,17 @@ AutoCompleteInput.prototype = {
throw Components.results.NS_ERROR_NO_INTERFACE;
}
}
// Get tagging service
try {
var tagssvc = Cc["@mozilla.org/browser/tagging-service;1"].
getService(Ci.nsITaggingService);
-} catch(ex) {
+} catch (ex) {
do_throw("Could not get tagging service\n");
}
function ensure_tag_results(uris, searchTerm)
{
var controller = Components.classes["@mozilla.org/autocomplete/controller;1"].
getService(Components.interfaces.nsIAutoCompleteController);
--- a/toolkit/components/places/tests/unit/test_415757.js
+++ b/toolkit/components/places/tests/unit/test_415757.js
@@ -83,20 +83,20 @@ add_task(function* test_execute()
let testURI = uri(site);
do_check_true(uri_in_db(testURI));
}
// check that annotation on the removed item does not exists
try {
PlacesUtils.annotations.getPageAnnotation(testAnnoDeletedURI, testAnnoName);
do_throw("fetching page-annotation that doesn't exist, should've thrown");
- } catch(ex) {}
+ } catch (ex) {}
// check that annotation on the NOT removed item still exists
try {
var annoVal = PlacesUtils.annotations.getPageAnnotation(testAnnoRetainedURI,
testAnnoRetainedName);
- } catch(ex) {
+ } catch (ex) {
do_throw("The annotation has been removed erroneously");
}
do_check_eq(annoVal, testAnnoRetainedValue);
});
--- a/toolkit/components/places/tests/unit/test_418643_removeFolderChildren.js
+++ b/toolkit/components/places/tests/unit/test_418643_removeFolderChildren.js
@@ -7,17 +7,17 @@
// Get services.
try {
var histSvc = Cc["@mozilla.org/browser/nav-history-service;1"].
getService(Ci.nsINavHistoryService);
var bmSvc = Cc["@mozilla.org/browser/nav-bookmarks-service;1"].
getService(Ci.nsINavBookmarksService);
var annoSvc = Cc["@mozilla.org/browser/annotation-service;1"]
.getService(Ci.nsIAnnotationService);
-} catch(ex) {
+} catch (ex) {
do_throw("Could not get services\n");
}
var validAnnoName = "validAnno";
var validItemName = "validItem";
var deletedAnnoName = "deletedAnno";
var deletedItemName = "deletedItem";
var bookmarkedURI = uri("http://www.mozilla.org/");
@@ -93,17 +93,17 @@ function add_bookmarks() {
deletedBookmarkIds.push(deletedItemId);
return validFolderId;
}
function check_bookmarks(aFolderId) {
// check that we still have valid bookmarks
var bookmarks = bmSvc.getBookmarkIdsForURI(bookmarkedURI);
- for(var i = 0; i < bookmarks.length; i++) {
+ for (var i = 0; i < bookmarks.length; i++) {
do_check_eq(bmSvc.getItemTitle(bookmarks[i]), validItemName);
do_check_true(annoSvc.itemHasAnnotation(bookmarks[i],validAnnoName));
}
// check that folder exists and has still its annotation
do_check_eq(bmSvc.getItemTitle(aFolderId), validItemName);
do_check_true(annoSvc.itemHasAnnotation(aFolderId, validAnnoName));
--- a/toolkit/components/places/tests/unit/test_433317_query_title_update.js
+++ b/toolkit/components/places/tests/unit/test_433317_query_title_update.js
@@ -5,17 +5,17 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
function run_test() {
try {
var histsvc = Cc["@mozilla.org/browser/nav-history-service;1"].
getService(Ci.nsINavHistoryService);
var bmsvc = Cc["@mozilla.org/browser/nav-bookmarks-service;1"].
getService(Ci.nsINavBookmarksService);
- } catch(ex) {
+ } catch (ex) {
do_throw("Unable to initialize Places services");
}
// create a query bookmark
var queryId = bmsvc.insertBookmark(bmsvc.toolbarFolder, uri("place:"),
0 /* first item */, "test query");
// query for that query
--- a/toolkit/components/places/tests/unit/test_433525_hasChildren_crash.js
+++ b/toolkit/components/places/tests/unit/test_433525_hasChildren_crash.js
@@ -11,17 +11,17 @@ function run_test()
add_task(function* test_execute()
{
try {
var histsvc = Cc["@mozilla.org/browser/nav-history-service;1"].
getService(Ci.nsINavHistoryService);
var bmsvc = Cc["@mozilla.org/browser/nav-bookmarks-service;1"].
getService(Ci.nsINavBookmarksService);
- } catch(ex) {
+ } catch (ex) {
do_throw("Unable to initialize Places services");
}
// add a visit
var testURI = uri("http://test");
yield PlacesTestUtils.addVisits(testURI);
// query for the visit
--- a/toolkit/components/places/tests/unit/test_annotations.js
+++ b/toolkit/components/places/tests/unit/test_annotations.js
@@ -2,24 +2,24 @@
/* vim:set ts=2 sw=2 sts=2 et: */
/* 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/. */
// Get bookmark service
try {
var bmsvc = Cc["@mozilla.org/browser/nav-bookmarks-service;1"].getService(Ci.nsINavBookmarksService);
-} catch(ex) {
+} catch (ex) {
do_throw("Could not get nav-bookmarks-service\n");
}
// Get annotation service
try {
var annosvc= Cc["@mozilla.org/browser/annotation-service;1"].getService(Ci.nsIAnnotationService);
-} catch(ex) {
+} catch (ex) {
do_throw("Could not get annotation service\n");
}
var annoObserver = {
PAGE_lastSet_URI: "",
PAGE_lastSet_AnnoName: "",
onPageAnnotationSet: function(aURI, aName) {
@@ -61,17 +61,17 @@ add_task(function* test_execute()
var testItemId = bmsvc.insertBookmark(bmsvc.bookmarksMenuFolder, testURI, -1, "");
var testAnnoName = "moz-test-places/annotations";
var testAnnoVal = "test";
annosvc.addObserver(annoObserver);
// create new string annotation
try {
annosvc.setPageAnnotation(testURI, testAnnoName, testAnnoVal, 0, 0);
- } catch(ex) {
+ } catch (ex) {
do_throw("unable to add page-annotation");
}
do_check_eq(annoObserver.PAGE_lastSet_URI, testURI.spec);
do_check_eq(annoObserver.PAGE_lastSet_AnnoName, testAnnoName);
// get string annotation
do_check_true(annosvc.pageHasAnnotation(testURI, testAnnoName));
var storedAnnoVal = annosvc.getPageAnnotation(testURI, testAnnoName);
@@ -82,27 +82,27 @@ add_task(function* test_execute()
// Verify that lastModified equals dateAdded before we set the annotation.
do_check_eq(lastModified, bmsvc.getItemDateAdded(testItemId));
// Workaround possible VM timers issues moving last modified to the past.
bmsvc.setItemLastModified(testItemId, --lastModified);
annosvc.setItemAnnotation(testItemId, testAnnoName, testAnnoVal, 0, 0);
var lastModified2 = bmsvc.getItemLastModified(testItemId);
// verify that setting the annotation updates the last modified time
do_check_true(lastModified2 > lastModified);
- } catch(ex) {
+ } catch (ex) {
do_throw("unable to add item annotation");
}
do_check_eq(annoObserver.ITEM_lastSet_Id, testItemId);
do_check_eq(annoObserver.ITEM_lastSet_AnnoName, testAnnoName);
try {
var annoVal = annosvc.getItemAnnotation(testItemId, testAnnoName);
// verify the anno value
do_check_true(testAnnoVal === annoVal);
- } catch(ex) {
+ } catch (ex) {
do_throw("unable to get item annotation");
}
// test getPagesWithAnnotation
var uri2 = uri("http://www.tests.tld");
yield PlacesTestUtils.addVisits(uri2);
annosvc.setPageAnnotation(uri2, testAnnoName, testAnnoVal, 0, 0);
var pages = annosvc.getPagesWithAnnotation(testAnnoName);
@@ -121,21 +121,21 @@ add_task(function* test_execute()
do_check_true(items[0] != items[1]);
do_check_true(items[0] == testItemId || items[1] == testItemId);
do_check_true(items[0] == testItemId2 || items[1] == testItemId2);
// get annotation that doesn't exist
try {
annosvc.getPageAnnotation(testURI, "blah");
do_throw("fetching page-annotation that doesn't exist, should've thrown");
- } catch(ex) {}
+ } catch (ex) {}
try {
annosvc.getItemAnnotation(testURI, "blah");
do_throw("fetching item-annotation that doesn't exist, should've thrown");
- } catch(ex) {}
+ } catch (ex) {}
// get annotation info
var flags = {}, exp = {}, storageType = {};
annosvc.getPageAnnotationInfo(testURI, testAnnoName, flags, exp, storageType);
do_check_eq(flags.value, 0);
do_check_eq(exp.value, 0);
do_check_eq(storageType.value, Ci.nsIAnnotationService.TYPE_STRING);
annosvc.getItemAnnotationInfo(testItemId, testAnnoName, flags, exp, storageType);
@@ -288,26 +288,26 @@ add_task(function* test_execute()
// Setting item annotations on invalid item ids should throw
var invalidIds = [-1, 0, 37643];
for (var id of invalidIds) {
try {
annosvc.setItemAnnotation(id, "foo", "bar", 0, 0);
do_throw("setItemAnnotation* should throw for invalid item id: " + id)
}
- catch(ex) { }
+ catch (ex) { }
}
// setting an annotation with EXPIRE_HISTORY for an item should throw
itemId = bmsvc.insertBookmark(bmsvc.bookmarksMenuFolder, testURI, -1, "");
try {
annosvc.setItemAnnotation(itemId, "foo", "bar", 0, annosvc.EXPIRE_WITH_HISTORY);
do_throw("setting an item annotation with EXPIRE_HISTORY should throw");
}
- catch(ex) {
+ catch (ex) {
}
annosvc.removeObserver(annoObserver);
});
add_test(function test_getAnnotationsHavingName() {
let uri = NetUtil.newURI("http://cat.mozilla.org");
let id = PlacesUtils.bookmarks.insertBookmark(
--- a/toolkit/components/places/tests/unit/test_async_transactions.js
+++ b/toolkit/components/places/tests/unit/test_async_transactions.js
@@ -118,17 +118,17 @@ function run_test() {
function sanityCheckTransactionHistory() {
do_check_true(PT.undoPosition <= PT.length);
let check_entry_throws = f => {
try {
f();
do_throw("PT.entry should throw for invalid input");
- } catch(ex) {}
+ } catch (ex) {}
};
check_entry_throws( () => PT.entry(-1) );
check_entry_throws( () => PT.entry({}) );
check_entry_throws( () => PT.entry(PT.length) );
if (PT.undoPosition < PT.length)
do_check_eq(PT.topUndoEntry, PT.entry(PT.undoPosition));
else
@@ -328,17 +328,17 @@ function* ensureNonExistent(...aGuids) {
add_task(function* test_recycled_transactions() {
function* ensureTransactThrowsFor(aTransaction) {
let [txns, undoPosition] = getTransactionsHistoryState();
try {
yield aTransaction.transact();
do_throw("Shouldn't be able to use the same transaction twice");
}
- catch(ex) { }
+ catch (ex) { }
ensureUndoState(txns, undoPosition);
}
let txn_a = PT.NewFolder(createTestFolderInfo());
yield txn_a.transact();
ensureUndoState([[txn_a]], 0);
yield ensureTransactThrowsFor(txn_a);
@@ -351,17 +351,17 @@ add_task(function* test_recycled_transac
ensureTransactThrowsFor(txn_a);
let txn_b = PT.NewFolder(createTestFolderInfo());
yield PT.batch(function* () {
try {
yield txn_a.transact();
do_throw("Shouldn't be able to use the same transaction twice");
}
- catch(ex) { }
+ catch (ex) { }
ensureUndoState();
yield txn_b.transact();
});
ensureUndoState([[txn_b]], 0);
yield PT.undo();
ensureUndoState([[txn_b]], 1);
ensureTransactThrowsFor(txn_a);
--- a/toolkit/components/places/tests/unit/test_browserhistory.js
+++ b/toolkit/components/places/tests/unit/test_browserhistory.js
@@ -47,17 +47,17 @@ add_task(function* test_removePages() {
do_check_true(PlacesUtils.bookmarks.getIdForItemAt(PlacesUtils.unfiledBookmarksFolderId, 0) > 0);
do_check_eq(PlacesUtils.annotations.getPageAnnotation(pages[BOOKMARK_INDEX], ANNO_NAME),
ANNO_VALUE);
// Check the annotation on the non-bookmarked page does not exist anymore.
try {
PlacesUtils.annotations.getPageAnnotation(pages[ANNO_INDEX], ANNO_NAME);
do_throw("did not expire expire_never anno on a not bookmarked item");
- } catch(ex) {}
+ } catch (ex) {}
// Cleanup.
PlacesUtils.bookmarks.removeFolderChildren(PlacesUtils.unfiledBookmarksFolderId);
yield PlacesTestUtils.clearHistory();
});
add_task(function* test_removePagesByTimeframe() {
let visits = [];
--- a/toolkit/components/places/tests/unit/test_database_replaceOnStartup.js
+++ b/toolkit/components/places/tests/unit/test_database_replaceOnStartup.js
@@ -32,15 +32,15 @@ function run_test() {
dbFile.append("places.sqlite");
do_check_true(dbFile.exists());
// Check the new database is really a new one.
db = Services.storage.openUnsharedDatabase(file);
try {
db.executeSimpleSQL("DELETE * FROM test");
do_throw("The new database should not have our unique content");
- } catch(ex) {}
+ } catch (ex) {}
db.close();
dbFile = gProfD.clone();
dbFile.append("places.sqlite.corrupt");
do_check_true(dbFile.exists());
}
--- a/toolkit/components/places/tests/unit/test_frecency.js
+++ b/toolkit/components/places/tests/unit/test_frecency.js
@@ -113,17 +113,17 @@ function ensure_results_internal(uris, s
try {
var histsvc = Cc["@mozilla.org/browser/nav-history-service;1"].
getService(Ci.nsINavHistoryService);
var bhist = histsvc.QueryInterface(Ci.nsIBrowserHistory);
var tagssvc = Cc["@mozilla.org/browser/tagging-service;1"].
getService(Ci.nsITaggingService);
var bmksvc = Cc["@mozilla.org/browser/nav-bookmarks-service;1"].
getService(Ci.nsINavBookmarksService);
-} catch(ex) {
+} catch (ex) {
do_throw("Could not get history service\n");
}
function* task_setCountDate(aURI, aCount, aDate)
{
// We need visits so that frecency can be computed over multiple visits
let visits = [];
for (let i = 0; i < aCount; i++) {
--- a/toolkit/components/places/tests/unit/test_getChildIndex.js
+++ b/toolkit/components/places/tests/unit/test_getChildIndex.js
@@ -41,17 +41,17 @@ function run_test() {
print("Now testing: " + node.title);
do_check_eq(root.getChildIndex(node), i);
}
// Now search for an invalid node and expect an exception.
try {
root.getChildIndex(unfiledNode);
do_throw("Searching for an invalid node should have thrown.");
- } catch(ex) {
+ } catch (ex) {
print("We correctly got an exception.");
}
root.containerOpen = false;
}
function getNodeAt(aFolderId, aIndex) {
let hs = PlacesUtils.history;
--- a/toolkit/components/places/tests/unit/test_getPlacesInfo.js
+++ b/toolkit/components/places/tests/unit/test_getPlacesInfo.js
@@ -60,17 +60,17 @@ function* test_promisedHelper() {
let placeInfo = yield PlacesUtils.promisePlaceInfo(uri);
do_check_true(placeInfo instanceof Ci.mozIPlaceInfo);
uri = NetUtil.newURI("http://www.helper_non_existent_example.tld");
try {
let placeInfo = yield PlacesUtils.promisePlaceInfo(uri);
do_throw("PlacesUtils.promisePlaceInfo should have rejected the promise");
}
- catch(ex) { }
+ catch (ex) { }
}
add_task(test_promisedHelper);
function* test_infoByGUID() {
let testURI = NetUtil.newURI("http://www.guid_example.tld");
yield PlacesTestUtils.addVisits(testURI);
let placeInfoByURI = yield PlacesUtils.promisePlaceInfo(testURI);
@@ -79,17 +79,17 @@ function* test_infoByGUID() {
}
add_task(test_infoByGUID);
function* test_invalid_guid() {
try {
let placeInfoByGUID = yield PlacesUtils.promisePlaceInfo("###");
do_throw("getPlacesInfo should fail for invalid guids")
}
- catch(ex) { }
+ catch (ex) { }
}
add_task(test_invalid_guid);
function* test_mixed_selection() {
let placeInfo1, placeInfo2;
let uri = NetUtil.newURI("http://www.mixed_selection_test_1.tld");
yield PlacesTestUtils.addVisits(uri);
placeInfo1 = yield PlacesUtils.promisePlaceInfo(uri);
--- a/toolkit/components/places/tests/unit/test_history.js
+++ b/toolkit/components/places/tests/unit/test_history.js
@@ -158,17 +158,17 @@ add_task(function* test_execute()
// test for schema changes in bug 373239
// get direct db connection
var db = histsvc.QueryInterface(Ci.nsPIPlacesDatabase).DBConnection;
var q = "SELECT id FROM moz_bookmarks";
var statement;
try {
statement = db.createStatement(q);
- } catch(ex) {
+ } catch (ex) {
do_throw("bookmarks table does not have id field, schema is too old!");
}
finally {
statement.finalize();
}
// bug 394741 - regressed history text searches
yield PlacesTestUtils.addVisits(uri("http://mozilla.com"));
--- a/toolkit/components/places/tests/unit/test_history_autocomplete_tags.js
+++ b/toolkit/components/places/tests/unit/test_history_autocomplete_tags.js
@@ -57,17 +57,17 @@ AutoCompleteInput.prototype = {
throw Components.results.NS_ERROR_NO_INTERFACE;
}
}
// Get tagging service
try {
var tagssvc = Cc["@mozilla.org/browser/tagging-service;1"].
getService(Ci.nsITaggingService);
-} catch(ex) {
+} catch (ex) {
do_throw("Could not get tagging service\n");
}
function ensure_tag_results(uris, searchTerm)
{
print("Searching for '" + searchTerm + "'");
var controller = Components.classes["@mozilla.org/autocomplete/controller;1"].
getService(Components.interfaces.nsIAutoCompleteController);
--- a/toolkit/components/places/tests/unit/test_history_notifications.js
+++ b/toolkit/components/places/tests/unit/test_history_notifications.js
@@ -20,17 +20,17 @@ add_task(function* () {
/NS_ERROR_XPC_GS_RETURNED_FAILURE/);
yield promiseLocked;
// Close our connection and try to cleanup the file (could fail on Windows)
dbConn.close();
if (db.exists()) {
try {
db.remove(false);
- } catch(e) {
+ } catch (e) {
do_print("Unable to remove dummy places.sqlite");
}
}
// Create history service correctly
let promiseComplete = promiseTopicObserved(NS_PLACES_INIT_COMPLETE_TOPIC);
Cc["@mozilla.org/browser/nav-history-service;1"]
.getService(Ci.nsINavHistoryService);
--- a/toolkit/components/places/tests/unit/test_hosts_triggers.js
+++ b/toolkit/components/places/tests/unit/test_hosts_triggers.js
@@ -17,17 +17,17 @@ function isHostInMozPlaces(aURI)
{
let stmt = DBConn().createStatement(
`SELECT url
FROM moz_places
WHERE url_hash = hash(:host) AND url = :host`
);
let result = false;
stmt.params.host = aURI.spec;
- while(stmt.executeStep()) {
+ while (stmt.executeStep()) {
if (stmt.row.url == aURI.spec) {
result = true;
break;
}
}
stmt.finalize();
return result;
}
--- a/toolkit/components/places/tests/unit/test_isvisited.js
+++ b/toolkit/components/places/tests/unit/test_isvisited.js
@@ -51,27 +51,27 @@ add_task(function* test_execute()
"wyciwyg:/0/http://mozilla.org",
"javascript:alert('hello wolrd!');",
"http://localhost/" + "a".repeat(1984),
];
for (let currentURL of URLS) {
try {
var cantAddUri = uri(currentURL);
}
- catch(e) {
+ catch (e) {
// nsIIOService.newURI() can throw if e.g. our app knows about imap://
// but the account is not set up and so the URL is invalid for us.
// Note this in the log but ignore as it's not the subject of this test.
do_print("Could not construct URI for '" + currentURL + "'; ignoring");
}
if (cantAddUri) {
try {
yield PlacesTestUtils.addVisits({uri: cantAddUri, referrer: referrer});
do_throw("Should have generated an exception.");
- } catch(ex) {
+ } catch (ex) {
if (ex.result != Cr.NS_ERROR_ILLEGAL_VALUE) {
throw ex;
}
}
do_check_false(yield promiseIsURIVisited(cantAddUri));
}
}
});
--- a/toolkit/components/places/tests/unit/test_mozIAsyncLivemarks.js
+++ b/toolkit/components/places/tests/unit/test_mozIAsyncLivemarks.js
@@ -235,45 +235,45 @@ add_task(function* test_addLivemark_bogu
add_task(function* test_addLivemark_bogusParentId_fails() {
try {
yield PlacesUtils.livemarks.addLivemark(
{ title: "test"
, parentId: 187
, feedURI: FEED_URI
});
do_throw("Adding a livemark with a bogus parent should fail");
- } catch(ex) {}
+ } catch (ex) {}
});
add_task(function* test_addLivemark_bogusParentGuid_fails() {
try {
yield PlacesUtils.livemarks.addLivemark(
{ title: "test"
, parentGuid: "123456789012"
, feedURI: FEED_URI
});
do_throw("Adding a livemark with a bogus parent should fail");
- } catch(ex) {}
+ } catch (ex) {}
})
add_task(function* test_addLivemark_intoLivemark_fails() {
let livemark = yield PlacesUtils.livemarks.addLivemark(
{ title: "test"
, parentGuid: PlacesUtils.bookmarks.unfiledGuid
, feedURI: FEED_URI
});
try {
yield PlacesUtils.livemarks.addLivemark(
{ title: "test"
, parentGuid: livemark.guid
, feedURI: FEED_URI
});
do_throw("Adding a livemark into a livemark should fail");
- } catch(ex) {
+ } catch (ex) {
do_check_eq(ex.result, Cr.NS_ERROR_INVALID_ARG);
}
});
add_task(function* test_addLivemark_forceGuid_succeeds() {
let livemark = yield PlacesUtils.livemarks.addLivemark(
{ title: "test"
, parentGuid: PlacesUtils.bookmarks.unfiledGuid
@@ -325,17 +325,17 @@ add_task(function* test_removeLivemark_n
}
});
add_task(function* test_removeLivemark_nonExistent_fails() {
try {
yield PlacesUtils.livemarks.removeLivemark({ id: 1337 });
do_throw("Removing a non-existent livemark should fail");
}
- catch(ex) {
+ catch (ex) {
}
});
add_task(function* test_removeLivemark_guid_succeeds() {
let livemark = yield PlacesUtils.livemarks.addLivemark(
{ title: "test"
, parentGuid: PlacesUtils.bookmarks.unfiledGuid
, feedURI: FEED_URI
--- a/toolkit/components/places/tests/unit/test_multi_word_tags.js
+++ b/toolkit/components/places/tests/unit/test_multi_word_tags.js
@@ -3,34 +3,34 @@
/* 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/. */
// Get history service
try {
var histsvc = Cc["@mozilla.org/browser/nav-history-service;1"].
getService(Ci.nsINavHistoryService);
-} catch(ex) {
+} catch (ex) {
do_throw("Could not get history service\n");
}
// Get bookmark service
try {
var bmsvc = Cc["@mozilla.org/browser/nav-bookmarks-service;1"].
getService(Ci.nsINavBookmarksService);
}
-catch(ex) {
+catch (ex) {
do_throw("Could not get the nav-bookmarks-service\n");
}
// Get tagging service
try {
var tagssvc = Cc["@mozilla.org/browser/tagging-service;1"].
getService(Ci.nsITaggingService);
-} catch(ex) {
+} catch (ex) {
do_throw("Could not get tagging service\n");
}
// main
function run_test() {
var uri1 = uri("http://site.tld/1");
var uri2 = uri("http://site.tld/2");
var uri3 = uri("http://site.tld/3");
--- a/toolkit/components/places/tests/unit/test_null_interfaces.js
+++ b/toolkit/components/places/tests/unit/test_null_interfaces.js
@@ -71,17 +71,17 @@ function run_test()
func.apply(s, args);
do_print(`The function did not throw! Is it one of the nothrow? ${nothrow}`);
Assert.notEqual(nothrow.indexOf(n), -1);
do_print("Must have been an expected nothrow, so no need to try again");
tryAgain = false;
}
- catch(ex) {
+ catch (ex) {
if (ex.result == Cr.NS_ERROR_ILLEGAL_VALUE) {
do_print(`Caught an expected exception: ${ex.name}`);
do_print("Moving on to the next test..");
tryAgain = false;
} else if (ex.result == Cr.NS_ERROR_XPC_NEED_OUT_OBJECT) {
let pos = Number(ex.message.match(/object arg (\d+)/)[1]);
do_print(`Function call expects an out object at ${pos}`);
args[pos] = {};
--- a/toolkit/components/places/tests/unit/test_pageGuid_bookmarkGuid.js
+++ b/toolkit/components/places/tests/unit/test_pageGuid_bookmarkGuid.js
@@ -111,32 +111,32 @@ add_task(function* test_addVisitAndCheck
add_task(function* test_addItemsWithInvalidGUIDsFails() {
const INVALID_GUID = "XYZ";
try {
bmsvc.createFolder(bmsvc.placesRoot, "XYZ folder",
bmsvc.DEFAULT_INDEX, INVALID_GUID);
do_throw("Adding a folder with an invalid guid should fail");
}
- catch(ex) { }
+ catch (ex) { }
let folder = bmsvc.createFolder(bmsvc.placesRoot, "test folder",
bmsvc.DEFAULT_INDEX);
try {
bmsvc.insertBookmark(folder, uri("http://test.tld"), bmsvc.DEFAULT_INDEX,
"title", INVALID_GUID);
do_throw("Adding a bookmark with an invalid guid should fail");
}
- catch(ex) { }
+ catch (ex) { }
try {
bmsvc.insertSeparator(folder, bmsvc.DEFAULT_INDEX, INVALID_GUID);
do_throw("Adding a separator with an invalid guid should fail");
}
- catch(ex) { }
+ catch (ex) { }
yield PlacesUtils.bookmarks.eraseEverything();
});
add_task(function* test_addItemsWithGUIDs() {
const FOLDER_GUID = "FOLDER--GUID";
const BOOKMARK_GUID = "BM------GUID";
const SEPARATOR_GUID = "SEP-----GUID";
@@ -169,12 +169,12 @@ add_task(function* test_usingSameGUIDFai
const GUID = "XYZXYZXYZXYZ";
bmsvc.createFolder(bmsvc.placesRoot, "test folder",
bmsvc.DEFAULT_INDEX, GUID);
try {
bmsvc.createFolder(bmsvc.placesRoot, "test folder 2",
bmsvc.DEFAULT_INDEX, GUID);
do_throw("Using the same guid twice should fail");
}
- catch(ex) { }
+ catch (ex) { }
yield PlacesUtils.bookmarks.eraseEverything();
});
--- a/toolkit/components/places/tests/unit/test_placeURIs.js
+++ b/toolkit/components/places/tests/unit/test_placeURIs.js
@@ -3,17 +3,17 @@
/* 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/. */
// Get history service
try {
var histsvc = Cc["@mozilla.org/browser/nav-history-service;1"].getService(Ci.nsINavHistoryService);
-} catch(ex) {
+} catch (ex) {
do_throw("Could not get history service\n");
}
// main
function run_test() {
// XXX Full testing coverage for QueriesToQueryString and
// QueryStringToQueries
--- a/toolkit/components/places/tests/unit/test_tag_autocomplete_search.js
+++ b/toolkit/components/places/tests/unit/test_tag_autocomplete_search.js
@@ -57,17 +57,17 @@ AutoCompleteInput.prototype = {
throw Components.results.NS_ERROR_NO_INTERFACE;
}
}
// Get tagging service
try {
var tagssvc = Cc["@mozilla.org/browser/tagging-service;1"].
getService(Ci.nsITaggingService);
-} catch(ex) {
+} catch (ex) {
do_throw("Could not get tagging service\n");
}
function ensure_tag_results(results, searchTerm)
{
var controller = Cc["@mozilla.org/autocomplete/controller;1"].
getService(Ci.nsIAutoCompleteController);
--- a/toolkit/components/printing/content/printPageSetup.js
+++ b/toolkit/components/printing/content/printPageSetup.js
@@ -64,17 +64,17 @@ function initDialog()
//---------------------------------------------------
function isListOfPrinterFeaturesAvailable()
{
var has_printerfeatures = false;
try {
has_printerfeatures = gPrefs.getBoolPref("print.tmp.printerfeatures." + gPrintSettings.printerName + ".has_special_printerfeatures");
- } catch(ex) {
+ } catch (ex) {
}
return has_printerfeatures;
}
//---------------------------------------------------
function checkDouble(element)
{
@@ -261,17 +261,17 @@ function loadDialog()
gPrintService = Components.classes["@mozilla.org/gfx/printsettings-service;1"];
if (gPrintService) {
gPrintService = gPrintService.getService();
if (gPrintService) {
gPrintService = gPrintService.QueryInterface(Components.interfaces.nsIPrintSettingsService);
}
}
- } catch(ex) {
+ } catch (ex) {
dump("loadDialog: ex="+ex+"\n");
}
setPrinterDefaultsForSelectedPrinter();
gDialog.printBG.checked = gPrintSettings.printBGColors || gPrintSettings.printBGImages;
gDialog.shrinkToFit.checked = gPrintSettings.shrinkToFit;
--- a/toolkit/components/printing/content/printPreviewBindings.xml
+++ b/toolkit/components/printing/content/printPreviewBindings.xml
@@ -231,17 +231,17 @@
<![CDATA[
var value = Math.round(aValue);
var promptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"].getService(Components.interfaces.nsIPromptService);
var promptStr = this.mScaleLabel.value;
var renameTitle = this.mCustomTitle;
var result = {value:value};
var confirmed = promptService.prompt(window, renameTitle, promptStr, result, null, {value:value});
if (!confirmed || (!result.value) || (result.value == "") || result.value == value) {
- return(-1);
+ return -1;
}
return result.value;
]]>
</body>
</method>
<method name="setScaleCombobox">
<parameter name="aValue"/>
--- a/toolkit/components/printing/content/printPreviewProgress.js
+++ b/toolkit/components/printing/content/printPreviewProgress.js
@@ -110,17 +110,17 @@ function onLoad() {
function onUnload()
{
if (!printProgress)
return;
try {
printProgress.unregisterListener(progressListener);
printProgress = null;
}
- catch(e) {}
+ catch (e) {}
}
function getString (stringId) {
// Check if we've fetched this string already.
if (!(stringId in dialog.strings)) {
// Try to get it.
var elem = document.getElementById( "dialog.strings."+stringId);
try {
@@ -137,17 +137,17 @@ function getString (stringId) {
// If the user presses cancel, tell the app launcher and close the dialog...
function onCancel ()
{
// Cancel app launcher.
try {
printProgress.processCanceledByUser = true;
}
- catch(e) {return true;}
+ catch (e) {return true;}
// don't Close up dialog by returning false, the backend will close the dialog when everything will be aborted.
return false;
}
function doneIniting()
{
// called by function timeout in onLoad
--- a/toolkit/components/printing/content/printProgress.js
+++ b/toolkit/components/printing/content/printProgress.js
@@ -261,29 +261,29 @@ function onUnload()
if (printProgress)
{
try
{
printProgress.unregisterListener(progressListener);
printProgress = null;
}
- catch( exception ) {}
+ catch ( exception ) {}
}
}
// If the user presses cancel, tell the app launcher and close the dialog...
function onCancel ()
{
// Cancel app launcher.
try
{
printProgress.processCanceledByUser = true;
}
- catch( exception ) {return true;}
+ catch ( exception ) {return true;}
// don't Close up dialog by returning false, the backend will close the dialog when everything will be aborted.
return false;
}
function doneIniting()
{
printProgress.doneIniting();
--- a/toolkit/components/printing/content/printUtils.js
+++ b/toolkit/components/printing/content/printUtils.js
@@ -356,17 +356,17 @@ var PrintUtils = {
let msg, title;
if (!isPrinting) {
// Try first with _PP suffix.
let ppMsgName = msgName + "_PP";
try {
msg = this.bundle.GetStringFromName(ppMsgName);
- } catch(e) {
+ } catch (e) {
// We allow localizers to not have the print preview error string,
// and just fall back to the printing error string.
}
}
if (!msg) {
msg = this.bundle.GetStringFromName(msgName);
}
--- a/toolkit/components/printing/content/printdialog.js
+++ b/toolkit/components/printing/content/printdialog.js
@@ -79,17 +79,17 @@ function stripTrailingWhitespace(element
//---------------------------------------------------
function getPrinterDescription(printerName)
{
var s = "";
try {
/* This may not work with non-ASCII test (see bug 235763 comment #16) */
s = gPrefs.getCharPref("print.printer_" + printerName + ".printer_description")
- } catch(e) {
+ } catch (e) {
}
return s;
}
//---------------------------------------------------
function listElement(aListElement)
{
@@ -143,17 +143,17 @@ function getPrinters()
selectElement.clearList();
var printerEnumerator;
try {
printerEnumerator =
Components.classes["@mozilla.org/gfx/printerenumerator;1"]
.getService(Components.interfaces.nsIPrinterEnumerator)
.printerNameList;
- } catch(e) { printerEnumerator = null; }
+ } catch (e) { printerEnumerator = null; }
selectElement.appendPrinterNames(printerEnumerator);
selectElement.listElement.value = printService.defaultPrinterName;
// make sure we load the prefs for the initially selected printer
setPrinterDefaultsForSelectedPrinter();
}
@@ -183,17 +183,17 @@ function displayPropertiesDialog()
gPrintSettings.numCopies = dialog.numCopiesInput.value;
try {
var printingPromptService = Components.classes["@mozilla.org/embedcomp/printingprompt-service;1"]
.getService(Components.interfaces.nsIPrintingPromptService);
if (printingPromptService) {
printingPromptService.showPrinterProperties(null, dialog.printerList.value, gPrintSettings);
dialog.numCopiesInput.value = gPrintSettings.numCopies;
}
- } catch(e) {
+ } catch (e) {
dump("problems getting printingPromptService\n");
}
}
//---------------------------------------------------
function doPrintRange(inx)
{
if (inx == 1) {
@@ -223,17 +223,17 @@ function loadDialog()
printService = Components.classes["@mozilla.org/gfx/printsettings-service;1"];
if (printService) {
printService = printService.getService();
if (printService) {
printService = printService.QueryInterface(Components.interfaces.nsIPrintSettingsService);
}
}
- } catch(e) {}
+ } catch (e) {}
// Note: getPrinters sets up the PrintToFile control
getPrinters();
if (gPrintSettings) {
print_tofile = gPrintSettings.printToFile;
gOriginalNumCopies = gPrintSettings.numCopies;
@@ -411,15 +411,15 @@ function chooseFile()
.createInstance(nsIFilePicker);
fp.init(window, dialog.fpDialog.getAttribute("label"), nsIFilePicker.modeSave);
fp.appendFilters(nsIFilePicker.filterAll);
if (fp.show() != Components.interfaces.nsIFilePicker.returnCancel &&
fp.file && fp.file.path) {
gPrintSettings.toFileName = fp.file.path;
return true;
}
- } catch(ex) {
+ } catch (ex) {
dump(ex);
}
return false;
}
--- a/toolkit/components/printing/content/printjoboptions.js
+++ b/toolkit/components/printing/content/printjoboptions.js
@@ -34,17 +34,17 @@ function checkDouble(element, maxVal)
//---------------------------------------------------
function isListOfPrinterFeaturesAvailable()
{
var has_printerfeatures = false;
try {
has_printerfeatures = gPrefs.getBoolPref("print.tmp.printerfeatures." + gPrintSettings.printerName + ".has_special_printerfeatures");
- } catch(ex) {
+ } catch (ex) {
}
return has_printerfeatures;
}
//---------------------------------------------------
function getDoubleStr(val, dec)
{
--- a/toolkit/components/processsingleton/MainProcessSingleton.js
+++ b/toolkit/components/processsingleton/MainProcessSingleton.js
@@ -39,17 +39,17 @@ MainProcessSingleton.prototype = {
let isWeb = ["https", "http", "ftp"];
if (isWeb.indexOf(engineURL.scheme) < 0)
throw "Unsupported search engine URL: " + engineURL;
if (iconURL && isWeb.indexOf(iconURL.scheme) < 0)
throw "Unsupported search icon URL: " + iconURL;
}
- catch(ex) {
+ catch (ex) {
Cu.reportError("Invalid argument passed to window.external.AddSearchProvider: " + ex);
var searchBundle = Services.strings.createBundle("chrome://global/locale/search/search.properties");
var brandBundle = Services.strings.createBundle("chrome://branding/locale/brand.properties");
var brandName = brandBundle.GetStringFromName("brandShortName");
var title = searchBundle.GetStringFromName("error_invalid_engine_title");
var msg = searchBundle.formatStringFromName("error_invalid_engine_msg",
[brandName], 1);
--- a/toolkit/components/prompts/content/tabprompts.xml
+++ b/toolkit/components/prompts/content/tabprompts.xml
@@ -183,17 +183,17 @@
<method name="shutdownPrompt">
<body>
<![CDATA[
// remove our event listeners
try {
window.removeEventListener("resize", this, false);
window.removeEventListener("unload", this, false);
this.linkedTab.removeEventListener("TabClose", this, false);
- } catch(e) { }
+ } catch (e) { }
this.isLive = false;
// invoke callback
this.onCloseCallback();
]]>
</body>
</method>
<method name="abortPrompt">
--- a/toolkit/components/prompts/test/test_dom_prompts.html
+++ b/toolkit/components/prompts/test/test_dom_prompts.html
@@ -64,17 +64,17 @@ add_task(function* test_alert_noargs() {
buttonClick: "ok",
};
promptDone = handlePrompt(state, action);
try {
alert();
ok(true, "alert() without arguments should not throw!");
- } catch(e) {
+ } catch (e) {
ok(false, "alert() without arguments should not throw!");
}
yield promptDone;
});
add_task(function* test_confirm_ok() {
@@ -126,17 +126,17 @@ add_task(function* test_confirm_noargs()
buttonClick: "ok",
};
promptDone = handlePrompt(state, action);
try {
rv = confirm();
ok(true, "confirm() without arguments should not throw!");
- } catch(e) {
+ } catch (e) {
ok(false, "confirm() without arguments should not throw!");
}
is(rv, true, "check prompt return value");
yield promptDone;
});
@@ -189,17 +189,17 @@ add_task(function* test_prompt_noargs()
buttonClick: "ok",
};
promptDone = handlePrompt(state, action);
try {
rv = prompt();
ok(true, "prompt() without arguments should not throw!");
- } catch(e) {
+ } catch (e) {
ok(false, "prompt() without arguments should not throw!");
}
is(rv, "", "check prompt return value");
yield promptDone;
});
</script>
--- a/toolkit/components/reader/AboutReader.jsm
+++ b/toolkit/components/reader/AboutReader.jsm
@@ -708,17 +708,17 @@ AboutReader.prototype = {
img.onload = function() {
setImageMargins(img);
}
}
}
},
_maybeSetTextDirection: function Read_maybeSetTextDirection(article) {
- if(!article.dir)
+ if (!article.dir)
return;
//Set "dir" attribute on content
this._contentElement.setAttribute("dir", article.dir);
this._headerElement.setAttribute("dir", article.dir);
},
_showError: function() {
--- a/toolkit/components/reader/ReaderMode.jsm
+++ b/toolkit/components/reader/ReaderMode.jsm
@@ -71,17 +71,17 @@ this.ReaderMode = {
let isEnabled = Services.prefs.getBoolPref("reader.parse-on-load.enabled");
let isForceEnabled = Services.prefs.getBoolPref("reader.parse-on-load.force-enabled");
// For low-memory devices, don't allow reader mode since it takes up a lot of memory.
// See https://bugzilla.mozilla.org/show_bug.cgi?id=792603 for details.
return isForceEnabled || (isEnabled && !this.isOnLowMemoryPlatform);
},
observe: function(aMessage, aTopic, aData) {
- switch(aTopic) {
+ switch (aTopic) {
case "nsPref:changed":
if (aData.startsWith("reader.parse-on-load.")) {
this.isEnabledForParseOnLoad = this._getStateForParseOnLoad();
} else if (aData === "reader.parse-node-limit") {
this.parseNodeLimit = Services.prefs.getIntPref(aData);
}
break;
}
--- a/toolkit/components/satchel/nsFormAutoComplete.js
+++ b/toolkit/components/satchel/nsFormAutoComplete.js
@@ -240,17 +240,17 @@ FormAutoComplete.prototype = {
// We have a list of results for a shorter search string, so just
// filter them further based on the new search string and add to a new array.
let entries = wrappedResult.entries;
let filteredEntries = [];
for (let i = 0; i < entries.length; i++) {
let entry = entries[i];
// Remove results that do not contain the token
// XXX bug 394604 -- .toLowerCase can be wrong for some intl chars
- if(searchTokens.some(tok => entry.textLowerCase.indexOf(tok) < 0))
+ if (searchTokens.some(tok => entry.textLowerCase.indexOf(tok) < 0))
continue;
this._calculateScore(entry, searchString, searchTokens);
this.log("Reusing autocomplete entry '" + entry.text +
"' (" + entry.frecency +" / " + entry.totalScore + ")");
filteredEntries.push(entry);
}
filteredEntries.sort(sortBytotalScore);
wrappedResult.entries = filteredEntries;
--- a/toolkit/components/satchel/nsFormHistory.js
+++ b/toolkit/components/satchel/nsFormHistory.js
@@ -403,17 +403,17 @@ FormHistory.prototype = {
return this.dbConnection;
},
/* ---- nsIObserver interface ---- */
observe : function observe(subject, topic, data) {
- switch(topic) {
+ switch (topic) {
case "nsPref:changed":
this.updatePrefs();
break;
case "profile-before-change":
this._dbClose(false);
break;
default:
this.log("Oops! Unexpected notification: " + topic);
--- a/toolkit/components/satchel/test/test_form_autocomplete.html
+++ b/toolkit/components/satchel/test/test_form_autocomplete.html
@@ -230,17 +230,17 @@ registerPopupShownListener(popupShownLis
* to listen to for when the search is complete.
* - some items still use setTimeout
*/
function runTest() {
testNum++;
ok(true, "Starting test #" + testNum);
- switch(testNum) {
+ switch (testNum) {
case 1:
// Make sure initial form is empty.
checkForm("");
// Trigger autocomplete popup
expectPopup();
restoreForm();
doKey("down");
break;
--- a/toolkit/components/satchel/test/test_form_autocomplete_with_list.html
+++ b/toolkit/components/satchel/test/test_form_autocomplete_with_list.html
@@ -101,17 +101,17 @@ registerPopupShownListener(popupShownLis
* - set expectingPopup to true, and the next test will occur when the autocomplete popup is shown
* - call waitForMenuChange(x) to run the next test when the autocomplete popup to have x items in it
*/
function runTest() {
testNum++;
info("Starting test #" + testNum);
- switch(testNum) {
+ switch (testNum) {
case 1:
// Make sure initial form is empty.
checkForm("");
// Trigger autocomplete popup
expectPopup();
restoreForm();
doKey("down");
break;
--- a/toolkit/components/search/SearchSuggestionController.jsm
+++ b/toolkit/components/search/SearchSuggestionController.jsm
@@ -276,17 +276,17 @@ this.SearchSuggestionController.prototyp
if (status != HTTP_OK || this._request.responseText == "") {
deferredResponse.resolve("Non-200 status or empty HTTP response: " + status);
return;
}
try {
serverResults = JSON.parse(this._request.responseText);
- } catch(ex) {
+ } catch (ex) {
deferredResponse.resolve("Failed to parse suggestion JSON: " + ex);
return;
}
if (!serverResults[0] ||
this._searchString.localeCompare(serverResults[0], undefined,
{ sensitivity: "base" })) {
// something is wrong here so drop remote results
--- a/toolkit/components/search/nsSidebar.js
+++ b/toolkit/components/search/nsSidebar.js
@@ -16,17 +16,17 @@ function nsSidebar() {
nsSidebar.prototype = {
init: function(window) {
this.window = window;
try {
this.mm = window.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIDocShell)
.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIContentFrameMessageManager);
- } catch(e) {
+ } catch (e) {
Cu.reportError(e);
}
},
// Deprecated, only left here to avoid breaking old browser-detection scripts.
addSearchEngine: function(engineURL, iconURL, suggestedTitle, suggestedCategory) {
if (SHERLOCK_FILE_EXT_REGEXP.test(engineURL)) {
Cu.reportError("Installing Sherlock search plugins is no longer supported.");
--- a/toolkit/components/search/tests/xpcshell/head_search.js
+++ b/toolkit/components/search/tests/xpcshell/head_search.js
@@ -305,17 +305,17 @@ function parseJsonFromStream(aInputStrea
* Read a JSON file and return the JS object
*/
function readJSONFile(aFile) {
let stream = Cc["@mozilla.org/network/file-input-stream;1"].
createInstance(Ci.nsIFileInputStream);
try {
stream.init(aFile, MODE_RDONLY, FileUtils.PERMS_FILE, 0);
return parseJsonFromStream(stream, stream.available());
- } catch(ex) {
+ } catch (ex) {
dumpn("readJSONFile: Error reading JSON file: " + ex);
} finally {
stream.close();
}
return false;
}
/**
--- a/toolkit/components/social/MozSocialAPI.jsm
+++ b/toolkit/components/social/MozSocialAPI.jsm
@@ -59,33 +59,33 @@ function injectController(doc, topic, da
.QueryInterface(Ci.nsIDocShell)
.chromeEventHandler;
// limit injecting into social panels or same-origin browser tabs if
// social.debug.injectIntoTabs is enabled
let allowTabs = false;
try {
allowTabs = containingBrowser.contentWindow == window &&
Services.prefs.getBoolPref("social.debug.injectIntoTabs");
- } catch(e) {}
+ } catch (e) {}
let origin = containingBrowser.getAttribute("origin");
if (!allowTabs && !origin) {
return;
}
// we always handle window.close on social content, even if they are not
// "enabled".
hookWindowCloseForPanelClose(window);
SocialService.getProvider(doc.nodePrincipal.origin, function(provider) {
if (provider && provider.enabled) {
attachToWindow(provider, window);
}
});
- } catch(e) {
+ } catch (e) {
Cu.reportError("MozSocialAPI injectController: unable to attachToWindow for " + doc.location + ": " + e);
}
}
// Loads mozSocial support functions associated with provider into targetWindow
function attachToWindow(provider, targetWindow) {
// If the loaded document isn't from the provider's origin (or a protocol
// that inherits the principal), don't attach the mozSocial API.
--- a/toolkit/components/social/SocialService.jsm
+++ b/toolkit/components/social/SocialService.jsm
@@ -171,17 +171,17 @@ function getOriginActivationType(origin)
var ActiveProviders = {
get _providers() {
delete this._providers;
this._providers = {};
try {
let pref = Services.prefs.getComplexValue("social.activeProviders",
Ci.nsISupportsString);
this._providers = JSON.parse(pref);
- } catch(ex) {}
+ } catch (ex) {}
return this._providers;
},
has: function (origin) {
return (origin in this._providers);
},
add: function (origin) {
@@ -212,48 +212,48 @@ var ActiveProviders = {
Ci.nsISupportsString, string);
}
};
function migrateSettings() {
let activeProviders, enabled;
try {
activeProviders = Services.prefs.getCharPref("social.activeProviders");
- } catch(e) {
+ } catch (e) {
// not set, we'll check if we need to migrate older prefs
}
if (Services.prefs.prefHasUserValue("social.enabled")) {
enabled = Services.prefs.getBoolPref("social.enabled");
}
if (activeProviders) {
// migration from fx21 to fx22 or later
// ensure any *builtin* provider in activeproviders is in user level prefs
for (let origin in ActiveProviders._providers) {
let prefname;
let manifest;
let defaultManifest;
try {
prefname = getPrefnameFromOrigin(origin);
manifest = JSON.parse(Services.prefs.getComplexValue(prefname, Ci.nsISupportsString).data);
- } catch(e) {
+ } catch (e) {
// Our preference is missing or bad, remove from ActiveProviders and
// continue. This is primarily an error-case and should only be
// reached by either messing with preferences or hitting the one or
// two days of nightly that ran into it, so we'll flush right away.
ActiveProviders.delete(origin);
ActiveProviders.flush();
continue;
}
let needsUpdate = !manifest.updateDate;
// fx23 may have built-ins with shareURL
try {
defaultManifest = Services.prefs.getDefaultBranch(null)
.getComplexValue(prefname, Ci.nsISupportsString).data;
defaultManifest = JSON.parse(defaultManifest);
- } catch(e) {
+ } catch (e) {
// not a built-in, continue
}
if (defaultManifest) {
if (defaultManifest.shareURL && !manifest.shareURL) {
manifest.shareURL = defaultManifest.shareURL;
needsUpdate = true;
}
if (defaultManifest.version && (!manifest.version || defaultManifest.version > manifest.version)) {
@@ -285,30 +285,30 @@ function migrateSettings() {
Services.prefs.clearUserPref("social.enabled");
return;
}
// primary migration from pre-fx21
let active;
try {
active = Services.prefs.getBoolPref("social.active");
- } catch(e) {}
+ } catch (e) {}
if (!active)
return;
// primary difference from SocialServiceInternal.manifests is that we
// only read the default branch here.
let manifestPrefs = Services.prefs.getDefaultBranch("social.manifest.");
let prefs = manifestPrefs.getChildList("", []);
for (let pref of prefs) {
try {
let manifest;
try {
manifest = JSON.parse(manifestPrefs.getComplexValue(pref, Ci.nsISupportsString).data);
- } catch(e) {
+ } catch (e) {
// bad or missing preference, we wont update this one.
continue;
}
if (manifest && typeof(manifest) == "object" && manifest.origin) {
// our default manifests have been updated with the builtin flags as of
// fx22, delete it so we can set the user-pref
delete manifest.builtin;
if (!manifest.updateDate) {
@@ -336,17 +336,17 @@ function initService() {
Services.obs.addObserver(function xpcomShutdown() {
ActiveProviders.flush();
SocialService._providerListeners = null;
Services.obs.removeObserver(xpcomShutdown, "xpcom-shutdown");
}, "xpcom-shutdown", false);
try {
migrateSettings();
- } catch(e) {
+ } catch (e) {
// no matter what, if migration fails we do not want to render social
// unusable. Worst case scenario is that, when upgrading Firefox, previously
// enabled providers are not migrated.
Cu.reportError("Error migrating social settings: " + e);
}
}
function schedule(callback) {
@@ -533,17 +533,17 @@ this.SocialService = {
if (data[url]) {
try {
let resolved = Services.io.newURI(principal.URI.resolve(data[url]), null, null);
if (!(resolved.schemeIs("http") || resolved.schemeIs("https"))) {
Cu.reportError("SocialService.manifestFromData unsupported scheme '" + resolved.scheme + "' for " + principal.origin);
return null;
}
data[url] = resolved.spec;
- } catch(e) {
+ } catch (e) {
Cu.reportError("SocialService.manifestFromData unable to resolve '" + url + "' for " + principal.origin);
return null;
}
}
}
return data;
},
@@ -603,17 +603,17 @@ this.SocialService = {
aAddon.userDisabled = false;
}
schedule(function () {
try {
this._installProvider(data, options, aManifest => {
this._notifyProviderListeners("provider-installed", aManifest.origin);
installCallback(aManifest);
});
- } catch(e) {
+ } catch (e) {
Cu.reportError("Activation failed: " + e);
installCallback(null);
}
}.bind(this));
}.bind(this));
},
_installProvider: function(data, options, installCallback) {
@@ -715,17 +715,17 @@ function SocialProvider(input) {
let originUri = Services.io.newURI(input.origin, null, null);
this.principal = Services.scriptSecurityManager.createCodebasePrincipal(originUri, {});
this.ambientNotificationIcons = {};
this.errorState = null;
this.frecency = 0;
try {
this.domain = etld.getBaseDomainFromHost(originUri.host);
- } catch(e) {
+ } catch (e) {
this.domain = originUri.host;
}
}
SocialProvider.prototype = {
reload: function() {
// calling terminate/activate does not set the enabled state whereas setting
// enabled will call terminate/activate
@@ -891,17 +891,17 @@ var SocialAddonProvider = {
for (let manifest of SocialServiceInternal.manifests) {
try {
if (ActiveProviders.has(manifest.origin)) {
let addon = new AddonWrapper(manifest);
if (addon.blocklistState != Ci.nsIBlocklistService.STATE_NOT_BLOCKED) {
SocialService.disableProvider(manifest.origin);
}
}
- } catch(e) {
+ } catch (e) {
Cu.reportError(e);
}
}
},
getAddonByID: function(aId, aCallback) {
for (let manifest of SocialServiceInternal.manifests) {
if (aId == getAddonIDFromOrigin(manifest.origin)) {
--- a/toolkit/components/telemetry/TelemetryEnvironment.jsm
+++ b/toolkit/components/telemetry/TelemetryEnvironment.jsm
@@ -374,18 +374,18 @@ function getWindowsVersionInfo() {
try {
let GetVersionEx = kernel32.declare("GetVersionExW",
ctypes.default_abi,
BOOL,
OSVERSIONINFOEXW.ptr);
let winVer = OSVERSIONINFOEXW();
winVer.dwOSVersionInfoSize = OSVERSIONINFOEXW.size;
- if(0 === GetVersionEx(winVer.address())) {
- throw("Failure in GetVersionEx (returned 0)");
+ if (0 === GetVersionEx(winVer.address())) {
+ throw ("Failure in GetVersionEx (returned 0)");
}
return {
servicePackMajor: winVer.wServicePackMajor,
servicePackMinor: winVer.wServicePackMinor,
buildNumber: winVer.dwBuildNumber,
};
} catch (e) {
@@ -706,17 +706,17 @@ EnvironmentAddonBuilder.prototype = {
let scope = {};
Cu.import("resource:///modules/experiments/Experiments.jsm", scope);
let experiments = scope.Experiments.instance();
let activeExperiment = experiments.getActiveExperimentID();
if (activeExperiment) {
experimentInfo.id = activeExperiment;
experimentInfo.branch = experiments.getActiveExperimentBranch();
}
- } catch(e) {
+ } catch (e) {
// If this is not Firefox, the import will fail.
}
return experimentInfo;
},
};
function EnvironmentCache() {
@@ -884,17 +884,17 @@ EnvironmentCache.prototype = {
/**
* Start watching the preferences.
*/
_startWatchingPrefs: function () {
this._log.trace("_startWatchingPrefs - " + this._watchedPrefs);
for (let [pref, options] of this._watchedPrefs) {
- if(!("requiresRestart" in options) || !options.requiresRestart) {
+ if (!("requiresRestart" in options) || !options.requiresRestart) {
Preferences.observe(pref, this._onPrefChanged, this);
}
}
},
_onPrefChanged: function() {
this._log.trace("_onPrefChanged");
let oldEnvironment = Cu.cloneInto(this._currentEnvironment, myScope);
@@ -904,17 +904,17 @@ EnvironmentCache.prototype = {
/**
* Do not receive any more change notifications for the preferences.
*/
_stopWatchingPrefs: function () {
this._log.trace("_stopWatchingPrefs");
for (let [pref, options] of this._watchedPrefs) {
- if(!("requiresRestart" in options) || !options.requiresRestart) {
+ if (!("requiresRestart" in options) || !options.requiresRestart) {
Preferences.ignore(pref, this._onPrefChanged, this);
}
}
},
_addObservers: function () {
// Watch the search engine change and service topics.
Services.obs.addObserver(this, COMPOSITOR_CREATED_TOPIC, false);
@@ -923,17 +923,17 @@ EnvironmentCache.prototype = {
Services.obs.addObserver(this, SEARCH_ENGINE_MODIFIED_TOPIC, false);
Services.obs.addObserver(this, SEARCH_SERVICE_TOPIC, false);
},
_removeObservers: function () {
Services.obs.removeObserver(this, COMPOSITOR_CREATED_TOPIC);
try {
Services.obs.removeObserver(this, DISTRIBUTION_CUSTOMIZATION_COMPLETE_TOPIC);
- } catch(ex) {}
+ } catch (ex) {}
Services.obs.removeObserver(this, GFX_FEATURES_READY_TOPIC);
Services.obs.removeObserver(this, SEARCH_ENGINE_MODIFIED_TOPIC);
Services.obs.removeObserver(this, SEARCH_SERVICE_TOPIC);
},
observe: function (aSubject, aTopic, aData) {
this._log.trace("observe - aTopic: " + aTopic + ", aData: " + aData);
switch (aTopic) {
@@ -1408,17 +1408,17 @@ EnvironmentCache.prototype = {
this._delayedInitFinished &&
(CHANGE_THROTTLE_INTERVAL_MS >=
(now.getTime() - this._lastEnvironmentChangeDate.getTime()))) {
this._log.trace("_onEnvironmentChange - throttling changes, now: " + now +
", last change: " + this._lastEnvironmentChangeDate);
return;
}
- if(this._delayedInitFinished) {
+ if (this._delayedInitFinished) {
this._lastEnvironmentChangeDate = now;
}
for (let [name, listener] of this._changeListeners) {
try {
this._log.debug("_onEnvironmentChange - calling " + name);
listener(what, oldEnvironment);
} catch (e) {
--- a/toolkit/components/telemetry/TelemetryLog.jsm
+++ b/toolkit/components/telemetry/TelemetryLog.jsm
@@ -11,17 +11,17 @@ const Telemetry = Cc["@mozilla.org/base/
var gLogEntries = [];
this.TelemetryLog = Object.freeze({
log: function(id, data) {
id = String(id);
var ts;
try {
ts = Math.floor(Telemetry.msSinceProcessStart());
- } catch(e) {
+ } catch (e) {
// If timestamp is screwed up, we just give up instead of making up
// data.
return;
}
var entry = [id, ts];
if (data !== undefined) {
entry = entry.concat(Array.prototype.map.call(data, String));
--- a/toolkit/components/telemetry/TelemetryReportingPolicy.jsm
+++ b/toolkit/components/telemetry/TelemetryReportingPolicy.jsm
@@ -247,17 +247,17 @@ var TelemetryReportingPolicyImpl = {
get minimumPolicyVersion() {
const minPolicyVersion = Preferences.get(PREF_MINIMUM_POLICY_VERSION, 1);
// First check if the current channel has a specific minimum policy version. If not,
// use the general minimum policy version.
let channel = "";
try {
channel = UpdateUtils.getUpdateChannel(false);
- } catch(e) {
+ } catch (e) {
this._log.error("minimumPolicyVersion - Unable to retrieve the current channel.");
return minPolicyVersion;
}
const channelPref = PREF_MINIMUM_POLICY_VERSION + ".channel-" + channel;
return Preferences.get(channelPref, minPolicyVersion);
},
get dataSubmissionPolicyAcceptedVersion() {
--- a/toolkit/components/telemetry/TelemetrySend.jsm
+++ b/toolkit/components/telemetry/TelemetrySend.jsm
@@ -669,17 +669,17 @@ var TelemetrySendImpl = {
*/
notifyCanUpload: function() {
// Let the scheduler trigger sending pings if possible.
SendScheduler.triggerSendingPings(true);
return this.promisePendingPingActivity();
},
observe: function(subject, topic, data) {
- switch(topic) {
+ switch (topic) {
case TOPIC_IDLE_DAILY:
SendScheduler.triggerSendingPings(true);
break;
}
},
submitPing: function(ping) {
this._log.trace("submitPing - ping id: " + ping.id);
--- a/toolkit/components/telemetry/TelemetrySession.jsm
+++ b/toolkit/components/telemetry/TelemetrySession.jsm
@@ -234,17 +234,17 @@ var processInfo = {
ctypes.winapi_abi,
ctypes.voidptr_t); // return
this._initialized = true;
} catch (err) {
return null;
}
}
let io = new this._IO_COUNTERS();
- if(!this._GetProcessIoCounters(this._GetCurrentProcess(), io.address()))
+ if (!this._GetProcessIoCounters(this._GetCurrentProcess(), io.address()))
return null;
return [parseInt(io.readBytes), parseInt(io.writeBytes)];
}
};
/**
* TelemetryScheduler contains a single timer driving all regularly-scheduled
* Telemetry related jobs. Having a single place with this logic simplifies
@@ -392,17 +392,17 @@ var TelemetryScheduler = {
.catch(e => this._log.error("_saveAbortedPing - Failed", e));
},
/**
* The notifications handler.
*/
observe: function(aSubject, aTopic, aData) {
this._log.trace("observe - aTopic: " + aTopic);
- switch(aTopic) {
+ switch (aTopic) {
case "idle":
// If the user is idle, increase the tick interval.
this._isUserIdle = true;
return this._onSchedulerTick();
break;
case "active":
// User is back to work, restore the original tick interval.
this._isUserIdle = false;
--- a/toolkit/components/telemetry/TelemetryStopwatch.jsm
+++ b/toolkit/components/telemetry/TelemetryStopwatch.jsm
@@ -88,17 +88,17 @@ let Timers = {
this._timers.get(histogram).has(obj) &&
this._timers.get(histogram).get(obj).has(key);
},
delete: function(histogram, obj, key) {
key = key === null ? NULL_KEY : key;
obj = obj || NULL_OBJECT;
- if(!this.has(histogram, obj, key)) {
+ if (!this.has(histogram, obj, key)) {
return false;
}
let objectMap = this._timers.get(histogram);
let keyedInfo = objectMap.get(obj);
if (keyedInfo.size > 1) {
keyedInfo.delete(key);
return true;
}
--- a/toolkit/components/telemetry/TelemetryStorage.jsm
+++ b/toolkit/components/telemetry/TelemetryStorage.jsm
@@ -738,17 +738,17 @@ var TelemetryStorageImpl = {
_saveSessionData: Task.async(function* (sessionData) {
let dataDir = OS.Path.join(OS.Constants.Path.profileDir, DATAREPORTING_DIR);
yield OS.File.makeDir(dataDir);
let filePath = OS.Path.join(gDataReportingDir, SESSION_STATE_FILE_NAME);
try {
yield CommonUtils.writeJSON(sessionData, filePath);
- } catch(e) {
+ } catch (e) {
this._log.error("_saveSessionData - Failed to write session data to " + filePath, e);
Telemetry.getHistogramById("TELEMETRY_SESSIONDATA_FAILED_SAVE").add(1);
}
}),
/**
* Loads session data from the session data file.
* @return {Promise<Object>} A promise resolved with an object on success,
@@ -1258,17 +1258,17 @@ var TelemetryStorageImpl = {
try {
this._log.trace("savePingToFile - path: " + filePath);
let pingString = JSON.stringify(ping);
let options = { tmpPath: filePath + ".tmp", noOverwrite: !overwrite };
if (compress) {
options.compression = "lz4";
}
yield OS.File.writeAtomic(filePath, pingString, options);
- } catch(e) {
+ } catch (e) {
if (!e.becauseExists) {
throw e;
}
}
}),
/**
* Save a ping to its file.
@@ -1346,17 +1346,17 @@ var TelemetryStorageImpl = {
Telemetry.getHistogramById("TELEMETRY_PING_SIZE_EXCEEDED_PENDING").add();
throw new Error("loadPendingPing - exceeded the maximum ping size: " + fileSize);
}
// Try to load the ping file. Update the related histograms on failure.
let ping;
try {
ping = yield this.loadPingFile(info.path, false);
- } catch(e) {
+ } catch (e) {
// If we failed to load the ping, check what happened and update the histogram.
if (e instanceof PingReadError) {
Telemetry.getHistogramById("TELEMETRY_PENDING_LOAD_FAILURE_READ").add();
} else if (e instanceof PingParseError) {
Telemetry.getHistogramById("TELEMETRY_PENDING_LOAD_FAILURE_PARSE").add();
}
// Remove the ping from the cache, so we don't try to load it again.
this._pendingPings.delete(id);
@@ -1582,17 +1582,17 @@ var TelemetryStorageImpl = {
let options = {};
if (aCompressed) {
options.compression = "lz4";
}
let array;
try {
array = yield OS.File.read(aFilePath, options);
- } catch(e) {
+ } catch (e) {
this._log.trace("loadPingfile - unreadable ping " + aFilePath, e);
throw new PingReadError(e.message, e.becauseNoSuchFile);
}
let decoder = new TextDecoder();
let string = decoder.decode(array);
let ping;
try {
--- a/toolkit/components/telemetry/tests/unit/test_nsITelemetry.js
+++ b/toolkit/components/telemetry/tests/unit/test_nsITelemetry.js
@@ -55,17 +55,17 @@ function compareHistograms(h1, h2) {
for (let i = 0; i < s1.ranges.length; i++)
do_check_eq(s1.ranges[i], s2.ranges[i]);
}
function check_histogram(histogram_type, name, min, max, bucket_count) {
var h = Telemetry.newHistogram(name, "never", histogram_type, min, max, bucket_count);
var r = h.snapshot().ranges;
var sum = 0;
- for(let i=0;i<r.length;i++) {
+ for (let i=0;i<r.length;i++) {
var v = r[i];
sum += v;
h.add(v);
}
var s = h.snapshot();
// verify properties
do_check_eq(sum, s.sum);
@@ -142,17 +142,17 @@ add_task(function* test_noSerialization(
});
add_task(function* test_boolean_histogram() {
var h = Telemetry.newHistogram("test::boolean histogram", "never", Telemetry.HISTOGRAM_BOOLEAN);
var r = h.snapshot().ranges;
// boolean histograms ignore numeric parameters
do_check_eq(uneval(r), uneval([0, 1, 2]))
var sum = 0
- for(var i=0;i<r.length;i++) {
+ for (var i=0;i<r.length;i++) {
var v = r[i];
sum += v;
h.add(v);
}
h.add(true);
h.add(false);
var s = h.snapshot();
do_check_eq(s.histogram_type, Telemetry.HISTOGRAM_BOOLEAN);
--- a/toolkit/components/thumbnails/BackgroundPageThumbs.jsm
+++ b/toolkit/components/thumbnails/BackgroundPageThumbs.jsm
@@ -93,40 +93,40 @@ const BackgroundPageThumbs = {
* @return {Promise} A Promise that resolves when this task completes
*/
captureIfMissing: Task.async(function* (url, options={}) {
// The fileExistsForURL call is an optimization, potentially but unlikely
// incorrect, and no big deal when it is. After the capture is done, we
// atomically test whether the file exists before writing it.
let exists = yield PageThumbsStorage.fileExistsForURL(url);
if (exists) {
- if(options.onDone) {
+ if (options.onDone) {
options.onDone(url);
}
return url;
}
let thumbPromise = new Promise((resolve, reject) => {
function observe(subject, topic, data) { // jshint ignore:line
if (data === url) {
- switch(topic) {
+ switch (topic) {
case "page-thumbnail:create":
resolve();
break;
case "page-thumbnail:error":
reject(new Error("page-thumbnail:error"));
break;
}
Services.obs.removeObserver(observe, "page-thumbnail:create");
Services.obs.removeObserver(observe, "page-thumbnail:error");
}
}
Services.obs.addObserver(observe, "page-thumbnail:create", false);
Services.obs.addObserver(observe, "page-thumbnail:error", false);
});
- try{
+ try {
this.capture(url, options);
yield thumbPromise;
} catch (err) {
if (options.onDone) {
options.onDone(url);
}
throw err;
}
--- a/toolkit/components/thumbnails/test/head.js
+++ b/toolkit/components/thumbnails/test/head.js
@@ -276,17 +276,17 @@ function bgTestPageURL(aOpts = {}) {
let TEST_PAGE_URL = "http://mochi.test:8888/browser/toolkit/components/thumbnails/test/thumbnails_background.sjs";
return TEST_PAGE_URL + "?" + encodeURIComponent(JSON.stringify(aOpts));
}
function bgAddPageThumbObserver(url) {
return new Promise((resolve, reject) => {
function observe(subject, topic, data) { // jshint ignore:line
if (data === url) {
- switch(topic) {
+ switch (topic) {
case "page-thumbnail:create":
resolve();
break;
case "page-thumbnail:error":
reject(new Error("page-thumbnail:error"));
break;
}
Services.obs.removeObserver(observe, "page-thumbnail:create");
--- a/toolkit/components/tooltiptext/TooltipTextProvider.js
+++ b/toolkit/components/tooltiptext/TooltipTextProvider.js
@@ -81,17 +81,17 @@ TooltipTextProvider.prototype = {
let xmoreStr = bundle.GetStringFromName("AndNMoreFiles");
let xmoreNum = files.length - TRUNCATED_FILE_COUNT;
let tmp = {};
Cu.import("resource://gre/modules/PluralForm.jsm", tmp);
let andXMoreStr = tmp.PluralForm.get(xmoreNum, xmoreStr).replace("#1", xmoreNum);
titleText += "\n" + andXMoreStr;
}
}
- } catch(e) {}
+ } catch (e) {}
}
// Check texts against null so that title="" can be used to undefine a
// title on a child element.
while (tipElement &&
(titleText == null) && (XLinkTitleText == null) &&
(SVGTitleText == null) && (XULtooltiptextText == null)) {
--- a/toolkit/components/viewsource/ViewSourceBrowser.jsm
+++ b/toolkit/components/viewsource/ViewSourceBrowser.jsm
@@ -110,17 +110,17 @@ ViewSourceBrowser.prototype = {
/**
* Anything added to the messages array will get handled here, and should
* get dispatched to a specific function for the message name.
*/
receiveMessage(message) {
let data = message.data;
- switch(message.name) {
+ switch (message.name) {
case "ViewSource:PromptAndGoToLine":
this.promptAndGoToLine();
break;
case "ViewSource:GoToLine:Success":
this.onGoToLineSuccess(data.lineNumber);
break;
case "ViewSource:GoToLine:Failed":
this.onGoToLineFailed();
--- a/toolkit/components/viewsource/content/viewSource-content.js
+++ b/toolkit/components/viewsource/content/viewSource-content.js
@@ -121,17 +121,17 @@ var ViewSourceContent = {
* get dispatched to a specific function for the message name.
*/
receiveMessage(msg) {
if (!this.isViewSource && !this.isAboutBlank) {
return;
}
let data = msg.data;
let objects = msg.objects;
- switch(msg.name) {
+ switch (msg.name) {
case "ViewSource:LoadSource":
this.viewSource(data.URL, data.outerWindowID, data.lineNumber,
data.shouldWrap);
break;
case "ViewSource:LoadSourceDeprecated":
this.viewSourceDeprecated(data.URL, objects.pageDescriptor, data.lineNumber,
data.forcedCharSet);
break;
@@ -156,17 +156,17 @@ var ViewSourceContent = {
/**
* Any events should get handled here, and should get dispatched to
* a specific function for the event type.
*/
handleEvent(event) {
if (!this.isViewSource) {
return;
}
- switch(event.type) {
+ switch (event.type) {
case "pagehide":
this.onPageHide(event);
break;
case "pageshow":
this.onPageShow(event);
break;
case "click":
this.onClick(event);
@@ -225,17 +225,17 @@ var ViewSourceContent = {
if (outerWindowID) {
let contentWindow = Services.wm.getOuterWindowWithId(outerWindowID);
let requestor = contentWindow.QueryInterface(Ci.nsIInterfaceRequestor);
try {
let otherWebNav = requestor.getInterface(Ci.nsIWebNavigation);
pageDescriptor = otherWebNav.QueryInterface(Ci.nsIWebPageDescriptor)
.currentDescriptor;
- } catch(e) {
+ } catch (e) {
// We couldn't get the page descriptor, so we'll probably end up re-retrieving
// this document off of the network.
}
let utils = requestor.getInterface(Ci.nsIDOMWindowUtils);
let doc = contentWindow.document;
let forcedCharSet = utils.docCharsetIsForced ? doc.characterSet
: null;
@@ -313,17 +313,17 @@ var ViewSourceContent = {
this.loadSourceFromURL(viewSrcURL);
return;
}
try {
let pageLoader = docShell.QueryInterface(Ci.nsIWebPageDescriptor);
pageLoader.loadPage(pageDescriptor,
Ci.nsIWebPageDescriptor.DISPLAY_AS_SOURCE);
- } catch(e) {
+ } catch (e) {
// We were not able to load the source from the network cache.
this.loadSourceFromURL(viewSrcURL);
return;
}
let shEntrySource = pageDescriptor.QueryInterface(Ci.nsISHEntry);
let shEntry = Cc["@mozilla.org/browser/session-history-entry;1"]
.createInstance(Ci.nsISHEntry);
@@ -711,17 +711,17 @@ var ViewSourceContent = {
/**
* Reloads the content.
*/
reload() {
let pageLoader = docShell.QueryInterface(Ci.nsIWebPageDescriptor);
try {
pageLoader.loadPage(pageLoader.currentDescriptor,
Ci.nsIWebPageDescriptor.DISPLAY_NORMAL);
- } catch(e) {
+ } catch (e) {
let webNav = docShell.QueryInterface(Ci.nsIWebNavigation);
webNav.reload(Ci.nsIWebNavigation.LOAD_FLAGS_NONE);
}
},
/**
* A reference to a DeferredTask that is armed every time the
* selection changes.
@@ -811,17 +811,17 @@ var ViewSourceContent = {
// find the special selection markers that we added earlier, and
// draw the selection between the two...
var findService = null;
try {
// get the find service which stores the global find state
findService = Cc["@mozilla.org/find/find_service;1"]
.getService(Ci.nsIFindService);
- } catch(e) { }
+ } catch (e) { }
if (!findService)
return;
// cache the current global find state
var matchCase = findService.matchCase;
var entireWord = findService.entireWord;
var wrapFind = findService.wrapFind;
var findBackwards = findService.findBackwards;
@@ -873,17 +873,17 @@ var ViewSourceContent = {
// the selection, whereas in this situation, it is more user-friendly
// to scroll at the beginning. So we override the default behavior here
try {
this.selectionController.scrollSelectionIntoView(
Ci.nsISelectionController.SELECTION_NORMAL,
Ci.nsISelectionController.SELECTION_ANCHOR_REGION,
true);
}
- catch(e) { }
+ catch (e) { }
// restore the current find state
findService.matchCase = matchCase;
findService.entireWord = entireWord;
findService.wrapFind = wrapFind;
findService.findBackwards = findBackwards;
findService.searchString = searchString;
findService.replaceString = replaceString;
--- a/toolkit/components/viewsource/content/viewSource.js
+++ b/toolkit/components/viewsource/content/viewSource.js
@@ -115,17 +115,17 @@ ViewSourceChrome.prototype = {
/**
* Anything added to the messages array will get handled here, and should
* get dispatched to a specific function for the message name.
*/
receiveMessage(message) {
let data = message.data;
- switch(message.name) {
+ switch (message.name) {
// Begin messages from super class
case "ViewSource:PromptAndGoToLine":
this.promptAndGoToLine();
break;
case "ViewSource:GoToLine:Success":
this.onGoToLineSuccess(data.lineNumber);
break;
case "ViewSource:GoToLine:Failed":
@@ -162,17 +162,17 @@ ViewSourceChrome.prototype = {
}
},
/**
* Any events should get handled here, and should get dispatched to
* a specific function for the event type.
*/
handleEvent(event) {
- switch(event.type) {
+ switch (event.type) {
case "unload":
this.uninit();
break;
case "load":
this.onXULLoaded();
break;
case "AppCommand":
this.onAppCommand(event);
--- a/toolkit/components/xulstore/XULStore.js
+++ b/toolkit/components/xulstore/XULStore.js
@@ -108,17 +108,17 @@ XULStore.prototype = {
let resources = localStore.GetAllResources();
while (resources.hasMoreElements()) {
let resource = resources.getNext().QueryInterface(Ci.nsIRDFResource);
let uri;
try {
uri = NetUtil.newURI(resource.ValueUTF8);
- } catch(ex) {
+ } catch (ex) {
continue; // skip invalid uris
}
// If this has a ref, then this is an attribute reference. Otherwise,
// this is a document reference.
if (!uri.hasRef)
continue;
@@ -147,17 +147,17 @@ XULStore.prototype = {
const FILE_PERMS = 0o600;
let stream = Cc["@mozilla.org/network/file-input-stream;1"].
createInstance(Ci.nsIFileInputStream);
let json = Cc["@mozilla.org/dom/json;1"].createInstance(Ci.nsIJSON);
try {
stream.init(this._storeFile, MODE_RDONLY, FILE_PERMS, 0);
this._data = json.decodeFromStream(stream, stream.available());
- } catch(e) {
+ } catch (e) {
this.log("Error reading JSON: " + e);
// Ignore problem, we'll just continue on with an empty dataset.
} finally {
stream.close();
}
},
writeFile: Task.async(function* () {
--- a/toolkit/content/aboutProfiles.js
+++ b/toolkit/content/aboutProfiles.js
@@ -25,47 +25,47 @@ const bundle = Services.strings.createBu
// tab, the selectedProfile returns the default profile.
// In this function we use the ProfD to find the current profile.
function findCurrentProfile() {
let cpd;
try {
cpd = Cc["@mozilla.org/file/directory_service;1"]
.getService(Ci.nsIProperties)
.get("ProfD", Ci.nsIFile);
- } catch(e) {}
+ } catch (e) {}
if (cpd) {
let itr = ProfileService.profiles;
- while(itr.hasMoreElements()) {
+ while (itr.hasMoreElements()) {
let profile = itr.getNext().QueryInterface(Ci.nsIToolkitProfile);
if (profile.rootDir.path == cpd.path) {
return profile;
}
}
}
// selectedProfile can trow if nothing is selected or if the selected profile
// has been deleted.
try {
return ProfileService.selectedProfile;
- } catch(e) {
+ } catch (e) {
return null;
}
}
function refreshUI() {
let parent = document.getElementById('profiles');
while (parent.firstChild) {
parent.removeChild(parent.firstChild);
}
let defaultProfile;
try {
defaultProfile = ProfileService.defaultProfile;
- } catch(e) {}
+ } catch (e) {}
let currentProfile = findCurrentProfile() || defaultProfile;
let iter = ProfileService.profiles;
while (iter.hasMoreElements()) {
let profile = iter.getNext().QueryInterface(Ci.nsIToolkitProfile);
display({ profile: profile,
isDefault: profile == defaultProfile,
@@ -217,17 +217,17 @@ function renameProfile(profile) {
newName = newName.value;
if (newName == profile.name) {
return;
}
try {
profile.name = newName;
- } catch(e) {
+ } catch (e) {
let title = bundle.GetStringFromName('invalidProfileNameTitle');
let msg = bundle.formatStringFromName('invalidProfileName', [newName], 1);
Services.prompt.alert(window, title, msg);
return;
}
ProfileService.flush();
refreshUI();
@@ -259,26 +259,26 @@ function removeProfile(profile) {
}
}
// If we are deleting the selected or the default profile we must choose a
// different one.
let isSelected = false;
try {
isSelected = ProfileService.selectedProfile == profile;
- } catch(e) {}
+ } catch (e) {}
let isDefault = false;
try {
isDefault = ProfileService.defaultProfile == profile;
- } catch(e) {}
+ } catch (e) {}
if (isSelected || isDefault) {
let itr = ProfileService.profiles;
- while(itr.hasMoreElements()) {
+ while (itr.hasMoreElements()) {
let p = itr.getNext().QueryInterface(Ci.nsIToolkitProfile);
if (profile == p) {
continue;
}
if (isSelected) {
ProfileService.selectedProfile = p;
}
--- a/toolkit/content/aboutServiceWorkers.js
+++ b/toolkit/content/aboutServiceWorkers.js
@@ -45,17 +45,17 @@ function init() {
div.classList.add("active");
return;
}
let ps = undefined;
try {
ps = Cc["@mozilla.org/push/Service;1"]
.getService(Ci.nsIPushService);
- } catch(e) {
+ } catch (e) {
dump("Could not acquire PushService\n");
}
for (let i = 0; i < length; ++i) {
let info = data.queryElementAt(i, Ci.nsIServiceWorkerRegistrationInfo);
if (!info) {
dump("AboutServiceWorkers: Invalid nsIServiceWorkerRegistrationInfo interface.\n");
continue;
--- a/toolkit/content/browser-child.js
+++ b/toolkit/content/browser-child.js
@@ -369,17 +369,17 @@ var SecurityUI = {
var ControllerCommands = {
init: function () {
addMessageListener("ControllerCommands:Do", this);
addMessageListener("ControllerCommands:DoWithParams", this);
},
receiveMessage: function(message) {
- switch(message.name) {
+ switch (message.name) {
case "ControllerCommands:Do":
if (docShell.isCommandEnabled(message.data))
docShell.doCommand(message.data);
break;
case "ControllerCommands:DoWithParams":
var data = message.data;
if (docShell.isCommandEnabled(data.cmd)) {
--- a/toolkit/content/browser-content.js
+++ b/toolkit/content/browser-content.js
@@ -434,17 +434,17 @@ var Printing = {
nsresult: nsresult,
});
}
},
receiveMessage(message) {
let objects = message.objects;
let data = message.data;
- switch(message.name) {
+ switch (message.name) {
case "Printing:Preview:Enter": {
this.enterPrintPreview(Services.wm.getOuterWindowWithId(data.windowID), data.simplifiedMode);
break;
}
case "Printing:Preview:Exit": {
this.exitPrintPreview();
break;
@@ -484,17 +484,17 @@ var Printing = {
// First get any defaults from the printer
PSSVC.initPrintSettingsFromPrinter(printSettings.printerName,
printSettings);
// now augment them with any values from last time
PSSVC.initPrintSettingsFromPrefs(printSettings, true,
printSettings.kInitSaveAll);
return printSettings;
- } catch(e) {
+ } catch (e) {
Components.utils.reportError(e);
}
return null;
},
parseDocument(URL, contentWindow) {
// By using ReaderMode primitives, we parse given document and place the
@@ -614,17 +614,17 @@ var Printing = {
// If we happen to be on simplified mode, we need to set docURL in order
// to generate header/footer content correctly, since simplified tab has
// "about:blank" as its URI.
if (printSettings && simplifiedMode)
printSettings.docURL = contentWindow.document.baseURI;
docShell.printPreview.printPreview(printSettings, contentWindow, this);
- } catch(error) {
+ } catch (error) {
// This might fail if we, for example, attempt to print a XUL document.
// In that case, we inform the parent to bail out of print preview.
Components.utils.reportError(error);
notifyEntered(error);
}
},
exitPrintPreview() {
@@ -652,17 +652,17 @@ var Printing = {
if (simplifiedMode) {
histogram.add("SIMPLIFIED");
} else {
histogram.add("WITH_PREVIEW");
}
} else {
histogram.add("WITHOUT_PREVIEW");
}
- } catch(e) {
+ } catch (e) {
// Pressing cancel is expressed as an NS_ERROR_ABORT return value,
// causing an exception to be thrown which we catch here.
if (e.result != Cr.NS_ERROR_ABORT) {
Cu.reportError(`In Printing:Print:Done handler, got unexpected rv
${e.result}.`);
sendAsyncMessage("Printing:Error", {
isPrinting: true,
nsresult: e.result,
@@ -1347,17 +1347,17 @@ var ViewSelectionSource = {
return letter;
}
}
if (!this._entityConverter) {
try {
this._entityConverter = Cc["@mozilla.org/intl/entityconverter;1"]
.createInstance(Ci.nsIEntityConverter);
- } catch(e) { }
+ } catch (e) { }
}
const entityVersion = Ci.nsIEntityConverter.entityW3C;
var str = text;
// replace chars in our charTable
str = str.replace(/[<>&"]/g, charTableLookup);
--- a/toolkit/content/tests/fennec-tile-testapp/chrome/content/WidgetStack.js
+++ b/toolkit/content/tests/fennec-tile-testapp/chrome/content/WidgetStack.js
@@ -861,17 +861,17 @@ WidgetStack.prototype = {
let panX = 0, panY = 0;
if (vr.right > pb.right)
panX = pb.right - vr.right;
else if (vr.left < pb.left)
panX = pb.left - vr.left;
if (vr.bottom > pb.bottom)
panY = pb.bottom - vr.bottom;
- else if(vr.top < pb.top)
+ else if (vr.top < pb.top)
panY = pb.top - vr.top;
this.panBy(panX, panY, true);
},
_getState: function (wid) {
let w = this._widgetState[wid];
if (!w)
--- a/toolkit/content/tests/unit/test_contentAreaUtils.js
+++ b/toolkit/content/tests/unit/test_contentAreaUtils.js
@@ -21,35 +21,35 @@ function test_urlSecurityCheck() {
const CHROME_URI = "chrome://browser/content/browser.xul";
const DISALLOW_INHERIT_PRINCIPAL =
Ci.nsIScriptSecurityManager.DISALLOW_INHERIT_PRINCIPAL;
try {
urlSecurityCheck(makeURI(HTTP_URI), nullPrincipal,
DISALLOW_INHERIT_PRINCIPAL);
}
- catch(ex) {
+ catch (ex) {
do_throw("urlSecurityCheck should not throw when linking to a http uri with a null principal");
}
// urlSecurityCheck also supports passing the url as a string
try {
urlSecurityCheck(HTTP_URI, nullPrincipal,
DISALLOW_INHERIT_PRINCIPAL);
}
- catch(ex) {
+ catch (ex) {
do_throw("urlSecurityCheck failed to handle the http URI as a string (uri spec)");
}
let shouldThrow = true;
try {
urlSecurityCheck(CHROME_URI, nullPrincipal,
DISALLOW_INHERIT_PRINCIPAL);
}
- catch(ex) {
+ catch (ex) {
shouldThrow = false;
}
if (shouldThrow)
do_throw("urlSecurityCheck should throw when linking to a chrome uri with a null principal");
}
function test_stringBundle() {
// This test verifies that the elements that can be used as file picker title
--- a/toolkit/content/widgets/autocomplete.xml
+++ b/toolkit/content/widgets/autocomplete.xml
@@ -1810,17 +1810,17 @@ extends="chrome://global/content/binding
while (aDescriptionElement.hasChildNodes())
aDescriptionElement.firstChild.remove();
for (let [text, emphasise] of aTextPairs) {
if (emphasise) {
let span = aDescriptionElement.appendChild(
document.createElementNS("http://www.w3.org/1999/xhtml", "span"));
span.textContent = text;
- switch(emphasise) {
+ switch (emphasise) {
case "match":
this._setUpEmphasisSpan(span, aDescriptionElement);
break;
}
} else {
aDescriptionElement.appendChild(document.createTextNode(text));
}
}
--- a/toolkit/content/widgets/browser.xml
+++ b/toolkit/content/widgets/browser.xml
@@ -18,17 +18,17 @@
<![CDATA[
if (this.getAttribute("autoscroll") == "false")
return false;
var enabled = true;
try {
enabled = this.mPrefs.getBoolPref("general.autoScroll");
}
- catch(ex) {
+ catch (ex) {
}
return enabled;
]]>
</getter>
</property>
<property name="canGoBack"
@@ -903,17 +903,17 @@
var os = Components.classes["@mozilla.org/observer-service;1"]
.getService(Components.interfaces.nsIObserverService);
os.addObserver(this, "browser:purge-session-history", true);
// enable global history if we weren't told otherwise
if (!this.hasAttribute("disableglobalhistory") && !this.isRemoteBrowser) {
try {
this.docShell.useGlobalHistory = true;
- } catch(ex) {
+ } catch (ex) {
// This can occur if the Places database is locked
Components.utils.reportError("Error enabling browser global history: " + ex);
}
}
}
}
catch (e) {
Components.utils.reportError(e);
@@ -1149,17 +1149,17 @@
</body>
</method>
<method name="handleEvent">
<parameter name="aEvent"/>
<body>
<![CDATA[
if (this._scrolling) {
- switch(aEvent.type) {
+ switch (aEvent.type) {
case "mousemove": {
var x = aEvent.screenX - this._startX;
var y = aEvent.screenY - this._startY;
if ((x > this._AUTOSCROLL_SNAP || x < -this._AUTOSCROLL_SNAP) ||
(y > this._AUTOSCROLL_SNAP || y < -this._AUTOSCROLL_SNAP))
this._ignoreMouseEvents = false;
break;
@@ -1273,17 +1273,17 @@
}
if (window.PopupNotifications)
PopupNotifications._swapBrowserNotifications(aOtherBrowser, this);
try {
this.QueryInterface(Components.interfaces.nsIFrameLoaderOwner)
.swapFrameLoaders(aOtherBrowser);
- } catch(ex) {
+ } catch (ex) {
// This may not be implemented for browser elements that are not
// attached to a BrowserDOMWindow.
}
// Before we swap the actual docShell property we need to detach the
// form fill controller from those docShells.
if (!this.isRemoteBrowser) {
this.detachFormFill();
--- a/toolkit/content/widgets/findbar.xml
+++ b/toolkit/content/widgets/findbar.xml
@@ -828,17 +828,17 @@
window.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
.getInterface(Components.interfaces.nsIWebNavigation)
.QueryInterface(Components.interfaces.nsIDocShellTreeItem)
.treeOwner
.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
.getInterface(Components.interfaces.nsIXULWindow)
.XULBrowserWindow;
}
- catch(ex) { }
+ catch (ex) { }
if (!this._xulBrowserWindow)
return false;
}
// Call this has the same effect like hovering over link,
// the browser shows the URL as a tooltip.
this._xulBrowserWindow.setOverLink(aFoundURL || "", null);
return true;
--- a/toolkit/content/widgets/notification.xml
+++ b/toolkit/content/widgets/notification.xml
@@ -351,17 +351,17 @@
bgcolor = prefService.getCharPref("browser.display.background_color");
var win = content.contentWindow;
var context = canvas.getContext("2d");
context.globalAlpha = 0.5;
context.drawWindow(win, win.scrollX, win.scrollY,
width, height, bgcolor);
}
- catch(ex) { }
+ catch (ex) { }
}
else if (canvas) {
canvas.parentNode.removeChild(canvas);
this._blockingCanvas = null;
let content = this.firstChild;
if (content)
content.collapsed = false;
}
--- a/toolkit/content/widgets/popup.xml
+++ b/toolkit/content/widgets/popup.xml
@@ -44,33 +44,33 @@
<parameter name="aTriggerEvent"/>
<body>
<![CDATA[
try {
var popupBox = this.popupBoxObject;
if (popupBox)
popupBox.openPopup(aAnchorElement, aPosition, aX, aY,
aIsContextMenu, aAttributesOverride, aTriggerEvent);
- } catch(e) {}
+ } catch (e) {}
]]>
</body>
</method>
<method name="openPopupAtScreen">
<parameter name="aX"/>
<parameter name="aY"/>
<parameter name="aIsContextMenu"/>
<parameter name="aTriggerEvent"/>
<body>
<![CDATA[
try {
var popupBox = this.popupBoxObject;
if (popupBox)
popupBox.openPopupAtScreen(aX, aY, aIsContextMenu, aTriggerEvent);
- } catch(e) {}
+ } catch (e) {}
]]>
</body>
</method>
<method name="openPopupAtScreenRect">
<parameter name="aPosition"/>
<parameter name="aX"/>
<parameter name="aY"/>
@@ -81,17 +81,17 @@
<parameter name="aTriggerEvent"/>
<body>
<![CDATA[
try {
var popupBox = this.popupBoxObject;
if (popupBox)
popupBox.openPopupAtScreenRect(aPosition, aX, aY, aWidth, aHeight,
aIsContextMenu, aAttributesOverride, aTriggerEvent);
- } catch(e) {}
+ } catch (e) {}
]]>
</body>
</method>
<method name="showPopup">
<parameter name="element"/>
<parameter name="xpos"/>
<parameter name="ypos"/>
@@ -99,40 +99,40 @@
<parameter name="anchoralignment"/>
<parameter name="popupalignment"/>
<body>
<![CDATA[
var popupBox = null;
var menuBox = null;
try {
popupBox = this.popupBoxObject;
- } catch(e) {}
+ } catch (e) {}
try {
menuBox = this.parentNode.boxObject;
- } catch(e) {}
+ } catch (e) {}
if (menuBox instanceof MenuBoxObject)
menuBox.openMenu(true);
else if (popupBox)
popupBox.showPopup(element, this, xpos, ypos, popuptype, anchoralignment, popupalignment);
]]>
</body>
</method>
<method name="hidePopup">
<parameter name="cancel"/>
<body>
<![CDATA[
var popupBox = null;
var menuBox = null;
try {
popupBox = this.popupBoxObject;
- } catch(e) {}
+ } catch (e) {}
try {
menuBox = this.parentNode.boxObject;
- } catch(e) {}
+ } catch (e) {}
if (menuBox instanceof MenuBoxObject)
menuBox.openMenu(false);
else if (popupBox instanceof PopupBoxObject)
popupBox.hidePopup(cancel);
]]>
</body>
</method>
@@ -320,26 +320,26 @@
var prevFocus = this._prevFocus ? this._prevFocus.get() : null;
this._currentFocus = null;
this._prevFocus = null;
if (prevFocus && currentFocus && this.getAttribute("norestorefocus") != "true") {
// Try to restore focus
try {
if (document.commandDispatcher.focusedWindow != window)
return; // Focus has already been set to a window outside of this panel
- } catch(ex) {}
+ } catch (ex) {}
while (currentFocus) {
if (currentFocus == this) {
// Focus was set on an element inside this panel,
// so we need to move it back to where it was previously
try {
let fm = Components.classes["@mozilla.org/focus-manager;1"]
.getService(Components.interfaces.nsIFocusManager);
fm.setFocus(prevFocus, fm.FLAG_NOSCROLL);
- } catch(e) {
+ } catch (e) {
prevFocus.focus();
}
return;
}
currentFocus = currentFocus.parentNode;
}
}
]]></handler>
--- a/toolkit/content/widgets/scrollbox.xml
+++ b/toolkit/content/widgets/scrollbox.xml
@@ -616,17 +616,17 @@
// See bug 341047 and comments in overflow handler as to why
// try..catch is needed here
this._updateScrollButtonsDisabledState();
let childNodes = this._getScrollableElements();
if (childNodes && childNodes.length)
this.ensureElementIsVisible(childNodes[0], false);
}
- catch(e) {
+ catch (e) {
this.removeAttribute("notoverflowing");
}
]]></handler>
<handler event="overflow" phase="capturing"><![CDATA[
// filter underflow events which were dispatched on nested scrollboxes
if (event.target != this)
return;
@@ -650,17 +650,17 @@
try {
// See bug 341047, the overflow event is dispatched when the
// scrollbox already is mostly destroyed. This causes some code in
// _updateScrollButtonsDisabledState() to throw an error. It also
// means that the notoverflowing attribute was removed erroneously,
// as the whole overflow event should not be happening in that case.
this._updateScrollButtonsDisabledState();
}
- catch(e) {
+ catch (e) {
this.setAttribute("notoverflowing", "true");
}
]]></handler>
<handler event="scroll" action="this._updateScrollButtonsDisabledState()"/>
</handlers>
</binding>
--- a/toolkit/content/widgets/tabbox.xml
+++ b/toolkit/content/widgets/tabbox.xml
@@ -490,17 +490,17 @@
try {
let el = document.commandDispatcher.focusedElement;
while (el && el != this.tabbox.tabpanels) {
if (el == this.tabbox || el == selectedPanel)
return;
el = el.parentNode;
}
aNewTab.focus();
- } catch(e) {
+ } catch (e) {
}
}
}
]]>
</body>
</method>
<method name="_canAdvanceToTab">
--- a/toolkit/content/widgets/textbox.xml
+++ b/toolkit/content/widgets/textbox.xml
@@ -97,17 +97,17 @@
<method name="reset">
<body><![CDATA[
this.value = this.defaultValue;
try {
this.editor.transactionManager.clear();
return true;
}
- catch(e) {}
+ catch (e) {}
return false;
]]></body>
</method>
<method name="select">
<body>
this.inputField.select();
</body>
@@ -580,17 +580,17 @@
var textbox = document.getBindingParent(this);
if (!textbox || !(textbox instanceof CI.nsIDOMXULTextBoxElement))
return null;
try {
Components.utils.import("resource://gre/modules/InlineSpellChecker.jsm", this);
this.InlineSpellCheckerUI = new this.InlineSpellChecker(textbox.editor);
- } catch(ex) { }
+ } catch (ex) { }
}
return this.InlineSpellCheckerUI;
]]></getter>
</property>
<method name="_doPopupItemEnablingSpell">
<parameter name="popupNode"/>
--- a/toolkit/content/widgets/toolbar.xml
+++ b/toolkit/content/widgets/toolbar.xml
@@ -110,17 +110,17 @@
if (toolboxId) {
let toolbox = document.getElementById(toolboxId);
if (!toolbox) {
let tbName = this.toolbarName;
if (tbName)
tbName = " (" + tbName + ")";
else
tbName = "";
- throw("toolbar ID " + this.id + tbName + ": toolboxid attribute '" + toolboxId + "' points to a toolbox that doesn't exist");
+ throw new Error(`toolbar ID ${this.id}${tbName}: toolboxid attribute '${toolboxId}' points to a toolbox that doesn't exist`);
}
if (toolbox.externalToolbars.indexOf(this) == -1)
toolbox.externalToolbars.push(this);
return this._toolbox = toolbox;
}
--- a/toolkit/crashreporter/CrashSubmit.jsm
+++ b/toolkit/crashreporter/CrashSubmit.jsm
@@ -544,17 +544,17 @@ this.CrashSubmit = {
}
}
return null;
});
}
return null;
}
);
- } catch(ex) {
+ } catch (ex) {
Cu.reportError(ex);
} finally {
iterator.close();
}
}
return ids;
}),
--- a/toolkit/crashreporter/test/CrashTestUtils.jsm
+++ b/toolkit/crashreporter/test/CrashTestUtils.jsm
@@ -47,17 +47,17 @@ CrashTestUtils.lockDir = lib.declare("Lo
ctypes.voidptr_t); // nsISupports*
try {
CrashTestUtils.TryOverrideExceptionHandler = lib.declare("TryOverrideExceptionHandler",
ctypes.default_abi,
ctypes.void_t);
}
-catch(ex) {}
+catch (ex) {}
CrashTestUtils.dumpHasStream = lib.declare("DumpHasStream",
ctypes.default_abi,
ctypes.bool,
ctypes.char.ptr,
ctypes.uint32_t);
CrashTestUtils.dumpHasInstructionPointerMemory =
--- a/toolkit/crashreporter/test/browser/browser_aboutCrashesResubmit.js
+++ b/toolkit/crashreporter/test/browser/browser_aboutCrashesResubmit.js
@@ -1,12 +1,12 @@
function cleanup_and_finish() {
try {
cleanup_fake_appdir();
- } catch(ex) {}
+ } catch (ex) {}
Services.prefs.clearUserPref("breakpad.reportURL");
BrowserTestUtils.removeTab(gBrowser.selectedTab).then(finish);
}
/*
* check_crash_list
*
* Check that the list of crashes displayed by about:crashes matches
@@ -16,17 +16,17 @@ function cleanup_and_finish() {
*/
function check_crash_list(crashes) {
let doc = content.document;
let crashlinks = doc.getElementById("tbody").getElementsByTagName("a");
Assert.equal(crashlinks.length, crashes.length,
"about:crashes lists correct number of crash reports");
// no point in checking this if the lists aren't the same length
if (crashlinks.length == crashes.length) {
- for(let i=0; i<crashes.length; i++) {
+ for (let i=0; i<crashes.length; i++) {
Assert.equal(crashlinks[i].id, crashes[i].id, i + ": crash ID is correct");
if (crashes[i].pending) {
// we set the breakpad.reportURL pref in test()
Assert.equal(crashlinks[i].getAttribute("href"),
"http://example.com/browser/toolkit/crashreporter/about/throttling",
"pending URL links to the correct static page");
}
}
@@ -69,24 +69,24 @@ function check_submit_pending(tab, crash
return { id: CrashID, url: CrashURL, result };
}).then(({ id, url, result }) => {
// Likewise, this is discarded before it gets to the server
delete SubmittedCrash.extra.ServerURL;
CrashID = id;
CrashURL = url;
- for(let x in result) {
+ for (let x in result) {
if (x in SubmittedCrash.extra)
is(result[x], SubmittedCrash.extra[x],
"submitted value for " + x + " matches expected");
else
ok(false, "property " + x + " missing from submitted data!");
}
- for(let y in SubmittedCrash.extra) {
+ for (let y in SubmittedCrash.extra) {
if (!(y in result))
ok(false, "property " + y + " missing from result data!");
}
// NB: Despite appearances, this doesn't use a CPOW.
BrowserTestUtils.waitForEvent(browser, "pageshow", true).then(csp_pageshow);
// now navigate back
--- a/toolkit/crashreporter/test/browser/head.js
+++ b/toolkit/crashreporter/test/browser/head.js
@@ -48,29 +48,29 @@ function make_fake_appdir() {
}
};
// register our new provider
dirSvc.QueryInterface(Ci.nsIDirectoryService)
.registerProvider(_provider);
// and undefine the old value
try {
dirSvc.undefine("UAppData");
- } catch(ex) {} // it's ok if this fails, the value might not be cached yet
+ } catch (ex) {} // it's ok if this fails, the value might not be cached yet
return appD.clone();
}
function cleanup_fake_appdir() {
let dirSvc = Cc["@mozilla.org/file/directory_service;1"]
.getService(Ci.nsIProperties);
dirSvc.QueryInterface(Ci.nsIDirectoryService)
.unregisterProvider(_provider);
// undefine our value so future calls get the real value
try {
dirSvc.undefine("UAppData");
- } catch(ex) {
+ } catch (ex) {
dump("cleanup_fake_appdir: dirSvc.undefine failed: " + ex.message +"\n");
}
}
function add_fake_crashes(crD, count) {
let results = [];
let uuidGenerator = Cc["@mozilla.org/uuid-generator;1"]
.getService(Ci.nsIUUIDGenerator);
--- a/toolkit/crashreporter/test/unit/head_crashreporter.js
+++ b/toolkit/crashreporter/test/unit/head_crashreporter.js
@@ -67,17 +67,17 @@ function do_crash(setup, callback, canRe
crashD.create(crashD.DIRECTORY_TYPE, 0o700);
}
env.set("CRASHES_EVENTS_DIR", crashD.path);
try {
process.run(true, args, args.length);
}
- catch(ex) {} // on Windows we exit with a -1 status when crashing.
+ catch (ex) {} // on Windows we exit with a -1 status when crashing.
finally {
env.set("CRASHES_EVENTS_DIR", "");
}
if (!canReturnZero) {
// should exit with an error (should have crashed)
do_check_neq(process.exitValue, 0);
}
--- a/toolkit/crashreporter/test/unit/test_crash_terminator.js
+++ b/toolkit/crashreporter/test/unit/test_crash_terminator.js
@@ -19,17 +19,17 @@ function setup_crash() {
terminator.observe(null, "profile-after-change", null);
// Inform the terminator that shutdown has started
// Pick an arbitrary notification
terminator.observe(null, "xpcom-will-shutdown", null);
terminator.observe(null, "profile-before-change", null);
dump("Waiting (actively) for the crash\n");
- while(true) {
+ while (true) {
Services.tm.currentThread.processNextEvent(true);
}
}
function after_crash(mdump, extra) {
do_print("Crash signature: " + JSON.stringify(extra, null, "\t"));
Assert.equal(extra.ShutdownProgress, "profile-before-change");
--- a/toolkit/forgetaboutsite/test/unit/test_removeDataFromDomain.js
+++ b/toolkit/forgetaboutsite/test/unit/test_removeDataFromDomain.js
@@ -464,17 +464,17 @@ function* test_content_preferences_not_c
// Push
function* test_push_cleared()
{
let ps;
try {
ps = Cc["@mozilla.org/push/Service;1"].
getService(Ci.nsIPushService);
- } catch(e) {
+ } catch (e) {
// No push service, skip test.
return;
}
do_get_profile();
setPrefs();
const {PushDB, PushService, PushServiceWebSocket} = serviceExports;
const userAgentID = 'bd744428-f125-436a-b6d0-dd0c9845837f';
--- a/toolkit/identity/Identity.jsm
+++ b/toolkit/identity/Identity.jsm
@@ -73,17 +73,17 @@ IDService.prototype = {
},
shutdown: function shutdown() {
log("shutdown");
Services.obs.removeObserver(this, "identity-auth-complete");
// try to prevent abort/crash during shutdown of mochitest-browser2...
try {
Services.obs.removeObserver(this, "quit-application-granted");
- } catch(e) {}
+ } catch (e) {}
},
/**
* Parse an email into username and domain if it is valid, else return null
*/
parseEmail: function parseEmail(email) {
var match = email.match(/^([^@]+)@([^@^/]+.[a-z]+)$/);
if (match) {
--- a/toolkit/identity/IdentityProvider.jsm
+++ b/toolkit/identity/IdentityProvider.jsm
@@ -97,17 +97,17 @@ IdentityProviderService.prototype = {
Services.obs.removeObserver(this, "quit-application-granted");
},
get securityLevel() {
return 1;
},
get certDuration() {
- switch(this.securityLevel) {
+ switch (this.securityLevel) {
default:
return 3600;
}
},
/**
* Provision an Identity
*
--- a/toolkit/identity/LogUtils.jsm
+++ b/toolkit/identity/LogUtils.jsm
@@ -22,17 +22,17 @@ function IdentityLogger() {
this._debug = Services.prefs.getBoolPref(PREF_DEBUG);
return this;
}
IdentityLogger.prototype = {
QueryInterface: XPCOMUtils.generateQI([Ci.nsISupports, Ci.nsIObserver]),
observe: function observe(aSubject, aTopic, aData) {
- switch(aTopic) {
+ switch (aTopic) {
case "nsPref:changed":
this._debug = Services.prefs.getBoolPref(PREF_DEBUG);
break;
case "quit-application-granted":
Services.prefs.removeObserver(PREF_DEBUG, this);
break;
@@ -53,17 +53,17 @@ IdentityLogger.prototype = {
strings.push(arg);
} else if (typeof arg === 'undefined') {
strings.push('undefined');
} else if (arg === null) {
strings.push('null');
} else {
try {
strings.push(JSON.stringify(arg, null, 2));
- } catch(err) {
+ } catch (err) {
strings.push("<<something>>");
}
}
});
return 'Identity ' + aPrefix + ': ' + strings.join(' ');
},
/**
--- a/toolkit/identity/tests/unit/head_identity.js
+++ b/toolkit/identity/tests/unit/head_identity.js
@@ -231,24 +231,24 @@ function setup_provisioning(identity, af
afterSetupCallback(caller);
}
// Switch debug messages on by default
var initialPrefDebugValue = false;
try {
initialPrefDebugValue = Services.prefs.getBoolPref("toolkit.identity.debug");
-} catch(noPref) {}
+} catch (noPref) {}
Services.prefs.setBoolPref("toolkit.identity.debug", true);
// Switch on firefox accounts
var initialPrefFXAValue = false;
try {
initialPrefFXAValue = Services.prefs.getBoolPref("identity.fxaccounts.enabled");
-} catch(noPref) {}
+} catch (noPref) {}
Services.prefs.setBoolPref("identity.fxaccounts.enabled", true);
// after execution, restore prefs
do_register_cleanup(function() {
log("restoring prefs to their initial values");
Services.prefs.setBoolPref("toolkit.identity.debug", initialPrefDebugValue);
Services.prefs.setBoolPref("identity.fxaccounts.enabled", initialPrefFXAValue);
});
--- a/toolkit/modules/BrowserUtils.jsm
+++ b/toolkit/modules/BrowserUtils.jsm
@@ -71,17 +71,17 @@ this.BrowserUtils = {
secMan.checkLoadURIWithPrincipal(aPrincipal, aURL, aFlags);
else
secMan.checkLoadURIStrWithPrincipal(aPrincipal, aURL, aFlags);
} catch (e) {
let principalStr = "";
try {
principalStr = " from " + aPrincipal.URI.spec;
}
- catch(e2) { }
+ catch (e2) { }
throw "Load of " + aURL + principalStr + " denied.";
}
},
/**
* Constructs a new URI, using nsIIOService.
* @param aURL The URI spec.
@@ -161,17 +161,17 @@ this.BrowserUtils = {
// External links from within app tabs should always open in new tabs
// instead of replacing the app tab's page (Bug 575561)
let linkHost;
let docHost;
try {
linkHost = linkURI.host;
docHost = linkNode.ownerDocument.documentURIObject.host;
- } catch(e) {
+ } catch (e) {
// nsIURI.host can throw for non-nsStandardURL nsIURIs.
// If we fail to get either host, just return originalTarget.
return originalTarget;
}
if (docHost == linkHost)
return originalTarget;
--- a/toolkit/modules/FinderHighlighter.jsm
+++ b/toolkit/modules/FinderHighlighter.jsm
@@ -434,17 +434,17 @@ FinderHighlighter.prototype = {
if (!this._modalHighlightOutline)
return;
if (kDebug)
this._modalHighlightOutline.remove();
try {
this.finder._getWindow().document
.removeAnonymousContent(this._modalHighlightOutline);
- } catch(ex) {}
+ } catch (ex) {}
this._modalHighlightOutline = null;
},
/**
* When `kModalHighlightPref` pref changed during a session, this callback is
* invoked. When modal highlighting is turned off, we hide the CanvasFrame
* contents.
@@ -751,17 +751,17 @@ FinderHighlighter.prototype = {
_removeHighlightAllMask(window) {
if (this._modalHighlightAllMask) {
// If the current window isn't the one the content was inserted into, this
// will fail, but that's fine.
if (kDebug)
this._modalHighlightAllMask.remove();
try {
window.document.removeAnonymousContent(this._modalHighlightAllMask);
- } catch(ex) {}
+ } catch (ex) {}
this._modalHighlightAllMask = null;
}
},
/**
* Doing a full repaint each time a range is delivered by the highlight iterator
* is way too costly, thus we pipe the frequency down to every
* `kModalHighlightRepaintFreqMs` milliseconds.
--- a/toolkit/modules/GMPInstallManager.jsm
+++ b/toolkit/modules/GMPInstallManager.jsm
@@ -264,17 +264,17 @@ GMPInstallManager.prototype = {
}
}
if (failureEncountered) {
throw {status: "failed",
results: installResults};
}
return {status: "succeeded",
results: installResults};
- } catch(e) {
+ } catch (e) {
log.error("Could not check for addons", e);
throw e;
}
}),
/**
* Makes sure everything is cleaned up
*/
@@ -391,17 +391,17 @@ GMPExtractor.prototype = {
zipReader.open(zipFile)
let entries = this._getZipEntries(zipReader);
let extractedPaths = [];
let destDir = Cc["@mozilla.org/file/local;1"].
createInstance(Ci.nsILocalFile);
destDir.initWithPath(this.installToDirPath);
// Make sure the destination exists
- if(!destDir.exists()) {
+ if (!destDir.exists()) {
destDir.create(Ci.nsIFile.DIRECTORY_TYPE, parseInt("0755", 8));
}
// Extract each of the entries
entries.forEach(entry => {
// We don't need these types of files
if (entry.includes("__MACOSX") ||
entry == "_metadata/verified_contents.json" ||
--- a/toolkit/modules/InlineSpellChecker.jsm
+++ b/toolkit/modules/InlineSpellChecker.jsm
@@ -21,17 +21,17 @@ InlineSpellChecker.prototype = {
// Call this function to initialize for a given editor
init: function(aEditor)
{
this.uninit();
this.mEditor = aEditor;
try {
this.mInlineSpellChecker = this.mEditor.getInlineSpellChecker(true);
// note: this might have been NULL if there is no chance we can spellcheck
- } catch(e) {
+ } catch (e) {
this.mInlineSpellChecker = null;
}
},
initFromRemote: function(aSpellInfo)
{
if (this.mRemote)
throw new Error("Unexpected state");
@@ -138,17 +138,17 @@ InlineSpellChecker.prototype = {
{
if (!this.mRemote && (!this.mInlineSpellChecker || !this.mOverMisspelling))
return 0; // nothing to do
var spellchecker = this.mRemote || this.mInlineSpellChecker.spellChecker;
try {
if (!this.mRemote && !spellchecker.CheckCurrentWord(this.mMisspelling))
return 0; // word seems not misspelled after all (?)
- } catch(e) {
+ } catch (e) {
return 0;
}
this.mMenu = menu;
this.mSpellSuggestions = [];
this.mSuggestionItems = [];
for (var i = 0; i < maxNumber; i ++) {
var suggestion = spellchecker.GetSuggestedWord();
@@ -217,17 +217,17 @@ InlineSpellChecker.prototype = {
else if (this.mInlineSpellChecker) {
var spellchecker = this.mInlineSpellChecker.spellChecker;
var o1 = {}, o2 = {};
spellchecker.GetDictionaryList(o1, o2);
list = o1.value;
var listcount = o2.value;
try {
curlang = spellchecker.GetCurrentDictionary();
- } catch(e) {}
+ } catch (e) {}
}
var sortedList = this.sortDictionaryList(list);
for (var i = 0; i < sortedList.length; i ++) {
this.mDictionaryNames.push(sortedList[i].id);
var item = menu.ownerDocument.createElement("menuitem");
item.setAttribute("id", "spell-check-dictionary-" + sortedList[i].id);
@@ -259,17 +259,17 @@ InlineSpellChecker.prototype = {
},
// Formats a valid BCP 47 language tag based on available localized names.
getDictionaryDisplayName: function(dictionaryName) {
try {
// Get the display name for this dictionary.
let languageTagMatch = /^([a-z]{2,3}|[a-z]{4}|[a-z]{5,8})(?:[-_]([a-z]{4}))?(?:[-_]([A-Z]{2}|[0-9]{3}))?((?:[-_](?:[a-z0-9]{5,8}|[0-9][a-z0-9]{3}))*)(?:[-_][a-wy-z0-9](?:[-_][a-z0-9]{2,8})+)*(?:[-_]x(?:[-_][a-z0-9]{1,8})+)?$/i;
var [languageTag, languageSubtag, scriptSubtag, regionSubtag, variantSubtags] = dictionaryName.match(languageTagMatch);
- } catch(e) {
+ } catch (e) {
// If we weren't given a valid language tag, just use the raw dictionary name.
return dictionaryName;
}
if (!gLanguageBundle) {
// Create the bundles for language and region names.
var bundleService = Components.classes["@mozilla.org/intl/stringbundle;1"]
.getService(Components.interfaces.nsIStringBundleService);
@@ -279,27 +279,27 @@ InlineSpellChecker.prototype = {
"chrome://global/locale/regionNames.properties");
}
var displayName = "";
// Language subtag will normally be 2 or 3 letters, but could be up to 8.
try {
displayName += gLanguageBundle.GetStringFromName(languageSubtag.toLowerCase());
- } catch(e) {
+ } catch (e) {
displayName += languageSubtag.toLowerCase(); // Fall back to raw language subtag.
}
// Region subtag will be 2 letters or 3 digits.
if (regionSubtag) {
displayName += " (";
try {
displayName += gRegionBundle.GetStringFromName(regionSubtag.toLowerCase());
- } catch(e) {
+ } catch (e) {
displayName += regionSubtag.toUpperCase(); // Fall back to raw region subtag.
}
displayName += ")";
}
// Script subtag will be 4 letters.
if (scriptSubtag) {
@@ -501,17 +501,17 @@ var SpellCheckHelper = {
.getInterface(Ci.nsIWebNavigation)
.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIEditingSession);
if (editingSession.windowIsEditable(win) &&
this.getComputedStyle(element, "-moz-user-modify") == "read-write") {
isEditable = true;
}
}
- catch(ex) {
+ catch (ex) {
// If someone built with composer disabled, we can't get an editing session.
}
if (isEditable)
flags |= this.CONTENTEDITABLE;
}
}
--- a/toolkit/modules/Log.jsm
+++ b/toolkit/modules/Log.jsm
@@ -97,17 +97,17 @@ this.Log = {
enumerateInterfaces: function Log_enumerateInterfaces(aObject) {
let interfaces = [];
for (i in Ci) {
try {
aObject.QueryInterface(Ci[i]);
interfaces.push(i);
}
- catch(ex) {}
+ catch (ex) {}
}
return interfaces;
},
// Logging helper:
// let logger = Log.repository.getLogger("foo");
// logger.info(Log.enumerateProperties(someObject).join(","));
@@ -116,17 +116,17 @@ this.Log = {
for (p in aObject) {
try {
if (aExcludeComplexTypes &&
(typeof(aObject[p]) == "object" || typeof(aObject[p]) == "function"))
continue;
properties.push(p + " = " + aObject[p]);
}
- catch(ex) {
+ catch (ex) {
properties.push(p + " = " + ex);
}
}
return properties;
},
_formatError: function _formatError(e) {
@@ -829,17 +829,17 @@ StorageStreamAppender.prototype = {
},
doAppend: function (formatted) {
if (!formatted) {
return;
}
try {
this.outputStream.writeString(formatted + "\n");
- } catch(ex) {
+ } catch (ex) {
if (ex.result == Cr.NS_BASE_STREAM_CLOSED) {
// The underlying output stream is closed, so let's open a new one
// and try again.
this._outputStream = null;
} try {
this.outputStream.writeString(formatted + "\n");
} catch (ex) {
// Ah well, we tried, but something seems to be hosed permanently.
--- a/toolkit/modules/PopupNotifications.jsm
+++ b/toolkit/modules/PopupNotifications.jsm
@@ -1146,17 +1146,17 @@ PopupNotifications.prototype = {
timeSinceShown + "ms");
return;
}
notification._recordTelemetryStat(TELEMETRY_STAT_ACTION_1);
try {
notification.mainAction.callback.call();
- } catch(error) {
+ } catch (error) {
Cu.reportError(error);
}
if (notification.mainAction.dismiss) {
this._dismiss();
return;
}
@@ -1170,17 +1170,17 @@ PopupNotifications.prototype = {
throw "menucommand target has no associated action/notification";
event.stopPropagation();
target.notification._recordTelemetryStat(target.action.telemetryStatId);
try {
target.action.callback.call();
- } catch(error) {
+ } catch (error) {
Cu.reportError(error);
}
if (target.action.dismiss) {
this._dismiss();
return;
}
--- a/toolkit/modules/Preferences.jsm
+++ b/toolkit/modules/Preferences.jsm
@@ -125,17 +125,17 @@ Preferences._set = function(prefName, pr
break;
case "Number":
// We throw if the number is outside the range, since the result
// will never be what the consumer wanted to store, but we only warn
// if the number is non-integer, since the consumer might not mind
// the loss of precision.
if (prefValue > MAX_INT || prefValue < MIN_INT)
- throw("you cannot set the " + prefName + " pref to the number " +
+ throw ("you cannot set the " + prefName + " pref to the number " +
prefValue + ", as number pref values must be in the signed " +
"32-bit integer range -(2^31-1) to 2^31-1. To store numbers " +
"outside that range, store them as strings.");
this._prefBranch.setIntPref(prefName, prefValue);
if (prefValue % 1 != 0)
Cu.reportError("Warning: setting the " + prefName + " pref to the " +
"non-integer number " + prefValue + " converted it " +
"to the integer number " + this.get(prefName) +
@@ -323,17 +323,17 @@ Preferences.ignore = function(prefName,
Cu.reportError(`Attempt to stop observing a preference "${prefName}" that's not being observed`);
}
};
Preferences.resetBranch = function(prefBranch = "") {
try {
this._prefBranch.resetBranch(prefBranch);
}
- catch(ex) {
+ catch (ex) {
// The current implementation of nsIPrefBranch in Mozilla
// doesn't implement resetBranch, so we do it ourselves.
if (ex.result == Cr.NS_ERROR_NOT_IMPLEMENTED)
this.reset(this._prefBranch.getChildList(prefBranch, []));
else
throw ex;
}
},
--- a/toolkit/modules/PropertyListUtils.jsm
+++ b/toolkit/modules/PropertyListUtils.jsm
@@ -112,17 +112,17 @@ this.PropertyListUtils = Object.freeze({
}
finally {
aCallback(root);
}
}.bind(this);
fileReader.addEventListener("loadend", onLoadEnd, false);
fileReader.readAsArrayBuffer(file);
}
- catch(ex) {
+ catch (ex) {
aCallback(null);
throw ex;
}
}.bind(this), Ci.nsIThread.DISPATCH_NORMAL);
},
/**
* DO NOT USE ME. Once Bug 718189 is fixed, this method won't be public.
@@ -137,17 +137,17 @@ this.PropertyListUtils = Object.freeze({
let domParser = Cc["@mozilla.org/xmlextras/domparser;1"].
createInstance(Ci.nsIDOMParser);
let bytesView = new Uint8Array(aBuffer);
try {
let doc = domParser.parseFromBuffer(bytesView, bytesView.length,
"application/xml");
return new XMLPropertyListReader(doc).root;
}
- catch(ex) {
+ catch (ex) {
throw new Error("aBuffer cannot be parsed as a DOM document: " + ex);
}
return null;
},
TYPE_PRIMITIVE: 0,
TYPE_DATE: 1,
TYPE_UINT8_ARRAY: 2,
@@ -242,17 +242,17 @@ function BinaryPropertyListReader(aBuffe
this._JS_MAX_INT_SIGNED = ctypes.Int64(JS_MAX_INT);
this._JS_MAX_INT_UNSIGNED = ctypes.UInt64(JS_MAX_INT);
this._JS_MIN_INT = ctypes.Int64(-JS_MAX_INT);
try {
this._readTrailerInfo();
this._readObjectsOffsets();
}
- catch(ex) {
+ catch (ex) {
throw new Error("Could not read aBuffer as a binary property list");
}
this._objects = [];
}
BinaryPropertyListReader.prototype = {
/**
* Checks if the given ArrayBuffer can be read as a binary property list.
--- a/toolkit/modules/SpatialNavigation.jsm
+++ b/toolkit/modules/SpatialNavigation.jsm
@@ -513,25 +513,25 @@ var PrefObserver = {
}
// aSubject is the nsIPrefBranch we're observing (after appropriate QI)
// aData is the name of the pref that's been changed (relative to aSubject)
switch (aData) {
case "enabled":
try {
this.enabled = this._branch.getBoolPref("enabled");
- } catch(e) {
+ } catch (e) {
this.enabled = false;
}
break;
case "xulContentEnabled":
try {
this.xulContentEnabled = this._branch.getBoolPref("xulContentEnabled");
- } catch(e) {
+ } catch (e) {
this.xulContentEnabled = false;
}
break;
case "keyCode.modifier": {
let keyCodeModifier;
try {
keyCodeModifier = this._branch.getCharPref("keyCode.modifier");
@@ -555,52 +555,52 @@ var PrefObserver = {
else if (mod == kCtrl)
this.modifierCtrl = true;
else {
keyCodeModifier = kNone;
break;
}
}
}
- } catch(e) { }
+ } catch (e) { }
break;
}
case "keyCode.up":
try {
this.keyCodeUp = this._branch.getIntPref("keyCode.up");
- } catch(e) {
+ } catch (e) {
this.keyCodeUp = Ci.nsIDOMKeyEvent.DOM_VK_UP;
}
break;
case "keyCode.down":
try {
this.keyCodeDown = this._branch.getIntPref("keyCode.down");
- } catch(e) {
+ } catch (e) {
this.keyCodeDown = Ci.nsIDOMKeyEvent.DOM_VK_DOWN;
}
break;
case "keyCode.left":
try {
this.keyCodeLeft = this._branch.getIntPref("keyCode.left");
- } catch(e) {
+ } catch (e) {
this.keyCodeLeft = Ci.nsIDOMKeyEvent.DOM_VK_LEFT;
}
break;
case "keyCode.right":
try {
this.keyCodeRight = this._branch.getIntPref("keyCode.right");
- } catch(e) {
+ } catch (e) {
this.keyCodeRight = Ci.nsIDOMKeyEvent.DOM_VK_RIGHT;
}
break;
case "keyCode.return":
try {
this.keyCodeReturn = this._branch.getIntPref("keyCode.return");
- } catch(e) {
+ } catch (e) {
this.keyCodeReturn = Ci.nsIDOMKeyEvent.DOM_VK_RETURN;
}
break;
}
}
};
PrefObserver.register();
--- a/toolkit/modules/UpdateUtils.jsm
+++ b/toolkit/modules/UpdateUtils.jsm
@@ -135,17 +135,17 @@ XPCOMUtils.defineLazyGetter(UpdateUtils,
channel = NetUtil.newChannel({
uri: "resource://" + res + "/" + FILE_UPDATE_LOCALE,
contentPolicyType: Ci.nsIContentPolicy.TYPE_INTERNAL_XMLHTTPREQUEST,
loadUsingSystemPrincipal: true
});
try {
let inputStream = channel.open2();
locale = NetUtil.readInputStreamToString(inputStream, inputStream.available());
- } catch(e) {}
+ } catch (e) {}
if (locale)
return locale.trim();
}
Cu.reportError(FILE_UPDATE_LOCALE + " file doesn't exist in either the " +
"application or GRE directories");
return null;
@@ -347,17 +347,17 @@ XPCOMUtils.defineLazyGetter(UpdateUtils,
try {
let GetVersionEx = kernel32.declare("GetVersionExW",
ctypes.default_abi,
BOOL,
OSVERSIONINFOEXW.ptr);
let winVer = OSVERSIONINFOEXW();
winVer.dwOSVersionInfoSize = OSVERSIONINFOEXW.size;
- if(0 !== GetVersionEx(winVer.address())) {
+ if (0 !== GetVersionEx(winVer.address())) {
osVersion += "." + winVer.wServicePackMajor +
"." + winVer.wServicePackMinor;
} else {
Cu.reportError("Unknown failure in GetVersionEX (returned 0)");
osVersion += ".unknown";
}
} catch (e) {
Cu.reportError("Error getting service pack information. Exception: " + e);
--- a/toolkit/modules/debug.js
+++ b/toolkit/modules/debug.js
@@ -40,17 +40,17 @@ this.NS_ASSERT = function NS_ASSERT(cond
try {
switch (defB.getCharPref("app.update.channel")) {
case "nightly":
case "aurora":
case "beta":
case "default":
releaseBuild = false;
}
- } catch(ex) {}
+ } catch (ex) {}
var caller = arguments.callee.caller;
var assertionText = "ASSERT: " + message + "\n";
// Report the error to the console
Components.utils.reportError(assertionText);
if (releaseBuild) {
--- a/toolkit/modules/secondscreen/SimpleServiceDiscovery.jsm
+++ b/toolkit/modules/secondscreen/SimpleServiceDiscovery.jsm
@@ -58,17 +58,17 @@ var SimpleServiceDiscovery = {
_searchTimeout: Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer),
_searchRepeat: Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer),
_discoveryMethods: [],
_forceTrailingSlash: function(aURL) {
// Cleanup the URL to make it consistent across devices
try {
aURL = Services.io.newURI(aURL, null, null).spec;
- } catch(e) {}
+ } catch (e) {}
return aURL;
},
// nsIUDPSocketListener implementation
onPacketReceived: function(aSocket, aMessage) {
// Listen for responses from specific devices. There could be more than one
// available.
let response = aMessage.data.split("\n");
--- a/toolkit/modules/tests/xpcshell/test_GMPInstallManager.js
+++ b/toolkit/modules/tests/xpcshell/test_GMPInstallManager.js
@@ -489,17 +489,17 @@ function* test_checkForAddons_installAdd
// Make sure it reports as being installed
do_check_true(gmpAddon.isInstalled);
// Cleanup
extractedFile.parent.remove(true);
zipFile.remove(false);
httpServer.stop(function() {});
installManager.uninit();
- } catch(ex) {
+ } catch (ex) {
zipFile.remove(false);
if (!wantInstallReject) {
do_throw("install update should not reject " + ex.message);
}
}
}
add_task(test_checkForAddons_installAddon.bind(null, "1", true, false));
--- a/toolkit/modules/tests/xpcshell/test_Log_stackTrace.js
+++ b/toolkit/modules/tests/xpcshell/test_Log_stackTrace.js
@@ -7,17 +7,17 @@ print("Make sure lazy constructor callin
Components.utils.import("resource://gre/modules/Log.jsm");
function run_test() {
print("Make sure functions, arguments, files are pretty printed in the trace");
let trace = "";
try {
foo(0);
}
- catch(ex) {
+ catch (ex) {
trace = Log.stackTrace(ex);
}
print(`Got trace: ${trace}`);
do_check_neq(trace, "");
let bazPos = trace.indexOf("baz@test_Log_stackTrace.js:4");
let barPos = trace.indexOf("bar@test_Log_stackTrace.js:3");
let fooPos = trace.indexOf("foo@test_Log_stackTrace.js:2");
--- a/toolkit/modules/tests/xpcshell/test_Preferences.js
+++ b/toolkit/modules/tests/xpcshell/test_Preferences.js
@@ -87,39 +87,39 @@ add_test(function test_set_get_unicode_p
});
add_test(function test_set_null_pref() {
try {
Preferences.set("test_set_null_pref", null);
// We expect this to throw, so the test is designed to fail if it doesn't.
do_check_true(false);
}
- catch(ex) {}
+ catch (ex) {}
run_next_test();
});
add_test(function test_set_undefined_pref() {
try {
Preferences.set("test_set_undefined_pref");
// We expect this to throw, so the test is designed to fail if it doesn't.
do_check_true(false);
}
- catch(ex) {}
+ catch (ex) {}
run_next_test();
});
add_test(function test_set_unsupported_pref() {
try {
Preferences.set("test_set_unsupported_pref", new Array());
// We expect this to throw, so the test is designed to fail if it doesn't.
do_check_true(false);
}
- catch(ex) {}
+ catch (ex) {}
run_next_test();
});
// Make sure that we can get a string pref that we didn't set ourselves
// (i.e. that the way we get a string pref using getComplexValue doesn't
// hork us getting a string pref that wasn't set using setComplexValue).
add_test(function test_get_string_pref() {
@@ -162,17 +162,17 @@ add_test(function test_set_get_number_pr
do_check_eq(Preferences.get("test_set_get_number_pref"), 3);
// Values outside the range -(2^31-1) to 2^31-1 overflow.
try {
Preferences.set("test_set_get_number_pref", Math.pow(2, 31));
// We expect this to throw, so the test is designed to fail if it doesn't.
do_check_true(false);
}
- catch(ex) {}
+ catch (ex) {}
// Clean up.
Preferences.reset("test_set_get_number_pref");
run_next_test();
});
add_test(function test_reset_pref() {
--- a/toolkit/modules/tests/xpcshell/test_Promise.js
+++ b/toolkit/modules/tests/xpcshell/test_Promise.js
@@ -127,17 +127,17 @@ tests.push(make_promise_test(
let i;
for (i = 0; i < SIZE/2; ++i) {
install_observer(i);
}
source.resolve(RESULT);
// Install remaining observers
- for(;i < SIZE; ++i) {
+ for (;i < SIZE; ++i) {
install_observer(i);
}
return result;
}));
// Test that observers get the correct "this" value in strict mode.
tests.push(
@@ -255,17 +255,17 @@ tests.push(make_promise_test(
let i;
for (i = 0; i < SIZE/2; ++i) {
install_observer(i);
}
observed.resolve(RESULT);
// Install remaining observers
- for(;i < SIZE; ++i) {
+ for (;i < SIZE; ++i) {
install_observer(i);
}
// Resolve some more
for (i = 0; i < 10; ++i) {
observed.resolve(RESULT);
observed.reject();
}
@@ -920,17 +920,17 @@ tests.push(
tests.push(
make_promise_test(function promise_nested_eventloop_deadlock(test) {
// Set up a (long enough to be noticeable) timeout to
// exit the nested event loop and throw if the test run is hung
let shouldExitNestedEventLoop = false;
function event_loop() {
let thr = Services.tm.mainThread;
- while(!shouldExitNestedEventLoop) {
+ while (!shouldExitNestedEventLoop) {
thr.processNextEvent(true);
}
}
// I wish there was a way to cancel xpcshell do_timeout()s
do_timeout(2000, () => {
if (!shouldExitNestedEventLoop) {
shouldExitNestedEventLoop = true;
--- a/toolkit/modules/tests/xpcshell/test_UpdateUtils_url.js
+++ b/toolkit/modules/tests/xpcshell/test_UpdateUtils_url.js
@@ -63,17 +63,17 @@ function getServicePack() {
ctypes.default_abi,
BOOL,
OSVERSIONINFOEXW.ptr);
let winVer = OSVERSIONINFOEXW();
winVer.dwOSVersionInfoSize = OSVERSIONINFOEXW.size;
if (0 === GetVersionEx(winVer.address())) {
// Using "throw" instead of "do_throw" (see NOTE above)
- throw("Failure in GetVersionEx (returned 0)");
+ throw ("Failure in GetVersionEx (returned 0)");
}
return winVer.wServicePackMajor + "." + winVer.wServicePackMinor;
} finally {
kernel32.close();
}
}
@@ -108,26 +108,26 @@ function getProcArchitecture() {
ctypes.default_abi,
ctypes.void_t,
SYSTEM_INFO.ptr);
let sysInfo = SYSTEM_INFO();
// Default to unknown
sysInfo.wProcessorArchitecture = 0xffff;
GetNativeSystemInfo(sysInfo.address());
- switch(sysInfo.wProcessorArchitecture) {
+ switch (sysInfo.wProcessorArchitecture) {
case 9:
return "x64";
case 6:
return "IA64";
case 0:
return "x86";
default:
// Using "throw" instead of "do_throw" (see NOTE above)
- throw("Unknown architecture returned from GetNativeSystemInfo: " + sysInfo.wProcessorArchitecture);
+ throw ("Unknown architecture returned from GetNativeSystemInfo: " + sysInfo.wProcessorArchitecture);
}
} finally {
kernel32.close();
}
}
// Helper function for formatting a url and getting the result we're
// interested in
--- a/toolkit/modules/tests/xpcshell/test_ZipUtils.js
+++ b/toolkit/modules/tests/xpcshell/test_ZipUtils.js
@@ -47,17 +47,17 @@ function ensureHasSymlink(target) {
}
add_task(function test_extractFiles() {
let target = dir.clone();
target.append("test_extractFiles");
try {
ZipUtils.extractFiles(archive, target);
- } catch(e) {
+ } catch (e) {
do_throw("Failed to extract synchronously!");
}
ensureExtracted(target);
ensureHasSymlink(target);
});
add_task(function* test_extractFilesAsync() {
--- a/toolkit/mozapps/extensions/AddonManager.jsm
+++ b/toolkit/mozapps/extensions/AddonManager.jsm
@@ -878,17 +878,17 @@ var AddonManagerInternal = {
try {
gStrictCompatibility = Services.prefs.getBoolPref(PREF_EM_STRICT_COMPATIBILITY);
} catch (e) {}
Services.prefs.addObserver(PREF_EM_STRICT_COMPATIBILITY, this, false);
try {
let defaultBranch = Services.prefs.getDefaultBranch("");
gCheckUpdateSecurityDefault = defaultBranch.getBoolPref(PREF_EM_CHECK_UPDATE_SECURITY);
- } catch(e) {}
+ } catch (e) {}
try {
gCheckUpdateSecurity = Services.prefs.getBoolPref(PREF_EM_CHECK_UPDATE_SECURITY);
} catch (e) {}
Services.prefs.addObserver(PREF_EM_CHECK_UPDATE_SECURITY, this, false);
try {
gUpdateEnabled = Services.prefs.getBoolPref(PREF_EM_UPDATE_ENABLED);
@@ -1193,30 +1193,30 @@ var AddonManagerInternal = {
gPluginPageListener = null;
let savedError = null;
// Only shut down providers if they've been started.
if (gStarted) {
try {
yield gShutdownBarrier.wait();
}
- catch(err) {
+ catch (err) {
savedError = err;
logger.error("Failure during wait for shutdown barrier", err);
AddonManagerPrivate.recordException("AMI", "Async shutdown of AddonManager providers", err);
}
}
// Shut down AddonRepository after providers (if any).
try {
gRepoShutdownState = "in progress";
yield AddonRepository.shutdown();
gRepoShutdownState = "done";
}
- catch(err) {
+ catch (err) {
savedError = err;
logger.error("Failure during AddonRepository shutdown", err);
AddonManagerPrivate.recordException("AMI", "Async shutdown of AddonRepository", err);
}
logger.debug("Async provider shutdown done");
this.managerListeners.splice(0, this.managerListeners.length);
this.installListeners.splice(0, this.installListeners.length);
@@ -1258,83 +1258,83 @@ var AddonManagerInternal = {
* @see nsIObserver
*/
observe: function(aSubject, aTopic, aData) {
switch (aData) {
case PREF_EM_CHECK_COMPATIBILITY: {
let oldValue = gCheckCompatibility;
try {
gCheckCompatibility = Services.prefs.getBoolPref(PREF_EM_CHECK_COMPATIBILITY);
- } catch(e) {
+ } catch (e) {
gCheckCompatibility = true;
}
this.callManagerListeners("onCompatibilityModeChanged");
if (gCheckCompatibility != oldValue)
this.updateAddonAppDisabledStates();
break;
}
case PREF_EM_STRICT_COMPATIBILITY: {
let oldValue = gStrictCompatibility;
try {
gStrictCompatibility = Services.prefs.getBoolPref(PREF_EM_STRICT_COMPATIBILITY);
- } catch(e) {
+ } catch (e) {
gStrictCompatibility = true;
}
this.callManagerListeners("onCompatibilityModeChanged");
if (gStrictCompatibility != oldValue)
this.updateAddonAppDisabledStates();
break;
}
case PREF_EM_CHECK_UPDATE_SECURITY: {
let oldValue = gCheckUpdateSecurity;
try {
gCheckUpdateSecurity = Services.prefs.getBoolPref(PREF_EM_CHECK_UPDATE_SECURITY);
- } catch(e) {
+ } catch (e) {
gCheckUpdateSecurity = true;
}
this.callManagerListeners("onCheckUpdateSecurityChanged");
if (gCheckUpdateSecurity != oldValue)
this.updateAddonAppDisabledStates();
break;
}
case PREF_EM_UPDATE_ENABLED: {
let oldValue = gUpdateEnabled;
try {
gUpdateEnabled = Services.prefs.getBoolPref(PREF_EM_UPDATE_ENABLED);
- } catch(e) {
+ } catch (e) {
gUpdateEnabled = true;
}
this.callManagerListeners("onUpdateModeChanged");
break;
}
case PREF_EM_AUTOUPDATE_DEFAULT: {
let oldValue = gAutoUpdateDefault;
try {
gAutoUpdateDefault = Services.prefs.getBoolPref(PREF_EM_AUTOUPDATE_DEFAULT);
- } catch(e) {
+ } catch (e) {
gAutoUpdateDefault = true;
}
this.callManagerListeners("onUpdateModeChanged");
break;
}
case PREF_EM_HOTFIX_ID: {
try {
gHotfixID = Services.prefs.getCharPref(PREF_EM_HOTFIX_ID);
- } catch(e) {
+ } catch (e) {
gHotfixID = null;
}
break;
}
case PREF_MIN_WEBEXT_PLATFORM_VERSION: {
gWebExtensionsMinPlatformVersion = Services.prefs.getCharPref(PREF_MIN_WEBEXT_PLATFORM_VERSION);
break;
}
@@ -1404,17 +1404,17 @@ var AddonManagerInternal = {
getService(Ci.nsICategoryManager);
}
try {
var contractID = catMan.getCategoryEntry(CATEGORY_UPDATE_PARAMS, aParam);
var paramHandler = Cc[contractID].getService(Ci.nsIPropertyBag2);
return paramHandler.getPropertyAsAString(aParam);
}
- catch(e) {
+ catch (e) {
return aMatch;
}
});
// escape() does not properly encode + symbols in any embedded FVF strings.
return uri.replace(/\+/g, "%2B");
},
--- a/toolkit/mozapps/extensions/DeferredSave.jsm
+++ b/toolkit/mozapps/extensions/DeferredSave.jsm
@@ -203,17 +203,17 @@ this.DeferredSave.prototype = {
this._writing = pending.promise;
// In either the success or the exception handling case, we don't need to handle
// the error from _writing here; it's already being handled in another then()
let toSave = null;
try {
toSave = this._dataProvider();
}
- catch(e) {
+ catch (e) {
this.logger.error("Deferred save dataProvider failed", e);
writing.then(null, error => {})
.then(count => {
pending.reject(e);
});
return;
}
--- a/toolkit/mozapps/extensions/LightweightThemeManager.jsm
+++ b/toolkit/mozapps/extensions/LightweightThemeManager.jsm
@@ -74,17 +74,17 @@ var _themeIDBeingDisabled = null;
// Convert from the old storage format (in which the order of usedThemes
// was combined with isThemeSelected to determine which theme was selected)
// to the new one (where a selectedThemeID determines which theme is selected).
(function() {
let wasThemeSelected = false;
try {
wasThemeSelected = _prefs.getBoolPref("isThemeSelected");
- } catch(e) { }
+ } catch (e) { }
if (wasThemeSelected) {
_prefs.clearUserPref("isThemeSelected");
let themes = [];
try {
themes = JSON.parse(_prefs.getComplexValue("usedThemes",
Ci.nsISupportsString).data);
} catch (e) { }
--- a/toolkit/mozapps/extensions/amInstallTrigger.js
+++ b/toolkit/mozapps/extensions/amInstallTrigger.js
@@ -210,17 +210,17 @@ InstallTrigger.prototype = {
_checkLoadURIFromScript: function(uri) {
let secman = Services.scriptSecurityManager;
try {
secman.checkLoadURIWithPrincipal(this._principal,
uri,
secman.DISALLOW_INHERIT_PRINCIPAL);
return true;
}
- catch(e) {
+ catch (e) {
return false;
}
},
classID: Components.ID("{9df8ef2b-94da-45c9-ab9f-132eb55fddf1}"),
contractID: "@mozilla.org/addons/installtrigger;1",
QueryInterface: XPCOMUtils.generateQI([Ci.nsISupports, Ci.nsIDOMGlobalPropertyInitializer])
};
--- a/toolkit/mozapps/extensions/amWebInstallListener.js
+++ b/toolkit/mozapps/extensions/amWebInstallListener.js
@@ -204,17 +204,17 @@ Installer.prototype = {
/**
* Checks if all installs are now complete and if so notifies observers.
*/
checkAllInstalled: function() {
var failed = [];
for (let install of this.downloads) {
- switch(install.state) {
+ switch (install.state) {
case AddonManager.STATE_DOWNLOADED:
case AddonManager.STATE_INSTALLING:
// Exit early if any add-ons haven't started installing yet or are
// still installing
return;
case AddonManager.STATE_INSTALL_FAILED:
failed.push(install);
break;
--- a/toolkit/mozapps/extensions/content/extensions.js
+++ b/toolkit/mozapps/extensions/content/extensions.js
@@ -540,17 +540,17 @@ var gEventManager = {
return;
var listeners = this._listeners[addon.id];
for (let listener of listeners) {
if (!(aEvent in listener))
continue;
try {
listener[aEvent].apply(listener, aParams);
- } catch(e) {
+ } catch (e) {
// this shouldn't be fatal
Cu.reportError(e);
}
}
},
delegateInstallEvent: function(aEvent, aParams) {
var existingAddon = aEvent == "onExternalInstall" ? aParams[1] : aParams[0].existingAddon;
@@ -559,17 +559,17 @@ var gEventManager = {
if (existingAddon)
this.delegateAddonEvent(aEvent, [existingAddon].concat(aParams));
for (let listener of this._installListeners) {
if (!(aEvent in listener))
continue;
try {
listener[aEvent].apply(listener, aParams);
- } catch(e) {
+ } catch (e) {
// this shouldn't be fatal
Cu.reportError(e);
}
}
},
refreshGlobalWarning: function() {
var page = document.getElementById("addons-page");
@@ -659,17 +659,17 @@ var gViewController = {
this.currentViewObj.hide();
this.currentViewRequest = 0;
for (let type in this.viewObjects) {
let view = this.viewObjects[type];
if ("shutdown" in view) {
try {
view.shutdown();
- } catch(e) {
+ } catch (e) {
// this shouldn't be fatal
Cu.reportError(e);
}
}
}
window.controllers.removeController(this);
},
@@ -2437,17 +2437,17 @@ var gSearchView = {
createSearchResults(aAddons, false, false);
createSearchResults(aInstalls, true, false);
finishSearch();
});
var maxRemoteResults = 0;
try {
maxRemoteResults = Services.prefs.getIntPref(PREF_MAXRESULTS);
- } catch(e) {}
+ } catch (e) {}
if (maxRemoteResults <= 0) {
finishSearch(0);
return;
}
AddonRepository.searchAddons(aQuery, maxRemoteResults, {
searchFailed: () => {
@@ -3431,17 +3431,17 @@ var gDetailView = {
xhr.onerror = function(aEvent) {
Cu.reportError("Error " + aEvent.target.status +
" occurred while receiving " + this._addon.optionsURL);
if (aCallback)
aCallback();
};
xhr.send();
}
- } catch(e) {
+ } catch (e) {
Cu.reportError(e);
if (aCallback)
aCallback();
}
},
scrollToPreferencesRows: function() {
// We find this row, rather than remembering it from above,
--- a/toolkit/mozapps/extensions/content/setting.xml
+++ b/toolkit/mozapps/extensions/content/setting.xml
@@ -201,27 +201,27 @@
</binding>
<binding id="setting-localized-bool" extends="chrome://mozapps/content/extensions/setting.xml#setting-bool">
<implementation>
<method name="valueFromPreference">
<body>
<![CDATA[
let val = Services.prefs.getComplexValue(this.pref, Components.interfaces.nsIPrefLocalizedString).data;
- if(this.inverted) val = !val;
+ if (this.inverted) val = !val;
this.value = (val == "true");
]]>
</body>
</method>
<method name="valueToPreference">
<body>
<![CDATA[
let val = this.value;
- if(this.inverted) val = !val;
+ if (this.inverted) val = !val;
let pref = Components.classes["@mozilla.org/pref-localizedstring;1"].createInstance(Components.interfaces.nsIPrefLocalizedString);
pref.data = this.inverted ? (!val).toString() : val.toString();
Services.prefs.setComplexValue(this.pref, Components.interfaces.nsIPrefLocalizedString, pref);
]]>
</body>
</method>
</implementation>
</binding>
--- a/toolkit/mozapps/extensions/internal/AddonRepository.jsm
+++ b/toolkit/mozapps/extensions/internal/AddonRepository.jsm
@@ -134,17 +134,17 @@ function getAddonsToCache(aIds, aCallbac
AddonManager.getAddonsByIDs(aIds, function(aAddons) {
let enabledIds = [];
for (var i = 0; i < aIds.length; i++) {
var preference = PREF_GETADDONS_CACHE_ID_ENABLED.replace("%ID%", aIds[i]);
try {
if (!Services.prefs.getBoolPref(preference))
continue;
- } catch(e) {
+ } catch (e) {
// If the preference doesn't exist caching is enabled by default
}
// The add-ons manager may not know about this ID yet if it is a pending
// install. In that case we'll just cache it regardless
if (aAddons[i] && (types.indexOf(aAddons[i].type) == -1))
continue;
@@ -478,17 +478,17 @@ this.AddonRepository = {
/**
* Whether caching is currently enabled
*/
get cacheEnabled() {
let preference = PREF_GETADDONS_CACHE_ENABLED;
let enabled = false;
try {
enabled = Services.prefs.getBoolPref(preference);
- } catch(e) {
+ } catch (e) {
logger.warn("cacheEnabled: Couldn't get pref: " + preference);
}
return enabled;
},
// A cache of the add-ons stored in the database
_addons: null,
@@ -1507,17 +1507,17 @@ this.AddonRepository = {
});
},
// Create url from preference, returning null if preference does not exist
_formatURLPref: function(aPreference, aSubstitutions) {
let url = null;
try {
url = Services.prefs.getCharPref(aPreference);
- } catch(e) {
+ } catch (e) {
logger.warn("_formatURLPref: Couldn't get pref: " + aPreference);
return null;
}
url = url.replace(/%([A-Z_]+)%/g, function(aMatch, aKey) {
return (aKey in aSubstitutions) ? aSubstitutions[aKey] : aMatch;
});
--- a/toolkit/mozapps/extensions/internal/Content.js
+++ b/toolkit/mozapps/extensions/internal/Content.js
@@ -26,13 +26,13 @@ try {
let file = new nsIFile(message.data);
Services.obs.notifyObservers(file, "flush-cache-entry", null);
});
// Propagate message manager caches flush notifications across processes.
addMessageListener(MSG_MESSAGE_MANAGER_CACHES_FLUSH, function() {
Services.obs.notifyObservers(null, "message-manager-flush-caches", null);
});
}
-} catch(e) {
+} catch (e) {
Cu.reportError(e);
}
})();
--- a/toolkit/mozapps/extensions/internal/GMPProvider.jsm
+++ b/toolkit/mozapps/extensions/internal/GMPProvider.jsm
@@ -389,17 +389,17 @@ GMPWrapper.prototype = {
}, delay);
},
receiveMessage: function({target: browser, data: data}) {
this._log.trace("receiveMessage() data=" + data);
let parsedData;
try {
parsedData = JSON.parse(data);
- } catch(ex) {
+ } catch (ex) {
this._log.error("Malformed EME video message with data: " + data);
return;
}
let {status: status, keySystem: keySystem} = parsedData;
if (status == "cdm-not-installed" || status == "cdm-insufficient-version") {
this.checkForUpdates(0);
}
},
--- a/toolkit/mozapps/extensions/internal/XPIProvider.jsm
+++ b/toolkit/mozapps/extensions/internal/XPIProvider.jsm
@@ -559,17 +559,17 @@ SafeInstallOperation.prototype = {
* The new location of the file.
*/
moveTo: function(aOldLocation, aNewLocation) {
try {
let oldFile = aOldLocation.clone(), newFile = aNewLocation.clone();
oldFile.moveTo(newFile.parent, newFile.leafName);
this._installedFiles.push({ oldFile: oldFile, newFile: newFile, isMoveTo: true});
}
- catch(e) {
+ catch (e) {
this.rollback();
throw e;
}
},
/**
* Copies a file or directory into a new directory. If an error occurs then
* all new files that have been created will be removed.
@@ -2014,17 +2014,17 @@ function getDirectoryEntries(aDir, aSort
* and returns the same result unless aFunction throws, in which case it logs
* a warning and returns undefined.
*/
function makeSafe(aFunction) {
return function(...aArgs) {
try {
return aFunction(...aArgs);
}
- catch(ex) {
+ catch (ex) {
logger.warn("XPIProvider callback failed", ex);
}
return undefined;
}
}
/**
* Record a bit of per-addon telemetry
@@ -6441,17 +6441,17 @@ AddonInstall.createStagedInstall = funct
AddonInstall.createInstall = function(aCallback, aFile) {
let location = XPIProvider.installLocationsByName[KEY_APP_PROFILE];
let url = Services.io.newFileURI(aFile);
try {
let install = new AddonInstall(location, url);
install.initLocalInstall(aCallback);
}
- catch(e) {
+ catch (e) {
logger.error("Error creating install", e);
makeSafe(aCallback)(null);
}
};
/**
* Creates a new AddonInstall to download and install a URL.
*
@@ -7200,22 +7200,22 @@ AddonWrapper.prototype = {
if (this.hasResource("icon.png")) {
icons[32] = icons[48] = this.getResourceURI("icon.png").spec;
}
if (this.hasResource("icon64.png")) {
icons[64] = this.getResourceURI("icon64.png").spec;
}
}
- if(this.isActive && addon.iconURL) {
+ if (this.isActive && addon.iconURL) {
icons[32] = addon.iconURL;
icons[48] = addon.iconURL;
}
- if(this.isActive && addon.icon64URL) {
+ if (this.isActive && addon.icon64URL) {
icons[64] = addon.icon64URL;
}
Object.freeze(icons);
return icons;
},
get screenshots() {
--- a/toolkit/mozapps/extensions/internal/XPIProviderUtils.js
+++ b/toolkit/mozapps/extensions/internal/XPIProviderUtils.js
@@ -163,17 +163,17 @@ function getRepositoryAddon(aAddon, aCal
/**
* Wrap an API-supplied function in an exception handler to make it safe to call
*/
function makeSafe(aCallback) {
return function(...aArgs) {
try {
aCallback(...aArgs);
}
- catch(ex) {
+ catch (ex) {
logger.warn("XPI Database callback failed", ex);
}
}
}
/**
* A helper method to asynchronously call a function on an array
* of objects, calling a callback when function(x) has been gathered
@@ -587,17 +587,17 @@ this.XPIDatabase = {
do {
read = cstream.readString(0xffffffff, str); // read as much as we can and put it in str.value
data += str.value;
} while (read != 0);
readTimer.done();
this.parseDB(data, aRebuildOnError);
}
- catch(e) {
+ catch (e) {
logger.error("Failed to load XPI JSON data from profile", e);
let rebuildTimer = AddonManagerPrivate.simpleTimer("XPIDB_rebuildReadFailed_MS");
this.rebuildDatabase(aRebuildOnError);
rebuildTimer.done();
}
finally {
if (cstream)
cstream.close();
@@ -675,17 +675,17 @@ this.XPIDatabase = {
let newAddon = new DBAddonInternal(loadedAddon);
addonDB.set(newAddon._key, newAddon);
}
parseTimer.done();
this.addonDB = addonDB;
logger.debug("Successfully read XPI database");
this.initialized = true;
}
- catch(e) {
+ catch (e) {
// If we catch and log a SyntaxError from the JSON
// parser, the xpcshell test harness fails the test for us: bug 870828
parseTimer.done();
if (e.name == "SyntaxError") {
logger.error("Syntax error parsing saved XPI JSON data");
AddonManagerPrivate.recordSimpleMeasure("XPIDB_startupError", "syntax");
}
else {
@@ -711,17 +711,17 @@ this.XPIDatabase = {
this.migrateData = this.getMigrateDataFromSQLITE();
}
else {
// we've upgraded before but the JSON file is gone, fall through
// and rebuild from scratch
AddonManagerPrivate.recordSimpleMeasure("XPIDB_startupError", "dbMissing");
}
}
- catch(e) {
+ catch (e) {
// No schema version pref means either a really old upgrade (RDF) or
// a new profile
this.migrateData = this.getMigrateDataFromRDF();
}
this.rebuildDatabase(aRebuildOnError);
upgradeTimer.done();
},
--- a/toolkit/mozapps/extensions/nsBlocklistService.js
+++ b/toolkit/mozapps/extensions/nsBlocklistService.js
@@ -861,17 +861,17 @@ Blocklist.prototype = {
try {
yield this._preloadBlocklistFile(profPath);
return;
} catch (e) {
LOG("Blocklist::_preloadBlocklist: Failed to load XML file " + e)
}
var appFile = FileUtils.getFile(KEY_APPDIR, [FILE_BLOCKLIST]);
- try{
+ try {
yield this._preloadBlocklistFile(appFile.path);
return;
} catch (e) {
LOG("Blocklist::_preloadBlocklist: Failed to load XML file " + e)
}
LOG("Blocklist::_preloadBlocklist: no XML File found");
}),
--- a/toolkit/mozapps/extensions/test/browser/browser_bug567127.js
+++ b/toolkit/mozapps/extensions/test/browser/browser_bug567127.js
@@ -114,17 +114,17 @@ add_task(function* test_install_from_fil
"addon-install-started", false);
// Set handler that executes the core test after the window opens,
// and resolves the promise when the window closes
let pInstallURIClosed = new Promise((resolve, reject) => {
new WindowOpenListener(INSTALL_URI, function(aWindow) {
try {
test_confirmation(aWindow, filePaths.map(aPath => aPath.spec));
- } catch(e) {
+ } catch (e) {
reject(e);
}
}, resolve);
});
gManagerWindow.gViewController.doCommand("cmd_installFromFile");
yield pInstallURIClosed;
--- a/toolkit/mozapps/extensions/test/browser/browser_bug577990.js
+++ b/toolkit/mozapps/extensions/test/browser/browser_bug577990.js
@@ -14,17 +14,17 @@ var gInstallProperties = [{
type: "locale"
}];
function test() {
try {
if (Components.classes["@mozilla.org/gfx/info;1"].getService(Components.interfaces.nsIGfxInfo).D2DEnabled) {
requestLongerTimeout(2);
}
- } catch(e) {}
+ } catch (e) {}
waitForExplicitFinish();
gProvider = new MockProvider();
open_manager("addons://list/extension", function(aWindow) {
gManagerWindow = aWindow;
gCategoryUtilities = new CategoryUtilities(gManagerWindow);
run_next_test();
--- a/toolkit/mozapps/extensions/test/browser/browser_bug590347.js
+++ b/toolkit/mozapps/extensions/test/browser/browser_bug590347.js
@@ -44,17 +44,17 @@ function get_list_view_warning_node() {
}
item = item.nextSibling;
}
ok(found, "Test add-on node should have been found.");
return item.ownerDocument.getAnonymousElementByAttribute(item, "anonid", "warning");
}
function get_detail_view_warning_node(aManagerWindow) {
- if(aManagerWindow)
+ if (aManagerWindow)
return aManagerWindow.document.getElementById("detail-warning");
return undefined;
}
function test() {
waitForExplicitFinish();
gProvider = new MockProvider();
--- a/toolkit/mozapps/extensions/test/browser/browser_discovery.js
+++ b/toolkit/mozapps/extensions/test/browser/browser_discovery.js
@@ -577,25 +577,25 @@ add_test(function() {
});
// Test for Bug 601442 - extensions.getAddons.showPane need to be update
// for the new addon manager.
function bug_601442_test_elements(visible) {
open_manager("addons://list/extension", function(aWindow) {
gManagerWindow = aWindow;
gCategoryUtilities = new CategoryUtilities(gManagerWindow);
- if(visible)
+ if (visible)
ok(gCategoryUtilities.isTypeVisible("discover"), "Discover category should be visible");
else
ok(!gCategoryUtilities.isTypeVisible("discover"), "Discover category should not be visible");
gManagerWindow.loadView("addons://list/dictionary");
wait_for_view_load(gManagerWindow, function(aManager) {
var button = aManager.document.getElementById("discover-button-install");
- if(visible)
+ if (visible)
ok(!is_hidden(button), "Discover button should be visible!");
else
ok(is_hidden(button), "Discover button should not be visible!");
close_manager(gManagerWindow, run_next_test);
});
});
}
--- a/toolkit/mozapps/extensions/test/browser/head.js
+++ b/toolkit/mozapps/extensions/test/browser/head.js
@@ -268,17 +268,17 @@ var get_tooltip_info = Task.async(functi
});
function get_addon_file_url(aFilename) {
try {
var cr = Cc["@mozilla.org/chrome/chrome-registry;1"].
getService(Ci.nsIChromeRegistry);
var fileurl = cr.convertChromeURL(makeURI(CHROMEROOT + "addons/" + aFilename));
return fileurl.QueryInterface(Ci.nsIFileURL);
- } catch(ex) {
+ } catch (ex) {
var jar = getJar(CHROMEROOT + "addons/" + aFilename);
var tmpDir = extractJarToTmp(jar);
tmpDir.append(aFilename);
return Services.io.newFileURI(tmpDir).QueryInterface(Ci.nsIFileURL);
}
}
@@ -446,17 +446,17 @@ function close_manager(aManagerWindow, a
ok(aManagerWindow != null, "Should have an add-ons manager window to close");
is(aManagerWindow.location, MANAGER_URI, "Should be closing window with correct URI");
aManagerWindow.addEventListener("unload", function() {
try {
dump("Manager window unload handler\n");
this.removeEventListener("unload", arguments.callee, false);
resolve();
- } catch(e) {
+ } catch (e) {
reject(e);
}
}, false);
});
info("Telling manager window to close");
aManagerWindow.close();
info("Manager window close() call returned");
@@ -904,17 +904,17 @@ MockProvider.prototype = {
while (this.callbackTimers.length > 0) {
// When we notify the callback timer, it removes itself from our array
let timer = this.callbackTimers[0];
try {
let setAt = this.timerLocations.get(timer);
info("Notifying timer set at " + (setAt || "unknown location"));
timer.callback.notify(timer);
timer.cancel();
- } catch(e) {
+ } catch (e) {
info("Timer notify failed: " + e);
}
}
this.callbackTimers = [];
this.timerLocations = null;
this.started = false;
},
--- a/toolkit/mozapps/extensions/test/xpcshell/head_addons.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/head_addons.js
@@ -1977,17 +1977,17 @@ function remove_port(url) {
return url;
}
// Wrap a function (typically a callback) to catch and report exceptions
function do_exception_wrap(func) {
return function() {
try {
func.apply(null, arguments);
}
- catch(e) {
+ catch (e) {
do_report_unexpected_exception(e);
}
};
}
/**
* Change the schema version of the JSON extensions database
*/
@@ -2021,17 +2021,17 @@ function loadFile(aFile) {
}
/**
* Raw load of a JSON file
*/
function loadJSON(aFile) {
let data = loadFile(aFile);
do_print("Loaded JSON file " + aFile.path);
- return(JSON.parse(data));
+ return (JSON.parse(data));
}
/**
* Raw save of a JSON blob to file
*/
function saveJSON(aData, aFile) {
do_print("Starting to save JSON file " + aFile.path);
let stream = FileUtils.openSafeFileOutputStream(aFile);
--- a/toolkit/mozapps/extensions/test/xpcshell/test_AddonRepository.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_AddonRepository.js
@@ -398,17 +398,17 @@ function run_test() {
do_get_file("data/test_AddonRepository.xml"),
gServer);
// Create an active AddonInstall so can check that it isn't returned in the results
AddonManager.getInstallForURL(BASE_URL + INSTALL_URL2, function addon_2_get(aInstall) {
try {
aInstall.install();
}
- catch(e) {
+ catch (e) {
do_print("Failed to install add-on " + aInstall.sourceURI.spec);
do_report_unexpected_exception(e);
}
// Create a non-active AddonInstall so can check that it is returned in the results
AddonManager.getInstallForURL(BASE_URL + INSTALL_URL3,
run_test_1, "application/x-xpinstall");
}, "application/x-xpinstall");
--- a/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_prefs.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_prefs.js
@@ -118,17 +118,17 @@ function run_test() {
do_check_eq(status, Ci.nsIGfxInfo.FEATURE_STATUS_OK);
var prefs = Cc["@mozilla.org/preferences-service;1"].
getService(Ci.nsIPrefBranch);
var exists = false;
try {
prefs.getIntPref("gfx.blacklist.direct2d");
exists = true;
- } catch(e) {}
+ } catch (e) {}
do_check_false(exists);
gTestserver.stop(do_test_finished);
}
Services.obs.addObserver(blacklistAdded, "blocklist-data-gfxItems", false);
load_blocklist("test_gfxBlacklist.xml");
--- a/toolkit/mozapps/extensions/test/xpcshell/test_nodisable_hidden.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_nodisable_hidden.js
@@ -85,17 +85,17 @@ add_task(function*() {
do_check_false(addon.userDisabled);
do_check_true(addon.isActive);
do_check_eq(addon.type, "extension");
// system add-ons cannot be disabled by the user.
try {
addon.userDisabled = true;
do_throw("Expected addon.userDisabled on a hidden add-on to throw!");
- } catch(e) {
+ } catch (e) {
do_check_eq(e.message, `Cannot disable hidden add-on ${SYSTEM_ID}`);
}
do_check_neq(addon, null);
do_check_eq(addon.version, "1.0");
do_check_eq(addon.name, "Test disabling hidden add-ons, hidden system add-on case.");
do_check_true(addon.isCompatible);
do_check_false(addon.appDisabled);
--- a/toolkit/mozapps/extensions/test/xpcshell/test_update.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_update.js
@@ -526,17 +526,17 @@ for (let test of testParams) {
let [req_version, item_id, item_version,
item_maxappversion, item_status,
app_id, app_version, current_app_version,
app_os, app_abi, app_locale, update_type] =
request.queryString.split("/").map(a => decodeURIComponent(a));
do_check_eq(req_version, "2");
- switch(item_id) {
+ switch (item_id) {
case "addon1@tests.mozilla.org":
do_check_eq(item_version, "5.0");
do_check_eq(item_maxappversion, "2");
do_check_eq(item_status, "userEnabled");
do_check_eq(app_version, "1");
do_check_eq(update_type, "97");
break;
case "addon2@tests.mozilla.org":
--- a/toolkit/mozapps/extensions/test/xpcshell/test_update_strictcompat.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_update_strictcompat.js
@@ -513,17 +513,17 @@ for (let test of testParams) {
let [req_version, item_id, item_version,
item_maxappversion, item_status,
app_id, app_version, current_app_version,
app_os, app_abi, app_locale, update_type] =
request.queryString.split("/").map(a => decodeURIComponent(a));
do_check_eq(req_version, "2");
- switch(item_id) {
+ switch (item_id) {
case "addon1@tests.mozilla.org":
do_check_eq(item_version, "5.0");
do_check_eq(item_maxappversion, "2");
do_check_eq(item_status, "userEnabled");
do_check_eq(app_version, "1");
do_check_eq(update_type, "97");
break;
case "addon2@tests.mozilla.org":
--- a/toolkit/mozapps/extensions/test/xpcshell/test_updatecheck.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_updatecheck.js
@@ -94,17 +94,17 @@ add_task(function* () {
// required, but perform the remaining tests which aren't expected to fail
// because of the update key, without requiring one for the JSON variant.
try {
let updates = yield checkUpdates("test_bug378216_8@tests.mozilla.org",
updateKey, "test_updatecheck.json");
throw "Expected the update check to fail";
- } catch(e) {}
+ } catch (e) {}
for (let [file, key] of [["test_updatecheck.rdf", updateKey],
["test_updatecheck.json", null]]) {
let updates = yield checkUpdates("test_bug378216_8@tests.mozilla.org",
key, file);
equal(updates.length, 1);
ok(!("updateURL" in updates[0]));
}
--- a/toolkit/mozapps/installer/precompile_cache.js
+++ b/toolkit/mozapps/installer/precompile_cache.js
@@ -68,17 +68,17 @@ function get_modules_under(uri) {
}
function load_modules_under(spec, uri) {
var entries = get_modules_under(uri).sort();
for (let entry of entries) {
try {
dump(spec + entry + "\n");
Cu.import(spec + entry, null);
- } catch(e) {}
+ } catch (e) {}
}
}
function resolveResource(spec) {
var uri = Services.io.newURI(spec, null, null);
return Services.io.newURI(rph.resolveURI(uri), null, null);
}
--- a/toolkit/mozapps/update/UpdateTelemetry.jsm
+++ b/toolkit/mozapps/update/UpdateTelemetry.jsm
@@ -244,17 +244,17 @@ this.AUSTLMY = {
* An integer value as defined by the values that start with STATE_ in
* the above section for the update state from the update.status file.
*/
pingStateCode: function UT_pingStateCode(aSuffix, aCode) {
try {
let id = "UPDATE_STATE_CODE_" + aSuffix;
// enumerated type histogram
Services.telemetry.getHistogramById(id).add(aCode);
- } catch(e) {
+ } catch (e) {
Cu.reportError(e);
}
},
/**
* Submit a telemetry ping for the update status error code. This does not
* submit a success value which can be determined from the state code.
*
@@ -269,17 +269,17 @@ this.AUSTLMY = {
* @param aCode
* An integer value for the error code from the update.status file.
*/
pingStatusErrorCode: function UT_pingStatusErrorCode(aSuffix, aCode) {
try {
let id = "UPDATE_STATUS_ERROR_CODE_" + aSuffix;
// enumerated type histogram
Services.telemetry.getHistogramById(id).add(aCode);
- } catch(e) {
+ } catch (e) {
Cu.reportError(e);
}
},
/**
* Submit the interval in days since the last notification for this background
* update check or a boolean if the last notification is in the future.
*
@@ -296,27 +296,27 @@ this.AUSTLMY = {
let lastUpdateTimeSeconds = Services.prefs.getIntPref(PREF_APP_UPDATE_LASTUPDATETIME);
if (lastUpdateTimeSeconds) {
let currentTimeSeconds = Math.round(Date.now() / 1000);
if (lastUpdateTimeSeconds > currentTimeSeconds) {
try {
let id = "UPDATE_INVALID_LASTUPDATETIME_" + aSuffix;
// count type histogram
Services.telemetry.getHistogramById(id).add();
- } catch(e) {
+ } catch (e) {
Cu.reportError(e);
}
} else {
let intervalDays = (currentTimeSeconds - lastUpdateTimeSeconds) /
(60 * 60 * 24);
try {
let id = "UPDATE_LAST_NOTIFY_INTERVAL_DAYS_" + aSuffix;
// exponential type histogram
Services.telemetry.getHistogramById(id).add(intervalDays);
- } catch(e) {
+ } catch (e) {
Cu.reportError(e);
}
}
}
}
},
/**
@@ -374,42 +374,42 @@ this.AUSTLMY = {
Cu.reportError(Cr.NS_ERROR_NOT_AVAILABLE);
return;
}
try {
let id = "UPDATE_SERVICE_INSTALLED_" + aSuffix;
// boolean type histogram
Services.telemetry.getHistogramById(id).add(aInstalled);
- } catch(e) {
+ } catch (e) {
Cu.reportError(e);
}
let attempted = 0;
try {
let wrk = Cc["@mozilla.org/windows-registry-key;1"].
createInstance(Ci.nsIWindowsRegKey);
wrk.open(wrk.ROOT_KEY_LOCAL_MACHINE,
"SOFTWARE\\Mozilla\\MaintenanceService",
wrk.ACCESS_READ | wrk.WOW64_64);
// Was the service at some point installed, but is now uninstalled?
attempted = wrk.readIntValue("Attempted");
wrk.close();
- } catch(e) {
+ } catch (e) {
// Since this will throw if the registry key doesn't exist (e.g. the
// service has never been installed) don't report an error.
}
try {
let id = "UPDATE_SERVICE_MANUALLY_UNINSTALLED_" + aSuffix;
if (!aInstalled && attempted) {
// count type histogram
Services.telemetry.getHistogramById(id).add();
}
- } catch(e) {
+ } catch (e) {
Cu.reportError(e);
}
},
/**
* Submit a telemetry ping for a count type histogram when the expected value
* does not equal the boolean value of a pref or if the pref isn't present
* when the expected value does not equal default value. This lessens the
@@ -430,17 +430,17 @@ this.AUSTLMY = {
let val = aDefault;
if (Services.prefs.getPrefType(aPref) != Ci.nsIPrefBranch.PREF_INVALID) {
val = Services.prefs.getBoolPref(aPref);
}
if (val != aExpected) {
// count type histogram
Services.telemetry.getHistogramById(aID).add();
}
- } catch(e) {
+ } catch (e) {
Cu.reportError(e);
}
},
/**
* Submit a telemetry ping for a histogram with the integer value of a
* preference when it is not the expected value or the default value when it
* is not the expected value. This lessens the amount of data submitted to
@@ -461,17 +461,17 @@ this.AUSTLMY = {
let val = aDefault;
if (Services.prefs.getPrefType(aPref) != Ci.nsIPrefBranch.PREF_INVALID) {
val = Services.prefs.getIntPref(aPref);
}
if (aExpected === undefined || val != aExpected) {
// enumerated or exponential type histogram
Services.telemetry.getHistogramById(aID).add(val);
}
- } catch(e) {
+ } catch (e) {
Cu.reportError(e);
}
},
/**
* Submit a telemetry ping for all histogram types that take a single
* parameter to the telemetry add function and the count type histogram when
* the aExpected parameter is specified. If the aExpected parameter is
@@ -490,14 +490,14 @@ this.AUSTLMY = {
pingGeneric: function UT_pingGeneric(aID, aValue, aExpected) {
try {
if (aExpected === undefined) {
Services.telemetry.getHistogramById(aID).add(aValue);
} else if (aValue != aExpected) {
// count type histogram
Services.telemetry.getHistogramById(aID).add();
}
- } catch(e) {
+ } catch (e) {
Cu.reportError(e);
}
}
};
Object.freeze(AUSTLMY);
--- a/toolkit/mozapps/update/content/updates.js
+++ b/toolkit/mozapps/update/content/updates.js
@@ -913,17 +913,17 @@ var gDownloadingPage = {
return;
}
// Add this UI as a listener for active downloads
aus.addDownloadListener(this);
if (activeUpdate)
this._setUIState(!aus.isDownloading);
}
- catch(e) {
+ catch (e) {
LOG("gDownloadingPage", "onPageShow - error: " + e);
}
gUpdates.setButtons("hideButton", null, null, false);
gUpdates.wiz.getButton("extra1").focus();
},
/**
--- a/toolkit/mozapps/update/nsUpdateService.js
+++ b/toolkit/mozapps/update/nsUpdateService.js
@@ -1021,17 +1021,17 @@ function isServiceInstalled() {
try {
let wrk = Cc["@mozilla.org/windows-registry-key;1"].
createInstance(Ci.nsIWindowsRegKey);
wrk.open(wrk.ROOT_KEY_LOCAL_MACHINE,
"SOFTWARE\\Mozilla\\MaintenanceService",
wrk.ACCESS_READ | wrk.WOW64_64);
installed = wrk.readIntValue("Installed");
wrk.close();
- } catch(e) {
+ } catch (e) {
}
installed = installed == 1; // convert to bool
LOG("isServiceInstalled = " + installed);
return installed;
}
return false;
}
@@ -1646,17 +1646,17 @@ function Update(update) {
this.isSecurityUpdate = attr.value == "true";
} else if (attr.name == "isOSUpdate") {
this.isOSUpdate = attr.value == "true";
} else if (attr.name == "showNeverForVersion") {
this.showNeverForVersion = attr.value == "true";
} else if (attr.name == "showPrompt") {
this.showPrompt = attr.value == "true";
} else if (attr.name == "promptWaitTime") {
- if(!isNaN(attr.value)) {
+ if (!isNaN(attr.value)) {
this.promptWaitTime = parseInt(attr.value);
}
} else if (attr.name == "unsupported") {
this.unsupported = attr.value == "true";
} else if (attr.name == "version") {
// Prevent version from replacing displayVersion if displayVersion is
// present in the update xml.
if (!this.displayVersion) {
--- a/toolkit/mozapps/update/tests/chrome/utils.js
+++ b/toolkit/mozapps/update/tests/chrome/utils.js
@@ -444,17 +444,17 @@ function delayedDefaultCallback() {
}
// Used to verify that this test has been performed
gTest.ranTest = true;
if (gTest.buttonClick) {
debugDump("clicking " + gTest.buttonClick + " button");
if (gTest.extraDelayedFinishFunction) {
- throw("Tests cannot have a buttonClick and an extraDelayedFinishFunction property");
+ throw ("Tests cannot have a buttonClick and an extraDelayedFinishFunction property");
}
gDocElem.getButton(gTest.buttonClick).click();
} else if (gTest.extraDelayedFinishFunction) {
debugDump("calling extraDelayedFinishFunction " +
gTest.extraDelayedFinishFunction.name);
gTest.extraDelayedFinishFunction();
}
}
@@ -1028,17 +1028,17 @@ function resetPrefs() {
});
}
catch (e) {
}
try {
Services.prefs.deleteBranch(PREFBRANCH_APP_UPDATE_NEVER);
}
- catch(e) {
+ catch (e) {
}
}
function setupTimer(aTestTimeout) {
gTestTimeout = aTestTimeout;
if (gTimeoutTimer) {
gTimeoutTimer.cancel();
gTimeoutTimer = null;
--- a/toolkit/mozapps/update/tests/data/shared.js
+++ b/toolkit/mozapps/update/tests/data/shared.js
@@ -480,27 +480,27 @@ function cleanUpdatesDir(aDir) {
}
cleanUpdatesDir(entry);
entry.permissions = PERMS_DIRECTORY;
try {
entry.remove(true);
} catch (e) {
logTestInfo("cleanUpdatesDir: unable to remove directory. Path: " +
entry.path + ", Exception: " + e);
- throw(e);
+ throw (e);
}
}
} else {
entry.permissions = PERMS_FILE;
try {
entry.remove(false);
} catch (e) {
logTestInfo("cleanUpdatesDir: unable to remove file. Path: " +
entry.path + ", Exception: " + e);
- throw(e);
+ throw (e);
}
}
}
}
/**
* Deletes a directory and its children. First it tries nsIFile::Remove(true).
* If that fails it will fall back to recursing, setting the appropriate
@@ -530,28 +530,28 @@ function removeDirRecursive(aDir) {
removeDirRecursive(entry);
} else {
entry.permissions = PERMS_FILE;
try {
debugDump("attempting to remove file. Path: " + entry.path);
entry.remove(false);
} catch (e) {
logTestInfo("error removing file. Exception: " + e);
- throw(e);
+ throw (e);
}
}
}
aDir.permissions = PERMS_DIRECTORY;
try {
debugDump("attempting to remove directory. Path: " + aDir.path);
aDir.remove(true);
} catch (e) {
logTestInfo("error removing directory. Exception: " + e);
- throw(e);
+ throw (e);
}
}
/**
* Returns the directory for the currently running process. This is used to
* clean up after the tests and to locate the active-update.xml and updates.xml
* files.
*
--- a/toolkit/mozapps/update/tests/unit_aus_update/downloadAndHashCheckMar.js
+++ b/toolkit/mozapps/update/tests/unit_aus_update/downloadAndHashCheckMar.js
@@ -41,17 +41,17 @@ function finish_test() {
// call the nsIDOMEventListener's handleEvent method for onload.
function callHandleEvent(aXHR) {
aXHR.status = 400;
aXHR.responseText = gResponseBody;
try {
let parser = Cc["@mozilla.org/xmlextras/domparser;1"].
createInstance(Ci.nsIDOMParser);
aXHR.responseXML = parser.parseFromString(gResponseBody, "application/xml");
- } catch(e) {
+ } catch (e) {
}
let e = { target: aXHR };
aXHR.onload(e);
}
// Helper function for testing mar downloads that have the correct size
// specified in the update xml.
function run_test_helper_pt1(aMsg, aExpectedStatusResult, aNextRunFunc) {
--- a/toolkit/mozapps/update/tests/unit_aus_update/urlConstruction.js
+++ b/toolkit/mozapps/update/tests/unit_aus_update/urlConstruction.js
@@ -244,17 +244,17 @@ function getServicePack() {
ctypes.default_abi,
BOOL,
OSVERSIONINFOEXW.ptr);
let winVer = OSVERSIONINFOEXW();
winVer.dwOSVersionInfoSize = OSVERSIONINFOEXW.size;
if (0 === GetVersionEx(winVer.address())) {
// Using "throw" instead of "do_throw" (see NOTE above)
- throw("Failure in GetVersionEx (returned 0)");
+ throw ("Failure in GetVersionEx (returned 0)");
}
return winVer.wServicePackMajor + "." + winVer.wServicePackMinor;
} finally {
kernel32.close();
}
}
@@ -289,26 +289,26 @@ function getProcArchitecture() {
ctypes.default_abi,
ctypes.void_t,
SYSTEM_INFO.ptr);
let sysInfo = SYSTEM_INFO();
// Default to unknown
sysInfo.wProcessorArchitecture = 0xffff;
GetNativeSystemInfo(sysInfo.address());
- switch(sysInfo.wProcessorArchitecture) {
+ switch (sysInfo.wProcessorArchitecture) {
case 9:
return "x64";
case 6:
return "IA64";
case 0:
return "x86";
default:
// Using "throw" instead of "do_throw" (see NOTE above)
- throw("Unknown architecture returned from GetNativeSystemInfo: " + sysInfo.wProcessorArchitecture);
+ throw ("Unknown architecture returned from GetNativeSystemInfo: " + sysInfo.wProcessorArchitecture);
}
} finally {
kernel32.close();
}
}
function check_test_pt9() {
let osVersion;
--- a/toolkit/obsolete/content/nsUserSettings.js
+++ b/toolkit/obsolete/content/nsUserSettings.js
@@ -15,94 +15,94 @@ var nsPreferences = {
},
setBoolPref: function (aPrefName, aPrefValue)
{
try
{
this.mPrefService.setBoolPref(aPrefName, aPrefValue);
}
- catch(e)
+ catch (e)
{
}
},
getBoolPref: function (aPrefName, aDefVal)
{
try
{
return this.mPrefService.getBoolPref(aPrefName);
}
- catch(e)
+ catch (e)
{
return aDefVal != undefined ? aDefVal : null;
}
return null; // quiet warnings
},
setUnicharPref: function (aPrefName, aPrefValue)
{
try
{
var str = Components.classes["@mozilla.org/supports-string;1"]
.createInstance(Components.interfaces.nsISupportsString);
str.data = aPrefValue;
this.mPrefService.setComplexValue(aPrefName,
Components.interfaces.nsISupportsString, str);
}
- catch(e)
+ catch (e)
{
}
},
copyUnicharPref: function (aPrefName, aDefVal)
{
try
{
return this.mPrefService.getComplexValue(aPrefName,
Components.interfaces.nsISupportsString).data;
}
- catch(e)
+ catch (e)
{
return aDefVal != undefined ? aDefVal : null;
}
return null; // quiet warnings
},
setIntPref: function (aPrefName, aPrefValue)
{
try
{
this.mPrefService.setIntPref(aPrefName, aPrefValue);
}
- catch(e)
+ catch (e)
{
}
},
getIntPref: function (aPrefName, aDefVal)
{
try
{
return this.mPrefService.getIntPref(aPrefName);
}
- catch(e)
+ catch (e)
{
return aDefVal != undefined ? aDefVal : null;
}
return null; // quiet warnings
},
getLocalizedUnicharPref: function (aPrefName, aDefVal)
{
try
{
return this.mPrefService.getComplexValue(aPrefName,
Components.interfaces.nsIPrefLocalizedString).data;
}
- catch(e)
+ catch (e)
{
return aDefVal != undefined ? aDefVal : null;
}
return null; // quiet warnings
}
};
--- a/toolkit/profile/content/createProfileWizard.js
+++ b/toolkit/profile/content/createProfileWizard.js
@@ -29,17 +29,17 @@ function initWizard()
var dirService = C["@mozilla.org/file/directory_service;1"].getService(I.nsIProperties);
gDefaultProfileParent = dirService.get("DefProfRt", I.nsIFile);
// Initialize the profile location display.
gProfileDisplay = document.getElementById("profileDisplay").firstChild;
setDisplayToDefaultFolder();
}
- catch(e) {
+ catch (e) {
window.close();
throw (e);
}
}
// Called every time the second wizard page is displayed.
function initSecondWizardPage()
{
--- a/toolkit/profile/content/profileSelection.js
+++ b/toolkit/profile/content/profileSelection.js
@@ -46,24 +46,24 @@ function startup()
try {
if (profile === gProfileService.selectedProfile) {
setTimeout(function(a) {
profilesElement.ensureElementIsVisible(a);
profilesElement.selectItem(a);
}, 0, listitem);
}
}
- catch(e) { }
+ catch (e) { }
}
var autoSelectLastProfile = document.getElementById("autoSelectLastProfile");
autoSelectLastProfile.checked = gProfileService.startWithLastProfile;
profilesElement.focus();
}
- catch(e) {
+ catch (e) {
window.close();
throw (e);
}
}
function acceptDialog()
{
var appName = gBrandBundle.getString("brandShortName");
@@ -127,33 +127,33 @@ function updateStartupPrefs()
/* Bug 257777 */
gProfileService.startOffline = document.getElementById("offlineState").checked;
}
// handle key event on listboxes
function onProfilesKey(aEvent)
{
- switch( aEvent.keyCode )
+ switch ( aEvent.keyCode )
{
case KeyEvent.DOM_VK_BACK_SPACE:
if (AppConstants.platform != "macosx")
break;
case KeyEvent.DOM_VK_DELETE:
ConfirmDelete();
break;
case KeyEvent.DOM_VK_F2:
RenameProfile();
break;
}
}
function onProfilesDblClick(aEvent)
{
- if(aEvent.target.localName == "listitem")
+ if (aEvent.target.localName == "listitem")
document.documentElement.acceptDialog();
}
// invoke the createProfile Wizard
function CreateProfileWizard()
{
window.openDialog('chrome://mozapps/content/profile/createProfileWizard.xul',
'', 'centerscreen,chrome,modal,titlebar', gProfileService);