summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorportix <portix@gmx.net>2014-03-07 11:34:44 +0100
committerportix <portix@gmx.net>2014-03-07 11:34:44 +0100
commit279e552445cd6a418b460a4c21b3c6f172a87c28 (patch)
tree89da458ed69e09bf5dee03a384a3936e9ef0a8ed
parent22f78b85919e459433d5e95035b112562a768cf5 (diff)
downloaddwb-279e552445cd6a418b460a4c21b3c6f172a87c28.zip
Don't inject scripts twice
-rw-r--r--src/scripts.c22
1 files changed, 9 insertions, 13 deletions
diff --git a/src/scripts.c b/src/scripts.c
index 23db74bc..16784fca 100644
--- a/src/scripts.c
+++ b/src/scripts.c
@@ -446,19 +446,15 @@ inject(JSContextRef ctx, JSContextRef wctx, JSObjectRef function, JSObjectRef th
}
script = JSStringCreateWithUTF8CString(body);
- JSEvaluateScript(wctx, script, NULL, NULL, 0, &e);
+ JSValueRef wret = JSEvaluateScript(wctx, script, NULL, NULL, 0, &e);
if (!global && e == NULL)
{
- JSValueRef wret = JSEvaluateScript(wctx, script, NULL, NULL, 0, &e);
- if (e == NULL)
+ char *retx = js_value_to_json(wctx, wret, -1, NULL);
+ // This could be replaced with js_context_change
+ if (retx)
{
- char *retx = js_value_to_json(wctx, wret, -1, NULL);
- // This could be replaced with js_context_change
- if (retx)
- {
- ret = js_char_to_value(ctx, retx);
- g_free(retx);
- }
+ ret = js_char_to_value(ctx, retx);
+ g_free(retx);
}
}
if (e != NULL && !isnan(debug) && debug > 0)
@@ -1754,11 +1750,11 @@ frame_get_host(JSContextRef ctx, JSObjectRef object, JSStringRef js_name, JSValu
* @example
* //!javascript
* function injectable() {
- * var text = arguments[0];
+ * var text = exports.text;
* document.body.innerHTML = text;
* }
* signals.connect("documentLoaded", function(wv) {
- * wv.inject(injectable, "foo", 3);
+ * wv.inject(injectable, { text : "foo", number : 37 }, 3);
* });
*
* @param {String|Function} code
@@ -1767,7 +1763,7 @@ frame_get_host(JSContextRef ctx, JSObjectRef object, JSStringRef js_name, JSValu
* @param {Object} arg
* If the script isn’t injected into the global scope the script is wrapped
* inside a function. arg then is accesible via arguments in the injected
- * script, or by the variable <i>exports</i> optional
+ * script, or by the variable <i>exports</i>, optional
* @param {Number} [line]
* Starting line number, useful for debugging. If linenumber is greater
* than 0 error messages will be printed to stderr, optional.