Hi all,

I'm trying to call XPCOM from my Gecko plugin (based on the Scriptable
plug-in sample).

The problem is that CreateElement function fails with a strange message
"The value of ESP was not properly saved..." (please see the attached
image for the full error string).

When I step in CreateElement I see that the program actually goes to GetDocumentElement!?

I suppose it has smth to do with different call conventions used in plugins and in embedding applicaitons, but it's just a guess.

Please HELP!

Anton.

-------------------------------------------------------------
Attached a piece of my code:
-------------------------------------------------------------

#define TESTRES(res) if ((res) != 0) throw res;
void nsPluginInstance::MyFunction()
{
        try
        {
                nsCOMPtr<nsIDOMWindow> win;
                TESTRES(m_spWebBrowser->GetContentDOMWindow(getter_AddRefs(win)));

                nsCOMPtr<nsIDOMDocument> doc;
                TESTRES(win->GetDocument(getter_AddRefs(doc)));

nsCOMPtr<nsIDOMHTMLDocument> htmlDoc(do_QueryInterface(doc));


nsCOMPtr<nsIDOMElement> elem; nsAutoString tagName(NS_LITERAL_STRING("script")); TESTRES(htmlDoc->CreateElement(tagName, getter_AddRefs(elem)));

                nsCOMPtr<nsIDOMHTMLScriptElement> scrElem;
            TESTRES(elem->QueryInterface(NS_GET_IID(nsIDOMHTMLScriptElement),
(void **)&scrElem));

                nsAutoString 
scr(NS_LITERAL_STRING("http://localhost/mozilla/test.js";));
                TESTRES(scrElem->SetSrc(scr));

                nsAutoString type(NS_LITERAL_STRING("text/javascript"));
                TESTRES(scrElem->SetType(type));

                nsCOMPtr<nsIDOMNode> docNode = doc;
                nsCOMPtr<nsIDOMNode> scrNode = scrElem;
                nsCOMPtr<nsIDOMNode> resNode;

                TESTRES(docNode->AppendChild(scrNode, getter_AddRefs(resNode)));
        }
        catch (DOMException &ex)
        {
                PRUint32 code;
        }
        catch (nsresult res)
        {
                nsresult r = res;
        }
}


<<inline: esp_err.JPG>>

Reply via email to