Bug 1133277 - Remove nonstandard let blocks from toolkit/components and modules. r=mak

This commit is contained in:
Chris Peterson 2015-02-05 22:53:14 -08:00
Родитель bd1efc3d27
Коммит aa9e11586f
21 изменённых файлов: 261 добавлений и 269 удалений

Просмотреть файл

@ -65,13 +65,12 @@ let DownloadListener = {
cstream.init(fis, "UTF-8", 0, 0);
let val = "";
let (str = {}) {
let str = {};
let read = 0;
do {
read = cstream.readString(0xffffffff, str);
val += str.value;
} while (read != 0);
}
cstream.close();
// check if the file contents match the expected ones

Просмотреть файл

@ -10,7 +10,8 @@ const Cu = Components.utils;
Cu.import("resource://gre/modules/Services.jsm");
// Import common head.
let (commonFile = do_get_file("../head_common.js", false)) {
{
let commonFile = do_get_file("../head_common.js", false);
let uri = Services.io.newFileURI(commonFile);
Services.scriptloader.loadSubScript(uri.spec, this);
}

Просмотреть файл

@ -11,7 +11,8 @@ const Cu = Components.utils;
Cu.import("resource://gre/modules/Services.jsm");
// Import common head.
let (commonFile = do_get_file("../head_common.js", false)) {
{
let commonFile = do_get_file("../head_common.js", false);
let uri = Services.io.newFileURI(commonFile);
Services.scriptloader.loadSubScript(uri.spec, this);
}

Просмотреть файл

@ -12,7 +12,8 @@ const Cu = Components.utils;
Cu.import("resource://gre/modules/Services.jsm");
// Import common head.
let (commonFile = do_get_file("../head_common.js", false)) {
{
let commonFile = do_get_file("../head_common.js", false);
let uri = Services.io.newFileURI(commonFile);
Services.scriptloader.loadSubScript(uri.spec, this);
}

Просмотреть файл

@ -11,7 +11,8 @@ const Cu = Components.utils;
Cu.import("resource://gre/modules/Services.jsm");
// Import common head.
let (commonFile = do_get_file("../head_common.js", false)) {
{
let commonFile = do_get_file("../head_common.js", false);
let uri = Services.io.newFileURI(commonFile);
Services.scriptloader.loadSubScript(uri.spec, this);
}

Просмотреть файл

@ -58,38 +58,36 @@ function run_test()
getService(Ci.nsIIOService);
// Test that the default icon has the content type of image/png.
let (channel = ios.newChannelFromURI2(fs.defaultFavicon,
let channel = ios.newChannelFromURI2(fs.defaultFavicon,
null, // aLoadingNode
Services.scriptSecurityManager.getSystemPrincipal(),
null, // aTriggeringPrincipal
Ci.nsILoadInfo.SEC_NORMAL,
Ci.nsIContentPolicy.TYPE_IMAGE)) {
Ci.nsIContentPolicy.TYPE_IMAGE);
channel.asyncOpen(new streamListener("image/png"), null);
do_test_pending();
}
// Test URI that we don't know anything about. Will end up being the default
// icon, so expect image/png.
let (channel = ios.newChannel2(moz_anno_favicon_prefix + "http://mozilla.org",
null,
null,
null, // aLoadingNode
Services.scriptSecurityManager.getSystemPrincipal(),
null, // aTriggeringPrincipal
Ci.nsILoadInfo.SEC_NORMAL,
Ci.nsIContentPolicy.TYPE_IMAGE)) {
channel.asyncOpen(new streamListener("image/png"), null);
do_test_pending();
}
// Test that the content type of a favicon we add ends up being image/png.
let (testURI = uri("http://mozilla.org/")) {
// Add the data before opening
fs.replaceFaviconDataFromDataURL(testURI, testFaviconData,
(Date.now() + 60 * 60 * 24 * 1000) * 1000);
// Open the channel
let channel = ios.newChannel2(moz_anno_favicon_prefix + testURI.spec,
channel = ios.newChannel2(moz_anno_favicon_prefix + "http://mozilla.org",
null,
null,
null, // aLoadingNode
Services.scriptSecurityManager.getSystemPrincipal(),
null, // aTriggeringPrincipal
Ci.nsILoadInfo.SEC_NORMAL,
Ci.nsIContentPolicy.TYPE_IMAGE);
channel.asyncOpen(new streamListener("image/png"), null);
do_test_pending();
// Test that the content type of a favicon we add ends up being image/png.
let testURI = uri("http://mozilla.org/");
// Add the data before opening
fs.replaceFaviconDataFromDataURL(testURI, testFaviconData,
(Date.now() + 60 * 60 * 24 * 1000) * 1000);
// Open the channel
channel = ios.newChannel2(moz_anno_favicon_prefix + testURI.spec,
null,
null,
null, // aLoadingNode
@ -99,5 +97,4 @@ function run_test()
Ci.nsIContentPolicy.TYPE_IMAGE);
channel.asyncOpen(new streamListener("image/png"), null);
do_test_pending();
}
}

Просмотреть файл

@ -12,8 +12,8 @@ const Cu = Components.utils;
Cu.import("resource://gre/modules/Services.jsm");
// Import common head.
let (commonFile = do_get_file("../head_common.js", false)) {
{
let commonFile = do_get_file("../head_common.js", false);
let uri = Services.io.newFileURI(commonFile);
Services.scriptloader.loadSubScript(uri.spec, this);
};
}

Просмотреть файл

@ -10,7 +10,8 @@ const Cu = Components.utils;
Cu.import("resource://gre/modules/Services.jsm");
// Import common head.
let (commonFile = do_get_file("../head_common.js", false)) {
{
let commonFile = do_get_file("../head_common.js", false);
let uri = Services.io.newFileURI(commonFile);
Services.scriptloader.loadSubScript(uri.spec, this);
}

Просмотреть файл

@ -8,7 +8,8 @@ const { classes: Cc, interfaces: Ci, results: Cr, utils: Cu } = Components;
Cu.import("resource://gre/modules/Services.jsm");
// Import common head.
let (commonFile = do_get_file("../head_common.js", false)) {
{
let commonFile = do_get_file("../head_common.js", false);
let uri = Services.io.newFileURI(commonFile);
Services.scriptloader.loadSubScript(uri.spec, this);
}

Просмотреть файл

@ -12,7 +12,8 @@ Cu.import("resource://testing-common/httpd.js");
Cu.import("resource://gre/modules/Services.jsm");
// Import common head.
let (commonFile = do_get_file("../head_common.js", false)) {
{
let commonFile = do_get_file("../head_common.js", false);
let uri = Services.io.newFileURI(commonFile);
Services.scriptloader.loadSubScript(uri.spec, this);
}

Просмотреть файл

@ -12,7 +12,8 @@ const Cu = Components.utils;
Cu.import("resource://gre/modules/Services.jsm");
// Import common head.
let (commonFile = do_get_file("../head_common.js", false)) {
{
let commonFile = do_get_file("../head_common.js", false);
let uri = Services.io.newFileURI(commonFile);
Services.scriptloader.loadSubScript(uri.spec, this);
}

Просмотреть файл

@ -186,7 +186,8 @@ Test.prototype = {
openContainer: function () {
// Set up the result observer. It delegates to this object's callbacks and
// wraps them in a try-catch so that errors don't get eaten.
this.observer = let (self = this) {
let self = this;
this.observer = {
containerStateChanged: function (container, oldState, newState) {
print("New state passed to containerStateChanged() should equal the " +
"container's current state");
@ -230,7 +231,7 @@ Test.prototype = {
* This must be called before run(). It adds a bookmark and sets up the
* test's result. Override if need be.
*/
setup: function () {
setup: function*() {
// Populate the database with different types of bookmark items.
this.data = DataHelper.makeDataArray([
{ type: "bookmark" },
@ -290,7 +291,8 @@ let DataHelper = {
* @return An array of objects suitable for passing to populateDB().
*/
makeDataArray: function DH_makeDataArray(aData) {
return let (self = this) aData.map(function (dat) {
let self = this;
return aData.map(function (dat) {
let type = dat.type;
dat = self._makeDataWithDefaults(dat, self.defaults[type]);
switch (type) {
@ -348,7 +350,7 @@ function run_test()
run_next_test();
}
add_task(function test_async()
add_task(function* test_async()
{
for (let [, test] in Iterator(tests)) {
remove_all_bookmarks();

Просмотреть файл

@ -10,7 +10,8 @@ const Cu = Components.utils;
Cu.import("resource://gre/modules/Services.jsm");
// Import common head.
let (commonFile = do_get_file("../head_common.js", false)) {
{
let commonFile = do_get_file("../head_common.js", false);
let uri = Services.io.newFileURI(commonFile);
Services.scriptloader.loadSubScript(uri.spec, this);
}

Просмотреть файл

@ -11,7 +11,8 @@ const Cu = Components.utils;
Cu.import("resource://gre/modules/Services.jsm");
// Import common head.
let (commonFile = do_get_file("../head_common.js", false)) {
{
let commonFile = do_get_file("../head_common.js", false);
let uri = Services.io.newFileURI(commonFile);
Services.scriptloader.loadSubScript(uri.spec, this);
}

Просмотреть файл

@ -311,17 +311,16 @@ function* checkItem(aExpected, aNode)
do_check_eq(aNode.uri, aExpected.url)
break;
case "icon":
let (deferred = Promise.defer(), data) {
let deferred = Promise.defer();
PlacesUtils.favicons.getFaviconDataForPage(
NetUtil.newURI(aExpected.url),
function (aURI, aDataLen, aData, aMimeType) {
deferred.resolve(aData);
});
data = yield deferred.promise;
let data = yield deferred.promise;
let base64Icon = "data:image/png;base64," +
base64EncodeString(String.fromCharCode.apply(String, data));
do_check_true(base64Icon == aExpected.icon);
}
break;
case "keyword":
break;

Просмотреть файл

@ -171,17 +171,16 @@ function checkItem(aExpected, aNode) {
do_check_eq(aNode.uri, aExpected.url);
break;
case "icon":
let (deferred = Promise.defer(), data) {
let deferred = Promise.defer();
PlacesUtils.favicons.getFaviconDataForPage(
NetUtil.newURI(aExpected.url),
function (aURI, aDataLen, aData, aMimeType) {
deferred.resolve(aData);
});
data = yield deferred.promise;
let data = yield deferred.promise;
let base64Icon = "data:image/png;base64," +
base64EncodeString(String.fromCharCode.apply(String, data));
do_check_true(base64Icon == aExpected.icon);
}
break;
case "keyword":
break;

Просмотреть файл

@ -6,14 +6,13 @@
function run_test() {
// Ensure that our database doesn't already exist.
let (dbFile = gProfD.clone()) {
let dbFile = gProfD.clone();
dbFile.append("places.sqlite");
do_check_false(dbFile.exists());
}
let (dbFile = gProfD.clone()) {
dbFile = gProfD.clone();
dbFile.append("places.sqlite.corrupt");
do_check_false(dbFile.exists());
}
let file = do_get_file("default.sqlite");
file.copyToFollowingLinks(gProfD, "places.sqlite");
@ -29,20 +28,19 @@ function run_test() {
do_check_eq(PlacesUtils.history.databaseStatus,
PlacesUtils.history.DATABASE_STATUS_CORRUPT);
let (dbFile = gProfD.clone()) {
dbFile = gProfD.clone();
dbFile.append("places.sqlite");
do_check_true(dbFile.exists());
// Check the new database is really a new one.
let db = Services.storage.openUnsharedDatabase(file);
db = Services.storage.openUnsharedDatabase(file);
try {
db.executeSimpleSQL("DELETE * FROM test");
do_throw("The new database should not have our unique content");
} catch(ex) {}
db.close();
}
let (dbFile = gProfD.clone()) {
dbFile = gProfD.clone();
dbFile.append("places.sqlite.corrupt");
do_check_true(dbFile.exists());
}
};
}

Просмотреть файл

@ -28,7 +28,7 @@ function ensurePlacesInfoObjectsAreEqual(a, b) {
do_check_eq(a.placeId, b.placeId);
}
function test_getPlacesInfoExistentPlace() {
function* test_getPlacesInfoExistentPlace() {
let testURI = NetUtil.newURI("http://www.example.tld");
yield PlacesTestUtils.addVisits(testURI);
@ -46,7 +46,7 @@ function test_getPlacesInfoExistentPlace() {
}
add_task(test_getPlacesInfoExistentPlace);
function test_getPlacesInfoNonExistentPlace() {
function* test_getPlacesInfoNonExistentPlace() {
let testURI = NetUtil.newURI("http://www.example_non_existent.tld");
let getPlacesInfoResult = yield promiseGetPlacesInfo(testURI);
do_check_eq(getPlacesInfoResult.results.length, 0);
@ -54,24 +54,22 @@ function test_getPlacesInfoNonExistentPlace() {
}
add_task(test_getPlacesInfoNonExistentPlace);
function test_promisedHelper() {
let (uri = NetUtil.newURI("http://www.helper_existent_example.tld")) {
function* test_promisedHelper() {
let uri = NetUtil.newURI("http://www.helper_existent_example.tld");
yield PlacesTestUtils.addVisits(uri);
let placeInfo = yield PlacesUtils.promisePlaceInfo(uri);
do_check_true(placeInfo instanceof Ci.mozIPlaceInfo);
};
let (uri = NetUtil.newURI("http://www.helper_non_existent_example.tld")) {
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) { }
};
}
add_task(test_promisedHelper);
function test_infoByGUID() {
function* test_infoByGUID() {
let testURI = NetUtil.newURI("http://www.guid_example.tld");
yield PlacesTestUtils.addVisits(testURI);
@ -81,7 +79,7 @@ function test_infoByGUID() {
}
add_task(test_infoByGUID);
function test_invalid_guid() {
function* test_invalid_guid() {
try {
let placeInfoByGUID = yield PlacesUtils.promisePlaceInfo("###");
do_throw("getPlacesInfo should fail for invalid guids")
@ -90,17 +88,15 @@ function test_invalid_guid() {
}
add_task(test_invalid_guid);
function test_mixed_selection() {
function* test_mixed_selection() {
let placeInfo1, placeInfo2;
let (uri = NetUtil.newURI("http://www.mixed_selection_test_1.tld")) {
let uri = NetUtil.newURI("http://www.mixed_selection_test_1.tld");
yield PlacesTestUtils.addVisits(uri);
placeInfo1 = yield PlacesUtils.promisePlaceInfo(uri);
};
let (uri = NetUtil.newURI("http://www.mixed_selection_test_2.tld")) {
uri = NetUtil.newURI("http://www.mixed_selection_test_2.tld");
yield PlacesTestUtils.addVisits(uri);
placeInfo2 = yield PlacesUtils.promisePlaceInfo(uri);
};
let getPlacesInfoResult = yield promiseGetPlacesInfo([placeInfo1.uri, placeInfo2.guid]);
do_check_eq(getPlacesInfoResult.results.length, 2);

Просмотреть файл

@ -117,7 +117,8 @@ function run_test() {
do_check_true(uri4Tags.indexOf("456") != -1);
// Test sparse arrays.
let (curChildCount = tagRoot.childCount) {
let curChildCount = tagRoot.childCount;
try {
tagssvc.tagURI(uri1, [, "tagSparse"]);
do_check_eq(tagRoot.childCount, curChildCount + 1);
@ -172,8 +173,6 @@ function run_test() {
do_check_eq(ex.name, "NS_ERROR_ILLEGAL_VALUE");
}
}
// cleanup
tagRoot.containerOpen = false;
}

Просмотреть файл

@ -189,7 +189,7 @@ function test_set_property_lazy_getter() {
});
};
let (dict = new Dict()) {
let dict = new Dict();
setThunk(dict);
// Test that checking for the key existence does not invoke
@ -209,33 +209,29 @@ function test_set_property_lazy_getter() {
do_check_eq(dict.get("foo"), "bar");
do_check_false(thunkCalled);
do_check_false(dict.isLazyGetter("foo"));
}
// Test that listvalues works for lazy keys.
let (dict = new Dict()) {
dict = new Dict();
setThunk(dict);
do_check_true(dict.isLazyGetter("foo"));
let (listvalues = dict.listvalues()) {
let listvalues = dict.listvalues();
do_check_false(dict.isLazyGetter("foo"));
do_check_true(thunkCalled);
do_check_true(listvalues.length, 1);
do_check_eq(listvalues[0], "bar");
}
thunkCalled = false;
// Retrieving the list again shouldn't invoke our getter.
let (listvalues = dict.listvalues()) {
listvalues = dict.listvalues();
do_check_false(dict.isLazyGetter("foo"));
do_check_false(thunkCalled);
do_check_true(listvalues.length, 1);
do_check_eq(listvalues[0], "bar");
}
}
// Test that the values iterator also works as expected.
let (dict = new Dict()) {
dict = new Dict();
setThunk(dict);
let values = dict.values;
@ -249,7 +245,6 @@ function test_set_property_lazy_getter() {
do_check_false(dict.isLazyGetter("foo"));
do_check_eq(dict.get("foo"), "bar");
do_check_false(thunkCalled);
}
}
// This is used by both test_construct_dict_from_json_string and test_serialize_dict_to_json_string

Просмотреть файл

@ -36,7 +36,7 @@ function checkMainPropertyList(aPropertyListRoot) {
checkValue(aPropertyListRoot, PropertyListUtils.TYPE_DICTIONARY);
checkValue(aPropertyListRoot.get("Boolean"), PRIMITIVE, false);
let (array = aPropertyListRoot.get("Array")) {
let array = aPropertyListRoot.get("Array");
checkValue(array, PropertyListUtils.TYPE_ARRAY);
do_check_eq(array.length, 8);
@ -65,7 +65,7 @@ function checkMainPropertyList(aPropertyListRoot) {
do_check_eq(dataAsString, "2011-12-31T11:15:33Z");
// Dict
let (dict = array[7]) {
let dict = array[7];
checkValue(dict, PropertyListUtils.TYPE_DICTIONARY);
checkValue(dict.get("Negative Number"), PRIMITIVE, -400);
checkValue(dict.get("Real Number"), PRIMITIVE, 2.71828183);
@ -75,8 +75,6 @@ function checkMainPropertyList(aPropertyListRoot) {
checkValue(dict.get("Negative Big Int"),
PropertyListUtils.TYPE_INT64,
"-9007199254740993");
}
}
}
function readPropertyList(aFile, aCallback) {