michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this file, michael@0: * You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: "use strict"; michael@0: michael@0: function debug(str) { michael@0: dump("CHROME PERMISSON HANDLER -- " + str + "\n"); michael@0: } michael@0: michael@0: const Cc = Components.classes; michael@0: const Ci = Components.interfaces; michael@0: const Cu = Components.utils; michael@0: michael@0: const { Services } = Cu.import("resource://gre/modules/Services.jsm"); michael@0: const { SystemAppProxy } = Cu.import("resource://gre/modules/SystemAppProxy.jsm"); michael@0: michael@0: let eventHandler = function(evt) { michael@0: if (!evt.detail || evt.detail.type !== "permission-prompt") { michael@0: return; michael@0: } michael@0: michael@0: sendAsyncMessage("permission-request", evt.detail); michael@0: }; michael@0: michael@0: SystemAppProxy.addEventListener("mozChromeEvent", eventHandler); michael@0: michael@0: // need to remove ChromeEvent listener after test finished. michael@0: addMessageListener("teardown", function() { michael@0: SystemAppProxy.removeEventListener("mozChromeEvent", eventHandler); michael@0: }); michael@0: michael@0: addMessageListener("permission-response", function(detail) { michael@0: SystemAppProxy._sendCustomEvent('mozContentEvent', detail); michael@0: }); michael@0: