Skip to content

Commit

Permalink
Bug 1394556: Part 1 - Fix strict mode errors in JSM scripts. r=Mossop
Browse files Browse the repository at this point in the history
MozReview-Commit-ID: 4LmJQql7Y2c
  • Loading branch information
kmaglione committed Aug 30, 2017
1 parent db8baa8 commit fced399
Show file tree
Hide file tree
Showing 14 changed files with 51 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
* 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';
17 changes: 8 additions & 9 deletions browser/components/feeds/FeedWriter.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
/* 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;
Expand Down Expand Up @@ -78,6 +79,13 @@ function FeedWriter() {
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 = {
Expand Down Expand Up @@ -977,15 +985,6 @@ FeedWriter.prototype = {
}
},

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])
Expand Down
2 changes: 1 addition & 1 deletion dom/media/webvtt/vtt.jsm
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/* 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"];

Expand Down Expand Up @@ -351,7 +352,6 @@ const { XPCOMUtils } = require("resource://gre/modules/XPCOMUtils.jsm");
return null;
}
var element = window.document.createElement(tagName);
element.localName = tagName;
var name = TAG_ANNOTATION[type];
if (name) {
element[name] = annotation ? annotation.trim() : "";
Expand Down
9 changes: 5 additions & 4 deletions layout/tools/reftest/reftest.jsm
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
/* 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 = ["OnRefTestLoad", "OnRefTestUnload"];

Expand Down Expand Up @@ -852,9 +853,9 @@ function AddTestItem(aTest, aFilter)
if (!aFilter)
aFilter = [null, [], false];

globalFilter = aFilter[0];
manifestFilter = aFilter[1];
invertManifest = aFilter[2];
var globalFilter = aFilter[0];
var manifestFilter = aFilter[1];
var invertManifest = aFilter[2];
if ((globalFilter && !globalFilter.test(aTest.url1.spec)) ||
(manifestFilter &&
!(invertManifest ^ manifestFilter.test(aTest.url1.spec))))
Expand Down Expand Up @@ -1495,7 +1496,7 @@ function StartCurrentURI(aState)

function DoneTests()
{
logger.suiteEnd(extra={'results': gTestResults});
logger.suiteEnd({'results': gTestResults});
logger.info("Slowest test took " + gSlowestTestTime + "ms (" + gSlowestTestURL + ")");
logger.info("Total canvas count = " + gRecycledCanvases.length);
if (gFailedUseWidgetLayers) {
Expand Down
3 changes: 2 additions & 1 deletion mobile/android/modules/FxAccountsWebChannel.jsm
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
/* 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.
Expand Down Expand Up @@ -379,7 +380,7 @@ var singleton;
// ever created - we require this because the WebChannel is global in scope and
// allowing multiple channels would cause such notifications to be sent multiple
// times.
this.EnsureFxAccountsWebChannel = function() {
this.EnsureFxAccountsWebChannel = () => {
if (!singleton) {
let contentUri = Services.urlFormatter.formatURLPref("identity.fxaccounts.remote.webchannel.uri");
// The FxAccountsWebChannel listens for events and updates the Java layer.
Expand Down
3 changes: 2 additions & 1 deletion services/common/kinto-http-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
* 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.
Expand Down Expand Up @@ -2932,4 +2933,4 @@ function cleanUndefinedProperties(obj) {
}

},{}]},{},[1])(1)
});
});
5 changes: 4 additions & 1 deletion services/common/kinto-offline-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,14 @@
* 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"];

/*
Expand Down Expand Up @@ -2512,4 +2515,4 @@ function omitKeys(obj, keys = []) {
}

},{}]},{},[1])(1)
});
});
3 changes: 2 additions & 1 deletion services/fxaccounts/FxAccountsWebChannel.jsm
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/* 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.
Expand Down Expand Up @@ -540,7 +541,7 @@ var singleton;
// (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();
Expand Down
6 changes: 5 additions & 1 deletion services/sync/modules/stages/enginesync.js
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,11 @@ EngineSynchronizer.prototype = {
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);
}
}
}

Expand Down
5 changes: 4 additions & 1 deletion testing/modules/ajv-4.1.1.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
"use strict";
const global = this;

this.EXPORTED_SYMBOLS = ["Ajv"];

/*
Expand Down Expand Up @@ -7647,4 +7650,4 @@ function Ajv(opts) {
}

},{"./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")
});
});
5 changes: 3 additions & 2 deletions testing/specialpowers/content/SpecialPowersObserver.jsm
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/* 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
Expand Down Expand Up @@ -132,7 +133,7 @@ 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();
Expand Down Expand Up @@ -254,7 +255,7 @@ SpecialPowersObserver.prototype.receiveMessage = function(aMessage) {
try {
let promises = [];
aMessage.data.forEach(function(request) {
const filePerms = 0666; // eslint-disable-line no-octal
const filePerms = 0o666;
let testFile = Services.dirsvc.get("ProfD", Ci.nsIFile);
if (request.name) {
testFile.appendRelativePath(request.name);
Expand Down
7 changes: 5 additions & 2 deletions toolkit/components/satchel/FormHistory.jsm
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/* 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
Expand Down Expand Up @@ -441,6 +442,8 @@ function dbCreateAsyncStatement(aQuery, aParams, aBindingArrays) {
return stmt;
}

var dbMigrate;

/**
* Attempts to initialize the database. This creates the file if it doesn't
* exist, performs any migrations, etc.
Expand Down Expand Up @@ -498,7 +501,7 @@ function dbCreate() {
_dbConnection.schemaVersion = DB_SCHEMA_VERSION;
}

function dbMigrate(oldVersion) {
dbMigrate = (oldVersion) => {
log("Attempting to migrate from version " + oldVersion);

if (oldVersion > DB_SCHEMA_VERSION) {
Expand Down Expand Up @@ -539,7 +542,7 @@ function dbMigrate(oldVersion) {
_dbConnection.commitTransaction();

log("DB migration completed.");
}
};

/**
* Sanity check to ensure that the columns this version of the code expects
Expand Down
8 changes: 6 additions & 2 deletions toolkit/components/search/nsSearchService.js
Original file line number Diff line number Diff line change
Expand Up @@ -2341,8 +2341,12 @@ Engine.prototype = {
type = "application/x-moz-phonesearch";
}

delete this._defaultMobileResponseType;
return this._defaultMobileResponseType = type;
Object.defineProperty(this, "_defaultMobileResponseType", {
value: type,
configurable: true,
});

return type;
},

get _isWhiteListed() {
Expand Down
6 changes: 3 additions & 3 deletions toolkit/modules/debug.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

this.EXPORTED_SYMBOLS = ["NS_ASSERT"];

var gTraceOnAssert = true;
var gTraceOnAssert = false;

/**
* This function provides a simple assertion function for JavaScript.
Expand Down Expand Up @@ -47,8 +47,6 @@ this.NS_ASSERT = function NS_ASSERT(condition, message) {
}
} catch (ex) {}

// eslint-disable-next-line no-caller
var caller = arguments.callee.caller;
var assertionText = "ASSERT: " + message + "\n";

// Report the error to the console
Expand All @@ -63,6 +61,8 @@ this.NS_ASSERT = function NS_ASSERT(condition, message) {
if (gTraceOnAssert) {
stackText = "Stack Trace: \n";
var count = 0;
// eslint-disable-next-line no-caller
var caller = arguments.callee.caller;
while (caller) {
stackText += count++ + ":" + caller.name + "(";
for (var i = 0; i < caller.arguments.length; ++i) {
Expand Down

0 comments on commit fced399

Please sign in to comment.