johnson 1.2.0 → 2.0.0.pre0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (782) hide show
  1. data/CHANGELOG.rdoc +8 -0
  2. data/Manifest.txt +762 -48
  3. data/README.rdoc +2 -1
  4. data/Rakefile +90 -18
  5. data/ext/spidermonkey/conversions.c +9 -2
  6. data/ext/spidermonkey/ruby_land_proxy.c +1 -1
  7. data/ext/spidermonkey/runtime.h +1 -1
  8. data/ext/tracemonkey/context.cc +125 -0
  9. data/ext/tracemonkey/context.h +19 -0
  10. data/ext/tracemonkey/conversions.cc +365 -0
  11. data/ext/tracemonkey/conversions.h +32 -0
  12. data/ext/tracemonkey/debugger.cc +234 -0
  13. data/ext/tracemonkey/debugger.h +10 -0
  14. data/ext/tracemonkey/extconf.rb +37 -0
  15. data/ext/tracemonkey/extensions.cc +37 -0
  16. data/ext/tracemonkey/extensions.h +12 -0
  17. data/ext/tracemonkey/global.cc +40 -0
  18. data/ext/tracemonkey/global.h +11 -0
  19. data/ext/tracemonkey/idhash.cc +16 -0
  20. data/ext/tracemonkey/idhash.h +8 -0
  21. data/ext/tracemonkey/immutable_node.cc +1199 -0
  22. data/ext/tracemonkey/immutable_node.cc.erb +559 -0
  23. data/ext/tracemonkey/immutable_node.h +22 -0
  24. data/ext/tracemonkey/jroot.h +215 -0
  25. data/ext/tracemonkey/js_land_proxy.cc +620 -0
  26. data/ext/tracemonkey/js_land_proxy.h +20 -0
  27. data/ext/tracemonkey/ruby_land_proxy.cc +618 -0
  28. data/ext/tracemonkey/ruby_land_proxy.h +38 -0
  29. data/ext/tracemonkey/runtime.cc +454 -0
  30. data/ext/tracemonkey/runtime.h +27 -0
  31. data/ext/tracemonkey/split_global.cc +392 -0
  32. data/ext/tracemonkey/split_global.h +11 -0
  33. data/ext/tracemonkey/tracemonkey.cc +23 -0
  34. data/ext/tracemonkey/tracemonkey.h +32 -0
  35. data/lib/johnson.rb +12 -4
  36. data/lib/johnson/error.rb +5 -0
  37. data/lib/johnson/js/prelude.js +16 -1
  38. data/lib/johnson/parser.rb +2 -1
  39. data/lib/johnson/runtime.rb +87 -26
  40. data/lib/johnson/spidermonkey/runtime.rb +7 -16
  41. data/lib/johnson/tracemonkey.rb +13 -0
  42. data/lib/johnson/tracemonkey/context.rb +10 -0
  43. data/lib/johnson/tracemonkey/debugger.rb +67 -0
  44. data/lib/johnson/tracemonkey/immutable_node.rb +282 -0
  45. data/lib/johnson/tracemonkey/js_land_proxy.rb +64 -0
  46. data/lib/johnson/tracemonkey/mutable_tree_visitor.rb +242 -0
  47. data/lib/johnson/tracemonkey/ruby_land_proxy.rb +17 -0
  48. data/lib/johnson/tracemonkey/runtime.rb +80 -0
  49. data/test/{johnson_test.rb → generic/johnson_test.rb} +1 -1
  50. data/test/{parser_test.rb → generic/parser_test.rb} +1 -1
  51. data/test/helper.rb +23 -4
  52. data/test/johnson/{browser_test.rb → generic/browser_test.rb} +1 -1
  53. data/test/johnson/{conversions → generic/conversions}/array_test.rb +1 -1
  54. data/test/johnson/{conversions → generic/conversions}/boolean_test.rb +1 -1
  55. data/test/johnson/{conversions → generic/conversions}/callable_test.rb +1 -1
  56. data/test/johnson/{conversions → generic/conversions}/file_test.rb +1 -1
  57. data/test/johnson/generic/conversions/helper.rb +1 -0
  58. data/test/johnson/{conversions → generic/conversions}/nil_test.rb +1 -1
  59. data/test/johnson/{conversions → generic/conversions}/number_test.rb +1 -1
  60. data/test/johnson/{conversions → generic/conversions}/regexp_test.rb +1 -1
  61. data/test/johnson/{conversions → generic/conversions}/string_test.rb +1 -1
  62. data/test/johnson/{conversions → generic/conversions}/struct_test.rb +1 -1
  63. data/test/johnson/{conversions → generic/conversions}/symbol_test.rb +1 -1
  64. data/test/johnson/{conversions → generic/conversions}/thread_test.rb +1 -1
  65. data/test/johnson/{custom_conversions_test.rb → generic/custom_conversions_test.rb} +1 -1
  66. data/test/johnson/generic/default_test.rb +12 -0
  67. data/test/johnson/{error_test.rb → generic/error_test.rb} +1 -1
  68. data/test/johnson/{extensions_test.rb → generic/extensions_test.rb} +1 -1
  69. data/test/johnson/generic/helper.rb +1 -0
  70. data/test/johnson/{nodes → generic/nodes}/array_literal_test.rb +1 -1
  71. data/test/johnson/{nodes → generic/nodes}/array_node_test.rb +1 -1
  72. data/test/johnson/{nodes → generic/nodes}/binary_node_test.rb +1 -1
  73. data/test/johnson/{nodes → generic/nodes}/bracket_access_test.rb +1 -1
  74. data/test/johnson/{nodes → generic/nodes}/delete_test.rb +1 -1
  75. data/test/johnson/{nodes → generic/nodes}/do_while_test.rb +1 -1
  76. data/test/johnson/{nodes → generic/nodes}/dot_accessor_test.rb +1 -1
  77. data/test/johnson/generic/nodes/export_test.rb +11 -0
  78. data/test/johnson/{nodes → generic/nodes}/for_test.rb +1 -1
  79. data/test/johnson/{nodes → generic/nodes}/function_test.rb +1 -1
  80. data/test/johnson/generic/nodes/helper.rb +1 -0
  81. data/test/johnson/{nodes → generic/nodes}/if_test.rb +16 -6
  82. data/test/johnson/generic/nodes/import_test.rb +15 -0
  83. data/test/johnson/{nodes → generic/nodes}/label_test.rb +1 -1
  84. data/test/johnson/{nodes → generic/nodes}/let_test.rb +1 -1
  85. data/test/johnson/{nodes → generic/nodes}/object_literal_test.rb +1 -1
  86. data/test/johnson/{nodes → generic/nodes}/return_test.rb +1 -1
  87. data/test/johnson/{nodes → generic/nodes}/semi_test.rb +1 -1
  88. data/test/johnson/{nodes → generic/nodes}/switch_test.rb +1 -1
  89. data/test/johnson/{nodes → generic/nodes}/ternary_test.rb +1 -1
  90. data/test/johnson/{nodes → generic/nodes}/throw_test.rb +1 -1
  91. data/test/johnson/{nodes → generic/nodes}/try_node_test.rb +36 -6
  92. data/test/johnson/{nodes → generic/nodes}/typeof_test.rb +1 -1
  93. data/test/johnson/{nodes → generic/nodes}/unary_node_test.rb +1 -1
  94. data/test/johnson/{nodes → generic/nodes}/void_test.rb +1 -1
  95. data/test/johnson/{nodes → generic/nodes}/while_test.rb +1 -1
  96. data/test/johnson/{nodes → generic/nodes}/with_test.rb +1 -1
  97. data/test/johnson/{prelude_test.rb → generic/prelude_test.rb} +1 -1
  98. data/test/johnson/{runtime_test.rb → generic/runtime_test.rb} +3 -6
  99. data/test/johnson/generic/version_test.rb +13 -0
  100. data/test/johnson/{visitors → generic/visitors}/dot_visitor_test.rb +1 -1
  101. data/test/johnson/{visitors → generic/visitors}/enumerating_visitor_test.rb +1 -1
  102. data/test/johnson/generic/visitors/helper.rb +1 -0
  103. data/test/johnson/spidermonkey/js_land_proxy_test.rb +1 -5
  104. data/test/johnson/spidermonkey/ruby_land_proxy_test.rb +11 -7
  105. data/test/johnson/tracemonkey/context_test.rb +21 -0
  106. data/test/johnson/tracemonkey/immutable_node_test.rb +34 -0
  107. data/test/johnson/tracemonkey/js_land_proxy_test.rb +273 -0
  108. data/test/johnson/tracemonkey/ruby_land_proxy_test.rb +274 -0
  109. data/test/johnson/tracemonkey/runtime_test.rb +41 -0
  110. data/test/johnson/tracemonkey/split_global_test.rb +32 -0
  111. data/vendor/spidermonkey/js.pkg +2 -0
  112. data/vendor/tracemonkey/Makefile.in +668 -0
  113. data/vendor/tracemonkey/Makefile.ref +483 -0
  114. data/vendor/tracemonkey/README.html +54 -0
  115. data/vendor/tracemonkey/SpiderMonkey.rsp +11 -0
  116. data/vendor/tracemonkey/Y.js +19 -0
  117. data/vendor/tracemonkey/aclocal.m4 +9 -0
  118. data/vendor/tracemonkey/bench.sh +5 -0
  119. data/vendor/tracemonkey/build/autoconf/acoutput-fast.pl +202 -0
  120. data/vendor/tracemonkey/build/autoconf/altoptions.m4 +154 -0
  121. data/vendor/tracemonkey/build/autoconf/config.guess +1537 -0
  122. data/vendor/tracemonkey/build/autoconf/config.sub +1595 -0
  123. data/vendor/tracemonkey/build/autoconf/install-sh +119 -0
  124. data/vendor/tracemonkey/build/autoconf/make-makefile +315 -0
  125. data/vendor/tracemonkey/build/autoconf/match-dir.sh +101 -0
  126. data/vendor/tracemonkey/build/autoconf/moznbytetype.m4 +136 -0
  127. data/vendor/tracemonkey/build/autoconf/nspr.m4 +82 -0
  128. data/vendor/tracemonkey/build/autoconf/pkg.m4 +59 -0
  129. data/vendor/tracemonkey/build/autoconf/update-makefile.sh +118 -0
  130. data/vendor/tracemonkey/build/cygwin-wrapper +75 -0
  131. data/vendor/tracemonkey/build/hcc +111 -0
  132. data/vendor/tracemonkey/build/hcpp +155 -0
  133. data/vendor/tracemonkey/build/unix/mddepend.pl +165 -0
  134. data/vendor/tracemonkey/build/unix/uniq.pl +63 -0
  135. data/vendor/tracemonkey/build/win32/pgomerge.py +40 -0
  136. data/vendor/tracemonkey/builtins.tbl +91 -0
  137. data/vendor/tracemonkey/call.js +13 -0
  138. data/vendor/tracemonkey/config.mk +206 -0
  139. data/vendor/tracemonkey/config/Makefile.in +106 -0
  140. data/vendor/tracemonkey/config/Moz/Milestone.pm +232 -0
  141. data/vendor/tracemonkey/config/autoconf.mk.in +362 -0
  142. data/vendor/tracemonkey/config/check-sync-dirs.py +103 -0
  143. data/vendor/tracemonkey/config/check-sync-exceptions +7 -0
  144. data/vendor/tracemonkey/config/config.mk +881 -0
  145. data/vendor/tracemonkey/config/fastcwd.pl +66 -0
  146. data/vendor/tracemonkey/config/gcc_hidden.h +2 -0
  147. data/vendor/tracemonkey/config/insure.mk +53 -0
  148. data/vendor/tracemonkey/config/make-system-wrappers.pl +59 -0
  149. data/vendor/tracemonkey/config/milestone.pl +112 -0
  150. data/vendor/tracemonkey/config/milestone.txt +13 -0
  151. data/vendor/tracemonkey/config/mkdepend/Makefile.in +84 -0
  152. data/vendor/tracemonkey/config/mkdepend/cppsetup.c +233 -0
  153. data/vendor/tracemonkey/config/mkdepend/def.h +184 -0
  154. data/vendor/tracemonkey/config/mkdepend/ifparser.c +551 -0
  155. data/vendor/tracemonkey/config/mkdepend/ifparser.h +83 -0
  156. data/vendor/tracemonkey/config/mkdepend/imakemdep.h +733 -0
  157. data/vendor/tracemonkey/config/mkdepend/include.c +337 -0
  158. data/vendor/tracemonkey/config/mkdepend/main.c +860 -0
  159. data/vendor/tracemonkey/config/mkdepend/mkdepend.man +382 -0
  160. data/vendor/tracemonkey/config/mkdepend/parse.c +686 -0
  161. data/vendor/tracemonkey/config/mkdepend/pr.c +124 -0
  162. data/vendor/tracemonkey/config/nfspwd.pl +50 -0
  163. data/vendor/tracemonkey/config/nsinstall.c +481 -0
  164. data/vendor/tracemonkey/config/nsinstall.py +155 -0
  165. data/vendor/tracemonkey/config/pathsub.c +247 -0
  166. data/vendor/tracemonkey/config/pathsub.h +74 -0
  167. data/vendor/tracemonkey/config/preprocessor.pl +671 -0
  168. data/vendor/tracemonkey/config/revdepth-nt.pl +48 -0
  169. data/vendor/tracemonkey/config/revdepth.pl +51 -0
  170. data/vendor/tracemonkey/config/rules.mk +2310 -0
  171. data/vendor/tracemonkey/config/static-checking-config.mk +21 -0
  172. data/vendor/tracemonkey/config/static-checking.js +92 -0
  173. data/vendor/tracemonkey/config/string-format.js +61 -0
  174. data/vendor/tracemonkey/config/system-headers +1035 -0
  175. data/vendor/tracemonkey/config/version.mk +85 -0
  176. data/vendor/tracemonkey/config/version_win.pl +442 -0
  177. data/vendor/tracemonkey/configure +14183 -0
  178. data/vendor/tracemonkey/configure.in +5363 -0
  179. data/vendor/tracemonkey/correct.sh +23 -0
  180. data/vendor/tracemonkey/correct/check-3d-morph.js +55 -0
  181. data/vendor/tracemonkey/correct/check-3d-raytrace.js +445 -0
  182. data/vendor/tracemonkey/correct/check-access-binary-trees.js +52 -0
  183. data/vendor/tracemonkey/correct/check-access-fannkuch.js +66 -0
  184. data/vendor/tracemonkey/correct/check-access-nbody.js +171 -0
  185. data/vendor/tracemonkey/correct/check-access-nsieve.js +40 -0
  186. data/vendor/tracemonkey/correct/check-bitops-3bit-bits-in-byte.js +35 -0
  187. data/vendor/tracemonkey/correct/check-bitops-bits-in-byte.js +24 -0
  188. data/vendor/tracemonkey/correct/check-bitops-bitwise-and.js +29 -0
  189. data/vendor/tracemonkey/correct/check-bitops-nsieve-bits.js +40 -0
  190. data/vendor/tracemonkey/correct/check-controlflow-recursive.js +27 -0
  191. data/vendor/tracemonkey/correct/check-date-format-tofte.js +302 -0
  192. data/vendor/tracemonkey/correct/check-date-format-xparb.js +421 -0
  193. data/vendor/tracemonkey/correct/check-mont.js +119 -0
  194. data/vendor/tracemonkey/dtoa.c +3335 -0
  195. data/vendor/tracemonkey/editline/Makefile.in +55 -0
  196. data/vendor/tracemonkey/editline/Makefile.ref +143 -0
  197. data/vendor/tracemonkey/editline/README +83 -0
  198. data/vendor/tracemonkey/editline/editline.3 +175 -0
  199. data/vendor/tracemonkey/editline/editline.c +1371 -0
  200. data/vendor/tracemonkey/editline/editline.h +135 -0
  201. data/vendor/tracemonkey/editline/sysunix.c +182 -0
  202. data/vendor/tracemonkey/editline/unix.h +82 -0
  203. data/vendor/tracemonkey/if.js +13 -0
  204. data/vendor/tracemonkey/imacro_asm.js.in +396 -0
  205. data/vendor/tracemonkey/imacros.c.out +1034 -0
  206. data/vendor/tracemonkey/imacros.jsasm +770 -0
  207. data/vendor/tracemonkey/javascript-trace.d +73 -0
  208. data/vendor/tracemonkey/jitstats.tbl +55 -0
  209. data/vendor/tracemonkey/js-config.h.in +82 -0
  210. data/vendor/tracemonkey/js-config.in +111 -0
  211. data/vendor/tracemonkey/js.mdp +0 -0
  212. data/vendor/tracemonkey/js.msg +312 -0
  213. data/vendor/tracemonkey/js3240.rc +79 -0
  214. data/vendor/tracemonkey/jsOS240.def +654 -0
  215. data/vendor/tracemonkey/jsapi.cpp +6005 -0
  216. data/vendor/tracemonkey/jsapi.h +2727 -0
  217. data/vendor/tracemonkey/jsarena.cpp +450 -0
  218. data/vendor/tracemonkey/jsarena.h +318 -0
  219. data/vendor/tracemonkey/jsarray.cpp +3664 -0
  220. data/vendor/tracemonkey/jsarray.h +238 -0
  221. data/vendor/tracemonkey/jsatom.cpp +1244 -0
  222. data/vendor/tracemonkey/jsatom.h +493 -0
  223. data/vendor/tracemonkey/jsbit.h +249 -0
  224. data/vendor/tracemonkey/jsbool.cpp +184 -0
  225. data/vendor/tracemonkey/jsbool.h +88 -0
  226. data/vendor/tracemonkey/jsbuiltins.cpp +415 -0
  227. data/vendor/tracemonkey/jsbuiltins.h +456 -0
  228. data/vendor/tracemonkey/jsclist.h +139 -0
  229. data/vendor/tracemonkey/jscntxt.cpp +1816 -0
  230. data/vendor/tracemonkey/jscntxt.h +1541 -0
  231. data/vendor/tracemonkey/jscompat.h +57 -0
  232. data/vendor/tracemonkey/jsconfig.mk +181 -0
  233. data/vendor/tracemonkey/jscpucfg.cpp +194 -0
  234. data/vendor/tracemonkey/jscpucfg.h +91 -0
  235. data/vendor/tracemonkey/jsdate.cpp +2465 -0
  236. data/vendor/tracemonkey/jsdate.h +129 -0
  237. data/vendor/tracemonkey/jsdbgapi.cpp +2017 -0
  238. data/vendor/tracemonkey/jsdbgapi.h +500 -0
  239. data/vendor/tracemonkey/jsdhash.cpp +876 -0
  240. data/vendor/tracemonkey/jsdhash.h +588 -0
  241. data/vendor/tracemonkey/jsdtoa.cpp +572 -0
  242. data/vendor/tracemonkey/jsdtoa.h +131 -0
  243. data/vendor/tracemonkey/jsdtracef.c +318 -0
  244. data/vendor/tracemonkey/jsdtracef.h +81 -0
  245. data/vendor/tracemonkey/jsemit.cpp +7292 -0
  246. data/vendor/tracemonkey/jsemit.h +802 -0
  247. data/vendor/tracemonkey/jsexn.cpp +1337 -0
  248. data/vendor/tracemonkey/jsexn.h +96 -0
  249. data/vendor/tracemonkey/jsfile.cpp +2747 -0
  250. data/vendor/tracemonkey/jsfile.h +56 -0
  251. data/vendor/tracemonkey/jsfile.msg +90 -0
  252. data/vendor/tracemonkey/jsfun.cpp +3089 -0
  253. data/vendor/tracemonkey/jsfun.h +366 -0
  254. data/vendor/tracemonkey/jsgc.cpp +3816 -0
  255. data/vendor/tracemonkey/jsgc.h +429 -0
  256. data/vendor/tracemonkey/jshash.cpp +477 -0
  257. data/vendor/tracemonkey/jshash.h +151 -0
  258. data/vendor/tracemonkey/jsify.pl +483 -0
  259. data/vendor/tracemonkey/jsinterp.cpp +7441 -0
  260. data/vendor/tracemonkey/jsinterp.h +666 -0
  261. data/vendor/tracemonkey/jsinvoke.cpp +42 -0
  262. data/vendor/tracemonkey/jsiter.cpp +1040 -0
  263. data/vendor/tracemonkey/jsiter.h +140 -0
  264. data/vendor/tracemonkey/jskeyword.tbl +124 -0
  265. data/vendor/tracemonkey/jskwgen.cpp +460 -0
  266. data/vendor/tracemonkey/jslibmath.h +69 -0
  267. data/vendor/tracemonkey/jslock.cpp +1512 -0
  268. data/vendor/tracemonkey/jslock.h +325 -0
  269. data/vendor/tracemonkey/jslocko.asm +60 -0
  270. data/vendor/tracemonkey/jslog2.cpp +111 -0
  271. data/vendor/tracemonkey/jslong.h +167 -0
  272. data/vendor/tracemonkey/jsmath.cpp +806 -0
  273. data/vendor/tracemonkey/jsmath.h +63 -0
  274. data/vendor/tracemonkey/jsnum.cpp +1374 -0
  275. data/vendor/tracemonkey/jsnum.h +280 -0
  276. data/vendor/tracemonkey/jsobj.cpp +6165 -0
  277. data/vendor/tracemonkey/jsobj.h +870 -0
  278. data/vendor/tracemonkey/json.cpp +1338 -0
  279. data/vendor/tracemonkey/json.h +108 -0
  280. data/vendor/tracemonkey/jsopcode.cpp +5484 -0
  281. data/vendor/tracemonkey/jsopcode.h +434 -0
  282. data/vendor/tracemonkey/jsopcode.tbl +591 -0
  283. data/vendor/tracemonkey/jsoplengen.cpp +121 -0
  284. data/vendor/tracemonkey/jsotypes.h +202 -0
  285. data/vendor/tracemonkey/jsparse.cpp +9257 -0
  286. data/vendor/tracemonkey/jsparse.h +900 -0
  287. data/vendor/tracemonkey/jsprf.cpp +1262 -0
  288. data/vendor/tracemonkey/jsprf.h +150 -0
  289. data/vendor/tracemonkey/jsproto.tbl +117 -0
  290. data/vendor/tracemonkey/jsprvtd.h +366 -0
  291. data/vendor/tracemonkey/jspubtd.h +585 -0
  292. data/vendor/tracemonkey/jsregexp.cpp +5051 -0
  293. data/vendor/tracemonkey/jsregexp.h +199 -0
  294. data/vendor/tracemonkey/jsreops.tbl +145 -0
  295. data/vendor/tracemonkey/jsscan.cpp +2040 -0
  296. data/vendor/tracemonkey/jsscan.h +467 -0
  297. data/vendor/tracemonkey/jsscope.cpp +1966 -0
  298. data/vendor/tracemonkey/jsscope.h +487 -0
  299. data/vendor/tracemonkey/jsscript.cpp +1932 -0
  300. data/vendor/tracemonkey/jsscript.h +345 -0
  301. data/vendor/tracemonkey/jsshell.msg +54 -0
  302. data/vendor/tracemonkey/jsstack.js +167 -0
  303. data/vendor/tracemonkey/jsstaticcheck.h +69 -0
  304. data/vendor/tracemonkey/jsstddef.h +87 -0
  305. data/vendor/tracemonkey/jsstdint.h +96 -0
  306. data/vendor/tracemonkey/jsstr.cpp +5277 -0
  307. data/vendor/tracemonkey/jsstr.h +702 -0
  308. data/vendor/tracemonkey/jstracer.cpp +10991 -0
  309. data/vendor/tracemonkey/jstracer.h +794 -0
  310. data/vendor/tracemonkey/jstypes.h +481 -0
  311. data/vendor/tracemonkey/jsutil.cpp +361 -0
  312. data/vendor/tracemonkey/jsutil.h +178 -0
  313. data/vendor/tracemonkey/jsversion.h +243 -0
  314. data/vendor/tracemonkey/jswince.asm +44 -0
  315. data/vendor/tracemonkey/jsxdrapi.cpp +800 -0
  316. data/vendor/tracemonkey/jsxdrapi.h +220 -0
  317. data/vendor/tracemonkey/jsxml.cpp +8327 -0
  318. data/vendor/tracemonkey/jsxml.h +305 -0
  319. data/vendor/tracemonkey/liveconnect/LiveConnect.dsp +157 -0
  320. data/vendor/tracemonkey/liveconnect/LiveConnectShell.dsp +120 -0
  321. data/vendor/tracemonkey/liveconnect/LiveConnectShell.dsw +44 -0
  322. data/vendor/tracemonkey/liveconnect/Makefile.in +105 -0
  323. data/vendor/tracemonkey/liveconnect/Makefile.ref +169 -0
  324. data/vendor/tracemonkey/liveconnect/README.html +712 -0
  325. data/vendor/tracemonkey/liveconnect/_jni/netscape_javascript_JSException.h +14 -0
  326. data/vendor/tracemonkey/liveconnect/_jni/netscape_javascript_JSObject.h +155 -0
  327. data/vendor/tracemonkey/liveconnect/classes/Makefile.in +89 -0
  328. data/vendor/tracemonkey/liveconnect/classes/Makefile.ref +57 -0
  329. data/vendor/tracemonkey/liveconnect/classes/netscape/Makefile.ref +47 -0
  330. data/vendor/tracemonkey/liveconnect/classes/netscape/javascript/JSException.java +140 -0
  331. data/vendor/tracemonkey/liveconnect/classes/netscape/javascript/JSObject.java +183 -0
  332. data/vendor/tracemonkey/liveconnect/classes/netscape/javascript/JSProxy.java +58 -0
  333. data/vendor/tracemonkey/liveconnect/classes/netscape/javascript/JSRunnable.java +70 -0
  334. data/vendor/tracemonkey/liveconnect/classes/netscape/javascript/JSUtil.java +59 -0
  335. data/vendor/tracemonkey/liveconnect/classes/netscape/javascript/Makefile.ref +53 -0
  336. data/vendor/tracemonkey/liveconnect/config/AIX4.1.mk +45 -0
  337. data/vendor/tracemonkey/liveconnect/config/AIX4.2.mk +45 -0
  338. data/vendor/tracemonkey/liveconnect/config/AIX4.3.mk +50 -0
  339. data/vendor/tracemonkey/liveconnect/config/HP-UXB.10.10.mk +43 -0
  340. data/vendor/tracemonkey/liveconnect/config/HP-UXB.10.20.mk +43 -0
  341. data/vendor/tracemonkey/liveconnect/config/HP-UXB.11.00.mk +43 -0
  342. data/vendor/tracemonkey/liveconnect/config/IRIX6.2.mk +43 -0
  343. data/vendor/tracemonkey/liveconnect/config/IRIX6.3.mk +43 -0
  344. data/vendor/tracemonkey/liveconnect/config/IRIX6.5.mk +43 -0
  345. data/vendor/tracemonkey/liveconnect/config/Linux_All.mk +73 -0
  346. data/vendor/tracemonkey/liveconnect/config/OSF1V4.0.mk +65 -0
  347. data/vendor/tracemonkey/liveconnect/config/OSF1V5.0.mk +62 -0
  348. data/vendor/tracemonkey/liveconnect/config/SunOS5.5.1.mk +55 -0
  349. data/vendor/tracemonkey/liveconnect/config/SunOS5.6.mk +39 -0
  350. data/vendor/tracemonkey/liveconnect/config/SunOS5.7.mk +39 -0
  351. data/vendor/tracemonkey/liveconnect/config/SunOS5.8.mk +39 -0
  352. data/vendor/tracemonkey/liveconnect/config/WINNT4.0.mk +53 -0
  353. data/vendor/tracemonkey/liveconnect/jsj.c +886 -0
  354. data/vendor/tracemonkey/liveconnect/jsj.msg +98 -0
  355. data/vendor/tracemonkey/liveconnect/jsj_JSObject.c +1377 -0
  356. data/vendor/tracemonkey/liveconnect/jsj_JavaArray.c +474 -0
  357. data/vendor/tracemonkey/liveconnect/jsj_JavaClass.c +737 -0
  358. data/vendor/tracemonkey/liveconnect/jsj_JavaMember.c +191 -0
  359. data/vendor/tracemonkey/liveconnect/jsj_JavaObject.c +1079 -0
  360. data/vendor/tracemonkey/liveconnect/jsj_JavaPackage.c +569 -0
  361. data/vendor/tracemonkey/liveconnect/jsj_array.c +207 -0
  362. data/vendor/tracemonkey/liveconnect/jsj_class.c +770 -0
  363. data/vendor/tracemonkey/liveconnect/jsj_convert.c +902 -0
  364. data/vendor/tracemonkey/liveconnect/jsj_field.c +421 -0
  365. data/vendor/tracemonkey/liveconnect/jsj_hash.c +488 -0
  366. data/vendor/tracemonkey/liveconnect/jsj_hash.h +161 -0
  367. data/vendor/tracemonkey/liveconnect/jsj_method.c +1825 -0
  368. data/vendor/tracemonkey/liveconnect/jsj_nodl.c +1 -0
  369. data/vendor/tracemonkey/liveconnect/jsj_private.h +677 -0
  370. data/vendor/tracemonkey/liveconnect/jsj_simpleapi.c +219 -0
  371. data/vendor/tracemonkey/liveconnect/jsj_utils.c +513 -0
  372. data/vendor/tracemonkey/liveconnect/jsjava.h +316 -0
  373. data/vendor/tracemonkey/liveconnect/netscape_javascript_JSObject.h +155 -0
  374. data/vendor/tracemonkey/liveconnect/nsCLiveconnect.cpp +785 -0
  375. data/vendor/tracemonkey/liveconnect/nsCLiveconnect.h +197 -0
  376. data/vendor/tracemonkey/liveconnect/nsCLiveconnectFactory.cpp +118 -0
  377. data/vendor/tracemonkey/liveconnect/nsCLiveconnectFactory.h +76 -0
  378. data/vendor/tracemonkey/liveconnect/nsILiveconnect.h +197 -0
  379. data/vendor/tracemonkey/liveconnect/nsISecureLiveconnect.h +94 -0
  380. data/vendor/tracemonkey/liveconnect/nsISecurityContext.h +136 -0
  381. data/vendor/tracemonkey/lock_SunOS.s +119 -0
  382. data/vendor/tracemonkey/mandelbrot-results.js +3 -0
  383. data/vendor/tracemonkey/math-partial-sums.js +32 -0
  384. data/vendor/tracemonkey/math-trace-tests.js +507 -0
  385. data/vendor/tracemonkey/md5.js +289 -0
  386. data/vendor/tracemonkey/nanojit/Assembler.cpp +1984 -0
  387. data/vendor/tracemonkey/nanojit/Assembler.h +375 -0
  388. data/vendor/tracemonkey/nanojit/Fragmento.cpp +651 -0
  389. data/vendor/tracemonkey/nanojit/Fragmento.h +237 -0
  390. data/vendor/tracemonkey/nanojit/LIR.cpp +2314 -0
  391. data/vendor/tracemonkey/nanojit/LIR.h +879 -0
  392. data/vendor/tracemonkey/nanojit/LIRopcode.tbl +252 -0
  393. data/vendor/tracemonkey/nanojit/Native.h +127 -0
  394. data/vendor/tracemonkey/nanojit/NativeARM.cpp +1742 -0
  395. data/vendor/tracemonkey/nanojit/NativeARM.h +844 -0
  396. data/vendor/tracemonkey/nanojit/NativeSparc.cpp +1130 -0
  397. data/vendor/tracemonkey/nanojit/NativeSparc.h +948 -0
  398. data/vendor/tracemonkey/nanojit/NativeThumb.cpp +1322 -0
  399. data/vendor/tracemonkey/nanojit/NativeThumb.h +525 -0
  400. data/vendor/tracemonkey/nanojit/Nativei386.cpp +1748 -0
  401. data/vendor/tracemonkey/nanojit/Nativei386.h +857 -0
  402. data/vendor/tracemonkey/nanojit/RegAlloc.cpp +183 -0
  403. data/vendor/tracemonkey/nanojit/RegAlloc.h +95 -0
  404. data/vendor/tracemonkey/nanojit/TraceTreeDrawer.cpp +306 -0
  405. data/vendor/tracemonkey/nanojit/TraceTreeDrawer.h +88 -0
  406. data/vendor/tracemonkey/nanojit/avmplus.cpp +56 -0
  407. data/vendor/tracemonkey/nanojit/avmplus.h +1016 -0
  408. data/vendor/tracemonkey/nanojit/nanojit.h +253 -0
  409. data/vendor/tracemonkey/perfect.js +39 -0
  410. data/vendor/tracemonkey/plify_jsdhash.sed +35 -0
  411. data/vendor/tracemonkey/prmjtime.cpp +869 -0
  412. data/vendor/tracemonkey/prmjtime.h +103 -0
  413. data/vendor/tracemonkey/ref-config/AIX4.1.mk +65 -0
  414. data/vendor/tracemonkey/ref-config/AIX4.2.mk +64 -0
  415. data/vendor/tracemonkey/ref-config/AIX4.3.mk +65 -0
  416. data/vendor/tracemonkey/ref-config/Darwin.mk +85 -0
  417. data/vendor/tracemonkey/ref-config/Darwin1.3.mk +81 -0
  418. data/vendor/tracemonkey/ref-config/Darwin1.4.mk +41 -0
  419. data/vendor/tracemonkey/ref-config/Darwin5.2.mk +81 -0
  420. data/vendor/tracemonkey/ref-config/Darwin5.3.mk +81 -0
  421. data/vendor/tracemonkey/ref-config/Darwin64.mk +72 -0
  422. data/vendor/tracemonkey/ref-config/HP-UXB.10.10.mk +77 -0
  423. data/vendor/tracemonkey/ref-config/HP-UXB.10.20.mk +77 -0
  424. data/vendor/tracemonkey/ref-config/HP-UXB.11.00.mk +80 -0
  425. data/vendor/tracemonkey/ref-config/IRIX.mk +87 -0
  426. data/vendor/tracemonkey/ref-config/IRIX5.3.mk +44 -0
  427. data/vendor/tracemonkey/ref-config/IRIX6.1.mk +44 -0
  428. data/vendor/tracemonkey/ref-config/IRIX6.2.mk +44 -0
  429. data/vendor/tracemonkey/ref-config/IRIX6.3.mk +44 -0
  430. data/vendor/tracemonkey/ref-config/IRIX6.5.mk +44 -0
  431. data/vendor/tracemonkey/ref-config/Linux_All.mk +105 -0
  432. data/vendor/tracemonkey/ref-config/Mac_OS10.0.mk +82 -0
  433. data/vendor/tracemonkey/ref-config/OSF1V4.0.mk +72 -0
  434. data/vendor/tracemonkey/ref-config/OSF1V5.0.mk +69 -0
  435. data/vendor/tracemonkey/ref-config/SunOS4.1.4.mk +101 -0
  436. data/vendor/tracemonkey/ref-config/SunOS5.10.mk +50 -0
  437. data/vendor/tracemonkey/ref-config/SunOS5.3.mk +91 -0
  438. data/vendor/tracemonkey/ref-config/SunOS5.4.mk +92 -0
  439. data/vendor/tracemonkey/ref-config/SunOS5.5.1.mk +44 -0
  440. data/vendor/tracemonkey/ref-config/SunOS5.5.mk +87 -0
  441. data/vendor/tracemonkey/ref-config/SunOS5.6.mk +89 -0
  442. data/vendor/tracemonkey/ref-config/SunOS5.7.mk +44 -0
  443. data/vendor/tracemonkey/ref-config/SunOS5.8.mk +44 -0
  444. data/vendor/tracemonkey/ref-config/SunOS5.9.mk +44 -0
  445. data/vendor/tracemonkey/ref-config/WINNT4.0.mk +118 -0
  446. data/vendor/tracemonkey/ref-config/WINNT5.0.mk +118 -0
  447. data/vendor/tracemonkey/ref-config/WINNT5.1.mk +118 -0
  448. data/vendor/tracemonkey/ref-config/WINNT5.2.mk +118 -0
  449. data/vendor/tracemonkey/ref-config/WINNT6.0.mk +118 -0
  450. data/vendor/tracemonkey/ref-config/dgux.mk +64 -0
  451. data/vendor/tracemonkey/resource.h +15 -0
  452. data/vendor/tracemonkey/rules.mk +206 -0
  453. data/vendor/tracemonkey/shell/Makefile.in +72 -0
  454. data/vendor/tracemonkey/shell/js.cpp +4719 -0
  455. data/vendor/tracemonkey/t/3d-cube.js +337 -0
  456. data/vendor/tracemonkey/t/3d-morph.js +54 -0
  457. data/vendor/tracemonkey/t/3d-raytrace.js +441 -0
  458. data/vendor/tracemonkey/t/access-binary-trees.js +50 -0
  459. data/vendor/tracemonkey/t/access-fannkuch.js +66 -0
  460. data/vendor/tracemonkey/t/access-nbody.js +169 -0
  461. data/vendor/tracemonkey/t/access-nsieve.js +38 -0
  462. data/vendor/tracemonkey/t/bitops-3bit-bits-in-byte.js +32 -0
  463. data/vendor/tracemonkey/t/bitops-bits-in-byte.js +21 -0
  464. data/vendor/tracemonkey/t/bitops-bitwise-and.js +28 -0
  465. data/vendor/tracemonkey/t/bitops-nsieve-bits.js +32 -0
  466. data/vendor/tracemonkey/t/controlflow-recursive.js +25 -0
  467. data/vendor/tracemonkey/t/crypto-aes.js +422 -0
  468. data/vendor/tracemonkey/t/crypto-md5.js +286 -0
  469. data/vendor/tracemonkey/t/crypto-sha1.js +224 -0
  470. data/vendor/tracemonkey/t/date-format-tofte.js +299 -0
  471. data/vendor/tracemonkey/t/date-format-xparb.js +417 -0
  472. data/vendor/tracemonkey/t/math-cordic.js +95 -0
  473. data/vendor/tracemonkey/t/math-partial-sums.js +33 -0
  474. data/vendor/tracemonkey/t/math-spectral-norm.js +51 -0
  475. data/vendor/tracemonkey/t/regexp-dna.js +1712 -0
  476. data/vendor/tracemonkey/t/string-base64.js +135 -0
  477. data/vendor/tracemonkey/t/string-fasta.js +85 -0
  478. data/vendor/tracemonkey/t/string-tagcloud.js +265 -0
  479. data/vendor/tracemonkey/t/string-unpack-code.js +68 -0
  480. data/vendor/tracemonkey/t/string-validate-input.js +89 -0
  481. data/vendor/tracemonkey/time.sh +13 -0
  482. data/vendor/tracemonkey/trace-test.js +5564 -0
  483. data/vendor/tracemonkey/v8/base.js +187 -0
  484. data/vendor/tracemonkey/v8/crypto.js +1689 -0
  485. data/vendor/tracemonkey/v8/deltablue.js +880 -0
  486. data/vendor/tracemonkey/v8/earley-boyer.js +4682 -0
  487. data/vendor/tracemonkey/v8/raytrace.js +3418 -0
  488. data/vendor/tracemonkey/v8/richards.js +539 -0
  489. data/vendor/tracemonkey/v8/run-crypto.js +44 -0
  490. data/vendor/tracemonkey/v8/run-deltablue.js +44 -0
  491. data/vendor/tracemonkey/v8/run-earley-boyer.js +44 -0
  492. data/vendor/tracemonkey/v8/run-raytrace.js +44 -0
  493. data/vendor/tracemonkey/v8/run-richards.js +44 -0
  494. data/vendor/tracemonkey/v8/run.js +49 -0
  495. data/vendor/tracemonkey/vprof/readme.txt +93 -0
  496. data/vendor/tracemonkey/vprof/vprof.cpp +360 -0
  497. data/vendor/tracemonkey/vprof/vprof.h +245 -0
  498. data/vendor/tracemonkey/xpconnect/Makefile.in +67 -0
  499. data/vendor/tracemonkey/xpconnect/crashtests/117307-1.html +20 -0
  500. data/vendor/tracemonkey/xpconnect/crashtests/193710.html +11 -0
  501. data/vendor/tracemonkey/xpconnect/crashtests/290162-1.html +5 -0
  502. data/vendor/tracemonkey/xpconnect/crashtests/326615-1.html +16 -0
  503. data/vendor/tracemonkey/xpconnect/crashtests/328553-1.html +13 -0
  504. data/vendor/tracemonkey/xpconnect/crashtests/346258-1.html +12 -0
  505. data/vendor/tracemonkey/xpconnect/crashtests/346512-1-frame1.xhtml +16 -0
  506. data/vendor/tracemonkey/xpconnect/crashtests/346512-1-frame2.xhtml +15 -0
  507. data/vendor/tracemonkey/xpconnect/crashtests/346512-1.xhtml +30 -0
  508. data/vendor/tracemonkey/xpconnect/crashtests/382133-1.html +3 -0
  509. data/vendor/tracemonkey/xpconnect/crashtests/386680-1.html +22 -0
  510. data/vendor/tracemonkey/xpconnect/crashtests/394810-1.html +4 -0
  511. data/vendor/tracemonkey/xpconnect/crashtests/400349-1.html +20 -0
  512. data/vendor/tracemonkey/xpconnect/crashtests/403356-1.html +13 -0
  513. data/vendor/tracemonkey/xpconnect/crashtests/418139-1.svg +22 -0
  514. data/vendor/tracemonkey/xpconnect/crashtests/420513-1.html +11 -0
  515. data/vendor/tracemonkey/xpconnect/crashtests/453935-1.html +37 -0
  516. data/vendor/tracemonkey/xpconnect/crashtests/462926.html +12 -0
  517. data/vendor/tracemonkey/xpconnect/crashtests/468552-1.html +18 -0
  518. data/vendor/tracemonkey/xpconnect/crashtests/471366-1.html +12 -0
  519. data/vendor/tracemonkey/xpconnect/crashtests/475185-1.html +13 -0
  520. data/vendor/tracemonkey/xpconnect/crashtests/475291-1.html +14 -0
  521. data/vendor/tracemonkey/xpconnect/crashtests/503286-1.html +23 -0
  522. data/vendor/tracemonkey/xpconnect/crashtests/crashtests.list +21 -0
  523. data/vendor/tracemonkey/xpconnect/idl/Makefile.in +78 -0
  524. data/vendor/tracemonkey/xpconnect/idl/XPCIDispatch.idl +51 -0
  525. data/vendor/tracemonkey/xpconnect/idl/mozIJSSubScriptLoader.idl +64 -0
  526. data/vendor/tracemonkey/xpconnect/idl/nsIActiveXSecurityPolicy.idl +67 -0
  527. data/vendor/tracemonkey/xpconnect/idl/nsIDispatchSupport.idl +119 -0
  528. data/vendor/tracemonkey/xpconnect/idl/nsIJSContextStack.idl +85 -0
  529. data/vendor/tracemonkey/xpconnect/idl/nsIJSRuntimeService.idl +51 -0
  530. data/vendor/tracemonkey/xpconnect/idl/nsIScriptError.idl +102 -0
  531. data/vendor/tracemonkey/xpconnect/idl/nsIScriptableInterfaces.idl +67 -0
  532. data/vendor/tracemonkey/xpconnect/idl/nsIXPCScriptNotify.idl +66 -0
  533. data/vendor/tracemonkey/xpconnect/idl/nsIXPCScriptable.idl +183 -0
  534. data/vendor/tracemonkey/xpconnect/idl/nsIXPCSecurityManager.idl +114 -0
  535. data/vendor/tracemonkey/xpconnect/idl/nsIXPConnect.idl +819 -0
  536. data/vendor/tracemonkey/xpconnect/idl/xpcIJSModuleLoader.idl +95 -0
  537. data/vendor/tracemonkey/xpconnect/idl/xpcIJSWeakReference.idl +49 -0
  538. data/vendor/tracemonkey/xpconnect/idl/xpccomponents.idl +254 -0
  539. data/vendor/tracemonkey/xpconnect/idl/xpcexception.idl +66 -0
  540. data/vendor/tracemonkey/xpconnect/idl/xpcjsid.idl +83 -0
  541. data/vendor/tracemonkey/xpconnect/loader/ISO8601DateUtils.jsm +176 -0
  542. data/vendor/tracemonkey/xpconnect/loader/Makefile.in +63 -0
  543. data/vendor/tracemonkey/xpconnect/loader/XPCOMUtils.jsm +267 -0
  544. data/vendor/tracemonkey/xpconnect/loader/mozJSComponentLoader.cpp +1717 -0
  545. data/vendor/tracemonkey/xpconnect/loader/mozJSComponentLoader.h +172 -0
  546. data/vendor/tracemonkey/xpconnect/loader/mozJSLoaderConstructors.h +101 -0
  547. data/vendor/tracemonkey/xpconnect/loader/mozJSSubScriptLoader.cpp +360 -0
  548. data/vendor/tracemonkey/xpconnect/loader/mozJSSubScriptLoader.h +66 -0
  549. data/vendor/tracemonkey/xpconnect/public/Makefile.in +54 -0
  550. data/vendor/tracemonkey/xpconnect/public/nsAXPCNativeCallContext.h +89 -0
  551. data/vendor/tracemonkey/xpconnect/public/nsAutoJSValHolder.h +168 -0
  552. data/vendor/tracemonkey/xpconnect/public/xpc_map_end.h +327 -0
  553. data/vendor/tracemonkey/xpconnect/sample/Makefile.in +71 -0
  554. data/vendor/tracemonkey/xpconnect/sample/README +39 -0
  555. data/vendor/tracemonkey/xpconnect/sample/xpcsample1.cpp +337 -0
  556. data/vendor/tracemonkey/xpconnect/sample/xpcsample1.idl +82 -0
  557. data/vendor/tracemonkey/xpconnect/sample/xpcsample1.js +21 -0
  558. data/vendor/tracemonkey/xpconnect/shell/Makefile.in +106 -0
  559. data/vendor/tracemonkey/xpconnect/shell/jsshell.msg +50 -0
  560. data/vendor/tracemonkey/xpconnect/shell/xpcshell.cpp +1817 -0
  561. data/vendor/tracemonkey/xpconnect/shell/xpcshellMacUtils.h +43 -0
  562. data/vendor/tracemonkey/xpconnect/shell/xpcshellMacUtils.mm +54 -0
  563. data/vendor/tracemonkey/xpconnect/src/Makefile.in +228 -0
  564. data/vendor/tracemonkey/xpconnect/src/README +3 -0
  565. data/vendor/tracemonkey/xpconnect/src/XPCCrossOriginWrapper.cpp +1186 -0
  566. data/vendor/tracemonkey/xpconnect/src/XPCDispConvert.cpp +593 -0
  567. data/vendor/tracemonkey/xpconnect/src/XPCDispInlines.h +667 -0
  568. data/vendor/tracemonkey/xpconnect/src/XPCDispInterface.cpp +383 -0
  569. data/vendor/tracemonkey/xpconnect/src/XPCDispObject.cpp +516 -0
  570. data/vendor/tracemonkey/xpconnect/src/XPCDispParamPropJSClass.cpp +223 -0
  571. data/vendor/tracemonkey/xpconnect/src/XPCDispParams.cpp +103 -0
  572. data/vendor/tracemonkey/xpconnect/src/XPCDispPrivate.h +1401 -0
  573. data/vendor/tracemonkey/xpconnect/src/XPCDispTearOff.cpp +547 -0
  574. data/vendor/tracemonkey/xpconnect/src/XPCDispTypeInfo.cpp +471 -0
  575. data/vendor/tracemonkey/xpconnect/src/XPCIDispatchClassInfo.cpp +139 -0
  576. data/vendor/tracemonkey/xpconnect/src/XPCIDispatchExtension.cpp +362 -0
  577. data/vendor/tracemonkey/xpconnect/src/XPCNativeWrapper.cpp +1350 -0
  578. data/vendor/tracemonkey/xpconnect/src/XPCNativeWrapper.h +88 -0
  579. data/vendor/tracemonkey/xpconnect/src/XPCSafeJSObjectWrapper.cpp +1148 -0
  580. data/vendor/tracemonkey/xpconnect/src/XPCSystemOnlyWrapper.cpp +718 -0
  581. data/vendor/tracemonkey/xpconnect/src/XPCWrapper.cpp +850 -0
  582. data/vendor/tracemonkey/xpconnect/src/XPCWrapper.h +394 -0
  583. data/vendor/tracemonkey/xpconnect/src/dom_quickstubs.qsconf +568 -0
  584. data/vendor/tracemonkey/xpconnect/src/nsDispatchSupport.cpp +348 -0
  585. data/vendor/tracemonkey/xpconnect/src/nsScriptError.cpp +201 -0
  586. data/vendor/tracemonkey/xpconnect/src/nsXPConnect.cpp +2609 -0
  587. data/vendor/tracemonkey/xpconnect/src/qsgen.py +1487 -0
  588. data/vendor/tracemonkey/xpconnect/src/xpc.msg +217 -0
  589. data/vendor/tracemonkey/xpconnect/src/xpcJSWeakReference.cpp +148 -0
  590. data/vendor/tracemonkey/xpconnect/src/xpcJSWeakReference.h +56 -0
  591. data/vendor/tracemonkey/xpconnect/src/xpccallcontext.cpp +579 -0
  592. data/vendor/tracemonkey/xpconnect/src/xpccomponents.cpp +4144 -0
  593. data/vendor/tracemonkey/xpconnect/src/xpccontext.cpp +115 -0
  594. data/vendor/tracemonkey/xpconnect/src/xpcconvert.cpp +2298 -0
  595. data/vendor/tracemonkey/xpconnect/src/xpcdebug.cpp +481 -0
  596. data/vendor/tracemonkey/xpconnect/src/xpcexception.cpp +502 -0
  597. data/vendor/tracemonkey/xpconnect/src/xpcforwards.h +114 -0
  598. data/vendor/tracemonkey/xpconnect/src/xpcinlines.h +772 -0
  599. data/vendor/tracemonkey/xpconnect/src/xpcjsid.cpp +1025 -0
  600. data/vendor/tracemonkey/xpconnect/src/xpcjsruntime.cpp +1342 -0
  601. data/vendor/tracemonkey/xpconnect/src/xpclog.cpp +128 -0
  602. data/vendor/tracemonkey/xpconnect/src/xpclog.h +101 -0
  603. data/vendor/tracemonkey/xpconnect/src/xpcmaps.cpp +761 -0
  604. data/vendor/tracemonkey/xpconnect/src/xpcmaps.h +713 -0
  605. data/vendor/tracemonkey/xpconnect/src/xpcmodule.cpp +136 -0
  606. data/vendor/tracemonkey/xpconnect/src/xpcprivate.h +4138 -0
  607. data/vendor/tracemonkey/xpconnect/src/xpcquickstubs.cpp +1128 -0
  608. data/vendor/tracemonkey/xpconnect/src/xpcquickstubs.h +480 -0
  609. data/vendor/tracemonkey/xpconnect/src/xpcruntimesvc.cpp +179 -0
  610. data/vendor/tracemonkey/xpconnect/src/xpcstack.cpp +342 -0
  611. data/vendor/tracemonkey/xpconnect/src/xpcstring.cpp +139 -0
  612. data/vendor/tracemonkey/xpconnect/src/xpcthreadcontext.cpp +599 -0
  613. data/vendor/tracemonkey/xpconnect/src/xpcthrower.cpp +399 -0
  614. data/vendor/tracemonkey/xpconnect/src/xpcvariant.cpp +850 -0
  615. data/vendor/tracemonkey/xpconnect/src/xpcwrappedjs.cpp +670 -0
  616. data/vendor/tracemonkey/xpconnect/src/xpcwrappedjsclass.cpp +2015 -0
  617. data/vendor/tracemonkey/xpconnect/src/xpcwrappednative.cpp +3482 -0
  618. data/vendor/tracemonkey/xpconnect/src/xpcwrappednativeinfo.cpp +945 -0
  619. data/vendor/tracemonkey/xpconnect/src/xpcwrappednativejsops.cpp +2003 -0
  620. data/vendor/tracemonkey/xpconnect/src/xpcwrappednativeproto.cpp +302 -0
  621. data/vendor/tracemonkey/xpconnect/src/xpcwrappednativescope.cpp +991 -0
  622. data/vendor/tracemonkey/xpconnect/tests/Makefile.in +75 -0
  623. data/vendor/tracemonkey/xpconnect/tests/TestXPC.cpp +785 -0
  624. data/vendor/tracemonkey/xpconnect/tests/chrome/Makefile.in +51 -0
  625. data/vendor/tracemonkey/xpconnect/tests/chrome/test_bug500931.xul +43 -0
  626. data/vendor/tracemonkey/xpconnect/tests/components/Makefile.in +85 -0
  627. data/vendor/tracemonkey/xpconnect/tests/components/xpctest_array.cpp +388 -0
  628. data/vendor/tracemonkey/xpconnect/tests/components/xpctest_attributes.cpp +305 -0
  629. data/vendor/tracemonkey/xpconnect/tests/components/xpctest_calljs.cpp +135 -0
  630. data/vendor/tracemonkey/xpconnect/tests/components/xpctest_child.cpp +225 -0
  631. data/vendor/tracemonkey/xpconnect/tests/components/xpctest_const.cpp +76 -0
  632. data/vendor/tracemonkey/xpconnect/tests/components/xpctest_domstring.cpp +118 -0
  633. data/vendor/tracemonkey/xpconnect/tests/components/xpctest_echo.cpp +616 -0
  634. data/vendor/tracemonkey/xpconnect/tests/components/xpctest_in.cpp +204 -0
  635. data/vendor/tracemonkey/xpconnect/tests/components/xpctest_inout.cpp +171 -0
  636. data/vendor/tracemonkey/xpconnect/tests/components/xpctest_module.cpp +77 -0
  637. data/vendor/tracemonkey/xpconnect/tests/components/xpctest_multiple.cpp +554 -0
  638. data/vendor/tracemonkey/xpconnect/tests/components/xpctest_noisy.cpp +154 -0
  639. data/vendor/tracemonkey/xpconnect/tests/components/xpctest_out.cpp +335 -0
  640. data/vendor/tracemonkey/xpconnect/tests/components/xpctest_overloaded.cpp +250 -0
  641. data/vendor/tracemonkey/xpconnect/tests/components/xpctest_private.h +192 -0
  642. data/vendor/tracemonkey/xpconnect/tests/components/xpctest_string.cpp +185 -0
  643. data/vendor/tracemonkey/xpconnect/tests/components/xpctest_variant.cpp +355 -0
  644. data/vendor/tracemonkey/xpconnect/tests/idispatch/COM/StdAfx.cpp +12 -0
  645. data/vendor/tracemonkey/xpconnect/tests/idispatch/COM/StdAfx.h +28 -0
  646. data/vendor/tracemonkey/xpconnect/tests/idispatch/COM/XPCDispUtilities.h +28 -0
  647. data/vendor/tracemonkey/xpconnect/tests/idispatch/COM/XPCIDispatchTest.cpp +86 -0
  648. data/vendor/tracemonkey/xpconnect/tests/idispatch/COM/XPCIDispatchTest.def +9 -0
  649. data/vendor/tracemonkey/xpconnect/tests/idispatch/COM/XPCIDispatchTest.dsp +318 -0
  650. data/vendor/tracemonkey/xpconnect/tests/idispatch/COM/XPCIDispatchTest.dsw +29 -0
  651. data/vendor/tracemonkey/xpconnect/tests/idispatch/COM/XPCIDispatchTest.idl +454 -0
  652. data/vendor/tracemonkey/xpconnect/tests/idispatch/COM/XPCIDispatchTest.rc +145 -0
  653. data/vendor/tracemonkey/xpconnect/tests/idispatch/COM/nsXPCDispSimple.cpp +44 -0
  654. data/vendor/tracemonkey/xpconnect/tests/idispatch/COM/nsXPCDispSimple.h +56 -0
  655. data/vendor/tracemonkey/xpconnect/tests/idispatch/COM/nsXPCDispSimple.rgs +23 -0
  656. data/vendor/tracemonkey/xpconnect/tests/idispatch/COM/nsXPCDispTestArrays.cpp +221 -0
  657. data/vendor/tracemonkey/xpconnect/tests/idispatch/COM/nsXPCDispTestArrays.h +53 -0
  658. data/vendor/tracemonkey/xpconnect/tests/idispatch/COM/nsXPCDispTestArrays.rgs +23 -0
  659. data/vendor/tracemonkey/xpconnect/tests/idispatch/COM/nsXPCDispTestMethods.cpp +699 -0
  660. data/vendor/tracemonkey/xpconnect/tests/idispatch/COM/nsXPCDispTestMethods.h +138 -0
  661. data/vendor/tracemonkey/xpconnect/tests/idispatch/COM/nsXPCDispTestMethods.rgs +23 -0
  662. data/vendor/tracemonkey/xpconnect/tests/idispatch/COM/nsXPCDispTestNoIDispatch.cpp +23 -0
  663. data/vendor/tracemonkey/xpconnect/tests/idispatch/COM/nsXPCDispTestNoIDispatch.h +41 -0
  664. data/vendor/tracemonkey/xpconnect/tests/idispatch/COM/nsXPCDispTestNoIDispatch.rgs +23 -0
  665. data/vendor/tracemonkey/xpconnect/tests/idispatch/COM/nsXPCDispTestProperties.cpp +256 -0
  666. data/vendor/tracemonkey/xpconnect/tests/idispatch/COM/nsXPCDispTestProperties.h +88 -0
  667. data/vendor/tracemonkey/xpconnect/tests/idispatch/COM/nsXPCDispTestProperties.rgs +23 -0
  668. data/vendor/tracemonkey/xpconnect/tests/idispatch/COM/nsXPCDispTestScriptOff.cpp +23 -0
  669. data/vendor/tracemonkey/xpconnect/tests/idispatch/COM/nsXPCDispTestScriptOff.h +43 -0
  670. data/vendor/tracemonkey/xpconnect/tests/idispatch/COM/nsXPCDispTestScriptOff.rgs +23 -0
  671. data/vendor/tracemonkey/xpconnect/tests/idispatch/COM/nsXPCDispTestScriptOn.cpp +29 -0
  672. data/vendor/tracemonkey/xpconnect/tests/idispatch/COM/nsXPCDispTestScriptOn.h +45 -0
  673. data/vendor/tracemonkey/xpconnect/tests/idispatch/COM/nsXPCDispTestScriptOn.rgs +23 -0
  674. data/vendor/tracemonkey/xpconnect/tests/idispatch/COM/nsXPCDispTestWrappedJS.cpp +177 -0
  675. data/vendor/tracemonkey/xpconnect/tests/idispatch/COM/nsXPCDispTestWrappedJS.h +50 -0
  676. data/vendor/tracemonkey/xpconnect/tests/idispatch/COM/nsXPCDispTestWrappedJS.rgs +23 -0
  677. data/vendor/tracemonkey/xpconnect/tests/idispatch/COM/resource.h +36 -0
  678. data/vendor/tracemonkey/xpconnect/tests/idispatch/Tests/WrappedCOM/Arrays/XPCIDispatchArrayTests.js +54 -0
  679. data/vendor/tracemonkey/xpconnect/tests/idispatch/Tests/WrappedCOM/Attributes/XPCIDispatchAttributeTests.js +150 -0
  680. data/vendor/tracemonkey/xpconnect/tests/idispatch/Tests/WrappedCOM/General/XPCIDispatchInstantiations.js +122 -0
  681. data/vendor/tracemonkey/xpconnect/tests/idispatch/Tests/WrappedCOM/General/XPCStress.js +58 -0
  682. data/vendor/tracemonkey/xpconnect/tests/idispatch/Tests/WrappedCOM/Methods/XPCIDispatchMethodTests.js +376 -0
  683. data/vendor/tracemonkey/xpconnect/tests/idispatch/Tests/WrappedCOM/shell.js +377 -0
  684. data/vendor/tracemonkey/xpconnect/tests/idispatch/Tests/WrappedJS/General/XPCIDispatchTestWrappedJS.js +76 -0
  685. data/vendor/tracemonkey/xpconnect/tests/idispatch/Tests/WrappedJS/shell.js +377 -0
  686. data/vendor/tracemonkey/xpconnect/tests/idispatch/Tests/exectests.cmd +1 -0
  687. data/vendor/tracemonkey/xpconnect/tests/idispatch/Tests/jsDriver.pl +1288 -0
  688. data/vendor/tracemonkey/xpconnect/tests/idl/Makefile.in +61 -0
  689. data/vendor/tracemonkey/xpconnect/tests/idl/xpctest.idl +312 -0
  690. data/vendor/tracemonkey/xpconnect/tests/idl/xpctest2.idl +51 -0
  691. data/vendor/tracemonkey/xpconnect/tests/idl/xpctest_attributes.idl +67 -0
  692. data/vendor/tracemonkey/xpconnect/tests/idl/xpctest_calljs.idl +59 -0
  693. data/vendor/tracemonkey/xpconnect/tests/idl/xpctest_const.idl +61 -0
  694. data/vendor/tracemonkey/xpconnect/tests/idl/xpctest_domstring.idl +59 -0
  695. data/vendor/tracemonkey/xpconnect/tests/idl/xpctest_in.idl +88 -0
  696. data/vendor/tracemonkey/xpconnect/tests/idl/xpctest_inout.idl +86 -0
  697. data/vendor/tracemonkey/xpconnect/tests/idl/xpctest_multiple.idl +77 -0
  698. data/vendor/tracemonkey/xpconnect/tests/idl/xpctest_out.idl +142 -0
  699. data/vendor/tracemonkey/xpconnect/tests/js/checkid.js +82 -0
  700. data/vendor/tracemonkey/xpconnect/tests/js/evaluate.js +311 -0
  701. data/vendor/tracemonkey/xpconnect/tests/js/exceptions-2.js +153 -0
  702. data/vendor/tracemonkey/xpconnect/tests/js/exceptions-3.js +194 -0
  703. data/vendor/tracemonkey/xpconnect/tests/js/exceptions-4.js +297 -0
  704. data/vendor/tracemonkey/xpconnect/tests/js/exceptions-5.js +343 -0
  705. data/vendor/tracemonkey/xpconnect/tests/js/exceptions.js +230 -0
  706. data/vendor/tracemonkey/xpconnect/tests/js/javascript.js +96 -0
  707. data/vendor/tracemonkey/xpconnect/tests/js/multiple-2.js +151 -0
  708. data/vendor/tracemonkey/xpconnect/tests/js/multiple-3.js +148 -0
  709. data/vendor/tracemonkey/xpconnect/tests/js/multiple-4.js +152 -0
  710. data/vendor/tracemonkey/xpconnect/tests/js/multiple.js +137 -0
  711. data/vendor/tracemonkey/xpconnect/tests/js/notscriptable.js +104 -0
  712. data/vendor/tracemonkey/xpconnect/tests/js/old/simpletest.js +36 -0
  713. data/vendor/tracemonkey/xpconnect/tests/js/old/speed.js +60 -0
  714. data/vendor/tracemonkey/xpconnect/tests/js/old/testxpc.js +464 -0
  715. data/vendor/tracemonkey/xpconnect/tests/js/old/threads.js +74 -0
  716. data/vendor/tracemonkey/xpconnect/tests/js/old/try.js +27 -0
  717. data/vendor/tracemonkey/xpconnect/tests/js/old/xpctest_array.js +308 -0
  718. data/vendor/tracemonkey/xpconnect/tests/js/old/xpctest_callcontext.js +68 -0
  719. data/vendor/tracemonkey/xpconnect/tests/js/old/xpctest_echo.js +636 -0
  720. data/vendor/tracemonkey/xpconnect/tests/js/old/xpctest_enum_and_sort.js +28 -0
  721. data/vendor/tracemonkey/xpconnect/tests/js/old/xpctest_enum_constants.js +15 -0
  722. data/vendor/tracemonkey/xpconnect/tests/js/old/xpctest_enum_create.js +200 -0
  723. data/vendor/tracemonkey/xpconnect/tests/js/old/xpctest_exceptions.js +167 -0
  724. data/vendor/tracemonkey/xpconnect/tests/js/old/xpctest_ids.js +135 -0
  725. data/vendor/tracemonkey/xpconnect/tests/js/old/xpctest_observer.js +36 -0
  726. data/vendor/tracemonkey/xpconnect/tests/js/old/xpctest_overloaded.js +14 -0
  727. data/vendor/tracemonkey/xpconnect/tests/js/old/xpctest_primitives.js +141 -0
  728. data/vendor/tracemonkey/xpconnect/tests/js/old/xpctest_propertybag.js +36 -0
  729. data/vendor/tracemonkey/xpconnect/tests/js/old/xpctest_variant.js +339 -0
  730. data/vendor/tracemonkey/xpconnect/tests/js/old/xpctest_variant_array.js +30 -0
  731. data/vendor/tracemonkey/xpconnect/tests/js/readonlyattributes.js +74 -0
  732. data/vendor/tracemonkey/xpconnect/tests/js/readwriteattributes.js +101 -0
  733. data/vendor/tracemonkey/xpconnect/tests/js/scriptable.js +120 -0
  734. data/vendor/tracemonkey/xpconnect/tests/js/testin.js +203 -0
  735. data/vendor/tracemonkey/xpconnect/tests/js/xpcfun.js +234 -0
  736. data/vendor/tracemonkey/xpconnect/tests/js/xpctest_primitives.js +200 -0
  737. data/vendor/tracemonkey/xpconnect/tests/mochitest/Makefile.in +66 -0
  738. data/vendor/tracemonkey/xpconnect/tests/mochitest/bug500931_helper.html +7 -0
  739. data/vendor/tracemonkey/xpconnect/tests/mochitest/inner.html +7 -0
  740. data/vendor/tracemonkey/xpconnect/tests/mochitest/test_bug361111.xul +29 -0
  741. data/vendor/tracemonkey/xpconnect/tests/mochitest/test_bug384632.html +32 -0
  742. data/vendor/tracemonkey/xpconnect/tests/mochitest/test_bug390488.html +65 -0
  743. data/vendor/tracemonkey/xpconnect/tests/mochitest/test_bug393269.html +46 -0
  744. data/vendor/tracemonkey/xpconnect/tests/mochitest/test_bug396851.html +43 -0
  745. data/vendor/tracemonkey/xpconnect/tests/mochitest/test_bug428021.html +41 -0
  746. data/vendor/tracemonkey/xpconnect/tests/mochitest/test_bug446584.html +49 -0
  747. data/vendor/tracemonkey/xpconnect/tests/mochitest/test_bug448587.html +31 -0
  748. data/vendor/tracemonkey/xpconnect/tests/mochitest/test_bug462428.html +42 -0
  749. data/vendor/tracemonkey/xpconnect/tests/mochitest/test_bug478438.html +66 -0
  750. data/vendor/tracemonkey/xpconnect/tests/mochitest/test_bug484107.html +100 -0
  751. data/vendor/tracemonkey/xpconnect/tests/mochitest/test_bug484459.html +36 -0
  752. data/vendor/tracemonkey/xpconnect/tests/mochitest/test_bug500691.html +28 -0
  753. data/vendor/tracemonkey/xpconnect/tests/mochitest/test_wrappers.html +116 -0
  754. data/vendor/tracemonkey/xpconnect/tests/unit/bogus_element_type.jsm +1 -0
  755. data/vendor/tracemonkey/xpconnect/tests/unit/bogus_exports_type.jsm +1 -0
  756. data/vendor/tracemonkey/xpconnect/tests/unit/bug451678_subscript.js +2 -0
  757. data/vendor/tracemonkey/xpconnect/tests/unit/component_import.js +144 -0
  758. data/vendor/tracemonkey/xpconnect/tests/unit/recursive_importA.jsm +44 -0
  759. data/vendor/tracemonkey/xpconnect/tests/unit/recursive_importB.jsm +45 -0
  760. data/vendor/tracemonkey/xpconnect/tests/unit/syntax_error.jsm +1 -0
  761. data/vendor/tracemonkey/xpconnect/tests/unit/test_bogus_files.js +88 -0
  762. data/vendor/tracemonkey/xpconnect/tests/unit/test_bug408412.js +51 -0
  763. data/vendor/tracemonkey/xpconnect/tests/unit/test_bug451678.js +52 -0
  764. data/vendor/tracemonkey/xpconnect/tests/unit/test_bug_442086.js +68 -0
  765. data/vendor/tracemonkey/xpconnect/tests/unit/test_import.js +127 -0
  766. data/vendor/tracemonkey/xpconnect/tests/unit/test_js_weak_references.js +63 -0
  767. data/vendor/tracemonkey/xpconnect/tests/unit/test_recursive_import.js +62 -0
  768. data/vendor/tracemonkey/xpconnect/tools/Makefile.in +49 -0
  769. data/vendor/tracemonkey/xpconnect/tools/idl/Makefile.in +53 -0
  770. data/vendor/tracemonkey/xpconnect/tools/idl/nsIXPCToolsCompiler.idl +60 -0
  771. data/vendor/tracemonkey/xpconnect/tools/idl/nsIXPCToolsProfiler.idl +57 -0
  772. data/vendor/tracemonkey/xpconnect/tools/js/CompileJSFiles.js +28 -0
  773. data/vendor/tracemonkey/xpconnect/tools/js/ListJSFiles.js +18 -0
  774. data/vendor/tracemonkey/xpconnect/tools/src/Makefile.in +76 -0
  775. data/vendor/tracemonkey/xpconnect/tools/src/nsXPCToolsCompiler.cpp +161 -0
  776. data/vendor/tracemonkey/xpconnect/tools/src/nsXPCToolsModule.cpp +65 -0
  777. data/vendor/tracemonkey/xpconnect/tools/src/nsXPCToolsProfiler.cpp +370 -0
  778. data/vendor/tracemonkey/xpconnect/tools/src/xpctools_private.h +236 -0
  779. metadata +782 -107
  780. data/test/johnson/nodes/export_test.rb +0 -9
  781. data/test/johnson/nodes/import_test.rb +0 -13
  782. data/test/johnson/version_test.rb +0 -13
