mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
b0c1ba9c9e
--HG-- rename : toolkit/mozapps/shared/CertUtils.jsm => toolkit/modules/CertUtils.jsm rename : toolkit/content/DeferredTask.jsm => toolkit/modules/DeferredTask.jsm rename : toolkit/content/Deprecated.jsm => toolkit/modules/Deprecated.jsm rename : toolkit/content/Dict.jsm => toolkit/modules/Dict.jsm rename : toolkit/mozapps/shared/FileUtils.jsm => toolkit/modules/FileUtils.jsm rename : toolkit/content/Geometry.jsm => toolkit/modules/Geometry.jsm rename : toolkit/content/InlineSpellChecker.jsm => toolkit/modules/InlineSpellChecker.jsm rename : toolkit/content/LightweightThemeConsumer.jsm => toolkit/modules/LightweightThemeConsumer.jsm rename : toolkit/content/PageMenu.jsm => toolkit/modules/PageMenu.jsm rename : toolkit/content/PopupNotifications.jsm => toolkit/modules/PopupNotifications.jsm rename : toolkit/content/PrivateBrowsingUtils.jsm => toolkit/modules/PrivateBrowsingUtils.jsm rename : toolkit/content/PropertyListUtils.jsm => toolkit/modules/PropertyListUtils.jsm rename : toolkit/content/Services.jsm => toolkit/modules/Services.jsm rename : toolkit/content/Task.jsm => toolkit/modules/Task.jsm rename : toolkit/content/Troubleshoot.jsm => toolkit/modules/Troubleshoot.jsm rename : toolkit/content/UpdateChannel.jsm => toolkit/modules/UpdateChannel.jsm rename : toolkit/content/WindowDraggingUtils.jsm => toolkit/modules/WindowDraggingUtils.jsm rename : toolkit/content/debug.js => toolkit/modules/debug.js rename : toolkit/content/tests/browser/browser_DeferredTask.js => toolkit/modules/tests/browser/browser_DeferredTask.js rename : toolkit/content/tests/browser/browser_Deprecated.js => toolkit/modules/tests/browser/browser_Deprecated.js rename : toolkit/content/tests/browser/browser_Geometry.js => toolkit/modules/tests/browser/browser_Geometry.js rename : toolkit/content/tests/browser/browser_InlineSpellChecker.js => toolkit/modules/tests/browser/browser_InlineSpellChecker.js rename : toolkit/content/tests/browser/browser_Services.js => toolkit/modules/tests/browser/browser_Services.js rename : toolkit/content/tests/browser/browser_Troubleshoot.js => toolkit/modules/tests/browser/browser_Troubleshoot.js rename : toolkit/mozapps/shared/test/chrome/Makefile.in => toolkit/modules/tests/chrome/Makefile.in rename : toolkit/mozapps/shared/test/chrome/moz.build => toolkit/modules/tests/chrome/moz.build rename : toolkit/mozapps/shared/test/chrome/test_bug544442_checkCert.xul => toolkit/modules/tests/chrome/test_bug544442_checkCert.xul rename : toolkit/content/tests/unit/propertyLists/bug710259_propertyListBinary.plist => toolkit/modules/tests/xpcshell/propertyLists/bug710259_propertyListBinary.plist rename : toolkit/content/tests/unit/propertyLists/bug710259_propertyListXML.plist => toolkit/modules/tests/xpcshell/propertyLists/bug710259_propertyListXML.plist rename : toolkit/mozapps/shared/test/unit/test_FileUtils.js => toolkit/modules/tests/xpcshell/test_FileUtils.js rename : toolkit/content/tests/unit/test_dict.js => toolkit/modules/tests/xpcshell/test_dict.js rename : toolkit/content/tests/unit/test_propertyListsUtils.js => toolkit/modules/tests/xpcshell/test_propertyListsUtils.js rename : toolkit/mozapps/shared/test/unit/test_readCertPrefs.js => toolkit/modules/tests/xpcshell/test_readCertPrefs.js rename : toolkit/content/tests/unit/test_task.js => toolkit/modules/tests/xpcshell/test_task.js
103 lines
4.0 KiB
JavaScript
103 lines
4.0 KiB
JavaScript
/* 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";
|
|
|
|
Components.utils.import("resource://gre/modules/PropertyListUtils.jsm");
|
|
|
|
function checkValue(aPropertyListObject, aType, aValue) {
|
|
do_check_eq(PropertyListUtils.getObjectType(aPropertyListObject), aType);
|
|
if (aValue !== undefined) {
|
|
// Perform strict equality checks until Bug 714467 is fixed.
|
|
let strictEqualityCheck = function(a, b) {
|
|
do_check_eq(typeof(a), typeof(b));
|
|
do_check_eq(a, b);
|
|
};
|
|
|
|
if (typeof(aPropertyListObject) == "object")
|
|
strictEqualityCheck(aPropertyListObject.valueOf(), aValue.valueOf());
|
|
else
|
|
strictEqualityCheck(aPropertyListObject, aValue);
|
|
}
|
|
}
|
|
|
|
function checkLazyGetterValue(aObject, aPropertyName, aType, aValue) {
|
|
let descriptor = Object.getOwnPropertyDescriptor(aObject, aPropertyName);
|
|
do_check_eq(typeof(descriptor.get), "function");
|
|
do_check_eq(typeof(descriptor.value), "undefined");
|
|
checkValue(aObject[aPropertyName], aType, aValue);
|
|
descriptor = Object.getOwnPropertyDescriptor(aObject, aPropertyName);
|
|
do_check_eq(typeof(descriptor.get), "undefined");
|
|
do_check_neq(typeof(descriptor.value), "undefined");
|
|
}
|
|
|
|
function checkMainPropertyList(aPropertyListRoot) {
|
|
const PRIMITIVE = PropertyListUtils.TYPE_PRIMITIVE;
|
|
|
|
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);
|
|
|
|
// 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");
|
|
|
|
// 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");
|
|
|
|
// 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) {
|
|
PropertyListUtils.read(aFile, function(aPropertyListRoot) {
|
|
// Null root indicates failure to read property list.
|
|
// Note: It is important not to run do_check_n/eq directly on Dict and array
|
|
// objects, because it cases their toString to get invoked, doing away with
|
|
// all the lazy getter we'd like to test later.
|
|
do_check_true(aPropertyListRoot !== null);
|
|
aCallback(aPropertyListRoot);
|
|
run_next_test();
|
|
});
|
|
}
|
|
|
|
function run_test() {
|
|
add_test(readPropertyList.bind(this,
|
|
do_get_file("propertyLists/bug710259_propertyListBinary.plist", false),
|
|
checkMainPropertyList));
|
|
add_test(readPropertyList.bind(this,
|
|
do_get_file("propertyLists/bug710259_propertyListXML.plist", false),
|
|
checkMainPropertyList));
|
|
run_next_test();
|
|
}
|