Bug 1394556: Part 1 - Fix strict mode errors in JSM scripts. r?ehsan
MozReview-Commit-ID: 4LmJQql7Y2c
--- a/addon-sdk/source/test/fixtures/native-addon-test/dir/test.jsm
+++ b/addon-sdk/source/test/fixtures/native-addon-test/dir/test.jsm
@@ -1,6 +1,6 @@
/* 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/. */
this['EXPORTED_SYMBOLS'] = ['test'];
-test = 'this is a jsm';
+var test = 'this is a jsm';
--- a/browser/components/feeds/FeedWriter.js
+++ b/browser/components/feeds/FeedWriter.js
@@ -1,12 +1,13 @@
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
/* 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/. */
+"use strict";
const Cc = Components.classes;
const Ci = Components.interfaces;
const Cr = Components.results;
const Cu = Components.utils;
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
Cu.import("resource://gre/modules/Services.jsm");
@@ -73,16 +74,23 @@ function convertByteUnits(aBytes) {
return [aBytes, units[unitIndex]];
}
function FeedWriter() {
this._selectedApp = undefined;
this._selectedAppMenuItem = null;
this._subscribeCallback = null;
this._defaultHandlerMenuItem = null;
+
+
+ XPCOMUtils.defineLazyGetter(this, "_mm", () =>
+ this._window.QueryInterface(Ci.nsIInterfaceRequestor).
+ getInterface(Ci.nsIDocShell).
+ QueryInterface(Ci.nsIInterfaceRequestor).
+ getInterface(Ci.nsIContentFrameMessageManager));
}
FeedWriter.prototype = {
_getPropertyAsBag(container, property) {
return container.fields.getProperty(property).
QueryInterface(Ci.nsIPropertyBag2);
},
@@ -972,23 +980,14 @@ FeedWriter.prototype = {
subscribeCallback();
}
});
} else {
subscribeCallback();
}
},
- get _mm() {
- let mm = this._window.QueryInterface(Ci.nsIInterfaceRequestor).
- getInterface(Ci.nsIDocShell).
- QueryInterface(Ci.nsIInterfaceRequestor).
- getInterface(Ci.nsIContentFrameMessageManager);
- delete this._mm;
- return this._mm = mm;
- },
-
classID: FEEDWRITER_CID,
QueryInterface: XPCOMUtils.generateQI([Ci.nsIDOMEventListener, Ci.nsIObserver,
Ci.nsIDOMGlobalPropertyInitializer])
};
this.NSGetFactory = XPCOMUtils.generateNSGetFactory([FeedWriter]);
--- a/dom/media/webvtt/vtt.jsm
+++ b/dom/media/webvtt/vtt.jsm
@@ -1,11 +1,12 @@
/* 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/. */
+"use strict";
this.EXPORTED_SYMBOLS = ["WebVTT"];
/**
* Code below is vtt.js the JS WebVTT implementation.
* Current source code can be found at http://github.com/mozilla/vtt.js
*
* Code taken from commit b89bfd06cd788a68c67e03f44561afe833db0849
@@ -346,17 +347,16 @@ const { XPCOMUtils } = require("resource
// Create an element for this tag.
function createElement(type, annotation) {
var tagName = TAG_NAME[type];
if (!tagName) {
return null;
}
var element = window.document.createElement(tagName);
- element.localName = tagName;
var name = TAG_ANNOTATION[type];
if (name) {
element[name] = annotation ? annotation.trim() : "";
}
return element;
}
// https://w3c.github.io/webvtt/#webvtt-timestamp-object
--- a/services/common/kinto-http-client.js
+++ b/services/common/kinto-http-client.js
@@ -7,16 +7,17 @@
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+"use strict";
/*
* This file is generated from kinto-http.js - do not modify directly.
*/
const global = this;
this.EXPORTED_SYMBOLS = ["KintoHttpClient"];
@@ -2927,9 +2928,9 @@ function cleanUndefinedProperties(obj) {
if (typeof obj[key] !== "undefined") {
result[key] = obj[key];
}
}
return result;
}
},{}]},{},[1])(1)
-});
\ No newline at end of file
+});
--- a/services/common/kinto-offline-client.js
+++ b/services/common/kinto-offline-client.js
@@ -7,21 +7,24 @@
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+"use strict";
/*
* This file is generated from kinto.js - do not modify directly.
*/
+const global = this;
+
this.EXPORTED_SYMBOLS = ["Kinto"];
/*
* Version 9.0.2 - b025c7b
*/
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.Kinto = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
/*
@@ -2507,9 +2510,9 @@ function omitKeys(obj, keys = []) {
if (keys.indexOf(key) === -1) {
acc[key] = obj[key];
}
return acc;
}, {});
}
},{}]},{},[1])(1)
-});
\ No newline at end of file
+});
--- a/services/fxaccounts/FxAccountsWebChannel.jsm
+++ b/services/fxaccounts/FxAccountsWebChannel.jsm
@@ -1,11 +1,12 @@
/* 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/. */
+"use strict";
/**
* Firefox Accounts Web Channel.
*
* Uses the WebChannel component to receive messages
* about account state changes.
*/
@@ -535,17 +536,17 @@ this.FxAccountsWebChannelHelpers.prototy
};
var singleton;
// The entry-point for this module, which ensures only one of our channels is
// ever created - we require this because the WebChannel is global in scope
// (eg, it uses the observer service to tell interested parties of interesting
// things) and allowing multiple channels would cause such notifications to be
// sent multiple times.
-this.EnsureFxAccountsWebChannel = function() {
+this.EnsureFxAccountsWebChannel = () => {
let contentUri = Services.urlFormatter.formatURLPref("identity.fxaccounts.remote.webchannel.uri");
if (singleton && singleton._contentUri !== contentUri) {
singleton.tearDown();
singleton = null;
}
if (!singleton) {
try {
if (contentUri) {
--- a/services/sync/modules/stages/enginesync.js
+++ b/services/sync/modules/stages/enginesync.js
@@ -310,17 +310,21 @@ EngineSynchronizer.prototype = {
let engine = engineManager.get(engineName);
if (Svc.Prefs.get("engineStatusChanged." + engine.prefName, false)) {
this._log.trace("The " + engineName + " engine was enabled locally.");
toUndecline.add(engineName);
} else {
this._log.trace("The " + engineName + " engine was disabled remotely.");
// Don't automatically mark it as declined!
- engine.enabled = false;
+ try {
+ engine.enabled = false;
+ } catch (e) {
+ this._log.trace("Failed to disable engine " + engineName);
+ }
}
}
engineManager.decline(toDecline);
engineManager.undecline(toUndecline);
Svc.Prefs.resetBranch("engineStatusChanged.");
this.service._ignorePrefObserver = false;
--- a/testing/modules/ajv-4.1.1.js
+++ b/testing/modules/ajv-4.1.1.js
@@ -1,8 +1,11 @@
+"use strict";
+const global = this;
+
this.EXPORTED_SYMBOLS = ["Ajv"];
/*
* ajv 4.1.1: Another JSON Schema Validator
*
* https://github.com/epoberezkin/ajv
*
* The MIT License (MIT)
@@ -7642,9 +7645,9 @@ function Ajv(opts) {
var metaOpts = util.copy(self._opts);
for (var i=0; i<META_IGNORE_OPTIONS.length; i++)
delete metaOpts[META_IGNORE_OPTIONS[i]];
return metaOpts;
}
}
},{"./async":1,"./cache":2,"./compile":6,"./compile/formats":5,"./compile/resolve":7,"./compile/rules":8,"./compile/schema_obj":9,"./compile/util":10,"./compile/validation_error":11,"./keyword":35,"./refs/json-schema-draft-04.json":36,"./v5":38,"co":45,"json-stable-stringify":46}]},{},[])("ajv")
-});
\ No newline at end of file
+});
--- a/testing/specialpowers/content/SpecialPowersObserver.jsm
+++ b/testing/specialpowers/content/SpecialPowersObserver.jsm
@@ -1,11 +1,12 @@
/* 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/. */
+"use strict";
// Based on:
// https://bugzilla.mozilla.org/show_bug.cgi?id=549539
// https://bug549539.bugzilla.mozilla.org/attachment.cgi?id=429661
// https://developer.mozilla.org/en/XPCOM/XPCOM_changes_in_Gecko_1.9.3
// https://developer.mozilla.org/en/how_to_build_an_xpcom_component_in_javascript
/* import-globals-from SpecialPowersObserverAPI.js */
@@ -127,17 +128,17 @@ SpecialPowersObserver.prototype.init = f
this._loadFrameScript();
};
SpecialPowersObserver.prototype.uninit = function() {
var obs = Services.obs;
obs.removeObserver(this, "chrome-document-global-created");
obs.removeObserver(this, "http-on-modify-request");
- this._registerObservers._topics.forEach(function(element) {
+ this._registerObservers._topics.forEach((element) => {
obs.removeObserver(this._registerObservers, element);
});
this._removeProcessCrashObservers();
if (this._isFrameScriptLoaded) {
this._messageManager.removeMessageListener("SPPrefService", this);
this._messageManager.removeMessageListener("SPProcessCrashService", this);
this._messageManager.removeMessageListener("SPPingService", this);
@@ -249,17 +250,17 @@ SpecialPowersObserver.prototype.receiveM
let filePaths = [];
if (!this._createdFiles) {
this._createdFiles = [];
}
let createdFiles = this._createdFiles;
try {
let promises = [];
aMessage.data.forEach(function(request) {
- const filePerms = 0666; // eslint-disable-line no-octal
+ const filePerms = 0o666; // eslint-disable-line no-octal
let testFile = Services.dirsvc.get("ProfD", Ci.nsIFile);
if (request.name) {
testFile.appendRelativePath(request.name);
} else {
testFile.createUnique(Ci.nsIFile.NORMAL_FILE_TYPE, filePerms);
}
let outStream = Cc["@mozilla.org/network/file-output-stream;1"].createInstance(Ci.nsIFileOutputStream);
outStream.init(testFile, 0x02 | 0x08 | 0x20, // PR_WRONLY | PR_CREATE_FILE | PR_TRUNCATE
--- a/toolkit/components/satchel/FormHistory.jsm
+++ b/toolkit/components/satchel/FormHistory.jsm
@@ -1,11 +1,12 @@
/* 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/. */
+"use strict";
/**
* FormHistory
*
* Used to store values that have been entered into forms which may later
* be used to automatically fill in the values when the form is visited again.
*
* search(terms, queryData, callback)
@@ -436,16 +437,18 @@ function dbCreateAsyncStatement(aQuery,
for (let field in aParams) {
stmt.params[field] = aParams[field];
}
}
return stmt;
}
+var dbMigrate;
+
/**
* Attempts to initialize the database. This creates the file if it doesn't
* exist, performs any migrations, etc.
*/
function dbInit() {
log("Initializing Database");
if (!_dbConnection.tableExists("moz_formhistory")) {
@@ -493,17 +496,17 @@ function dbCreate() {
let statement = "CREATE INDEX IF NOT EXISTS " + name + " ON " + index.table +
"(" + index.columns.join(", ") + ")";
_dbConnection.executeSimpleSQL(statement);
}
_dbConnection.schemaVersion = DB_SCHEMA_VERSION;
}
-function dbMigrate(oldVersion) {
+dbMigrate = (oldVersion) => {
log("Attempting to migrate from version " + oldVersion);
if (oldVersion > DB_SCHEMA_VERSION) {
log("Downgrading to version " + DB_SCHEMA_VERSION);
// User's DB is newer. Sanity check that our expected columns are
// present, and if so mark the lower version and merrily continue
// on. If the columns are borked, something is wrong so blow away
// the DB and start from scratch. [Future incompatible upgrades
@@ -534,17 +537,17 @@ function dbMigrate(oldVersion) {
this.dbConnection.rollbackTransaction();
throw e;
}
_dbConnection.schemaVersion = DB_SCHEMA_VERSION;
_dbConnection.commitTransaction();
log("DB migration completed.");
-}
+};
/**
* Sanity check to ensure that the columns this version of the code expects
* are present in the DB we're using.
* @returns {boolean} whether expected columns are present
*/
function dbAreExpectedColumnsPresent() {
for (let name in dbSchema.tables) {