b2g/chrome/content/test/mochitest/RecordingStatusChromeScript.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 /* Any copyright is dedicated to the Public Domain.
     2    http://creativecommons.org/publicdomain/zero/1.0/ */
     4 const { classes: Cc, interfaces: Ci, results: Cr, utils: Cu } = Components;
     5 const { Services } = Cu.import('resource://gre/modules/Services.jsm');
     6 const { SystemAppProxy } = Cu.import('resource://gre/modules/SystemAppProxy.jsm');
     8 var processId;
    10 function peekChildId(aSubject, aTopic, aData) {
    11   Services.obs.removeObserver(peekChildId, 'recording-device-events');
    12   Services.obs.removeObserver(peekChildId, 'recording-device-ipc-events');
    13   let props = aSubject.QueryInterface(Ci.nsIPropertyBag2);
    14   if (props.hasKey('childID')) {
    15     processId = props.get('childID');
    16   }
    17 }
    19 addMessageListener('init-chrome-event', function(message) {
    20   // listen mozChromeEvent and forward to content process.
    21   let type = message.type;
    22   SystemAppProxy.addEventListener('mozChromeEvent', function(event) {
    23     let details = event.detail;
    24     if (details.type === type) {
    25       sendAsyncMessage('chrome-event', details);
    26     }
    27   }, true);
    29   Services.obs.addObserver(peekChildId, 'recording-device-events', false);
    30   Services.obs.addObserver(peekChildId, 'recording-device-ipc-events', false);
    31 });
    33 addMessageListener('fake-content-shutdown', function(message) {
    34     let props = Cc["@mozilla.org/hash-property-bag;1"]
    35                   .createInstance(Ci.nsIWritablePropertyBag2);
    36     if (processId) {
    37       props.setPropertyAsUint64('childID', processId);
    38     }
    39     Services.obs.notifyObservers(props, 'recording-device-ipc-events', 'content-shutdown');
    40 });

mercurial