summaryrefslogtreecommitdiffstats
path: root/js/xpconnect/tests/unit/head.js
blob: ca9a22bee89b9e1064eb6f5e27bf5fd3d72a71c2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
"use strict";

// Wraps the given object in an XPConnect wrapper and, if an interface
// is passed, queries the result to that interface.
function xpcWrap(obj, iface) {
  let ifacePointer = Cc[
    "@mozilla.org/supports-interface-pointer;1"
  ].createInstance(Ci.nsISupportsInterfacePointer);

  ifacePointer.data = obj;
  if (iface) {
    return ifacePointer.data.QueryInterface(iface);
  }
  return ifacePointer.data;
}