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 удалений

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

@ -57,21 +57,20 @@ let DownloadListener = {
do_check_neq(file.leafName, prevFile.leafName);
}
this.prevFiles.push(file);
// get the contents of the file
let fis = Cc["@mozilla.org/network/file-input-stream;1"].createInstance(Ci.nsIFileInputStream);
fis.init(file, -1, -1, 0);
var cstream = Cc["@mozilla.org/intl/converter-input-stream;1"].createInstance(Ci.nsIConverterInputStream);
cstream.init(fis, "UTF-8", 0, 0);
let val = "";
let (str = {}) {
let read = 0;
do {
read = cstream.readString(0xffffffff, str);
val += str.value;
} while (read != 0);
}
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,46 +58,43 @@ 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)) {
channel.asyncOpen(new streamListener("image/png"), null);
do_test_pending();
}
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();
}
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);
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,
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();
}
// Open the channel
channel = ios.newChannel2(moz_anno_favicon_prefix + testURI.spec,
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();
}

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

@ -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) {
PlacesUtils.favicons.getFaviconDataForPage(
NetUtil.newURI(aExpected.url),
function (aURI, aDataLen, aData, aMimeType) {
deferred.resolve(aData);
});
data = yield deferred.promise;
let base64Icon = "data:image/png;base64," +
base64EncodeString(String.fromCharCode.apply(String, data));
do_check_true(base64Icon == aExpected.icon);
}
let deferred = Promise.defer();
PlacesUtils.favicons.getFaviconDataForPage(
NetUtil.newURI(aExpected.url),
function (aURI, aDataLen, aData, aMimeType) {
deferred.resolve(aData);
});
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) {
PlacesUtils.favicons.getFaviconDataForPage(
NetUtil.newURI(aExpected.url),
function (aURI, aDataLen, aData, aMimeType) {
deferred.resolve(aData);
});
data = yield deferred.promise;
let base64Icon = "data:image/png;base64," +
base64EncodeString(String.fromCharCode.apply(String, data));
do_check_true(base64Icon == aExpected.icon);
}
let deferred = Promise.defer();
PlacesUtils.favicons.getFaviconDataForPage(
NetUtil.newURI(aExpected.url),
function (aURI, aDataLen, aData, aMimeType) {
deferred.resolve(aData);
});
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()) {
dbFile.append("places.sqlite");
do_check_false(dbFile.exists());
}
let (dbFile = gProfD.clone()) {
dbFile.append("places.sqlite.corrupt");
do_check_false(dbFile.exists());
}
let dbFile = gProfD.clone();
dbFile.append("places.sqlite");
do_check_false(dbFile.exists());
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.append("places.sqlite");
do_check_true(dbFile.exists());
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);
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.append("places.sqlite.corrupt");
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) {}
db.close();
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")) {
yield PlacesTestUtils.addVisits(uri);
let placeInfo = yield PlacesUtils.promisePlaceInfo(uri);
do_check_true(placeInfo instanceof Ci.mozIPlaceInfo);
};
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")) {
try {
let placeInfo = yield PlacesUtils.promisePlaceInfo(uri);
do_throw("PlacesUtils.promisePlaceInfo should have rejected the promise");
}
catch(ex) { }
};
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")) {
yield PlacesTestUtils.addVisits(uri);
placeInfo1 = yield PlacesUtils.promisePlaceInfo(uri);
};
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")) {
yield PlacesTestUtils.addVisits(uri);
placeInfo2 = yield PlacesUtils.promisePlaceInfo(uri);
};
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,61 +117,60 @@ function run_test() {
do_check_true(uri4Tags.indexOf("456") != -1);
// Test sparse arrays.
let (curChildCount = tagRoot.childCount) {
try {
tagssvc.tagURI(uri1, [, "tagSparse"]);
do_check_eq(tagRoot.childCount, curChildCount + 1);
} catch (ex) {
do_throw("Passing a sparse array should not throw");
}
try {
tagssvc.untagURI(uri1, [, "tagSparse"]);
do_check_eq(tagRoot.childCount, curChildCount);
} catch (ex) {
do_throw("Passing a sparse array should not throw");
}
let curChildCount = tagRoot.childCount;
// Test that the API throws for bad arguments.
try {
tagssvc.tagURI(uri1, ["", "test"]);
do_throw("Passing a bad tags array should throw");
} catch (ex) {
do_check_eq(ex.name, "NS_ERROR_ILLEGAL_VALUE");
}
try {
tagssvc.untagURI(uri1, ["", "test"]);
do_throw("Passing a bad tags array should throw");
} catch (ex) {
do_check_eq(ex.name, "NS_ERROR_ILLEGAL_VALUE");
}
try {
tagssvc.tagURI(uri1, [0, "test"]);
do_throw("Passing a bad tags array should throw");
} catch (ex) {
do_check_eq(ex.name, "NS_ERROR_ILLEGAL_VALUE");
}
try {
tagssvc.tagURI(uri1, [0, "test"]);
do_throw("Passing a bad tags array should throw");
} catch (ex) {
do_check_eq(ex.name, "NS_ERROR_ILLEGAL_VALUE");
}
// Tag name length should be limited to nsITaggingService.MAX_TAG_LENGTH (bug407821)
try {
// generate a long tag name. i.e. looooo...oong_tag
var n = Ci.nsITaggingService.MAX_TAG_LENGTH;
var someOos = new Array(n).join('o');
var longTagName = "l" + someOos + "ng_tag";
tagssvc.tagURI(uri1, ["short_tag", longTagName]);
do_throw("Passing a bad tags array should throw");
} catch (ex) {
do_check_eq(ex.name, "NS_ERROR_ILLEGAL_VALUE");
}
try {
tagssvc.tagURI(uri1, [, "tagSparse"]);
do_check_eq(tagRoot.childCount, curChildCount + 1);
} catch (ex) {
do_throw("Passing a sparse array should not throw");
}
try {
tagssvc.untagURI(uri1, [, "tagSparse"]);
do_check_eq(tagRoot.childCount, curChildCount);
} catch (ex) {
do_throw("Passing a sparse array should not throw");
}
// Test that the API throws for bad arguments.
try {
tagssvc.tagURI(uri1, ["", "test"]);
do_throw("Passing a bad tags array should throw");
} catch (ex) {
do_check_eq(ex.name, "NS_ERROR_ILLEGAL_VALUE");
}
try {
tagssvc.untagURI(uri1, ["", "test"]);
do_throw("Passing a bad tags array should throw");
} catch (ex) {
do_check_eq(ex.name, "NS_ERROR_ILLEGAL_VALUE");
}
try {
tagssvc.tagURI(uri1, [0, "test"]);
do_throw("Passing a bad tags array should throw");
} catch (ex) {
do_check_eq(ex.name, "NS_ERROR_ILLEGAL_VALUE");
}
try {
tagssvc.tagURI(uri1, [0, "test"]);
do_throw("Passing a bad tags array should throw");
} catch (ex) {
do_check_eq(ex.name, "NS_ERROR_ILLEGAL_VALUE");
}
// Tag name length should be limited to nsITaggingService.MAX_TAG_LENGTH (bug407821)
try {
// generate a long tag name. i.e. looooo...oong_tag
var n = Ci.nsITaggingService.MAX_TAG_LENGTH;
var someOos = new Array(n).join('o');
var longTagName = "l" + someOos + "ng_tag";
tagssvc.tagURI(uri1, ["short_tag", longTagName]);
do_throw("Passing a bad tags array should throw");
} catch (ex) {
do_check_eq(ex.name, "NS_ERROR_ILLEGAL_VALUE");
}
// cleanup

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

@ -189,67 +189,62 @@ function test_set_property_lazy_getter() {
});
};
let (dict = new Dict()) {
setThunk(dict);
let dict = new Dict();
setThunk(dict);
// Test that checking for the key existence does not invoke
// the getter function.
do_check_true(dict.has("foo"));
do_check_false(thunkCalled);
do_check_true(dict.isLazyGetter("foo"));
// Test that checking for the key existence does not invoke
// the getter function.
do_check_true(dict.has("foo"));
do_check_false(thunkCalled);
do_check_true(dict.isLazyGetter("foo"));
// Calling get the first time should invoke the getter function
// and unmark the key as a lazy getter.
do_check_eq(dict.get("foo"), "bar");
do_check_true(thunkCalled);
do_check_false(dict.isLazyGetter("foo"));
// Calling get the first time should invoke the getter function
// and unmark the key as a lazy getter.
do_check_eq(dict.get("foo"), "bar");
do_check_true(thunkCalled);
do_check_false(dict.isLazyGetter("foo"));
// Calling get again should not invoke the getter function
thunkCalled = false;
do_check_eq(dict.get("foo"), "bar");
do_check_false(thunkCalled);
do_check_false(dict.isLazyGetter("foo"));
}
// Calling get again should not invoke the getter function
thunkCalled = false;
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()) {
setThunk(dict);
do_check_true(dict.isLazyGetter("foo"));
dict = new Dict();
setThunk(dict);
do_check_true(dict.isLazyGetter("foo"));
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");
}
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;
thunkCalled = false;
// Retrieving the list again shouldn't invoke our getter.
let (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");
}
}
// Retrieving the list again shouldn't invoke our getter.
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()) {
setThunk(dict);
let values = dict.values;
dict = new Dict();
setThunk(dict);
let values = dict.values;
// Our getter shouldn't be called before the iterator reaches it.
do_check_true(dict.isLazyGetter("foo"));
do_check_false(thunkCalled);
do_check_eq(values.next(), "bar");
do_check_true(thunkCalled);
// Our getter shouldn't be called before the iterator reaches it.
do_check_true(dict.isLazyGetter("foo"));
do_check_false(thunkCalled);
do_check_eq(values.next(), "bar");
do_check_true(thunkCalled);
thunkCalled = false;
do_check_false(dict.isLazyGetter("foo"));
do_check_eq(dict.get("foo"), "bar");
do_check_false(thunkCalled);
}
thunkCalled = false;
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,47 +36,45 @@ function checkMainPropertyList(aPropertyListRoot) {
checkValue(aPropertyListRoot, PropertyListUtils.TYPE_DICTIONARY);
checkValue(aPropertyListRoot.get("Boolean"), PRIMITIVE, false);
let (array = aPropertyListRoot.get("Array")) {
checkValue(array, PropertyListUtils.TYPE_ARRAY);
do_check_eq(array.length, 8);
let array = aPropertyListRoot.get("Array");
checkValue(array, PropertyListUtils.TYPE_ARRAY);
do_check_eq(array.length, 8);
// Test both long and short values, since binary property lists store
// long values a little bit differently (see readDataLengthAndOffset).
// Test both long and short values, since binary property lists store
// long values a little bit differently (see readDataLengthAndOffset).
// Short ASCII string
checkLazyGetterValue(array, 0, PRIMITIVE, "abc");
// Long ASCII string
checkLazyGetterValue(array, 1, PRIMITIVE, new Array(1001).join("a"));
// Short unicode string
checkLazyGetterValue(array, 2, PRIMITIVE, "\u05D0\u05D0\u05D0");
// Long unicode string
checkLazyGetterValue(array, 3, PRIMITIVE, new Array(1001).join("\u05D0"));
// Unicode surrogate pair
checkLazyGetterValue(array, 4, PRIMITIVE,
"\uD800\uDC00\uD800\uDC00\uD800\uDC00");
// Short ASCII string
checkLazyGetterValue(array, 0, PRIMITIVE, "abc");
// Long ASCII string
checkLazyGetterValue(array, 1, PRIMITIVE, new Array(1001).join("a"));
// Short unicode string
checkLazyGetterValue(array, 2, PRIMITIVE, "\u05D0\u05D0\u05D0");
// Long unicode string
checkLazyGetterValue(array, 3, PRIMITIVE, new Array(1001).join("\u05D0"));
// Unicode surrogate pair
checkLazyGetterValue(array, 4, PRIMITIVE,
"\uD800\uDC00\uD800\uDC00\uD800\uDC00");
// Date
checkLazyGetterValue(array, 5, PropertyListUtils.TYPE_DATE,
new Date("2011-12-31T11:15:23Z"));
// Date
checkLazyGetterValue(array, 5, PropertyListUtils.TYPE_DATE,
new Date("2011-12-31T11:15:23Z"));
// Data
checkLazyGetterValue(array, 6, PropertyListUtils.TYPE_UINT8_ARRAY);
let dataAsString = [String.fromCharCode(b) for each (b in array[6])].join("");
do_check_eq(dataAsString, "2011-12-31T11:15:33Z");
// Data
checkLazyGetterValue(array, 6, PropertyListUtils.TYPE_UINT8_ARRAY);
let dataAsString = [String.fromCharCode(b) for each (b in array[6])].join("");
do_check_eq(dataAsString, "2011-12-31T11:15:33Z");
// Dict
let (dict = array[7]) {
checkValue(dict, PropertyListUtils.TYPE_DICTIONARY);
checkValue(dict.get("Negative Number"), PRIMITIVE, -400);
checkValue(dict.get("Real Number"), PRIMITIVE, 2.71828183);
checkValue(dict.get("Big Int"),
PropertyListUtils.TYPE_INT64,
"9007199254740993");
checkValue(dict.get("Negative Big Int"),
PropertyListUtils.TYPE_INT64,
"-9007199254740993");
}
}
// Dict
let dict = array[7];
checkValue(dict, PropertyListUtils.TYPE_DICTIONARY);
checkValue(dict.get("Negative Number"), PRIMITIVE, -400);
checkValue(dict.get("Real Number"), PRIMITIVE, 2.71828183);
checkValue(dict.get("Big Int"),
PropertyListUtils.TYPE_INT64,
"9007199254740993");
checkValue(dict.get("Negative Big Int"),
PropertyListUtils.TYPE_INT64,
"-9007199254740993");
}
function readPropertyList(aFile, aCallback) {