Bug 684465 - Add Reflect.parse support to xpcshell, r=jorendorff, bz
authorAlex Vincent <ajvincent@gmail.com>
Fri, 09 Sep 2011 15:11:00 -0700
changeset 77917 b384cfab8b1d5bfabd2229c8f84717a5442e5bb1
parent 77916 fd8e6806a30ba38cf115b98f6b50450b6d410f82
child 77918 5eba835c23a7a214156a4545d90fc626d78d5ca2
child 77920 7b9267933bb44fe14511997e8cf338b9bc3017b3
push id340
push userclegnitto@mozilla.com
push dateTue, 08 Nov 2011 22:56:33 +0000
treeherdermozilla-beta@f745dc151615 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjorendorff, bz
bugs684465
milestone9.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 684465 - Add Reflect.parse support to xpcshell, r=jorendorff, bz
js/src/xpconnect/shell/xpcshell.cpp
js/src/xpconnect/tests/unit/test_reflect_parse.js
js/src/xpconnect/tests/unit/xpcshell.ini
--- a/js/src/xpconnect/shell/xpcshell.cpp
+++ b/js/src/xpconnect/shell/xpcshell.cpp
@@ -1963,16 +1963,21 @@ main(int argc, char **argv, char **envp)
         JS_BeginRequest(cx);
         {
             JSAutoEnterCompartment ac;
             if (!ac.enter(cx, glob)) {
                 JS_EndRequest(cx);
                 return 1;
             }
 
+            if (!JS_InitReflect(cx, glob)) {
+                JS_EndRequest(cx);
+                return 1;
+            }
+
             if (!JS_DefineFunctions(cx, glob, glob_functions) ||
                 !JS_DefineProfilingFunctions(cx, glob)) {
                 JS_EndRequest(cx);
                 return 1;
             }
 
             envobj = JS_DefineObject(cx, glob, "environment", &env_class, NULL, 0);
             if (!envobj || !JS_SetPrivate(cx, envobj, envp)) {
new file mode 100644
--- /dev/null
+++ b/js/src/xpconnect/tests/unit/test_reflect_parse.js
@@ -0,0 +1,59 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is Test Reflect.parse in xpcshell.
+ *
+ * The Initial Developer of the Original Code is
+ * Alexander J. Vincent <ajvincent@gmail.com>.
+ * Portions created by the Initial Developer are Copyright (C) 2011
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+/*
+({
+  loc:{start:{line:1, column:0}, end:{line:1, column:12}, source:null},
+  type:"Program",
+  body:[
+    {
+      loc:{start:{line:1, column:0}, end:{line:1, column:12}, source:null},
+      type:"ExpressionStatement",
+      expression:{
+        loc:{start:{line:1, column:0}, end:{line:1, column:12}, source:null},
+        type:"Literal",
+        value:"use strict"
+      }
+    }
+  ]
+})
+*/
+
+function run_test() {
+  // Reflect.parse is better tested in js shell; this basically tests its presence.
+  var parseData = Reflect.parse('"use strict"');
+  do_check_eq(parseData.body[0].expression.value, "use strict");
+}
--- a/js/src/xpconnect/tests/unit/xpcshell.ini
+++ b/js/src/xpconnect/tests/unit/xpcshell.ini
@@ -9,14 +9,15 @@ tail =
 [test_bug604362.js]
 [test_bug608142.js]
 [test_bug641378.js]
 [test_bug677864.js]
 [test_bug_442086.js]
 [test_file.js]
 [test_import.js]
 [test_js_weak_references.js]
+[test_reflect_parse.js]
 [test_localeCompare.js]
 # Bug 676965: test fails consistently on Android
 fail-if = os == "android"
 [test_recursive_import.js]
 [test_xpcomutils.js]
 [test_unload.js]