Skip to content

Commit 90a83ff

Browse files
committed
New to xulrunner 2.0, the Javascript object we were passing through to EvaluateString was wrapped, so we need to unwrap it before usage.
1 parent 5289b85 commit 90a83ff

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

common/embed.cpp

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ using namespace std;
8181
#include "nsIWidget.h"
8282
#include "nsIWindowCreator2.h"
8383
#include "nsIWindowWatcher.h"
84+
#include "nsIXPConnect.h"
8485

8586
// globals
8687
static nsCOMPtr<WindowCreator> sWindowCreator;
@@ -569,7 +570,20 @@ char* MozView::EvaluateJavaScript(const char* aScript)
569570
nsCOMPtr<nsIScriptContext> ctx = sgo->GetContext();
570571
nsString retval;
571572
nsCOMPtr<nsIScriptObjectPrincipal> sgoPrincipal = do_QueryInterface(sgo);
572-
ctx->EvaluateString(NS_ConvertUTF8toUTF16(aScript), sgo->GetGlobalJSObject(),
573+
nsresult rv;
574+
JSObject * jsobj = sgo->GetGlobalJSObject();
575+
nsCOMPtr<nsIXPConnect> xpconnect = do_GetService(nsIXPConnect::GetCID(), &rv);
576+
if (NS_SUCCEEDED(rv))
577+
{
578+
JSContext * jsctx = static_cast<JSContext*>(ctx->GetNativeContext());
579+
JSObject * jsunwrapped;
580+
rv = xpconnect->GetJSObjectOfWrapper(jsctx, jsobj, &jsunwrapped);
581+
if (NS_SUCCEEDED(rv))
582+
{
583+
jsobj = jsunwrapped;
584+
}
585+
}
586+
ctx->EvaluateString(NS_ConvertUTF8toUTF16(aScript), jsobj,
573587
sgoPrincipal->GetPrincipal(),
574588
"mozembed", 0, nsnull, &retval, nsnull);
575589

0 commit comments

Comments
 (0)