Hi, I've to call injected javascript function in a web page by using JS-XPCOM from my C++ XPCOM. Following are the skeleton of my work..
1 - My IDL is as follows #include "nsISupports.idl" [scriptable, uuid(f22e7808-17a7-11e4-9620-58fc1d5d46b0)] interface nsIJSSupport: nsISupports { boolean doSomething(in string frameId, in string siteId,in bool bPage, in bool bIsGreater); }; 2 - My JS file is as follows Components.utils.import("resource://gre/modules/XPCOMUtils.jsm"); function MyComponent() { } MyComponent.prototype = { classDescription: "Shans Javascript XPCOM Component", classID: Components.ID("{17ca79ee-17ae-11e4-a5ea-fa011e5d46b0}"), contractID: "@Shans.com/jssource;1", QueryInterface: XPCOMUtils.generateQI([Components.interfaces.nsIJSSupport,Components.interfaces.nsISupports]), doSomething: function(frameId, siteId, bPage, bIsGreater) { //Get the proper window and get the call to sb_MyComponent //assuming the following will call the "sb_MyComponent" win.wrappedJSObject.injectedFunctioninWebPage(frameId, siteId, bPage, bIsGreater); } } var components = [MyComponent]; if ("generateNSGetFactory" in XPCOMUtils) var NSGetFactory = XPCOMUtils.generateNSGetFactory(components); else var NSGetModule = XPCOMUtils.generateNSGetModule(components); 3 - My C++ XP-COM code (skeleton) to make JS-XPCOM call as below : nsresult rv; nsCOMPtr<nsIDOMWindow> aDOMWindow( do_GetInterface( aWebProgress, &rv ) ); nsCOMPtr< nsPIDOMWindow > privateWindow( do_QueryInterface( aDOMWindow, &rv ) ); nsCOMPtr< nsIDocShell > docShell = privateWindow->GetDocShell(); nsCOMPtr<nsIJSSupport> iJSSupport = do_CreateInstance("@Shans.com/jssource;1",&rv); if(NS_SUCCEEDED(rv) && iJSSupport) { iJSSupport-> doSomething (frameId, siteId, bPage, bIsGreater) } Is it possible to call the "injectedFunctioninWebPage()" by using win.wrappedJSObject ? If not, how to call the JS functions in the page by using JS-XPCOM? Thanks in Advance, Shan' _______________________________________________ dev-platform mailing list dev-platform@lists.mozilla.org https://lists.mozilla.org/listinfo/dev-platform