Bug 1034474 - B2G NFC: onpeerlost is never called. r=dimi

From 6342cf34f7493711317b613a8e30ef6badabcfd1 Mon Sep 17 00:00:00 2001
---
 dom/nfc/tests/marionette/test_nfc_peer.js | 10 +++++++++-
 dom/system/gonk/Nfc.js                    |  4 ++--
 2 files changed, 11 insertions(+), 3 deletions(-)
This commit is contained in:
Yoshi Huang 2014-07-07 11:56:29 +08:00
parent 216da66080
commit ccf57a1dbf
2 changed files with 11 additions and 3 deletions

View File

@ -12,8 +12,15 @@ function peerReadyCb(evt) {
let peer = nfc.getNFCPeer(evt.detail);
ok(peer instanceof MozNFCPeer, "Should get a NFCPeer object.");
// reset callback and NFC Hardware.
// reset callback.
nfc.onpeerready = null;
emulator.deactivate();
}
function peerLostCb() {
log("peerLostCb called");
ok(true);
nfc.onpeerlost = null;
toggleNFC(false).then(runNextTest);
}
@ -23,6 +30,7 @@ function handleTechnologyDiscoveredRE0(msg) {
is(msg.techList[0], "P2P", "check for correct tech type");
nfc.onpeerready = peerReadyCb;
nfc.onpeerlost = peerLostCb;
let request = nfc.checkP2PRegistration(MANIFEST_URL);
request.onsuccess = function (evt) {

View File

@ -286,7 +286,7 @@ XPCOMUtils.defineLazyGetter(this, "gMessageManager", function () {
isRegisteredP2PTarget: function isRegisteredP2PTarget(appId, event) {
let targetInfo = this.peerTargetsMap[appId];
// Check if it is a registered target for the 'event'
return ((targetInfo != null) && (targetInfo.event & event !== 0));
return ((targetInfo != null) && ((targetInfo.event & event) !== 0));
},
notifyPeerEvent: function notifyPeerEvent(appId, event) {
@ -527,7 +527,7 @@ Nfc.prototype = {
gSystemMessenger.broadcastMessage("nfc-manager-tech-lost", message);
// Notify 'PeerLost' to appropriate registered target, if any
gMessageManager.notifyPeerEvent(this.currentPeerAppId, NFC.NFC_PEER_EVENT_LOST);
gMessageManager.notifyPeerEvent(gMessageManager.currentPeerAppId, NFC.NFC_PEER_EVENT_LOST);
delete this.sessionTokenMap[this._currentSessionId];
this._currentSessionId = null;
this.currentPeerAppId = null;