| |
1 /* This Source Code Form is subject to the terms of the Mozilla Public |
| |
2 * License, v. 2.0. If a copy of the MPL was not distributed with this file, |
| |
3 * You can obtain one at http://mozilla.org/MPL/2.0/. */ |
| |
4 |
| |
5 "use strict"; |
| |
6 |
| |
7 function debug(str) { |
| |
8 dump("CHROME PERMISSON HANDLER -- " + str + "\n"); |
| |
9 } |
| |
10 |
| |
11 const Cc = Components.classes; |
| |
12 const Ci = Components.interfaces; |
| |
13 const Cu = Components.utils; |
| |
14 |
| |
15 const { Services } = Cu.import("resource://gre/modules/Services.jsm"); |
| |
16 const { SystemAppProxy } = Cu.import("resource://gre/modules/SystemAppProxy.jsm"); |
| |
17 |
| |
18 let eventHandler = function(evt) { |
| |
19 if (!evt.detail || evt.detail.type !== "permission-prompt") { |
| |
20 return; |
| |
21 } |
| |
22 |
| |
23 sendAsyncMessage("permission-request", evt.detail); |
| |
24 }; |
| |
25 |
| |
26 SystemAppProxy.addEventListener("mozChromeEvent", eventHandler); |
| |
27 |
| |
28 // need to remove ChromeEvent listener after test finished. |
| |
29 addMessageListener("teardown", function() { |
| |
30 SystemAppProxy.removeEventListener("mozChromeEvent", eventHandler); |
| |
31 }); |
| |
32 |
| |
33 addMessageListener("permission-response", function(detail) { |
| |
34 SystemAppProxy._sendCustomEvent('mozContentEvent', detail); |
| |
35 }); |
| |
36 |