@@ -0,0 +1,21 @@
1
+
2
+ var clazz = Components.classes["xpc.sample_hookerupper.1"];
3
+ var iface = Components.interfaces.nsIXPCSample_HookerUpper;
4
+ var hookerupper = clazz.createInstance(iface);
5
+ hookerupper.createSampleObjectAtGlobalScope("A",5);
6
+
7
+ dump("A = "+A+"\n");
8
+ dump("A.someValue = "+A.someValue+"\n");
9
+ A.someValue++ ;
10
+ dump("A.someValue = "+A.someValue+"\n");
11
+
12
+ dump("A.B = "+A.B+"\n");
13
+ dump("A.B.someValue = "+A.B.someValue+"\n");
14
+ A.B.someValue++ ;
15
+ dump("A.B.someValue = "+A.B.someValue+"\n");
16
+
17
+ dump("A.B.C = "+A.B.C+"\n");
18
+ dump("A.B.C.someValue = "+A.B.C.someValue+"\n");
19
+ A.B.C.someValue++ ;
20
+ dump("A.B.C.someValue = "+A.B.C.someValue+"\n");
21
+
@@ -0,0 +1,106 @@
1
+ #
2
+ # ***** BEGIN LICENSE BLOCK *****
3
+ # Version: MPL 1.1/GPL 2.0/LGPL 2.1
4
+ #
5
+ # The contents of this file are subject to the Mozilla Public License Version
6
+ # 1.1 (the "License"); you may not use this file except in compliance with
7
+ # the License. You may obtain a copy of the License at
8
+ # http://www.mozilla.org/MPL/
9
+ #
10
+ # Software distributed under the License is distributed on an "AS IS" basis,
11
+ # WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12
+ # for the specific language governing rights and limitations under the
13
+ # License.
14
+ #
15
+ # The Original Code is Mozilla Communicator client code, released
16
+ # March 31, 1998.
17
+ #
18
+ # The Initial Developer of the Original Code is
19
+ # Netscape Communications Corporation.
20
+ # Portions created by the Initial Developer are Copyright (C) 1998
21
+ # the Initial Developer. All Rights Reserved.
22
+ #
23
+ # Contributor(s):
24
+ #
25
+ # Alternatively, the contents of this file may be used under the terms of
26
+ # either of the GNU General Public License Version 2 or later (the "GPL"),
27
+ # or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
28
+ # in which case the provisions of the GPL or the LGPL are applicable instead
29
+ # of those above. If you wish to allow use of your version of this file only
30
+ # under the terms of either the GPL or the LGPL, and not to allow others to
31
+ # use your version of this file under the terms of the MPL, indicate your
32
+ # decision by deleting the provisions above and replace them with the notice
33
+ # and other provisions required by the GPL or the LGPL. If you do not delete
34
+ # the provisions above, a recipient may use your version of this file under
35
+ # the terms of any one of the MPL, the GPL or the LGPL.
36
+ #
37
+ # ***** END LICENSE BLOCK *****
38
+
39
+ DEPTH = ../../../..
40
+ topsrcdir = @top_srcdir@
41
+ srcdir = @srcdir@
42
+ VPATH = @srcdir@
43
+
44
+ include $(DEPTH)/config/autoconf.mk
45
+
46
+ MODULE = xpcshell
47
+ PROGRAM = xpcshell$(BIN_SUFFIX)
48
+
49
+ REQUIRES = xpconnect \
50
+ xpcom \
51
+ js \
52
+ caps \
53
+ xulapp \
54
+ $(NULL)
55
+
56
+ CPPSRCS = xpcshell.cpp
57
+
58
+ ifneq (,$(filter mac cocoa,$(MOZ_WIDGET_TOOLKIT)))
59
+ CMMSRCS += xpcshellMacUtils.mm
60
+ endif
61
+
62
+ LIBS = \
63
+ $(DIST)/lib/$(LIB_PREFIX)xpcomglue_s.$(LIB_SUFFIX) \
64
+ $(LIBXUL_LIBS) \
65
+ $(MOZ_JS_LIBS) \
66
+ $(NSPR_LIBS) \
67
+ $(NULL)
68
+
69
+ NSDISTMODE = copy
70
+
71
+ ifdef _MSC_VER
72
+ ifdef WINCE
73
+ WIN32_EXE_LDFLAGS += -ENTRY:mainACRTStartup
74
+ endif
75
+ endif
76
+
77
+ include $(topsrcdir)/config/rules.mk
78
+
79
+ DEFINES += -DJS_THREADSAFE
80
+
81
+ ifdef MOZ_SHARK
82
+ DEFINES += -DMOZ_SHARK
83
+ CFLAGS += -F/System/Library/PrivateFrameworks
84
+ LDFLAGS += -F/System/Library/PrivateFrameworks -framework CHUD
85
+ endif
86
+ ifdef MOZ_CALLGRIND
87
+ DEFINES += -DMOZ_CALLGRIND
88
+ endif
89
+ ifdef MOZ_VTUNE
90
+ DEFINES += -DMOZ_VTUNE
91
+ CXXFLAGS += -IC:/Program\ Files/Intel/VTune/Analyzer/Include
92
+ LIBS += C:/Program\ Files/Intel/VTune/Analyzer/Lib/VtuneApi.lib
93
+ endif
94
+ #
95
+ # Line editing support. If your OS supplies the readline library, define
96
+ # JS_READLINE to get line editing in the xpcshell.
97
+ #
98
+ # If you can't link against readline because of GPL licensing issues
99
+ # (which may not apply, as xpcshell.c has the dual license) you might
100
+ # look at mozilla/js/src/editline, which is license-free (but not part
101
+ # of the mozilla build.)
102
+ #
103
+ ifdef JS_READLINE
104
+ DEFINES += -DEDITLINE
105
+ LIBS += -lreadline $(JS_READLINE_EXTRA_LIBS)
106
+ endif
@@ -0,0 +1,50 @@
1
+ /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2
+ *
3
+ * ***** BEGIN LICENSE BLOCK *****
4
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
5
+ *
6
+ * The contents of this file are subject to the Mozilla Public License Version
7
+ * 1.1 (the "License"); you may not use this file except in compliance with
8
+ * the License. You may obtain a copy of the License at
9
+ * http://www.mozilla.org/MPL/
10
+ *
11
+ * Software distributed under the License is distributed on an "AS IS" basis,
12
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13
+ * for the specific language governing rights and limitations under the
14
+ * License.
15
+ *
16
+ * The Original Code is Mozilla Communicator client code, released
17
+ * March 31, 1998.
18
+ *
19
+ * The Initial Developer of the Original Code is
20
+ * Netscape Communications Corporation.
21
+ * Portions created by the Initial Developer are Copyright (C) 1998
22
+ * the Initial Developer. All Rights Reserved.
23
+ *
24
+ * Contributor(s):
25
+ *
26
+ * Alternatively, the contents of this file may be used under the terms of
27
+ * either of the GNU General Public License Version 2 or later (the "GPL"),
28
+ * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
29
+ * in which case the provisions of the GPL or the LGPL are applicable instead
30
+ * of those above. If you wish to allow use of your version of this file only
31
+ * under the terms of either the GPL or the LGPL, and not to allow others to
32
+ * use your version of this file under the terms of the MPL, indicate your
33
+ * decision by deleting the provisions above and replace them with the notice
34
+ * and other provisions required by the GPL or the LGPL. If you do not delete
35
+ * the provisions above, a recipient may use your version of this file under
36
+ * the terms of any one of the MPL, the GPL or the LGPL.
37
+ *
38
+ * ***** END LICENSE BLOCK ***** */
39
+
40
+ /*
41
+ Error messages for JSShell. See js.msg for format.
42
+ */
43
+
44
+ MSG_DEF(JSSMSG_NOT_AN_ERROR, 0, 0, JSEXN_NONE, "<Error #0 is reserved>")
45
+ MSG_DEF(JSSMSG_CANT_OPEN, 1, 2, JSEXN_NONE, "can't open {0}: {1}")
46
+ MSG_DEF(JSSMSG_TRAP_USAGE, 2, 0, JSEXN_NONE, "usage: trap [fun] [pc] expr")
47
+ MSG_DEF(JSSMSG_LINE2PC_USAGE, 3, 0, JSEXN_NONE, "usage: line2pc [fun] line")
48
+ MSG_DEF(JSSMSG_FILE_SCRIPTS_ONLY, 4, 0, JSEXN_NONE, "only works on JS scripts read from files")
49
+ MSG_DEF(JSSMSG_UNEXPECTED_EOF, 5, 1, JSEXN_NONE, "unexpected EOF in {0}")
50
+ MSG_DEF(JSSMSG_DOEXP_USAGE, 6, 0, JSEXN_NONE, "usage: doexp obj id")
@@ -0,0 +1,1817 @@
1
+ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2
+ * vim: set ts=2 sw=4 et tw=80:
3
+ *
4
+ * ***** BEGIN LICENSE BLOCK *****
5
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
6
+ *
7
+ * The contents of this file are subject to the Mozilla Public License Version
8
+ * 1.1 (the "License"); you may not use this file except in compliance with
9
+ * the License. You may obtain a copy of the License at
10
+ * http://www.mozilla.org/MPL/
11
+ *
12
+ * Software distributed under the License is distributed on an "AS IS" basis,
13
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
14
+ * for the specific language governing rights and limitations under the
15
+ * License.
16
+ *
17
+ * The Original Code is Mozilla Communicator client code, released
18
+ * March 31, 1998.
19
+ *
20
+ * The Initial Developer of the Original Code is
21
+ * Netscape Communications Corporation.
22
+ * Portions created by the Initial Developer are Copyright (C) 1998
23
+ * the Initial Developer. All Rights Reserved.
24
+ *
25
+ * Contributor(s):
26
+ * John Bandhauer <jband@netscape.com>
27
+ * Pierre Phaneuf <pp@ludusdesign.com>
28
+ * IBM Corp.
29
+ * Dan Mosedale <dan.mosedale@oracle.com>
30
+ *
31
+ * Alternatively, the contents of this file may be used under the terms of
32
+ * either of the GNU General Public License Version 2 or later (the "GPL"),
33
+ * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
34
+ * in which case the provisions of the GPL or the LGPL are applicable instead
35
+ * of those above. If you wish to allow use of your version of this file only
36
+ * under the terms of either the GPL or the LGPL, and not to allow others to
37
+ * use your version of this file under the terms of the MPL, indicate your
38
+ * decision by deleting the provisions above and replace them with the notice
39
+ * and other provisions required by the GPL or the LGPL. If you do not delete
40
+ * the provisions above, a recipient may use your version of this file under
41
+ * the terms of any one of the MPL, the GPL or the LGPL.
42
+ *
43
+ * ***** END LICENSE BLOCK ***** */
44
+
45
+ /* XPConnect JavaScript interactive shell. */
46
+
47
+ #include <stdio.h>
48
+ #include "nsXULAppAPI.h"
49
+ #include "nsServiceManagerUtils.h"
50
+ #include "nsComponentManagerUtils.h"
51
+ #include "nsStringAPI.h"
52
+ #include "nsIXPConnect.h"
53
+ #include "nsIXPCScriptable.h"
54
+ #include "nsIInterfaceInfo.h"
55
+ #include "nsIInterfaceInfoManager.h"
56
+ #include "nsIXPCScriptable.h"
57
+ #include "nsIServiceManager.h"
58
+ #include "nsIComponentManager.h"
59
+ #include "nsIComponentRegistrar.h"
60
+ #include "nsILocalFile.h"
61
+ #include "nsStringAPI.h"
62
+ #include "nsIDirectoryService.h"
63
+ #include "nsILocalFile.h"
64
+ #include "nsDirectoryServiceDefs.h"
65
+ #include "jsapi.h"
66
+ #include "jsdbgapi.h"
67
+ #include "jsprf.h"
68
+ #include "nscore.h"
69
+ #include "nsMemory.h"
70
+ #include "nsIGenericFactory.h"
71
+ #include "nsISupportsImpl.h"
72
+ #include "nsIJSRuntimeService.h"
73
+ #include "nsCOMPtr.h"
74
+ #include "nsAutoPtr.h"
75
+ #include "nsIXPCSecurityManager.h"
76
+ #ifdef XP_MACOSX
77
+ #include "xpcshellMacUtils.h"
78
+ #endif
79
+ #ifdef XP_WIN
80
+ #include <windows.h>
81
+ #endif
82
+
83
+ #ifndef XPCONNECT_STANDALONE
84
+ #include "nsIScriptSecurityManager.h"
85
+ #include "nsIPrincipal.h"
86
+ #endif
87
+
88
+ // all this crap is needed to do the interactive shell stuff
89
+ #include <stdlib.h>
90
+ #include <errno.h>
91
+ #if defined(XP_WIN) || defined(XP_OS2)
92
+ #include <io.h> /* for isatty() */
93
+ #elif defined(XP_UNIX) || defined(XP_BEOS)
94
+ #include <unistd.h> /* for isatty() */
95
+ #endif
96
+
97
+ #include "nsIJSContextStack.h"
98
+
99
+ class XPCShellDirProvider : public nsIDirectoryServiceProvider
100
+ {
101
+ public:
102
+ NS_DECL_ISUPPORTS_INHERITED
103
+ NS_DECL_NSIDIRECTORYSERVICEPROVIDER
104
+
105
+ XPCShellDirProvider() { }
106
+ ~XPCShellDirProvider() { }
107
+
108
+ PRBool SetGREDir(const char *dir);
109
+ void ClearGREDir() { mGREDir = nsnull; }
110
+
111
+ private:
112
+ nsCOMPtr<nsILocalFile> mGREDir;
113
+ };
114
+
115
+ /***************************************************************************/
116
+
117
+ #ifdef JS_THREADSAFE
118
+ #define DoBeginRequest(cx) JS_BeginRequest((cx))
119
+ #define DoEndRequest(cx) JS_EndRequest((cx))
120
+ #else
121
+ #define DoBeginRequest(cx) ((void)0)
122
+ #define DoEndRequest(cx) ((void)0)
123
+ #endif
124
+
125
+ /***************************************************************************/
126
+
127
+ static const char kXPConnectServiceContractID[] = "@mozilla.org/js/xpc/XPConnect;1";
128
+
129
+ #define EXITCODE_RUNTIME_ERROR 3
130
+ #define EXITCODE_FILE_NOT_FOUND 4
131
+
132
+ FILE *gOutFile = NULL;
133
+ FILE *gErrFile = NULL;
134
+ FILE *gInFile = NULL;
135
+
136
+ int gExitCode = 0;
137
+ JSBool gQuitting = JS_FALSE;
138
+ static JSBool reportWarnings = JS_TRUE;
139
+ static JSBool compileOnly = JS_FALSE;
140
+
141
+ JSPrincipals *gJSPrincipals = nsnull;
142
+ nsAutoString *gWorkingDirectory = nsnull;
143
+
144
+ static JSBool
145
+ GetLocationProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
146
+ {
147
+ #if (!defined(XP_WIN) && !defined(XP_UNIX)) || defined(WINCE)
148
+ //XXX: your platform should really implement this
149
+ return JS_FALSE;
150
+ #else
151
+ JSStackFrame *fp = JS_GetScriptedCaller(cx, NULL);
152
+ JSScript *script = JS_GetFrameScript(cx, fp);
153
+ const char *filename = JS_GetScriptFilename(cx, script);
154
+
155
+ if (filename) {
156
+ nsresult rv;
157
+ nsCOMPtr<nsIXPConnect> xpc =
158
+ do_GetService(kXPConnectServiceContractID, &rv);
159
+
160
+ #if defined(XP_WIN)
161
+ // convert from the system codepage to UTF-16
162
+ int bufferSize = MultiByteToWideChar(CP_ACP, 0, filename,
163
+ -1, NULL, 0);
164
+ nsAutoString filenameString;
165
+ filenameString.SetLength(bufferSize);
166
+ MultiByteToWideChar(CP_ACP, 0, filename,
167
+ -1, (LPWSTR)filenameString.BeginWriting(),
168
+ filenameString.Length());
169
+ // remove the null terminator
170
+ filenameString.SetLength(bufferSize - 1);
171
+
172
+ // replace forward slashes with backslashes,
173
+ // since nsLocalFileWin chokes on them
174
+ PRUnichar *start, *end;
175
+
176
+ filenameString.BeginWriting(&start, &end);
177
+
178
+ while (start != end) {
179
+ if (*start == L'/')
180
+ *start = L'\\';
181
+ start++;
182
+ }
183
+ #elif defined(XP_UNIX)
184
+ NS_ConvertUTF8toUTF16 filenameString(filename);
185
+ #endif
186
+
187
+ nsCOMPtr<nsILocalFile> location;
188
+ if (NS_SUCCEEDED(rv)) {
189
+ rv = NS_NewLocalFile(filenameString,
190
+ PR_FALSE, getter_AddRefs(location));
191
+ }
192
+
193
+ if (!location && gWorkingDirectory) {
194
+ // could be a relative path, try appending it to the cwd
195
+ // and then normalize
196
+ nsAutoString absolutePath(*gWorkingDirectory);
197
+ absolutePath.Append(filenameString);
198
+
199
+ rv = NS_NewLocalFile(absolutePath,
200
+ PR_FALSE, getter_AddRefs(location));
201
+ }
202
+
203
+ if (location) {
204
+ nsCOMPtr<nsIXPConnectJSObjectHolder> locationHolder;
205
+ JSObject *locationObj = NULL;
206
+
207
+ PRBool symlink;
208
+ // don't normalize symlinks, because that's kind of confusing
209
+ if (NS_SUCCEEDED(location->IsSymlink(&symlink)) &&
210
+ !symlink)
211
+ location->Normalize();
212
+ rv = xpc->WrapNative(cx, obj, location,
213
+ NS_GET_IID(nsILocalFile),
214
+ getter_AddRefs(locationHolder));
215
+
216
+ if (NS_SUCCEEDED(rv) &&
217
+ NS_SUCCEEDED(locationHolder->GetJSObject(&locationObj))) {
218
+ *vp = OBJECT_TO_JSVAL(locationObj);
219
+ }
220
+ }
221
+ }
222
+
223
+ return JS_TRUE;
224
+ #endif
225
+ }
226
+
227
+ static JSBool
228
+ GetLine(JSContext *cx, char *bufp, FILE *file, const char *prompt) {
229
+ #ifdef EDITLINE
230
+ /*
231
+ * Use readline only if file is stdin, because there's no way to specify
232
+ * another handle. Are other filehandles interactive?
233
+ */
234
+ if (file == stdin) {
235
+ char *linep = readline(prompt);
236
+ if (!linep)
237
+ return JS_FALSE;
238
+ if (*linep)
239
+ add_history(linep);
240
+ strcpy(bufp, linep);
241
+ JS_free(cx, linep);
242
+ bufp += strlen(bufp);
243
+ *bufp++ = '\n';
244
+ *bufp = '\0';
245
+ } else
246
+ #endif
247
+ {
248
+ char line[256];
249
+ fprintf(gOutFile, prompt);
250
+ fflush(gOutFile);
251
+ if (!fgets(line, sizeof line, file))
252
+ return JS_FALSE;
253
+ strcpy(bufp, line);
254
+ }
255
+ return JS_TRUE;
256
+ }
257
+
258
+ static void
259
+ my_ErrorReporter(JSContext *cx, const char *message, JSErrorReport *report)
260
+ {
261
+ int i, j, k, n;
262
+ char *prefix = NULL, *tmp;
263
+ const char *ctmp;
264
+ JSStackFrame * fp = nsnull;
265
+ nsCOMPtr<nsIXPConnect> xpc;
266
+
267
+ // Don't report an exception from inner JS frames as the callers may intend
268
+ // to handle it.
269
+ while ((fp = JS_FrameIterator(cx, &fp))) {
270
+ if (!JS_IsNativeFrame(cx, fp)) {
271
+ return;
272
+ }
273
+ }
274
+
275
+ // In some cases cx->fp is null here so use XPConnect to tell us about inner
276
+ // frames.
277
+ if ((xpc = do_GetService(nsIXPConnect::GetCID()))) {
278
+ nsAXPCNativeCallContext *cc = nsnull;
279
+ xpc->GetCurrentNativeCallContext(&cc);
280
+ if (cc) {
281
+ nsAXPCNativeCallContext *prev = cc;
282
+ while (NS_SUCCEEDED(prev->GetPreviousCallContext(&prev)) && prev) {
283
+ PRUint16 lang;
284
+ if (NS_SUCCEEDED(prev->GetLanguage(&lang)) &&
285
+ lang == nsAXPCNativeCallContext::LANG_JS) {
286
+ return;
287
+ }
288
+ }
289
+ }
290
+ }
291
+
292
+ if (!report) {
293
+ fprintf(gErrFile, "%s\n", message);
294
+ return;
295
+ }
296
+
297
+ /* Conditionally ignore reported warnings. */
298
+ if (JSREPORT_IS_WARNING(report->flags) && !reportWarnings)
299
+ return;
300
+
301
+ if (report->filename)
302
+ prefix = JS_smprintf("%s:", report->filename);
303
+ if (report->lineno) {
304
+ tmp = prefix;
305
+ prefix = JS_smprintf("%s%u: ", tmp ? tmp : "", report->lineno);
306
+ JS_free(cx, tmp);
307
+ }
308
+ if (JSREPORT_IS_WARNING(report->flags)) {
309
+ tmp = prefix;
310
+ prefix = JS_smprintf("%s%swarning: ",
311
+ tmp ? tmp : "",
312
+ JSREPORT_IS_STRICT(report->flags) ? "strict " : "");
313
+ JS_free(cx, tmp);
314
+ }
315
+
316
+ /* embedded newlines -- argh! */
317
+ while ((ctmp = strchr(message, '\n')) != 0) {
318
+ ctmp++;
319
+ if (prefix) fputs(prefix, gErrFile);
320
+ fwrite(message, 1, ctmp - message, gErrFile);
321
+ message = ctmp;
322
+ }
323
+ /* If there were no filename or lineno, the prefix might be empty */
324
+ if (prefix)
325
+ fputs(prefix, gErrFile);
326
+ fputs(message, gErrFile);
327
+
328
+ if (!report->linebuf) {
329
+ fputc('\n', gErrFile);
330
+ goto out;
331
+ }
332
+
333
+ fprintf(gErrFile, ":\n%s%s\n%s", prefix, report->linebuf, prefix);
334
+ n = report->tokenptr - report->linebuf;
335
+ for (i = j = 0; i < n; i++) {
336
+ if (report->linebuf[i] == '\t') {
337
+ for (k = (j + 8) & ~7; j < k; j++) {
338
+ fputc('.', gErrFile);
339
+ }
340
+ continue;
341
+ }
342
+ fputc('.', gErrFile);
343
+ j++;
344
+ }
345
+ fputs("^\n", gErrFile);
346
+ out:
347
+ if (!JSREPORT_IS_WARNING(report->flags))
348
+ gExitCode = EXITCODE_RUNTIME_ERROR;
349
+ JS_free(cx, prefix);
350
+ }
351
+
352
+ static JSBool
353
+ ReadLine(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
354
+ {
355
+ // While 4096 might be quite arbitrary, this is something to be fixed in
356
+ // bug 105707. It is also the same limit as in ProcessFile.
357
+ char buf[4096];
358
+ JSString *str;
359
+
360
+ /* If a prompt was specified, construct the string */
361
+ if (argc > 0) {
362
+ str = JS_ValueToString(cx, argv[0]);
363
+ if (!str)
364
+ return JS_FALSE;
365
+ argv[0] = STRING_TO_JSVAL(str);
366
+ } else {
367
+ str = JSVAL_TO_STRING(JS_GetEmptyStringValue(cx));
368
+ }
369
+
370
+ /* Get a line from the infile */
371
+ if (!GetLine(cx, buf, gInFile, JS_GetStringBytes(str)))
372
+ return JS_FALSE;
373
+
374
+ /* Strip newline character added by GetLine() */
375
+ unsigned int buflen = strlen(buf);
376
+ if (buflen == 0) {
377
+ if (feof(gInFile)) {
378
+ *rval = JSVAL_NULL;
379
+ return JS_TRUE;
380
+ }
381
+ } else if (buf[buflen - 1] == '\n') {
382
+ --buflen;
383
+ }
384
+
385
+ /* Turn buf into a JSString */
386
+ str = JS_NewStringCopyN(cx, buf, buflen);
387
+ if (!str)
388
+ return JS_FALSE;
389
+
390
+ *rval = STRING_TO_JSVAL(str);
391
+ return JS_TRUE;
392
+ }
393
+
394
+ static JSBool
395
+ Print(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
396
+ {
397
+ uintN i, n;
398
+ JSString *str;
399
+
400
+ for (i = n = 0; i < argc; i++) {
401
+ str = JS_ValueToString(cx, argv[i]);
402
+ if (!str)
403
+ return JS_FALSE;
404
+ fprintf(gOutFile, "%s%s", i ? " " : "", JS_GetStringBytes(str));
405
+ }
406
+ n++;
407
+ if (n)
408
+ fputc('\n', gOutFile);
409
+ return JS_TRUE;
410
+ }
411
+
412
+ static JSBool
413
+ Dump(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
414
+ {
415
+ JSString *str;
416
+ if (!argc)
417
+ return JS_TRUE;
418
+
419
+ str = JS_ValueToString(cx, argv[0]);
420
+ if (!str)
421
+ return JS_FALSE;
422
+
423
+ char *bytes = JS_GetStringBytes(str);
424
+ bytes = strdup(bytes);
425
+
426
+ fputs(bytes, gOutFile);
427
+ free(bytes);
428
+ return JS_TRUE;
429
+ }
430
+
431
+ static JSBool
432
+ Load(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
433
+ {
434
+ uintN i;
435
+ JSString *str;
436
+ const char *filename;
437
+ JSScript *script;
438
+ JSBool ok;
439
+ jsval result;
440
+ FILE *file;
441
+
442
+ for (i = 0; i < argc; i++) {
443
+ str = JS_ValueToString(cx, argv[i]);
444
+ if (!str)
445
+ return JS_FALSE;
446
+ argv[i] = STRING_TO_JSVAL(str);
447
+ filename = JS_GetStringBytes(str);
448
+ file = fopen(filename, "r");
449
+ if (!file) {
450
+ JS_ReportError(cx, "cannot open file '%s' for reading", filename);
451
+ return JS_FALSE;
452
+ }
453
+ script = JS_CompileFileHandleForPrincipals(cx, obj, filename, file,
454
+ gJSPrincipals);
455
+ fclose(file);
456
+ if (!script)
457
+ return JS_FALSE;
458
+
459
+ ok = !compileOnly
460
+ ? JS_ExecuteScript(cx, obj, script, &result)
461
+ : JS_TRUE;
462
+ JS_DestroyScript(cx, script);
463
+ if (!ok)
464
+ return JS_FALSE;
465
+ }
466
+ return JS_TRUE;
467
+ }
468
+
469
+ static JSBool
470
+ Version(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
471
+ {
472
+ if (argc > 0 && JSVAL_IS_INT(argv[0]))
473
+ *rval = INT_TO_JSVAL(JS_SetVersion(cx, JSVersion(JSVAL_TO_INT(argv[0]))));
474
+ else
475
+ *rval = INT_TO_JSVAL(JS_GetVersion(cx));
476
+ return JS_TRUE;
477
+ }
478
+
479
+ static JSBool
480
+ BuildDate(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
481
+ {
482
+ fprintf(gOutFile, "built on %s at %s\n", __DATE__, __TIME__);
483
+ return JS_TRUE;
484
+ }
485
+
486
+ static JSBool
487
+ Quit(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
488
+ {
489
+ #ifdef LIVECONNECT
490
+ JSJ_SimpleShutdown();
491
+ #endif
492
+
493
+ gExitCode = 0;
494
+ JS_ConvertArguments(cx, argc, argv,"/ i", &gExitCode);
495
+
496
+ gQuitting = JS_TRUE;
497
+ // exit(0);
498
+ return JS_FALSE;
499
+ }
500
+
501
+ static JSBool
502
+ DumpXPC(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
503
+ {
504
+ int32 depth = 2;
505
+
506
+ if (argc > 0) {
507
+ if (!JS_ValueToInt32(cx, argv[0], &depth))
508
+ return JS_FALSE;
509
+ }
510
+
511
+ nsCOMPtr<nsIXPConnect> xpc = do_GetService(nsIXPConnect::GetCID());
512
+ if(xpc)
513
+ xpc->DebugDump((int16)depth);
514
+ return JS_TRUE;
515
+ }
516
+
517
+ /* XXX needed only by GC() */
518
+ #include "jscntxt.h"
519
+
520
+ static JSBool
521
+ GC(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
522
+ {
523
+ JSRuntime *rt;
524
+ uint32 preBytes;
525
+
526
+ rt = cx->runtime;
527
+ preBytes = rt->gcBytes;
528
+ JS_GC(cx);
529
+ fprintf(gOutFile, "before %lu, after %lu, break %08lx\n",
530
+ (unsigned long)preBytes, (unsigned long)rt->gcBytes,
531
+ #ifdef XP_UNIX
532
+ (unsigned long)sbrk(0)
533
+ #else
534
+ 0
535
+ #endif
536
+ );
537
+ #ifdef JS_GCMETER
538
+ js_DumpGCStats(rt, stdout);
539
+ #endif
540
+ return JS_TRUE;
541
+ }
542
+
543
+ #ifdef DEBUG
544
+
545
+ static JSBool
546
+ DumpHeap(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
547
+ {
548
+ char *fileName = NULL;
549
+ void* startThing = NULL;
550
+ uint32 startTraceKind = 0;
551
+ void *thingToFind = NULL;
552
+ size_t maxDepth = (size_t)-1;
553
+ void *thingToIgnore = NULL;
554
+ jsval *vp;
555
+ FILE *dumpFile;
556
+ JSBool ok;
557
+
558
+ vp = &argv[0];
559
+ if (*vp != JSVAL_NULL && *vp != JSVAL_VOID) {
560
+ JSString *str;
561
+
562
+ str = JS_ValueToString(cx, *vp);
563
+ if (!str)
564
+ return JS_FALSE;
565
+ *vp = STRING_TO_JSVAL(str);
566
+ fileName = JS_GetStringBytes(str);
567
+ }
568
+
569
+ vp = &argv[1];
570
+ if (*vp != JSVAL_NULL && *vp != JSVAL_VOID) {
571
+ if (!JSVAL_IS_TRACEABLE(*vp))
572
+ goto not_traceable_arg;
573
+ startThing = JSVAL_TO_TRACEABLE(*vp);
574
+ startTraceKind = JSVAL_TRACE_KIND(*vp);
575
+ }
576
+
577
+ vp = &argv[2];
578
+ if (*vp != JSVAL_NULL && *vp != JSVAL_VOID) {
579
+ if (!JSVAL_IS_TRACEABLE(*vp))
580
+ goto not_traceable_arg;
581
+ thingToFind = JSVAL_TO_TRACEABLE(*vp);
582
+ }
583
+
584
+ vp = &argv[3];
585
+ if (*vp != JSVAL_NULL && *vp != JSVAL_VOID) {
586
+ uint32 depth;
587
+
588
+ if (!JS_ValueToECMAUint32(cx, *vp, &depth))
589
+ return JS_FALSE;
590
+ maxDepth = depth;
591
+ }
592
+
593
+ vp = &argv[4];
594
+ if (*vp != JSVAL_NULL && *vp != JSVAL_VOID) {
595
+ if (!JSVAL_IS_TRACEABLE(*vp))
596
+ goto not_traceable_arg;
597
+ thingToIgnore = JSVAL_TO_TRACEABLE(*vp);
598
+ }
599
+
600
+ if (!fileName) {
601
+ dumpFile = gOutFile;
602
+ } else {
603
+ dumpFile = fopen(fileName, "w");
604
+ if (!dumpFile) {
605
+ fprintf(gErrFile, "dumpHeap: can't open %s: %s\n",
606
+ fileName, strerror(errno));
607
+ return JS_FALSE;
608
+ }
609
+ }
610
+
611
+ ok = JS_DumpHeap(cx, dumpFile, startThing, startTraceKind, thingToFind,
612
+ maxDepth, thingToIgnore);
613
+ if (dumpFile != gOutFile)
614
+ fclose(dumpFile);
615
+ return ok;
616
+
617
+ not_traceable_arg:
618
+ fprintf(gErrFile,
619
+ "dumpHeap: argument %u is not null or a heap-allocated thing\n",
620
+ (unsigned)(vp - argv));
621
+ return JS_FALSE;
622
+ }
623
+
624
+ #endif /* DEBUG */
625
+
626
+ static JSBool
627
+ Clear(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
628
+ {
629
+ if (argc > 0 && !JSVAL_IS_PRIMITIVE(argv[0])) {
630
+ JS_ClearScope(cx, JSVAL_TO_OBJECT(argv[0]));
631
+ } else {
632
+ JS_ReportError(cx, "'clear' requires an object");
633
+ return JS_FALSE;
634
+ }
635
+ return JS_TRUE;
636
+ }
637
+
638
+ static JSFunctionSpec glob_functions[] = {
639
+ {"print", Print, 0,0,0},
640
+ {"readline", ReadLine, 1,0,0},
641
+ {"load", Load, 1,0,0},
642
+ {"quit", Quit, 0,0,0},
643
+ {"version", Version, 1,0,0},
644
+ {"build", BuildDate, 0,0,0},
645
+ {"dumpXPC", DumpXPC, 1,0,0},
646
+ {"dump", Dump, 1,0,0},
647
+ {"gc", GC, 0,0,0},
648
+ {"clear", Clear, 1,0,0},
649
+ #ifdef DEBUG
650
+ {"dumpHeap", DumpHeap, 5,0,0},
651
+ #endif
652
+ #ifdef MOZ_SHARK
653
+ {"startShark", js_StartShark, 0,0,0},
654
+ {"stopShark", js_StopShark, 0,0,0},
655
+ {"connectShark", js_ConnectShark, 0,0,0},
656
+ {"disconnectShark", js_DisconnectShark, 0,0,0},
657
+ #endif
658
+ #ifdef MOZ_CALLGRIND
659
+ {"startCallgrind", js_StartCallgrind, 0,0,0},
660
+ {"stopCallgrind", js_StopCallgrind, 0,0,0},
661
+ {"dumpCallgrind", js_DumpCallgrind, 1,0,0},
662
+ #endif
663
+ {nsnull,nsnull,0,0,0}
664
+ };
665
+
666
+ JSClass global_class = {
667
+ "global", 0,
668
+ JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, JS_PropertyStub,
669
+ JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, JS_FinalizeStub
670
+ };
671
+
672
+ static JSBool
673
+ env_setProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
674
+ {
675
+ /* XXX porting may be easy, but these don't seem to supply setenv by default */
676
+ #if !defined XP_BEOS && !defined XP_OS2 && !defined SOLARIS
677
+ JSString *idstr, *valstr;
678
+ const char *name, *value;
679
+ int rv;
680
+
681
+ idstr = JS_ValueToString(cx, id);
682
+ valstr = JS_ValueToString(cx, *vp);
683
+ if (!idstr || !valstr)
684
+ return JS_FALSE;
685
+ name = JS_GetStringBytes(idstr);
686
+ value = JS_GetStringBytes(valstr);
687
+ #if defined XP_WIN || defined HPUX || defined OSF1 || defined IRIX \
688
+ || defined SCO
689
+ {
690
+ char *waste = JS_smprintf("%s=%s", name, value);
691
+ if (!waste) {
692
+ JS_ReportOutOfMemory(cx);
693
+ return JS_FALSE;
694
+ }
695
+ rv = putenv(waste);
696
+ #ifdef XP_WIN
697
+ /*
698
+ * HPUX9 at least still has the bad old non-copying putenv.
699
+ *
700
+ * Per mail from <s.shanmuganathan@digital.com>, OSF1 also has a putenv
701
+ * that will crash if you pass it an auto char array (so it must place
702
+ * its argument directly in the char *environ[] array).
703
+ */
704
+ free(waste);
705
+ #endif
706
+ }
707
+ #else
708
+ rv = setenv(name, value, 1);
709
+ #endif
710
+ if (rv < 0) {
711
+ JS_ReportError(cx, "can't set envariable %s to %s", name, value);
712
+ return JS_FALSE;
713
+ }
714
+ *vp = STRING_TO_JSVAL(valstr);
715
+ #endif /* !defined XP_BEOS && !defined XP_OS2 && !defined SOLARIS */
716
+ return JS_TRUE;
717
+ }
718
+
719
+ static JSBool
720
+ env_enumerate(JSContext *cx, JSObject *obj)
721
+ {
722
+ static JSBool reflected;
723
+ char **evp, *name, *value;
724
+ JSString *valstr;
725
+ JSBool ok;
726
+
727
+ if (reflected)
728
+ return JS_TRUE;
729
+
730
+ for (evp = (char **)JS_GetPrivate(cx, obj); (name = *evp) != NULL; evp++) {
731
+ value = strchr(name, '=');
732
+ if (!value)
733
+ continue;
734
+ *value++ = '\0';
735
+ valstr = JS_NewStringCopyZ(cx, value);
736
+ if (!valstr) {
737
+ ok = JS_FALSE;
738
+ } else {
739
+ ok = JS_DefineProperty(cx, obj, name, STRING_TO_JSVAL(valstr),
740
+ NULL, NULL, JSPROP_ENUMERATE);
741
+ }
742
+ value[-1] = '=';
743
+ if (!ok)
744
+ return JS_FALSE;
745
+ }
746
+
747
+ reflected = JS_TRUE;
748
+ return JS_TRUE;
749
+ }
750
+
751
+ static JSBool
752
+ env_resolve(JSContext *cx, JSObject *obj, jsval id, uintN flags,
753
+ JSObject **objp)
754
+ {
755
+ JSString *idstr, *valstr;
756
+ const char *name, *value;
757
+
758
+ if (flags & JSRESOLVE_ASSIGNING)
759
+ return JS_TRUE;
760
+
761
+ idstr = JS_ValueToString(cx, id);
762
+ if (!idstr)
763
+ return JS_FALSE;
764
+ name = JS_GetStringBytes(idstr);
765
+ value = getenv(name);
766
+ if (value) {
767
+ valstr = JS_NewStringCopyZ(cx, value);
768
+ if (!valstr)
769
+ return JS_FALSE;
770
+ if (!JS_DefineProperty(cx, obj, name, STRING_TO_JSVAL(valstr),
771
+ NULL, NULL, JSPROP_ENUMERATE)) {
772
+ return JS_FALSE;
773
+ }
774
+ *objp = obj;
775
+ }
776
+ return JS_TRUE;
777
+ }
778
+
779
+ static JSClass env_class = {
780
+ "environment", JSCLASS_HAS_PRIVATE | JSCLASS_NEW_RESOLVE,
781
+ JS_PropertyStub, JS_PropertyStub,
782
+ JS_PropertyStub, env_setProperty,
783
+ env_enumerate, (JSResolveOp) env_resolve,
784
+ JS_ConvertStub, JS_FinalizeStub
785
+ };
786
+
787
+ /***************************************************************************/
788
+
789
+ typedef enum JSShellErrNum {
790
+ #define MSG_DEF(name, number, count, exception, format) \
791
+ name = number,
792
+ #include "jsshell.msg"
793
+ #undef MSG_DEF
794
+ JSShellErr_Limit
795
+ #undef MSGDEF
796
+ } JSShellErrNum;
797
+
798
+ JSErrorFormatString jsShell_ErrorFormatString[JSErr_Limit] = {
799
+ #define MSG_DEF(name, number, count, exception, format) \
800
+ { format, count } ,
801
+ #include "jsshell.msg"
802
+ #undef MSG_DEF
803
+ };
804
+
805
+ static const JSErrorFormatString *
806
+ my_GetErrorMessage(void *userRef, const char *locale, const uintN errorNumber)
807
+ {
808
+ if ((errorNumber > 0) && (errorNumber < JSShellErr_Limit))
809
+ return &jsShell_ErrorFormatString[errorNumber];
810
+ else
811
+ return NULL;
812
+ }
813
+
814
+ #ifdef EDITLINE
815
+ extern "C" {
816
+ extern char *readline(const char *prompt);
817
+ extern void add_history(char *line);
818
+ }
819
+ #endif
820
+
821
+ static void
822
+ ProcessFile(JSContext *cx, JSObject *obj, const char *filename, FILE *file,
823
+ JSBool forceTTY)
824
+ {
825
+ JSScript *script;
826
+ jsval result;
827
+ int lineno, startline;
828
+ JSBool ok, hitEOF;
829
+ char *bufp, buffer[4096];
830
+ JSString *str;
831
+
832
+ if (forceTTY) {
833
+ file = stdin;
834
+ } else if (!isatty(fileno(file))) {
835
+ /*
836
+ * It's not interactive - just execute it.
837
+ *
838
+ * Support the UNIX #! shell hack; gobble the first line if it starts
839
+ * with '#'. TODO - this isn't quite compatible with sharp variables,
840
+ * as a legal js program (using sharp variables) might start with '#'.
841
+ * But that would require multi-character lookahead.
842
+ */
843
+ int ch = fgetc(file);
844
+ if (ch == '#') {
845
+ while((ch = fgetc(file)) != EOF) {
846
+ if(ch == '\n' || ch == '\r')
847
+ break;
848
+ }
849
+ }
850
+ ungetc(ch, file);
851
+ DoBeginRequest(cx);
852
+
853
+ script = JS_CompileFileHandleForPrincipals(cx, obj, filename, file,
854
+ gJSPrincipals);
855
+
856
+ if (script) {
857
+ if (!compileOnly)
858
+ (void)JS_ExecuteScript(cx, obj, script, &result);
859
+ JS_DestroyScript(cx, script);
860
+ }
861
+ DoEndRequest(cx);
862
+
863
+ return;
864
+ }
865
+
866
+ /* It's an interactive filehandle; drop into read-eval-print loop. */
867
+ lineno = 1;
868
+ hitEOF = JS_FALSE;
869
+ do {
870
+ bufp = buffer;
871
+ *bufp = '\0';
872
+
873
+ /*
874
+ * Accumulate lines until we get a 'compilable unit' - one that either
875
+ * generates an error (before running out of source) or that compiles
876
+ * cleanly. This should be whenever we get a complete statement that
877
+ * coincides with the end of a line.
878
+ */
879
+ startline = lineno;
880
+ do {
881
+ if (!GetLine(cx, bufp, file, startline == lineno ? "js> " : "")) {
882
+ hitEOF = JS_TRUE;
883
+ break;
884
+ }
885
+ bufp += strlen(bufp);
886
+ lineno++;
887
+ } while (!JS_BufferIsCompilableUnit(cx, obj, buffer, strlen(buffer)));
888
+
889
+ DoBeginRequest(cx);
890
+ /* Clear any pending exception from previous failed compiles. */
891
+ JS_ClearPendingException(cx);
892
+ script = JS_CompileScriptForPrincipals(cx, obj, gJSPrincipals, buffer,
893
+ strlen(buffer), "typein", startline);
894
+ if (script) {
895
+ JSErrorReporter older;
896
+
897
+ if (!compileOnly) {
898
+ ok = JS_ExecuteScript(cx, obj, script, &result);
899
+ if (ok && result != JSVAL_VOID) {
900
+ /* Suppress error reports from JS_ValueToString(). */
901
+ older = JS_SetErrorReporter(cx, NULL);
902
+ str = JS_ValueToString(cx, result);
903
+ JS_SetErrorReporter(cx, older);
904
+
905
+ if (str)
906
+ fprintf(gOutFile, "%s\n", JS_GetStringBytes(str));
907
+ else
908
+ ok = JS_FALSE;
909
+ }
910
+ }
911
+ JS_DestroyScript(cx, script);
912
+ }
913
+ DoEndRequest(cx);
914
+ } while (!hitEOF && !gQuitting);
915
+
916
+ fprintf(gOutFile, "\n");
917
+ }
918
+
919
+ static void
920
+ Process(JSContext *cx, JSObject *obj, const char *filename, JSBool forceTTY)
921
+ {
922
+ FILE *file;
923
+
924
+ if (forceTTY || !filename || strcmp(filename, "-") == 0) {
925
+ file = stdin;
926
+ } else {
927
+ file = fopen(filename, "r");
928
+ if (!file) {
929
+ JS_ReportErrorNumber(cx, my_GetErrorMessage, NULL,
930
+ JSSMSG_CANT_OPEN,
931
+ filename, strerror(errno));
932
+ gExitCode = EXITCODE_FILE_NOT_FOUND;
933
+ return;
934
+ }
935
+ }
936
+
937
+ ProcessFile(cx, obj, filename, file, forceTTY);
938
+ if (file != stdin)
939
+ fclose(file);
940
+ }
941
+
942
+ static int
943
+ usage(void)
944
+ {
945
+ fprintf(gErrFile, "%s\n", JS_GetImplementationVersion());
946
+ fprintf(gErrFile, "usage: xpcshell [-g gredir] [-PswWxCij] [-v version] [-f scriptfile] [-e script] [scriptfile] [scriptarg...]\n");
947
+ return 2;
948
+ }
949
+
950
+ extern JSClass global_class;
951
+
952
+ static int
953
+ ProcessArgs(JSContext *cx, JSObject *obj, char **argv, int argc)
954
+ {
955
+ const char rcfilename[] = "xpcshell.js";
956
+ FILE *rcfile;
957
+ int i, j, length;
958
+ JSObject *argsObj;
959
+ char *filename = NULL;
960
+ JSBool isInteractive = JS_TRUE;
961
+ JSBool forceTTY = JS_FALSE;
962
+
963
+ rcfile = fopen(rcfilename, "r");
964
+ if (rcfile) {
965
+ printf("[loading '%s'...]\n", rcfilename);
966
+ ProcessFile(cx, obj, rcfilename, rcfile, JS_FALSE);
967
+ fclose(rcfile);
968
+ }
969
+
970
+ /*
971
+ * Scan past all optional arguments so we can create the arguments object
972
+ * before processing any -f options, which must interleave properly with
973
+ * -v and -w options. This requires two passes, and without getopt, we'll
974
+ * have to keep the option logic here and in the second for loop in sync.
975
+ */
976
+ for (i = 0; i < argc; i++) {
977
+ if (argv[i][0] != '-' || argv[i][1] == '\0') {
978
+ ++i;
979
+ break;
980
+ }
981
+ switch (argv[i][1]) {
982
+ case 'v':
983
+ case 'f':
984
+ case 'e':
985
+ ++i;
986
+ break;
987
+ default:;
988
+ }
989
+ }
990
+
991
+ /*
992
+ * Create arguments early and define it to root it, so it's safe from any
993
+ * GC calls nested below, and so it is available to -f <file> arguments.
994
+ */
995
+ argsObj = JS_NewArrayObject(cx, 0, NULL);
996
+ if (!argsObj)
997
+ return 1;
998
+ if (!JS_DefineProperty(cx, obj, "arguments", OBJECT_TO_JSVAL(argsObj),
999
+ NULL, NULL, 0)) {
1000
+ return 1;
1001
+ }
1002
+
1003
+ length = argc - i;
1004
+ for (j = 0; j < length; j++) {
1005
+ JSString *str = JS_NewStringCopyZ(cx, argv[i++]);
1006
+ if (!str)
1007
+ return 1;
1008
+ if (!JS_DefineElement(cx, argsObj, j, STRING_TO_JSVAL(str),
1009
+ NULL, NULL, JSPROP_ENUMERATE)) {
1010
+ return 1;
1011
+ }
1012
+ }
1013
+
1014
+ for (i = 0; i < argc; i++) {
1015
+ if (argv[i][0] != '-' || argv[i][1] == '\0') {
1016
+ filename = argv[i++];
1017
+ isInteractive = JS_FALSE;
1018
+ break;
1019
+ }
1020
+ switch (argv[i][1]) {
1021
+ case 'v':
1022
+ if (++i == argc) {
1023
+ return usage();
1024
+ }
1025
+ JS_SetVersion(cx, JSVersion(atoi(argv[i])));
1026
+ break;
1027
+ case 'W':
1028
+ reportWarnings = JS_FALSE;
1029
+ break;
1030
+ case 'w':
1031
+ reportWarnings = JS_TRUE;
1032
+ break;
1033
+ case 's':
1034
+ JS_ToggleOptions(cx, JSOPTION_STRICT);
1035
+ break;
1036
+ case 'x':
1037
+ JS_ToggleOptions(cx, JSOPTION_XML);
1038
+ break;
1039
+ case 'P':
1040
+ if (JS_GET_CLASS(cx, JS_GetPrototype(cx, obj)) != &global_class) {
1041
+ JSObject *gobj;
1042
+
1043
+ if (!JS_SealObject(cx, obj, JS_TRUE))
1044
+ return JS_FALSE;
1045
+ gobj = JS_NewObject(cx, &global_class, NULL, NULL);
1046
+ if (!gobj)
1047
+ return JS_FALSE;
1048
+ if (!JS_SetPrototype(cx, gobj, obj))
1049
+ return JS_FALSE;
1050
+ JS_SetParent(cx, gobj, NULL);
1051
+ JS_SetGlobalObject(cx, gobj);
1052
+ obj = gobj;
1053
+ }
1054
+ break;
1055
+ case 'f':
1056
+ if (++i == argc) {
1057
+ return usage();
1058
+ }
1059
+ Process(cx, obj, argv[i], JS_FALSE);
1060
+ /*
1061
+ * XXX: js -f foo.js should interpret foo.js and then
1062
+ * drop into interactive mode, but that breaks test
1063
+ * harness. Just execute foo.js for now.
1064
+ */
1065
+ isInteractive = JS_FALSE;
1066
+ break;
1067
+ case 'i':
1068
+ isInteractive = forceTTY = JS_TRUE;
1069
+ break;
1070
+ case 'e':
1071
+ {
1072
+ jsval rval;
1073
+
1074
+ if (++i == argc) {
1075
+ return usage();
1076
+ }
1077
+
1078
+ JS_EvaluateScriptForPrincipals(cx, obj, gJSPrincipals, argv[i],
1079
+ strlen(argv[i]), "-e", 1, &rval);
1080
+
1081
+ isInteractive = JS_FALSE;
1082
+ break;
1083
+ }
1084
+ case 'C':
1085
+ compileOnly = JS_TRUE;
1086
+ isInteractive = JS_FALSE;
1087
+ break;
1088
+ case 'j':
1089
+ JS_ToggleOptions(cx, JSOPTION_JIT);
1090
+ break;
1091
+ #ifdef MOZ_SHARK
1092
+ case 'k':
1093
+ JS_ConnectShark();
1094
+ break;
1095
+ #endif
1096
+ default:
1097
+ return usage();
1098
+ }
1099
+ }
1100
+
1101
+ if (filename || isInteractive)
1102
+ Process(cx, obj, filename, forceTTY);
1103
+ return gExitCode;
1104
+ }
1105
+
1106
+ /***************************************************************************/
1107
+
1108
+ class FullTrustSecMan
1109
+ #ifndef XPCONNECT_STANDALONE
1110
+ : public nsIScriptSecurityManager
1111
+ #else
1112
+ : public nsIXPCSecurityManager
1113
+ #endif
1114
+ {
1115
+ public:
1116
+ NS_DECL_ISUPPORTS
1117
+ NS_DECL_NSIXPCSECURITYMANAGER
1118
+ #ifndef XPCONNECT_STANDALONE
1119
+ NS_DECL_NSISCRIPTSECURITYMANAGER
1120
+ #endif
1121
+
1122
+ FullTrustSecMan();
1123
+ virtual ~FullTrustSecMan();
1124
+
1125
+ #ifndef XPCONNECT_STANDALONE
1126
+ void SetSystemPrincipal(nsIPrincipal *aPrincipal) {
1127
+ mSystemPrincipal = aPrincipal;
1128
+ }
1129
+
1130
+ private:
1131
+ nsCOMPtr<nsIPrincipal> mSystemPrincipal;
1132
+ #endif
1133
+ };
1134
+
1135
+ NS_INTERFACE_MAP_BEGIN(FullTrustSecMan)
1136
+ NS_INTERFACE_MAP_ENTRY(nsIXPCSecurityManager)
1137
+ #ifndef XPCONNECT_STANDALONE
1138
+ NS_INTERFACE_MAP_ENTRY(nsIScriptSecurityManager)
1139
+ #endif
1140
+ NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIXPCSecurityManager)
1141
+ NS_INTERFACE_MAP_END
1142
+
1143
+ NS_IMPL_ADDREF(FullTrustSecMan)
1144
+ NS_IMPL_RELEASE(FullTrustSecMan)
1145
+
1146
+ FullTrustSecMan::FullTrustSecMan()
1147
+ {
1148
+ #ifndef XPCONNECT_STANDALONE
1149
+ mSystemPrincipal = nsnull;
1150
+ #endif
1151
+ }
1152
+
1153
+ FullTrustSecMan::~FullTrustSecMan()
1154
+ {
1155
+ }
1156
+
1157
+ NS_IMETHODIMP
1158
+ FullTrustSecMan::CanCreateWrapper(JSContext * aJSContext, const nsIID & aIID,
1159
+ nsISupports *aObj, nsIClassInfo *aClassInfo,
1160
+ void * *aPolicy)
1161
+ {
1162
+ return NS_OK;
1163
+ }
1164
+
1165
+ NS_IMETHODIMP
1166
+ FullTrustSecMan::CanCreateInstance(JSContext * aJSContext, const nsCID & aCID)
1167
+ {
1168
+ return NS_OK;
1169
+ }
1170
+
1171
+ NS_IMETHODIMP
1172
+ FullTrustSecMan::CanGetService(JSContext * aJSContext, const nsCID & aCID)
1173
+ {
1174
+ return NS_OK;
1175
+ }
1176
+
1177
+ #ifndef XPCONNECT_STANDALONE
1178
+ /* void CanAccess (in PRUint32 aAction, in nsIXPCNativeCallContext aCallContext, in JSContextPtr aJSContext, in JSObjectPtr aJSObject, in nsISupports aObj, in nsIClassInfo aClassInfo, in JSVal aName, inout voidPtr aPolicy); */
1179
+ NS_IMETHODIMP
1180
+ FullTrustSecMan::CanAccess(PRUint32 aAction,
1181
+ nsAXPCNativeCallContext *aCallContext,
1182
+ JSContext * aJSContext, JSObject * aJSObject,
1183
+ nsISupports *aObj, nsIClassInfo *aClassInfo,
1184
+ jsval aName, void * *aPolicy)
1185
+ {
1186
+ return NS_OK;
1187
+ }
1188
+
1189
+ /* [noscript] void checkPropertyAccess (in JSContextPtr aJSContext, in JSObjectPtr aJSObject, in string aClassName, in JSVal aProperty, in PRUint32 aAction); */
1190
+ NS_IMETHODIMP
1191
+ FullTrustSecMan::CheckPropertyAccess(JSContext * aJSContext,
1192
+ JSObject * aJSObject,
1193
+ const char *aClassName,
1194
+ jsval aProperty, PRUint32 aAction)
1195
+ {
1196
+ return NS_OK;
1197
+ }
1198
+
1199
+ /* [noscript] void checkConnect (in JSContextPtr aJSContext, in nsIURI aTargetURI, in string aClassName, in string aProperty); */
1200
+ NS_IMETHODIMP
1201
+ FullTrustSecMan::CheckConnect(JSContext * aJSContext, nsIURI *aTargetURI,
1202
+ const char *aClassName, const char *aProperty)
1203
+ {
1204
+ return NS_OK;
1205
+ }
1206
+
1207
+ /* [noscript] void checkLoadURIFromScript (in JSContextPtr cx, in nsIURI uri); */
1208
+ NS_IMETHODIMP
1209
+ FullTrustSecMan::CheckLoadURIFromScript(JSContext * cx, nsIURI *uri)
1210
+ {
1211
+ return NS_OK;
1212
+ }
1213
+
1214
+ /* void checkLoadURIWithPrincipal (in nsIPrincipal aPrincipal, in nsIURI uri, in unsigned long flags); */
1215
+ NS_IMETHODIMP
1216
+ FullTrustSecMan::CheckLoadURIWithPrincipal(nsIPrincipal *aPrincipal,
1217
+ nsIURI *uri, PRUint32 flags)
1218
+ {
1219
+ return NS_OK;
1220
+ }
1221
+
1222
+ /* void checkLoadURI (in nsIURI from, in nsIURI uri, in unsigned long flags); */
1223
+ NS_IMETHODIMP
1224
+ FullTrustSecMan::CheckLoadURI(nsIURI *from, nsIURI *uri, PRUint32 flags)
1225
+ {
1226
+ return NS_OK;
1227
+ }
1228
+
1229
+ /* void checkLoadURIStrWithPrincipal (in nsIPrincipal aPrincipal, in AUTF8String uri, in unsigned long flags); */
1230
+ NS_IMETHODIMP
1231
+ FullTrustSecMan::CheckLoadURIStrWithPrincipal(nsIPrincipal *aPrincipal,
1232
+ const nsACString & uri,
1233
+ PRUint32 flags)
1234
+ {
1235
+ return NS_OK;
1236
+ }
1237
+
1238
+ /* void checkLoadURIStr (in AUTF8String from, in AUTF8String uri, in unsigned long flags); */
1239
+ NS_IMETHODIMP
1240
+ FullTrustSecMan::CheckLoadURIStr(const nsACString & from,
1241
+ const nsACString & uri, PRUint32 flags)
1242
+ {
1243
+ return NS_OK;
1244
+ }
1245
+
1246
+ /* [noscript] void checkFunctionAccess (in JSContextPtr cx, in voidPtr funObj, in voidPtr targetObj); */
1247
+ NS_IMETHODIMP
1248
+ FullTrustSecMan::CheckFunctionAccess(JSContext * cx, void * funObj,
1249
+ void * targetObj)
1250
+ {
1251
+ return NS_OK;
1252
+ }
1253
+
1254
+ /* [noscript] boolean canExecuteScripts (in JSContextPtr cx, in nsIPrincipal principal); */
1255
+ NS_IMETHODIMP
1256
+ FullTrustSecMan::CanExecuteScripts(JSContext * cx, nsIPrincipal *principal,
1257
+ PRBool *_retval)
1258
+ {
1259
+ *_retval = PR_TRUE;
1260
+ return NS_OK;
1261
+ }
1262
+
1263
+ /* [noscript] nsIPrincipal getSubjectPrincipal (); */
1264
+ NS_IMETHODIMP
1265
+ FullTrustSecMan::GetSubjectPrincipal(nsIPrincipal **_retval)
1266
+ {
1267
+ NS_IF_ADDREF(*_retval = mSystemPrincipal);
1268
+ return *_retval ? NS_OK : NS_ERROR_FAILURE;
1269
+ }
1270
+
1271
+ /* [noscript] nsIPrincipal getSystemPrincipal (); */
1272
+ NS_IMETHODIMP
1273
+ FullTrustSecMan::GetSystemPrincipal(nsIPrincipal **_retval)
1274
+ {
1275
+ NS_IF_ADDREF(*_retval = mSystemPrincipal);
1276
+ return *_retval ? NS_OK : NS_ERROR_FAILURE;
1277
+ }
1278
+
1279
+ /* [noscript] nsIPrincipal getCertificatePrincipal (in AUTF8String aCertFingerprint, in AUTF8String aSubjectName, in AUTF8String aPrettyName, in nsISupports aCert, in nsIURI aURI); */
1280
+ NS_IMETHODIMP
1281
+ FullTrustSecMan::GetCertificatePrincipal(const nsACString & aCertFingerprint,
1282
+ const nsACString & aSubjectName,
1283
+ const nsACString & aPrettyName,
1284
+ nsISupports *aCert, nsIURI *aURI,
1285
+ nsIPrincipal **_retval)
1286
+ {
1287
+ NS_IF_ADDREF(*_retval = mSystemPrincipal);
1288
+ return *_retval ? NS_OK : NS_ERROR_FAILURE;
1289
+ }
1290
+
1291
+ /* [noscript] nsIPrincipal getCodebasePrincipal (in nsIURI aURI); */
1292
+ NS_IMETHODIMP
1293
+ FullTrustSecMan::GetCodebasePrincipal(nsIURI *aURI, nsIPrincipal **_retval)
1294
+ {
1295
+ NS_IF_ADDREF(*_retval = mSystemPrincipal);
1296
+ return *_retval ? NS_OK : NS_ERROR_FAILURE;
1297
+ }
1298
+
1299
+ /* [noscript] short requestCapability (in nsIPrincipal principal, in string capability); */
1300
+ NS_IMETHODIMP
1301
+ FullTrustSecMan::RequestCapability(nsIPrincipal *principal,
1302
+ const char *capability, PRInt16 *_retval)
1303
+ {
1304
+ *_retval = nsIPrincipal::ENABLE_GRANTED;
1305
+ return NS_OK;
1306
+ }
1307
+
1308
+ /* boolean isCapabilityEnabled (in string capability); */
1309
+ NS_IMETHODIMP
1310
+ FullTrustSecMan::IsCapabilityEnabled(const char *capability, PRBool *_retval)
1311
+ {
1312
+ *_retval = PR_TRUE;
1313
+ return NS_OK;
1314
+ }
1315
+
1316
+ /* void enableCapability (in string capability); */
1317
+ NS_IMETHODIMP
1318
+ FullTrustSecMan::EnableCapability(const char *capability)
1319
+ {
1320
+ return NS_OK;;
1321
+ }
1322
+
1323
+ /* void revertCapability (in string capability); */
1324
+ NS_IMETHODIMP
1325
+ FullTrustSecMan::RevertCapability(const char *capability)
1326
+ {
1327
+ return NS_OK;
1328
+ }
1329
+
1330
+ /* void disableCapability (in string capability); */
1331
+ NS_IMETHODIMP
1332
+ FullTrustSecMan::DisableCapability(const char *capability)
1333
+ {
1334
+ return NS_OK;
1335
+ }
1336
+
1337
+ /* void setCanEnableCapability (in AUTF8String certificateFingerprint, in string capability, in short canEnable); */
1338
+ NS_IMETHODIMP
1339
+ FullTrustSecMan::SetCanEnableCapability(const nsACString & certificateFingerprint,
1340
+ const char *capability,
1341
+ PRInt16 canEnable)
1342
+ {
1343
+ return NS_OK;
1344
+ }
1345
+
1346
+ /* [noscript] nsIPrincipal getObjectPrincipal (in JSContextPtr cx, in JSObjectPtr obj); */
1347
+ NS_IMETHODIMP
1348
+ FullTrustSecMan::GetObjectPrincipal(JSContext * cx, JSObject * obj,
1349
+ nsIPrincipal **_retval)
1350
+ {
1351
+ NS_IF_ADDREF(*_retval = mSystemPrincipal);
1352
+ return *_retval ? NS_OK : NS_ERROR_FAILURE;
1353
+ }
1354
+
1355
+ /* [noscript] boolean subjectPrincipalIsSystem (); */
1356
+ NS_IMETHODIMP
1357
+ FullTrustSecMan::SubjectPrincipalIsSystem(PRBool *_retval)
1358
+ {
1359
+ *_retval = PR_TRUE;
1360
+ return NS_OK;
1361
+ }
1362
+
1363
+ /* [noscript] void checkSameOrigin (in JSContextPtr aJSContext, in nsIURI aTargetURI); */
1364
+ NS_IMETHODIMP
1365
+ FullTrustSecMan::CheckSameOrigin(JSContext * aJSContext, nsIURI *aTargetURI)
1366
+ {
1367
+ return NS_OK;
1368
+ }
1369
+
1370
+ /* void checkSameOriginURI (in nsIURI aSourceURI, in nsIURI aTargetURI); */
1371
+ NS_IMETHODIMP
1372
+ FullTrustSecMan::CheckSameOriginURI(nsIURI *aSourceURI, nsIURI *aTargetURI,
1373
+ PRBool reportError)
1374
+ {
1375
+ return NS_OK;
1376
+ }
1377
+
1378
+ /* [noscript] nsIPrincipal getPrincipalFromContext (in JSContextPtr cx); */
1379
+ NS_IMETHODIMP
1380
+ FullTrustSecMan::GetPrincipalFromContext(JSContext * cx, nsIPrincipal **_retval)
1381
+ {
1382
+ NS_IF_ADDREF(*_retval = mSystemPrincipal);
1383
+ return *_retval ? NS_OK : NS_ERROR_FAILURE;
1384
+ }
1385
+
1386
+ /* [noscript] nsIPrincipal getChannelPrincipal (in nsIChannel aChannel); */
1387
+ NS_IMETHODIMP
1388
+ FullTrustSecMan::GetChannelPrincipal(nsIChannel *aChannel, nsIPrincipal **_retval)
1389
+ {
1390
+ NS_IF_ADDREF(*_retval = mSystemPrincipal);
1391
+ return *_retval ? NS_OK : NS_ERROR_FAILURE;
1392
+ }
1393
+
1394
+ /* boolean isSystemPrincipal (in nsIPrincipal aPrincipal); */
1395
+ NS_IMETHODIMP
1396
+ FullTrustSecMan::IsSystemPrincipal(nsIPrincipal *aPrincipal, PRBool *_retval)
1397
+ {
1398
+ *_retval = aPrincipal == mSystemPrincipal;
1399
+ return NS_OK;
1400
+ }
1401
+
1402
+ NS_IMETHODIMP_(nsIPrincipal *)
1403
+ FullTrustSecMan::GetCxSubjectPrincipal(JSContext *cx)
1404
+ {
1405
+ return mSystemPrincipal;
1406
+ }
1407
+
1408
+ NS_IMETHODIMP_(nsIPrincipal *)
1409
+ FullTrustSecMan::GetCxSubjectPrincipalAndFrame(JSContext *cx, JSStackFrame **fp)
1410
+ {
1411
+ *fp = nsnull;
1412
+ return mSystemPrincipal;
1413
+ }
1414
+
1415
+ #endif
1416
+
1417
+ /***************************************************************************/
1418
+
1419
+ // #define TEST_InitClassesWithNewWrappedGlobal
1420
+
1421
+ #ifdef TEST_InitClassesWithNewWrappedGlobal
1422
+ // XXX hacky test code...
1423
+ #include "xpctest.h"
1424
+
1425
+ class TestGlobal : public nsIXPCTestNoisy, public nsIXPCScriptable
1426
+ {
1427
+ public:
1428
+ NS_DECL_ISUPPORTS
1429
+ NS_DECL_NSIXPCTESTNOISY
1430
+ NS_DECL_NSIXPCSCRIPTABLE
1431
+
1432
+ TestGlobal(){}
1433
+ };
1434
+
1435
+ NS_IMPL_ISUPPORTS2(TestGlobal, nsIXPCTestNoisy, nsIXPCScriptable)
1436
+
1437
+ // The nsIXPCScriptable map declaration that will generate stubs for us...
1438
+ #define XPC_MAP_CLASSNAME TestGlobal
1439
+ #define XPC_MAP_QUOTED_CLASSNAME "TestGlobal"
1440
+ #define XPC_MAP_FLAGS nsIXPCScriptable::USE_JSSTUB_FOR_ADDPROPERTY |\
1441
+ nsIXPCScriptable::USE_JSSTUB_FOR_DELPROPERTY |\
1442
+ nsIXPCScriptable::USE_JSSTUB_FOR_SETPROPERTY
1443
+ #include "xpc_map_end.h" /* This will #undef the above */
1444
+
1445
+ NS_IMETHODIMP TestGlobal::Squawk() {return NS_OK;}
1446
+
1447
+ #endif
1448
+
1449
+ // uncomment to install the test 'this' translator
1450
+ // #define TEST_TranslateThis
1451
+
1452
+ #ifdef TEST_TranslateThis
1453
+
1454
+ #include "xpctest.h"
1455
+
1456
+ class nsXPCFunctionThisTranslator : public nsIXPCFunctionThisTranslator
1457
+ {
1458
+ public:
1459
+ NS_DECL_ISUPPORTS
1460
+ NS_DECL_NSIXPCFUNCTIONTHISTRANSLATOR
1461
+
1462
+ nsXPCFunctionThisTranslator();
1463
+ virtual ~nsXPCFunctionThisTranslator();
1464
+ /* additional members */
1465
+ };
1466
+
1467
+ /* Implementation file */
1468
+ NS_IMPL_ISUPPORTS1(nsXPCFunctionThisTranslator, nsIXPCFunctionThisTranslator)
1469
+
1470
+ nsXPCFunctionThisTranslator::nsXPCFunctionThisTranslator()
1471
+ {
1472
+ /* member initializers and constructor code */
1473
+ }
1474
+
1475
+ nsXPCFunctionThisTranslator::~nsXPCFunctionThisTranslator()
1476
+ {
1477
+ /* destructor code */
1478
+ #ifdef DEBUG_jband
1479
+ printf("destroying nsXPCFunctionThisTranslator\n");
1480
+ #endif
1481
+ }
1482
+
1483
+ /* nsISupports TranslateThis (in nsISupports aInitialThis, in nsIInterfaceInfo aInterfaceInfo, in PRUint16 aMethodIndex, out PRBool aHideFirstParamFromJS, out nsIIDPtr aIIDOfResult); */
1484
+ NS_IMETHODIMP
1485
+ nsXPCFunctionThisTranslator::TranslateThis(nsISupports *aInitialThis,
1486
+ nsIInterfaceInfo *aInterfaceInfo,
1487
+ PRUint16 aMethodIndex,
1488
+ PRBool *aHideFirstParamFromJS,
1489
+ nsIID * *aIIDOfResult,
1490
+ nsISupports **_retval)
1491
+ {
1492
+ NS_IF_ADDREF(aInitialThis);
1493
+ *_retval = aInitialThis;
1494
+ *aHideFirstParamFromJS = JS_FALSE;
1495
+ *aIIDOfResult = nsnull;
1496
+ return NS_OK;
1497
+ }
1498
+
1499
+ #endif
1500
+
1501
+ // ContextCallback calls are chained
1502
+ static JSContextCallback gOldJSContextCallback;
1503
+
1504
+ static JSBool
1505
+ ContextCallback(JSContext *cx, uintN contextOp)
1506
+ {
1507
+ if (gOldJSContextCallback && !gOldJSContextCallback(cx, contextOp))
1508
+ return JS_FALSE;
1509
+
1510
+ if (contextOp == JSCONTEXT_NEW) {
1511
+ JS_SetErrorReporter(cx, my_ErrorReporter);
1512
+ JS_SetVersion(cx, JSVERSION_LATEST);
1513
+ }
1514
+ return JS_TRUE;
1515
+ }
1516
+
1517
+ static bool
1518
+ GetCurrentWorkingDirectory(nsAString& workingDirectory)
1519
+ {
1520
+ #if (!defined(XP_WIN) && !defined(XP_UNIX)) || defined(WINCE)
1521
+ //XXX: your platform should really implement this
1522
+ return false;
1523
+ #elif XP_WIN
1524
+ DWORD requiredLength = GetCurrentDirectoryW(0, NULL);
1525
+ workingDirectory.SetLength(requiredLength);
1526
+ GetCurrentDirectoryW(workingDirectory.Length(),
1527
+ (LPWSTR)workingDirectory.BeginWriting());
1528
+ // we got a trailing null there
1529
+ workingDirectory.SetLength(requiredLength);
1530
+ workingDirectory.Replace(workingDirectory.Length() - 1, 1, L'\\');
1531
+ #elif defined(XP_UNIX)
1532
+ nsCAutoString cwd;
1533
+ // 1024 is just a guess at a sane starting value
1534
+ size_t bufsize = 1024;
1535
+ char* result = nsnull;
1536
+ while (result == nsnull) {
1537
+ if (!cwd.SetLength(bufsize))
1538
+ return false;
1539
+ result = getcwd(cwd.BeginWriting(), cwd.Length());
1540
+ if (!result) {
1541
+ if (errno != ERANGE)
1542
+ return false;
1543
+ // need to make the buffer bigger
1544
+ bufsize *= 2;
1545
+ }
1546
+ }
1547
+ // size back down to the actual string length
1548
+ cwd.SetLength(strlen(result) + 1);
1549
+ cwd.Replace(cwd.Length() - 1, 1, '/');
1550
+ workingDirectory = NS_ConvertUTF8toUTF16(cwd);
1551
+ #endif
1552
+ return true;
1553
+ }
1554
+
1555
+ int
1556
+ main(int argc, char **argv, char **envp)
1557
+ {
1558
+ #ifdef XP_MACOSX
1559
+ InitAutoreleasePool();
1560
+ #endif
1561
+ JSRuntime *rt;
1562
+ JSContext *cx;
1563
+ JSObject *glob, *envobj;
1564
+ int result;
1565
+ nsresult rv;
1566
+
1567
+ // unbuffer stdout so that output is in the correct order; note that stderr
1568
+ // is unbuffered by default
1569
+ setbuf(stdout, 0);
1570
+
1571
+ gErrFile = stderr;
1572
+ gOutFile = stdout;
1573
+ gInFile = stdin;
1574
+
1575
+ NS_LogInit();
1576
+
1577
+ nsCOMPtr<nsILocalFile> appFile;
1578
+ rv = XRE_GetBinaryPath(argv[0], getter_AddRefs(appFile));
1579
+ if (NS_FAILED(rv)) {
1580
+ printf("Couldn't find application file.\n");
1581
+ return 1;
1582
+ }
1583
+ nsCOMPtr<nsIFile> appDir;
1584
+ rv = appFile->GetParent(getter_AddRefs(appDir));
1585
+ if (NS_FAILED(rv)) {
1586
+ printf("Couldn't get application directory.\n");
1587
+ return 1;
1588
+ }
1589
+
1590
+ XPCShellDirProvider dirprovider;
1591
+
1592
+ if (argc > 1 && !strcmp(argv[1], "-g")) {
1593
+ if (argc < 3)
1594
+ return usage();
1595
+
1596
+ if (!dirprovider.SetGREDir(argv[2])) {
1597
+ printf("SetGREDir failed.\n");
1598
+ return 1;
1599
+ }
1600
+ argc -= 2;
1601
+ argv += 2;
1602
+ }
1603
+
1604
+ {
1605
+ nsCOMPtr<nsIServiceManager> servMan;
1606
+ rv = NS_InitXPCOM2(getter_AddRefs(servMan), appDir, &dirprovider);
1607
+ if (NS_FAILED(rv)) {
1608
+ printf("NS_InitXPCOM failed!\n");
1609
+ return 1;
1610
+ }
1611
+ {
1612
+ nsCOMPtr<nsIComponentRegistrar> registrar = do_QueryInterface(servMan);
1613
+ NS_ASSERTION(registrar, "Null nsIComponentRegistrar");
1614
+ if (registrar)
1615
+ registrar->AutoRegister(nsnull);
1616
+ }
1617
+
1618
+ nsCOMPtr<nsIJSRuntimeService> rtsvc = do_GetService("@mozilla.org/js/xpc/RuntimeService;1");
1619
+ // get the JSRuntime from the runtime svc
1620
+ if (!rtsvc) {
1621
+ printf("failed to get nsJSRuntimeService!\n");
1622
+ return 1;
1623
+ }
1624
+
1625
+ if (NS_FAILED(rtsvc->GetRuntime(&rt)) || !rt) {
1626
+ printf("failed to get JSRuntime from nsJSRuntimeService!\n");
1627
+ return 1;
1628
+ }
1629
+
1630
+ gOldJSContextCallback = JS_SetContextCallback(rt, ContextCallback);
1631
+
1632
+ cx = JS_NewContext(rt, 8192);
1633
+ if (!cx) {
1634
+ printf("JS_NewContext failed!\n");
1635
+ return 1;
1636
+ }
1637
+
1638
+ nsCOMPtr<nsIXPConnect> xpc = do_GetService(nsIXPConnect::GetCID());
1639
+ if (!xpc) {
1640
+ printf("failed to get nsXPConnect service!\n");
1641
+ return 1;
1642
+ }
1643
+
1644
+ // Since the caps security system might set a default security manager
1645
+ // we will be sure that the secman on this context gives full trust.
1646
+ nsRefPtr<FullTrustSecMan> secman = new FullTrustSecMan();
1647
+ xpc->SetSecurityManagerForJSContext(cx, secman, 0xFFFF);
1648
+
1649
+ #ifndef XPCONNECT_STANDALONE
1650
+ // Fetch the system principal and store it away in a global, to use for
1651
+ // script compilation in Load() and ProcessFile() (including interactive
1652
+ // eval loop)
1653
+ {
1654
+ nsCOMPtr<nsIPrincipal> princ;
1655
+
1656
+ nsCOMPtr<nsIScriptSecurityManager> securityManager =
1657
+ do_GetService(NS_SCRIPTSECURITYMANAGER_CONTRACTID, &rv);
1658
+ if (NS_SUCCEEDED(rv) && securityManager) {
1659
+ rv = securityManager->GetSystemPrincipal(getter_AddRefs(princ));
1660
+ if (NS_FAILED(rv)) {
1661
+ fprintf(gErrFile, "+++ Failed to obtain SystemPrincipal from ScriptSecurityManager service.\n");
1662
+ } else {
1663
+ // fetch the JS principals and stick in a global
1664
+ rv = princ->GetJSPrincipals(cx, &gJSPrincipals);
1665
+ if (NS_FAILED(rv)) {
1666
+ fprintf(gErrFile, "+++ Failed to obtain JS principals from SystemPrincipal.\n");
1667
+ }
1668
+ secman->SetSystemPrincipal(princ);
1669
+ }
1670
+ } else {
1671
+ fprintf(gErrFile, "+++ Failed to get ScriptSecurityManager service, running without principals");
1672
+ }
1673
+ }
1674
+ #endif
1675
+
1676
+ #ifdef TEST_TranslateThis
1677
+ nsCOMPtr<nsIXPCFunctionThisTranslator>
1678
+ translator(new nsXPCFunctionThisTranslator);
1679
+ xpc->SetFunctionThisTranslator(NS_GET_IID(nsITestXPCFunctionCallback), translator, nsnull);
1680
+ #endif
1681
+
1682
+ nsCOMPtr<nsIJSContextStack> cxstack = do_GetService("@mozilla.org/js/xpc/ContextStack;1");
1683
+ if (!cxstack) {
1684
+ printf("failed to get the nsThreadJSContextStack service!\n");
1685
+ return 1;
1686
+ }
1687
+
1688
+ if(NS_FAILED(cxstack->Push(cx))) {
1689
+ printf("failed to push the current JSContext on the nsThreadJSContextStack!\n");
1690
+ return 1;
1691
+ }
1692
+
1693
+ nsCOMPtr<nsIXPCScriptable> backstagePass;
1694
+ nsresult rv = rtsvc->GetBackstagePass(getter_AddRefs(backstagePass));
1695
+ if (NS_FAILED(rv)) {
1696
+ fprintf(gErrFile, "+++ Failed to get backstage pass from rtsvc: %8x\n",
1697
+ rv);
1698
+ return 1;
1699
+ }
1700
+
1701
+ nsCOMPtr<nsIXPConnectJSObjectHolder> holder;
1702
+ rv = xpc->InitClassesWithNewWrappedGlobal(cx, backstagePass,
1703
+ NS_GET_IID(nsISupports),
1704
+ nsIXPConnect::
1705
+ FLAG_SYSTEM_GLOBAL_OBJECT,
1706
+ getter_AddRefs(holder));
1707
+ if (NS_FAILED(rv))
1708
+ return 1;
1709
+
1710
+ rv = holder->GetJSObject(&glob);
1711
+ if (NS_FAILED(rv)) {
1712
+ NS_ASSERTION(glob == nsnull, "bad GetJSObject?");
1713
+ return 1;
1714
+ }
1715
+
1716
+ JS_BeginRequest(cx);
1717
+
1718
+ if (!JS_DefineFunctions(cx, glob, glob_functions)) {
1719
+ JS_EndRequest(cx);
1720
+ return 1;
1721
+ }
1722
+
1723
+ envobj = JS_DefineObject(cx, glob, "environment", &env_class, NULL, 0);
1724
+ if (!envobj || !JS_SetPrivate(cx, envobj, envp)) {
1725
+ JS_EndRequest(cx);
1726
+ return 1;
1727
+ }
1728
+
1729
+ nsAutoString workingDirectory;
1730
+ if (GetCurrentWorkingDirectory(workingDirectory))
1731
+ gWorkingDirectory = &workingDirectory;
1732
+
1733
+ JS_DefineProperty(cx, glob, "__LOCATION__", JSVAL_VOID,
1734
+ GetLocationProperty, NULL, 0);
1735
+
1736
+ argc--;
1737
+ argv++;
1738
+
1739
+ result = ProcessArgs(cx, glob, argv, argc);
1740
+
1741
+
1742
+ //#define TEST_CALL_ON_WRAPPED_JS_AFTER_SHUTDOWN 1
1743
+
1744
+ #ifdef TEST_CALL_ON_WRAPPED_JS_AFTER_SHUTDOWN
1745
+ // test of late call and release (see below)
1746
+ nsCOMPtr<nsIJSContextStack> bogus;
1747
+ xpc->WrapJS(cx, glob, NS_GET_IID(nsIJSContextStack),
1748
+ (void**) getter_AddRefs(bogus));
1749
+ #endif
1750
+
1751
+ JSPRINCIPALS_DROP(cx, gJSPrincipals);
1752
+ JS_ClearScope(cx, glob);
1753
+ JS_GC(cx);
1754
+ JSContext *oldcx;
1755
+ cxstack->Pop(&oldcx);
1756
+ NS_ASSERTION(oldcx == cx, "JS thread context push/pop mismatch");
1757
+ cxstack = nsnull;
1758
+ JS_GC(cx);
1759
+ JS_DestroyContext(cx);
1760
+ } // this scopes the nsCOMPtrs
1761
+ // no nsCOMPtrs are allowed to be alive when you call NS_ShutdownXPCOM
1762
+ rv = NS_ShutdownXPCOM( NULL );
1763
+ NS_ASSERTION(NS_SUCCEEDED(rv), "NS_ShutdownXPCOM failed");
1764
+
1765
+ #ifdef TEST_CALL_ON_WRAPPED_JS_AFTER_SHUTDOWN
1766
+ // test of late call and release (see above)
1767
+ JSContext* bogusCX;
1768
+ bogus->Peek(&bogusCX);
1769
+ bogus = nsnull;
1770
+ #endif
1771
+
1772
+ appDir = nsnull;
1773
+ appFile = nsnull;
1774
+ dirprovider.ClearGREDir();
1775
+
1776
+ NS_LogTerm();
1777
+
1778
+ #ifdef XP_MACOSX
1779
+ FinishAutoreleasePool();
1780
+ #endif
1781
+
1782
+ return result;
1783
+ }
1784
+
1785
+ PRBool
1786
+ XPCShellDirProvider::SetGREDir(const char *dir)
1787
+ {
1788
+ nsresult rv = XRE_GetFileFromPath(dir, getter_AddRefs(mGREDir));
1789
+ return NS_SUCCEEDED(rv);
1790
+ }
1791
+
1792
+ NS_IMETHODIMP_(nsrefcnt)
1793
+ XPCShellDirProvider::AddRef()
1794
+ {
1795
+ return 2;
1796
+ }
1797
+
1798
+ NS_IMETHODIMP_(nsrefcnt)
1799
+ XPCShellDirProvider::Release()
1800
+ {
1801
+ return 1;
1802
+ }
1803
+
1804
+ NS_IMPL_QUERY_INTERFACE1(XPCShellDirProvider, nsIDirectoryServiceProvider)
1805
+
1806
+ NS_IMETHODIMP
1807
+ XPCShellDirProvider::GetFile(const char *prop, PRBool *persistent,
1808
+ nsIFile* *result)
1809
+ {
1810
+ if (mGREDir && !strcmp(prop, NS_GRE_DIR)) {
1811
+ *persistent = PR_TRUE;
1812
+ NS_ADDREF(*result = mGREDir);
1813
+ return NS_OK;
1814
+ }
1815
+
1816
+ return NS_ERROR_FAILURE;
1817
+ }