Bug 1139774 - Add a function to wait promise for bluetooth adapter creation. r=shuang

This commit is contained in:
Will Wang 2015-10-01 07:32:00 +02:00
parent 4174446530
commit 3db4451175
2 changed files with 35 additions and 6 deletions

View File

@ -837,6 +837,10 @@ function cleanUp() {
function startBluetoothTestBase(aPermissions, aTestCaseMain) {
ensureBluetoothManager(aPermissions)
.then(function() {
log("Wait for creating bluetooth adapter...");
return waitForManagerStateChanged(bluetoothManager);
})
.then(aTestCaseMain)
.then(cleanUp, function() {
ok(false, "Unhandled rejected promise.");
@ -885,3 +889,22 @@ function startBluetoothTest(aReenable, aTestCaseMain) {
});
});
}
function waitForManagerStateChanged(aManager) {
let deferred = Promise.defer();
aManager.onattributechanged = function(evt) {
for (var i in evt.attrs) {
switch (evt.attrs[i]) {
case 'defaultAdapter':
deferred.resolve(evt);
break;
default:
break;
}
}
}
return deferred.promise;
}

View File

@ -6,15 +6,21 @@ qemu = false
# Hint: "disabled = xxxxx" statement should be added *below* the test that
# we want to disable.
[test_dom_BluetoothManager_API2.js]
[test_dom_BluetoothManager.js]
disabled = Bug 1175389
[test_dom_BluetoothAdapter_enable_API2.js]
[test_dom_BluetoothAdapter_enable.js]
disabled = Bug 1175389
[test_dom_BluetoothAdapter_setters_API2.js]
[test_dom_BluetoothAdapter_setters.js]
disabled = Bug 1175389
[test_dom_BluetoothAdapter_discovery_API2.js]
[test_dom_BluetoothDevice.js]
disabled = Bug 1175389
[test_dom_BluetoothDevice_API2.js]
[test_dom_BluetoothAdapter_discovery.js]
disabled = Bug 1175389
[test_dom_BluetoothAdapter_pair_API2.js]
[test_dom_BluetoothAdapter_pair.js]
disabled = Bug 1175389