Bug 1200969 - Fix timing issue in PresentationRequestUIGlue. r=fabrice

This commit is contained in:
Sean Lin 2015-09-03 10:04:59 +08:00
parent e7f7e9f776
commit 62c81a2eea
2 changed files with 12 additions and 7 deletions

View File

@ -4,6 +4,10 @@
"use strict"
function debug(aMsg) {
//dump("-*- PresentationRequestUIGlue: " + aMsg + "\n");
}
const { interfaces: Ci, utils: Cu, classes: Cc } = Components;
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
@ -30,9 +34,10 @@ function PresentationRequestUIGlue() {
return;
}
let sessionId = detail.sessionId;
let sessionId = detail.id;
let resolver = this._resolvers[sessionId];
if (!resolver) {
debug("No correspondent resolver for session ID: " + sessionId);
return;
}
@ -44,13 +49,13 @@ function PresentationRequestUIGlue() {
PresentationRequestUIGlue.prototype = {
sendRequest: function(aUrl, aSessionId) {
SystemAppProxy._sendCustomEvent("mozPresentationChromeEvent",
{ type: "presentation-launch-receiver",
url: aUrl,
id: aSessionId });
return new Promise(function(aResolve, aReject) {
this._resolvers[aSessionId] = aResolve;
SystemAppProxy._sendCustomEvent("mozPresentationChromeEvent",
{ type: "presentation-launch-receiver",
url: aUrl,
id: aSessionId });
}.bind(this));
},

View File

@ -28,7 +28,7 @@ addMessageListener('trigger-ui-glue', function(aData) {
addMessageListener('trigger-presentation-content-event', function(aData) {
var detail = {
type: 'presentation-receiver-launched',
sessionId: aData.sessionId,
id: aData.sessionId,
frame: aData.frame
};
SystemAppProxy._sendCustomEvent('mozPresentationContentEvent', detail);