Пример #1
0
// This is a temporary converter used by nsPlacesImportExportService until
// bug 482911 completes its js rewrite.
jsval
livemarkInfoToJSVal(PRInt64 aId,
                    const nsACString& aGUID,
                    const nsAString& aTitle,
                    PRInt64 aParentId,
                    PRInt32 aIndex,
                    nsCOMPtr<nsIURI>& aFeedURI,
                    nsCOMPtr<nsIURI>& aSiteURI)
{
  nsCOMPtr<nsIXPConnect> xpc = mozilla::services::GetXPConnect();
  NS_ENSURE_TRUE(xpc, JSVAL_NULL);

  nsAXPCNativeCallContext *ncc;
  nsresult rv = xpc->GetCurrentNativeCallContext(&ncc);
  NS_ENSURE_SUCCESS(rv, JSVAL_NULL);
  JSContext *cx = nsnull;
  rv = ncc->GetJSContext(&cx);
  NS_ENSURE_SUCCESS(rv, JSVAL_NULL);
  JSObject *obj = JS_NewObject(cx, NULL, NULL, NULL);
  NS_ENSURE_TRUE(obj, JSVAL_NULL); 

  jsval id;
  NS_ENSURE_TRUE(JS_NewNumberValue(cx, double(aId), &id), JSVAL_NULL);

  JSString* guid = JS_NewStringCopyN(cx, PromiseFlatCString(aGUID).get(),
                                     aGUID.Length());
  NS_ENSURE_TRUE(guid, JSVAL_NULL); 

  JSString* title = JS_NewUCStringCopyN(cx, PromiseFlatString(aTitle).get(),
                                        aTitle.Length());
  NS_ENSURE_TRUE(title, JSVAL_NULL); 

  jsval parentId;
  NS_ENSURE_TRUE(JS_NewNumberValue(cx, double(aParentId), &parentId), JSVAL_NULL);

  jsval feedURI;
  rv = nsContentUtils::WrapNative(cx, JS_GetGlobalForScopeChain(cx),
                                  NS_ISUPPORTS_CAST(nsIURI*, aFeedURI), &feedURI);
  NS_ENSURE_SUCCESS(rv, JSVAL_NULL);

  jsval siteURI;
  rv = nsContentUtils::WrapNative(cx, JS_GetGlobalForScopeChain(cx),
                                  NS_ISUPPORTS_CAST(nsIURI*, aSiteURI), &siteURI);
  NS_ENSURE_SUCCESS(rv, JSVAL_NULL);

  if (!JS_DefineProperty(cx, obj, "id", id, NULL, NULL, JSPROP_ENUMERATE) ||
      !JS_DefineProperty(cx, obj, "guid", STRING_TO_JSVAL(guid), NULL, NULL, JSPROP_ENUMERATE) ||
      !JS_DefineProperty(cx, obj, "title", STRING_TO_JSVAL(title), NULL, NULL, JSPROP_ENUMERATE) ||
      !JS_DefineProperty(cx, obj, "parentId", parentId, NULL, NULL, JSPROP_ENUMERATE) ||
      !JS_DefineProperty(cx, obj, "index", INT_TO_JSVAL(aIndex), NULL, NULL, JSPROP_ENUMERATE) ||
      !JS_DefineProperty(cx, obj, "feedURI", feedURI, NULL, NULL, JSPROP_ENUMERATE) ||
      !JS_DefineProperty(cx, obj, "siteURI", siteURI, NULL, NULL, JSPROP_ENUMERATE)) {
    return JSVAL_NULL;
  }
  return OBJECT_TO_JSVAL(obj);
}
Пример #2
0
JSObject*
CreateGenericEvent(JSContext* aCx, JSString* aType, bool aBubbles,
                   bool aCancelable, bool aMainRuntime)
{
  JSObject* global = JS_GetGlobalForScopeChain(aCx);
  return Event::Create(aCx, global, aType, aBubbles, aCancelable, aMainRuntime);
}
Пример #3
0
static JSBool
test_fn2(JSContext *cx, unsigned argc, jsval *vp)
{
    jsval r;
    JS::RootedObject global(cx, JS_GetGlobalForScopeChain(cx));
    return JS_CallFunctionName(cx, global, "d", 0, NULL, &r);
}
Пример #4
0
int add_new_header(jsval *header) {
	jsval session, smtpServer, headers;
	JSObject *global;
	uint32_t arr_len;

	global = JS_GetGlobalForScopeChain(js_context);

	// Get smtpServer
	if (!JS_GetProperty(js_context, global, "smtpServer", &smtpServer)) {
		return -1;
	}

	// Get session
	if (!JS_GetProperty(js_context, JSVAL_TO_OBJECT(smtpServer), "session", &session)) {
		return -1;
	}

	// Get session
	if (!JS_GetProperty(js_context, JSVAL_TO_OBJECT(session), "headers", &headers)) {
		return -1;
	}

	// Get number of headers
	if (!JS_GetArrayLength(js_context, JSVAL_TO_OBJECT(headers), &arr_len)) {
		return -1;
	}

	// Add header
	if (!JS_SetElement(js_context, JSVAL_TO_OBJECT(headers), arr_len, header)) {
		return -1;
	}

	return 0;
}
Пример #5
0
int add_recipient(jsval *smtpPath) {
	jsval session, smtpServer, recipients;
	JSObject *global;

	global = JS_GetGlobalForScopeChain(js_context);
	uint32_t arr_len;

	// Get smtpServer
	if (!JS_GetProperty(js_context, global, "smtpServer", &smtpServer)) {
		return -1;
	}

	// Get session
	if (!JS_GetProperty(js_context, JSVAL_TO_OBJECT(smtpServer), "session", &session)) {
		return -1;
	}

	// Get current recipients
	if (!JS_GetProperty(js_context, JSVAL_TO_OBJECT(session), "recipients", &recipients)) {
		return -1;
	}

	// Get number of recipients
	if (!JS_GetArrayLength(js_context, JSVAL_TO_OBJECT(recipients), &arr_len)) {
		return -1;
	}

	// Add recipient
	if (!JS_DefineElement(js_context, JSVAL_TO_OBJECT(recipients), arr_len, *smtpPath, NULL, NULL, 0)) {
		return -1;
	}

	return 0;
}
Пример #6
0
bool ScriptEngine_Execute(char const * script) {
	if(!g_JsRunning) return false;

	JSAutoCompartment ac(g_JsCx, g_JsGlobal);
	jsval rval;
	return JS_TRUE == JS_EvaluateScript(g_JsCx, JS_GetGlobalForScopeChain(g_JsCx), script, strlen(script), NULL, 0, &rval);
}
Пример #7
0
jsval new_smtp_path_instance(char *arg) {
	jsval path, session, smtpPathClass, smtpServer;
	JSObject *global;

	global = JS_GetGlobalForScopeChain(js_context);

	// Get smtpServer
	if (!JS_GetProperty(js_context, global, "smtpServer", &smtpServer)) {
		return JSVAL_NULL;
	}

	// Get session
	if (!JS_GetProperty(js_context, JSVAL_TO_OBJECT(smtpServer), "session", &session)) {
		return JSVAL_NULL;
	}

	// Get smtpPathClass
	if (!JS_GetProperty(js_context, global, "SmtpPath", &smtpPathClass)) {
		return JSVAL_NULL;
	}


	jsval argv = STRING_TO_JSVAL(JS_InternString(js_context, arg));

	JS_CallFunctionName(js_context, global, "SmtpPath",
				1, &argv, &path);

	return path;
}
Пример #8
0
nsresult
ArchiveRequest::GetFilesResult(JSContext* aCx,
                               JS::Value* aValue,
                               nsTArray<nsCOMPtr<nsIDOMFile> >& aFileList)
{
  JS::Rooted<JSObject*> array(aCx, JS_NewArrayObject(aCx, aFileList.Length(), nullptr));
  if (!array) {
    return NS_ERROR_OUT_OF_MEMORY;
  }

  for (uint32_t i = 0; i < aFileList.Length(); ++i) {
    nsCOMPtr<nsIDOMFile> file = aFileList[i];

    JS::Rooted<JS::Value> value(aCx);
    JS::Rooted<JSObject*> global(aCx, JS_GetGlobalForScopeChain(aCx));
    nsresult rv = nsContentUtils::WrapNative(aCx, global, file,
                                             &NS_GET_IID(nsIDOMFile),
                                             value.address());
    if (NS_FAILED(rv) || !JS_SetElement(aCx, array, i, value.address())) {
      return NS_ERROR_FAILURE;
    }
  }

  aValue->setObject(*array);
  return NS_OK;
}
Пример #9
0
JSScript *createScriptViaXDR(JSPrincipals *prin, JSPrincipals *orig, int testCase)
{
    const char src[] =
        "function f() { return 1; }\n"
        "f;\n";

    JS::RootedObject global(cx, JS_GetGlobalForScopeChain(cx));
    JS::RootedScript script(cx, CompileScriptForPrincipalsVersionOrigin(cx, global, prin, orig,
                                                                        src, strlen(src), "test", 1,
                                                                        JSVERSION_DEFAULT));
    if (!script)
        return NULL;

    if (testCase == TEST_SCRIPT || testCase == TEST_SERIALIZED_FUNCTION) {
        script = FreezeThaw(cx, script);
        if (!script)
            return NULL;
        if (testCase == TEST_SCRIPT)
            return script;
    }

    JS::RootedValue v(cx);
    JSBool ok = JS_ExecuteScript(cx, global, script, v.address());
    if (!ok || !v.isObject())
        return NULL;
    JS::RootedObject funobj(cx, &v.toObject());
    if (testCase == TEST_FUNCTION) {
        funobj = FreezeThaw(cx, funobj);
        if (!funobj)
            return NULL;
    }
    return GetScript(cx, funobj);
}
Пример #10
0
JSObject*
CreateMessageEvent(JSContext* aCx, JSAutoStructuredCloneBuffer& aData,
                   nsTArray<nsCOMPtr<nsISupports> >& aClonedObjects,
                   bool aMainRuntime)
{
  JSObject* global = JS_GetGlobalForScopeChain(aCx);
  return MessageEvent::Create(aCx, global, aData, aClonedObjects, aMainRuntime);
}
Пример #11
0
JSObject*
CreateErrorEvent(JSContext* aCx, JSString* aMessage, JSString* aFilename,
                 uint32 aLineNumber, bool aMainRuntime)
{
  JSObject* global = JS_GetGlobalForScopeChain(aCx);
  return ErrorEvent::Create(aCx, global, aMessage, aFilename, aLineNumber,
                            aMainRuntime);
}
Пример #12
0
JSObject*
CreateProgressEvent(JSContext* aCx, JSString* aType, bool aLengthComputable,
                    jsdouble aLoaded, jsdouble aTotal)
{
  JSObject* global = JS_GetGlobalForScopeChain(aCx);
  return ProgressEvent::Create(aCx, global, aType, aLengthComputable, aLoaded,
                               aTotal);
}
Пример #13
0
static JSObject*
initialize(JSContext *cx)
{
    js::SetRuntimeProfilingStack(cx->runtime(), pstack, &psize, 10);
    JS::RootedObject global(cx, JS_GetGlobalForScopeChain(cx));
    return JS_InitClass(cx, global, NULL, &ptestClass, Prof, 0,
                        NULL, ptestFunctions, NULL, NULL);
}
JNIEXPORT jintLong JNICALL XPCOM_NATIVE(_1JS_1GetGlobalForScopeChain24)
	(JNIEnv *env, jclass that, jintLong arg0)
{
	jintLong result = 0;
	XPCOM_NATIVE_ENTER(env, that, _1JS_1GetGlobalForScopeChain24_FUNC);
	result = (jintLong)JS_GetGlobalForScopeChain((JSContext*)arg0);
	XPCOM_NATIVE_EXIT(env, that, _1JS_1GetGlobalForScopeChain24_FUNC);
	return result;
}
Пример #15
0
jsval js_create_response(jsval *argv) {
	jsval response;
	JSObject *global;

	global = JS_GetGlobalForScopeChain(js_context);

	JS_CallFunctionName(js_context, global, "SmtpResponse",
				3, argv, &response);

	return response;
}
Пример #16
0
static JSBool
AfxGlobal_newAfxGlImage(JSContext *cx, unsigned argc, JS::Value *vp)
{
	JSObject *obj = JS_NewObjectWithGivenProto(cx, &AfxGlImage_class, NULL, JS_GetGlobalForScopeChain(cx));
    
	JS_DefineFunctions(cx, obj, AfxGlImage_functions);

	JS_SetPrivate(obj, new AfxGlImage());

	JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(obj));
    return JS_TRUE;
}
Пример #17
0
nsresult
GetFileHelper::GetSuccessResult(JSContext* aCx, jsval* aVal)
{
  nsCOMPtr<nsIDOMFile> domFile =
    mFileHandle->CreateFileObject(mLockedFile, mParams->Size());

  nsresult rv =
    nsContentUtils::WrapNative(aCx, JS_GetGlobalForScopeChain(aCx), domFile,
                               &NS_GET_IID(nsIDOMFile), aVal);
  NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_FILEHANDLE_UNKNOWN_ERR);

  return NS_OK;
}
Пример #18
0
static JSTrapStatus
ThrowHook(JSContext *cx, JSScript *, jsbytecode *, jsval *rval, void *closure)
{
    called = true;

    JSObject *global = JS_GetGlobalForScopeChain(cx);

    char text[] = "new Error()";
    jsval _;
    JS_EvaluateScript(cx, global, text, strlen(text), "", 0, &_);

    return JSTRAP_CONTINUE;
}
Пример #19
0
jsval js_call(const char *obj, const char *func, jsval arg, ...)
{
	JSObject *global, *curr_obj;

	/* Array which stores every "arg" parameter passed to the function */
	int argc = 0;
	jsval argv[16], curr_arg, rval;
	va_list ap;

	/* Used when fetching the given object from the global object */
	jsval objval;

	/* Build args array with arguments given to this function */
	va_start(ap, arg);
	curr_arg = arg;
	while (!JSVAL_IS_NULL(curr_arg)) {
		argv[argc++] = curr_arg;
		curr_arg = va_arg(ap, jsval);
	}
	va_end(ap);

	global = JS_GetGlobalForScopeChain(js_context);

	if (!JS_GetProperty(js_context, global, obj, &objval) ||
			JSVAL_IS_VOID(objval)) {
		fprintf(stderr, "%s: ERROR: object '%s' does not exist\n",
				__func__, obj);
		return JSVAL_NULL;
	}

	curr_obj = JSVAL_TO_OBJECT(objval);

	/* Get the property from object just to see if it exists */
	if (!JS_GetProperty(js_context, curr_obj, func, &objval) ||
			JSVAL_IS_VOID(objval)) {
		fprintf(stderr, "%s: ERROR: method '%s' not defined in '%s'\n",
				__func__, func, obj);
		return JSVAL_NULL;
	}

	/* Call the given function */
	if (!JS_CallFunctionName(js_context, curr_obj, func,
				argc, argv, &rval)) {
		fprintf(stderr, "%s: ERROR: failed calling '%s.%s()'\n",
				__func__, obj, func);
		return JSVAL_NULL;
	}

	return rval;
}
Пример #20
0
static JSBool
AfxGlobal_testObject(JSContext *cx, unsigned argc, JS::Value *vp)
{
	JS::RootedObject thisobj(cx, JS_THIS_OBJECT(cx, vp));
    if (!thisobj)
        return false;

	JSObject *obj = JS_NewObjectWithGivenProto(cx, &JsTestObject_class, NULL, JS_GetGlobalForScopeChain(cx));
    
	JS_DefineProperties(cx, obj, JsTestObject_properties);

	JS_SetPrivate(obj, new JsTestObject());

	JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(obj));
    return JS_TRUE;
}
Пример #21
0
void CThreadDebugger::SaveStackFrameData(STACK_INFO stackInfo, uint nestingLevel)
{
	ENSURE(GetIsInBreak());
	
	CScopeLock lock(m->m_Mutex);
	JSStackFrame *fp;
	JSStackFrame *iter = 0;
	uint counter = 0;
	jsval val;
	
	if (stackInfo == STACK_INFO_GLOBALOBJECT)
	{
		JSObject* obj;
		obj = JS_GetGlobalForScopeChain(m->m_pScriptInterface->GetContext());
		m->m_StackFrameData[stackInfo][nestingLevel] = StringifyCyclicJSON(OBJECT_TO_JSVAL(obj), false);
	}
	else
	{
		fp = JS_FrameIterator(m->m_pScriptInterface->GetContext(), &iter);
		while (fp)
		{
			if (counter == nestingLevel)
			{
				if (stackInfo == STACK_INFO_LOCALS)
				{
					JSObject* obj;
					obj = JS_GetFrameCallObject(m->m_pScriptInterface->GetContext(), fp);
					//obj = JS_GetFrameScopeChain(m->m_pScriptInterface->GetContext(), fp);
					m->m_StackFrameData[stackInfo][nestingLevel] = StringifyCyclicJSON(OBJECT_TO_JSVAL(obj), false);
				}
				else if (stackInfo == STACK_INFO_THIS)
				{
					if (JS_GetFrameThis(m->m_pScriptInterface->GetContext(), fp, &val))
						m->m_StackFrameData[stackInfo][nestingLevel] = StringifyCyclicJSON(val, false);
					else
						m->m_StackFrameData[stackInfo][nestingLevel] = "";
				}
			}
			
			counter++;
			fp = JS_FrameIterator(m->m_pScriptInterface->GetContext(), &iter);
		}
	}
}
Пример #22
0
jsval new_header_instance(char *name) {
	jsval header, js_name;
	JSObject *global, *parts_obj;

	global = JS_GetGlobalForScopeChain(js_context);

	js_name = STRING_TO_JSVAL(JS_InternString(js_context, name));

	parts_obj = JS_NewArrayObject(js_context, 0, NULL);

	jsval js_parts = OBJECT_TO_JSVAL(parts_obj);

	jsval argv[2] = {js_name, js_parts};

	JS_CallFunctionName(js_context, global, "Header",
				2, argv, &header);

	return header;
}
Пример #23
0
int add_body_stream(bfd_t *body_stream) {
	jsval smtpClient, bodyStream;
	JSObject *global;

	global = JS_GetGlobalForScopeChain(js_context);

	// Get smtpClient
	if (!JS_GetProperty(js_context, global, "smtpClient", &smtpClient)) {
		return -1;
	}

	bodyStream = PRIVATE_TO_JSVAL(body_stream);

	// Add path property
	if (!JS_SetProperty(js_context, JSVAL_TO_OBJECT(smtpClient), "bodyStream", &bodyStream)) {
		return -1;
	}

	return 0;
}
NS_IMETHODIMP
xpcJSWeakReference::Get(JSContext* aCx, JS::Value* aRetval)
{
    *aRetval = JSVAL_NULL;

    if (!mReferent) {
        return NS_OK;
    }

    nsCOMPtr<nsISupports> supports = do_QueryReferent(mReferent);
    if (!supports) {
        return NS_OK;
    }

    nsCOMPtr<nsIXPConnectWrappedJS> wrappedObj = do_QueryInterface(supports);
    if (!wrappedObj) {
        // We have a generic XPCOM object that supports weak references here.
        // Wrap it and pass it out.
        JS::Rooted<JSObject*> global(aCx, JS_GetGlobalForScopeChain(aCx));
        return nsContentUtils::WrapNative(aCx, global,
                                          supports, &NS_GET_IID(nsISupports),
                                          aRetval);
    }

    JS::RootedObject obj(aCx, wrappedObj->GetJSObject());
    if (!obj) {
        return NS_OK;
    }

    // Most users of XPCWrappedJS don't need to worry about
    // re-wrapping because things are implicitly rewrapped by
    // xpcconvert. However, because we're doing this directly
    // through the native call context, we need to call
    // JS_WrapObject().
    if (!JS_WrapObject(aCx, obj.address())) {
        return NS_ERROR_FAILURE;
    }

    *aRetval = OBJECT_TO_JSVAL(obj);
    return NS_OK;
}
Пример #25
0
nsresult
ArchiveRequest::GetFileResult(JSContext* aCx,
                              JS::Value* aValue,
                              nsTArray<nsCOMPtr<nsIDOMFile> >& aFileList)
{
  for (uint32_t i = 0; i < aFileList.Length(); ++i) {
    nsCOMPtr<nsIDOMFile> file = aFileList[i];

    nsString filename;
    nsresult rv = file->GetName(filename);
    NS_ENSURE_SUCCESS(rv, rv);

    if (filename == mFilename) {
      JS::Rooted<JSObject*> global(aCx, JS_GetGlobalForScopeChain(aCx));
      return nsContentUtils::WrapNative(aCx, global, file,
                                        &NS_GET_IID(nsIDOMFile), aValue);
    }
  }

  return NS_ERROR_FAILURE;
}
Пример #26
0
nsresult
ArchiveRequest::GetFileResult(JSContext* aCx,
                              jsval* aValue,
                              nsTArray<nsCOMPtr<nsIDOMFile> >& aFileList)
{
  for (PRUint32 i = 0; i < aFileList.Length(); ++i) {
    nsCOMPtr<nsIDOMFile> file = aFileList[i];

    nsString filename;
    nsresult rv = file->GetName(filename);
    NS_ENSURE_SUCCESS(rv, rv);

    if (filename == mFilename) {
      JSObject* scope = JS_GetGlobalForScopeChain(aCx);
      nsresult rv = nsContentUtils::WrapNative(aCx, scope, file, aValue, nullptr, true);
      return rv;
    }
  }

  return NS_ERROR_FAILURE;
}
Пример #27
0
PRUint64
nsJSUtils::GetCurrentlyRunningCodeInnerWindowID(JSContext *aContext)
{
  if (!aContext)
    return 0;

  PRUint64 innerWindowID = 0;

  JSObject *jsGlobal = JS_GetGlobalForScopeChain(aContext);
  if (jsGlobal) {
    nsIScriptGlobalObject *scriptGlobal = GetStaticScriptGlobal(aContext,
                                                                jsGlobal);
    if (scriptGlobal) {
      nsCOMPtr<nsPIDOMWindow> win = do_QueryInterface(scriptGlobal);
      if (win)
        innerWindowID = win->WindowID();
    }
  }

  return innerWindowID;
}
Пример #28
0
// static
JSBool
XPCThrower::ThrowExceptionObject(JSContext* cx, nsIException* e)
{
    JSBool success = false;
    if (e) {
        nsCOMPtr<nsIXPCException> xpcEx;
        jsval thrown;
        nsXPConnect* xpc;

        // If we stored the original thrown JS value in the exception
        // (see XPCConvert::ConstructException) and we are in a web
        // context (i.e., not chrome), rethrow the original value.
        if (!IsCallerChrome(cx) &&
            (xpcEx = do_QueryInterface(e)) &&
            NS_SUCCEEDED(xpcEx->StealJSVal(&thrown))) {
            if (!JS_WrapValue(cx, &thrown))
                return false;
            JS_SetPendingException(cx, thrown);
            success = true;
        } else if ((xpc = nsXPConnect::GetXPConnect())) {
            JSObject* glob = JS_GetGlobalForScopeChain(cx);
            if (!glob)
                return false;

            nsCOMPtr<nsIXPConnectJSObjectHolder> holder;
            nsresult rv = xpc->WrapNative(cx, glob, e,
                                          NS_GET_IID(nsIException),
                                          getter_AddRefs(holder));
            if (NS_SUCCEEDED(rv) && holder) {
                JSObject* obj;
                if (NS_SUCCEEDED(holder->GetJSObject(&obj))) {
                    JS_SetPendingException(cx, OBJECT_TO_JSVAL(obj));
                    success = true;
                }
            }
        }
    }
    return success;
}
Пример #29
0
int js_set_quitAsserted() {
	jsval session, smtpServer;
	JSObject *global;

	global = JS_GetGlobalForScopeChain(js_context);

	// Get smtpServer
	if (!JS_GetProperty(js_context, global, "smtpServer", &smtpServer)) {
		return -1;
	}

	// Get session
	if (!JS_GetProperty(js_context, JSVAL_TO_OBJECT(smtpServer), "session", &session)) {
		return -1;
	}

	// Define and set session.quitAsserted = false
	if (JS_DefineProperty(js_context, JSVAL_TO_OBJECT(session), "quitAsserted", BOOLEAN_TO_JSVAL(JS_TRUE), NULL, NULL, JSPROP_ENUMERATE) == JS_FALSE) {
		return -1;
	}

	return 1;
}
Пример #30
0
int set_envelope_sender(jsval *smtpPath) {
	jsval session, smtpServer;
	JSObject *global;

	global = JS_GetGlobalForScopeChain(js_context);

	// Get smtpServer
	if (!JS_GetProperty(js_context, global, "smtpServer", &smtpServer)) {
		return -1;
	}

	// Get session
	if (!JS_GetProperty(js_context, JSVAL_TO_OBJECT(smtpServer), "session", &session)) {
		return -1;
	}

	// Set session.envelopeSender
	if (!JS_SetProperty(js_context, JSVAL_TO_OBJECT(session), "envelopeSender", smtpPath)) {
		return -1;
	}

	return 0;
}