зеркало из https://github.com/mozilla/jsmodules.git
Allow extracting of the sync. function callback to make the sync. call not inject the callback.
This commit is contained in:
Родитель
86582b0d9e
Коммит
a1e71e87bc
7
Sync.js
7
Sync.js
|
@ -92,6 +92,13 @@ function syncBind(thisArg) {
|
|||
return retval;
|
||||
};
|
||||
|
||||
// Grabbing the onComplete converts the sync. function to not assume the first
|
||||
// argument is our custom callback
|
||||
syncFunc.__defineGetter__("onComplete", function() {
|
||||
insertCallback = false;
|
||||
return onComplete;
|
||||
});
|
||||
|
||||
return syncFunc;
|
||||
}
|
||||
|
||||
|
|
|
@ -63,6 +63,16 @@ function test_Sync_sync_bind() {
|
|||
do_check_true(duration >= 100);
|
||||
}
|
||||
|
||||
// Check that sync. function callbacks can be extracted
|
||||
function test_Function_prototype_sync_onComplete() {
|
||||
let add = slowAdd.sync;
|
||||
let duration = time(function() {
|
||||
let sum = add(add.onComplete, 100, 1000, 234);
|
||||
do_check_eq(sum, 1234);
|
||||
});
|
||||
do_check_true(duration >= 100);
|
||||
}
|
||||
|
||||
// Make sure the exported Sync object/function has Function properties
|
||||
function test_function_Sync() {
|
||||
// We can't check the functions directly because the Function object for Sync
|
||||
|
|
Загрузка…
Ссылка в новой задаче