Getting the current inner window ID in a Firefox 32 extension

213 Views Asked by At

I'm trying to maintain a Firefox extension and it relies on getting the current inner window ID. In Firefox 31 the window object has a QueryInterface:

components/foo.js:

Foo.prototype = {
  window: null,
  ...
  init: function(aWindow) {
    this.window = XPCNativeWrapper.unwrap(aWindow);
    var util = this.window.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindowUtils);
    dump('Your inner window ID is: ' + util.currentInnerWindowID + '\n');
  },
  ...
  shutdown: function() {
  }
}

In Firefox 32 the window.QueryInterface object has disappeared and I'm wondering how to get the current inner window ID.

Thanks.

1

There are 1 best solutions below

0
On

Calling XPCNativeWrapper.unwrap removes QueryInterface from aWindow.

if (aWindow.QueryInterface) {
  util = XPCNativeWrapper.unwrap(aWindow.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindowUtils));
  dump('Your inner window ID is: ' + util.currentInnerWindowID + '\n');
}