summaryrefslogtreecommitdiffstats
path: root/dom/console/tests/head.js
blob: 3e9c72cfb953599dffae296fdb77a60e34f07879 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
/**
 * Any copyright is dedicated to the Public Domain.
 * http://creativecommons.org/publicdomain/zero/1.0/
 */

const ConsoleAPIStorage = SpecialPowers.Cc[
  "@mozilla.org/consoleAPI-storage;1"
].getService(SpecialPowers.Ci.nsIConsoleAPIStorage);

// This is intended to just be a drop-in replacement for an old observer
// notification.
function addConsoleStorageListener(listener) {
  listener.__handler = (message, id) => {
    listener.observe(message, id);
  };
  ConsoleAPIStorage.addLogEventListener(
    listener.__handler,
    SpecialPowers.wrap(document).nodePrincipal
  );
}

function removeConsoleStorageListener(listener) {
  ConsoleAPIStorage.removeLogEventListener(listener.__handler);
}