Closed Bug 505195 Opened 15 years ago Closed 15 years ago

Could not query nsIDOMChromeWindow interface from root nsIDOMWindow.

Categories

(Firefox :: Extension Compatibility, defect)

x86
Windows XP
defect
Not set
major

Tracking

()

RESOLVED INVALID

People

(Reporter: extralogic, Unassigned)

Details

Attachments

(1 file)

User-Agent:       Opera/9.64 (Windows NT 5.1; U; en) Presto/2.1.1
Build Identifier: 20090715084055

To use nsIBrowserDOMWindow->OpenURI() method in our C++ XPCOM (to navigate to some URL) we need to get nsIBrowserDOMWindow interface (this is a widespread technique described in the internet). It works fine for Firefox 3.0.11 but does not for Firefox 3.5.1.

Reproducible: Always

Steps to Reproduce:
In your C++ code do the following:
1. Get nsIDOMWindowInternal (through nsIWindowMediator->GetMostRecentWindow()).
2. Get nsIWebNavigation (through nsIInterfaceRequestor->GetInterface()).
3. Get nsIDocShellTreeItem (through nsIDocShellTreeItem->GetRootTreeItem()).
4. Get nsIDOMWindow (through nsIInterfaceRequestor->GetInterface()).
5. Try to get nsIDOMChromeWindow using do_QueryInterface() from nsIDOMWindow.

Please see the attached source code.
Actual Results:  
do_QueryInterface() returns NULL.

Expected Results:  
do_QueryInterface() shoult return valid nsIDOMChromeWindow.

Please see the attached source code. It fails at the following line (returns NULL):
nsCOMPtr<nsIDOMChromeWindow> spRootDOMChromeWindow = do_QueryInterface(spRootDOMWindow);
What SDK are you compiling against? I'm pretty sure nsIDOMChromeWindow changed between 1.9 and 1.9.1, which means you either need to recompile your code against the new IID/interface, or use dynamic interface techniques to be compatible with both versions (nsIDOMChromeWindow is not a frozen interface).
We use the latest SDK available for Windows at https://developer.mozilla.org/en/Gecko_SDK ("xulrunner-1.9.0.11.en-US.win32.sdk.zip"). It's version is 1.9.0.11. Is there any new version of the SDK? Please describe more detailed what you mean under "dynamic interface techniques".

Thanks.
You could copy nsIDOMChromeWindow from the 1.9.1 tree and rename it to

nsIDOMChromeWindow_191 and then do something like:

nsCOMPtr<nsIDOMChromeWindow> spRootDOMChromeWindow =
do_QueryInterface(spRootDOMWindow);
if (spRootDOMChromeWindow) {
 // 1.9.0 code here
}
else {
  nsCOMPtr<nsIDOMChromeWindow_191> spRootDOMChromeWindow191 = do_QueryInterface(spRootDOMWindow);
  if (spRootDOMChromeWindow191) {
    // 1.9.1 code here
  }
}
else {
  // unknown future version code here
}

The 1.9.1 SDK is still in RC; you can get it from here:
http://ftp.mozilla.org/pub/mozilla.org/xulrunner/nightly/1.9.1-candidates/build1/

Please direct future questions to the mozilla.dev.extensions newsgroup.
Status: UNCONFIRMED → RESOLVED
Closed: 15 years ago
Resolution: --- → INVALID
Thanks a lot.
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: