AutoJSContext.EvaluateScript not returning?

Create issue
Issue #21 new
Former user created an issue

I have the following function:

public string EvaluateJSReturn(GeckoWebBrowser wb, string jsStr)
    string output;
    using (AutoJSContext jsContext = new AutoJSContext(wb.Window.JSContext))
       jsContext.EvaluateScript(jsStr, out output);

    MessageBox.Show("jsout: " + output);
    return output;

This was working previously in Geckofx 22 and the Javascript function I had would successfully return a value, however, in 29 I am not getting a return value.

I have checked using the console on regular Firefox that the Javascript code that I am calling in the function still returns a value and it does successfully, however, I don't get one in Geckofx.

Is there a new way of doing this or is this a bug?

Comments (3)

  1. hindlemail

    Firefox 29 has seemed to tighten up its context + comparment rules you could try:

    jsContext.EvaluateScript(jsStr, (nsISupports)wb.Window.DomWindow, out output);

    Alternatively if you use the JsVal EvaluateScript(string) overload, on error it throws a GeckoJavaScriptException which might tell you more information. eg:

      var jsVal = jsContext.EvaluateScript(jsStr);
    }catch(GeckoJavaScriptException ex)
      // look at ex
  2. dan evans

    Thanks hindlemail, I had the same error, resolved by using the overloaded EvaluateScript method that takes the DomWindow.

  3. Log in to comment