Bug 944164 - set the shell variable scriptPath to communicate the currently running script to the debugger, r=jorendorff
authorSteve Fink <sfink@mozilla.com>
Fri, 06 Dec 2013 17:00:49 -0800
changeset 266643 654dcfdaccca33ea15ef6aa167ea1c8d0955a578
parent 266642 bebc75f51b5d78b9420ceb101efc6ccff6a60652
child 266644 c68a6ebe60838c61b84699e3314d99ca18a6ff2d
push id830
push userraliiev@mozilla.com
push dateFri, 19 Jun 2015 19:24:37 +0000
treeherdermozilla-release@932614382a68 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjorendorff
bugs944164
milestone39.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 944164 - set the shell variable scriptPath to communicate the currently running script to the debugger, r=jorendorff
js/src/shell/js.cpp
--- a/js/src/shell/js.cpp
+++ b/js/src/shell/js.cpp
@@ -5700,16 +5700,30 @@ BindScriptArgs(JSContext *cx, OptionPars
         JS::RootedString str(cx, JS_NewStringCopyZ(cx, scriptArg));
         if (!str ||
             !JS_DefineElement(cx, scriptArgs, i, str, JSPROP_ENUMERATE))
         {
             return false;
         }
     }
 
+    const char *scriptPath = op->getStringArg("script");
+    RootedValue scriptPathValue(cx);
+    if (scriptPath) {
+        RootedString scriptPathString(cx, JS_NewStringCopyZ(cx, scriptPath));
+        if (!scriptPathString)
+            return false;
+        scriptPathValue = StringValue(scriptPathString);
+    } else {
+        scriptPathValue = UndefinedValue();
+    }
+
+    if (!JS_DefineProperty(cx, cx->global(), "scriptPath", scriptPathValue, 0))
+        return false;
+
     return true;
 }
 
 static bool
 OptionFailure(const char *option, const char *str)
 {
     fprintf(stderr, "Unrecognized option for %s: %s\n", option, str);
     return false;