b2g/components/test/mochitest/permission_handler_chrome.js

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     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/. */
     5 "use strict";
     7 function debug(str) {
     8   dump("CHROME PERMISSON HANDLER -- " + str + "\n");
     9 }
    11 const Cc = Components.classes;
    12 const Ci = Components.interfaces;
    13 const Cu = Components.utils;
    15 const { Services } = Cu.import("resource://gre/modules/Services.jsm");
    16 const { SystemAppProxy } = Cu.import("resource://gre/modules/SystemAppProxy.jsm");
    18 let eventHandler = function(evt) {
    19   if (!evt.detail || evt.detail.type !== "permission-prompt") {
    20     return;
    21   }
    23   sendAsyncMessage("permission-request", evt.detail);
    24 };
    26 SystemAppProxy.addEventListener("mozChromeEvent", eventHandler);
    28 // need to remove ChromeEvent listener after test finished.
    29 addMessageListener("teardown", function() {
    30   SystemAppProxy.removeEventListener("mozChromeEvent", eventHandler);
    31 });
    33 addMessageListener("permission-response", function(detail) {
    34   SystemAppProxy._sendCustomEvent('mozContentEvent', detail);
    35 });

mercurial