Bug 1200969 - Fix timing issue in PresentationRequestUIGlue. r=fabrice
--- a/b2g/components/PresentationRequestUIGlue.js
+++ b/b2g/components/PresentationRequestUIGlue.js
@@ -1,14 +1,18 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict"
+function debug(aMsg) {
+ //dump("-*- PresentationRequestUIGlue: " + aMsg + "\n");
+}
+
const { interfaces: Ci, utils: Cu, classes: Cc } = Components;
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
Cu.import("resource://gre/modules/Services.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "SystemAppProxy",
"resource://gre/modules/SystemAppProxy.jsm");
@@ -25,37 +29,38 @@ function PresentationRequestUIGlue() {
// Listen to the result for the opened iframe from front-end.
SystemAppProxy.addEventListener("mozPresentationContentEvent", aEvent => {
let detail = aEvent.detail;
if (detail.type != "presentation-receiver-launched") {
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;
}
delete this._resolvers[sessionId];
resolver(detail.frame);
});
}
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));
},
classID: Components.ID("{ccc8a839-0b64-422b-8a60-fb2af0e376d0}"),
QueryInterface: XPCOMUtils.generateQI([Ci.nsIPresentationRequestUIGlue])
};
--- a/b2g/components/test/mochitest/presentation_ui_glue_handler_chrome.js
+++ b/b2g/components/test/mochitest/presentation_ui_glue_handler_chrome.js
@@ -23,13 +23,13 @@ addMessageListener('trigger-ui-glue', fu
promise.then(function(aFrame){
sendAsyncMessage('iframe-resolved', aFrame);
});
});
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);
});