зеркало из https://github.com/mozilla/pjs.git
Bug 589413 - Failure to open libnss3.so when Firefox path contains UTF-8 characters. Part 3: tests. r=bent, a=final+
This commit is contained in:
Родитель
2d271f2770
Коммит
3606bb4b5a
|
@ -51,6 +51,10 @@
|
||||||
|
|
||||||
<script type="application/javascript">
|
<script type="application/javascript">
|
||||||
<![CDATA[
|
<![CDATA[
|
||||||
|
Components.utils.import("resource://gre/modules/ctypes.jsm");
|
||||||
|
|
||||||
|
CTYPES_TEST_LIB = ctypes.libraryName("jsctypes-test");
|
||||||
|
CTYPES_UNICODE_LIB = ctypes.libraryName("jsctyp\u00E8s-t\u00EB\u00DFt");
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* input: string of the url where we are running from
|
* input: string of the url where we are running from
|
||||||
|
@ -81,23 +85,42 @@
|
||||||
return dir;
|
return dir;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function setupLibs(path) {
|
||||||
|
let libFile = path.clone();
|
||||||
|
libFile.append(CTYPES_TEST_LIB);
|
||||||
|
ok(libFile.exists(), "ctypes test library doesn't exist!?");
|
||||||
|
|
||||||
|
libFile.copyTo(null, CTYPES_UNICODE_LIB);
|
||||||
|
}
|
||||||
|
|
||||||
|
function cleanupLibs(path) {
|
||||||
|
let unicodeFile = path.clone();
|
||||||
|
unicodeFile.append(CTYPES_UNICODE_LIB);
|
||||||
|
ok(unicodeFile.exists(), "ctypes unicode test library doesn't exist!?");
|
||||||
|
unicodeFile.remove(false);
|
||||||
|
}
|
||||||
|
|
||||||
function test()
|
function test()
|
||||||
{
|
{
|
||||||
SimpleTest.waitForExplicitFinish();
|
SimpleTest.waitForExplicitFinish();
|
||||||
|
|
||||||
|
var dir = getCurrentDir(location.path);
|
||||||
|
ok(dir.exists() && dir.isDirectory(), "Chrome test dir doesn't exist?!");
|
||||||
|
setupLibs(dir);
|
||||||
|
|
||||||
var worker = new ChromeWorker("ctypes_worker.js");
|
var worker = new ChromeWorker("ctypes_worker.js");
|
||||||
worker.onmessage = function(event) {
|
worker.onmessage = function(event) {
|
||||||
is(event.data, "Done!", "Wrong message!");
|
is(event.data, "Done!", "Wrong message!");
|
||||||
|
cleanupLibs(dir);
|
||||||
SimpleTest.finish();
|
SimpleTest.finish();
|
||||||
}
|
}
|
||||||
worker.onerror = function(event) {
|
worker.onerror = function(event) {
|
||||||
ok(false, "Worker had an error: " + event.message);
|
ok(false, "Worker had an error: " + event.message);
|
||||||
worker.terminate();
|
worker.terminate();
|
||||||
|
cleanupLibs(dir);
|
||||||
SimpleTest.finish();
|
SimpleTest.finish();
|
||||||
}
|
}
|
||||||
|
|
||||||
var dir = getCurrentDir(location.path);
|
|
||||||
ok(dir.exists() && dir.isDirectory(), "Chrome test dir doesn't exist?!");
|
|
||||||
worker.postMessage(dir.path);
|
worker.postMessage(dir.path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -38,12 +38,15 @@
|
||||||
*
|
*
|
||||||
* ***** END LICENSE BLOCK ***** */
|
* ***** END LICENSE BLOCK ***** */
|
||||||
|
|
||||||
Components.utils.import("resource://gre/modules/ctypes.jsm");
|
try {
|
||||||
|
// We might be running without privileges, in which case it's up to the
|
||||||
const Cc = Components.classes;
|
// harness to give us the 'ctypes' object.
|
||||||
const Ci = Components.interfaces;
|
Components.utils.import("resource://gre/modules/ctypes.jsm");
|
||||||
|
} catch(e) {
|
||||||
|
}
|
||||||
|
|
||||||
CTYPES_TEST_LIB = ctypes.libraryName("jsctypes-test");
|
CTYPES_TEST_LIB = ctypes.libraryName("jsctypes-test");
|
||||||
|
CTYPES_UNICODE_LIB = ctypes.libraryName("jsctyp\u00E8s-t\u00EB\u00DFt");
|
||||||
|
|
||||||
function getParent(obj, fun)
|
function getParent(obj, fun)
|
||||||
{
|
{
|
||||||
|
@ -59,8 +62,13 @@ function checkParentIsCTypes(o)
|
||||||
|
|
||||||
function do_check_throws(f, type, stack)
|
function do_check_throws(f, type, stack)
|
||||||
{
|
{
|
||||||
if (!stack)
|
if (!stack) {
|
||||||
stack = Components.stack.caller;
|
try {
|
||||||
|
// We might not have a 'Components' object.
|
||||||
|
stack = Components.stack.caller;
|
||||||
|
} catch (e) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
f();
|
f();
|
||||||
|
@ -88,8 +96,8 @@ function run_test()
|
||||||
run_abstract_class_tests();
|
run_abstract_class_tests();
|
||||||
|
|
||||||
// open the library
|
// open the library
|
||||||
let libfile = do_get_file(CTYPES_TEST_LIB).path;
|
let libfile = do_get_file(CTYPES_TEST_LIB);
|
||||||
let library = ctypes.open(libfile);
|
let library = ctypes.open(libfile.path);
|
||||||
|
|
||||||
// Make sure we can call a function in the library.
|
// Make sure we can call a function in the library.
|
||||||
run_void_tests(library);
|
run_void_tests(library);
|
||||||
|
@ -215,7 +223,7 @@ function run_test()
|
||||||
}, Error);
|
}, Error);
|
||||||
|
|
||||||
// test that library functions throw when bound to other objects
|
// test that library functions throw when bound to other objects
|
||||||
library = ctypes.open(libfile);
|
library = ctypes.open(libfile.path);
|
||||||
let obj = {};
|
let obj = {};
|
||||||
obj.declare = library.declare;
|
obj.declare = library.declare;
|
||||||
do_check_throws(function () { run_void_tests(obj); }, Error);
|
do_check_throws(function () { run_void_tests(obj); }, Error);
|
||||||
|
@ -233,6 +241,19 @@ function run_test()
|
||||||
|
|
||||||
// bug 522360
|
// bug 522360
|
||||||
do_check_eq(run_load_system_library(), true);
|
do_check_eq(run_load_system_library(), true);
|
||||||
|
|
||||||
|
// Test loading a library with a unicode name (bug 589413). Note that nsIFile
|
||||||
|
// implementations are not available in some harnesses; if not, the harness
|
||||||
|
// should take care of the copy for us.
|
||||||
|
let unicodefile = do_get_file(CTYPES_UNICODE_LIB, true);
|
||||||
|
let copy = libfile.copyTo instanceof Function;
|
||||||
|
if (copy)
|
||||||
|
libfile.copyTo(null, unicodefile.leafName);
|
||||||
|
library = ctypes.open(unicodefile.path);
|
||||||
|
run_void_tests(library);
|
||||||
|
library.close();
|
||||||
|
if (copy)
|
||||||
|
unicodefile.remove(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
function run_abstract_class_tests()
|
function run_abstract_class_tests()
|
||||||
|
|
Загрузка…
Ссылка в новой задаче