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

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

     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