-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathslimerjs.bat
191 lines (174 loc) · 7.51 KB
/
slimerjs.bat
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
@echo off
SET SLIMERJSLAUNCHER="%SLIMERJSLAUNCHER%"
REM % ~ d[rive] p[ath] 0[script name] is the absolute path to this bat file, without quotes, always.
REM ~ strips quotes from the argument
SET SLIMERDIR=%~dp0
REM %* is every argument passed to this script.
SET __SLIMER_ARGS=%*
SET __SLIMER_ENV=
SET CREATETEMP=Y
SET HIDE_ERRORS=Y
REM check arguments
FOR %%A IN (%*) DO (
if ["%%A"]==["/?"] (
call :helpMessage
goto :eof
)
if /I ["%%A"]==["--help"] (
call :helpMessage
goto :eof
)
if /I ["%%A"]==["-h"] (
call :helpMessage
goto :eof
)
if /I ["%%A"]==["/h"] (
call :helpMessage
goto :eof
)
if /I ["%%A"]==["-reset-profile"] (
SET CREATETEMP=
)
if /I ["%%A"]==["-profile"] (
SET CREATETEMP=
)
if /I ["%%A"]==["-p"] (
SET CREATETEMP=
)
if /I ["%%A"]==["-createprofile"] (
SET CREATETEMP=
)
if /I ["%%A"]==["-profilemanager"] (
SET CREATETEMP=
)
if /I ["%%A"]==["--reset-profile"] (
SET CREATETEMP=
)
if /I ["%%A"]==["--profile"] (
SET CREATETEMP=
)
if /I ["%%A"]==["--p"] (
SET CREATETEMP=
)
if /I ["%%A"]==["--createprofile"] (
SET CREATETEMP=
)
if /I ["%%A"]==["--profilemanager"] (
SET CREATETEMP=
)
if /I ["%%A"]==["/debug"] (
SET HIDE_ERRORS=
)
)
if not exist %SLIMERJSLAUNCHER% (
if exist "%SLIMERDIR%\xulrunner\xulrunner.exe" (
SET SLIMERJSLAUNCHER="%SLIMERDIR%\xulrunner\xulrunner.exe"
)
)
if not exist %SLIMERJSLAUNCHER% (
call :findFirefox
)
if not exist %SLIMERJSLAUNCHER% (
echo SLIMERJSLAUNCHER environment variable is missing or the path is invalid.
echo Set it with the path to Firefox or xulrunner.
echo The current value of SLIMERJSLAUNCHER is: %SLIMERJSLAUNCHER%
REM %% escapes the percent sign so it displays literally
echo SET SLIMERJSLAUNCHER="%%programfiles%%\Mozilla Firefox\firefox.exe"
echo SET SLIMERJSLAUNCHER="%%programfiles%%\XULRunner\xulrunner.exe"
pause
exit 1
)
SETLOCAL EnableDelayedExpansion
REM store environment variable into __SLIMER_ENV for SlimerJS
FOR /F "usebackq delims==" %%i IN (`set`) DO set __SLIMER_ENV=!__SLIMER_ENV!,%%i
REM let's create a temporary dir for the profile, if needed
if ["%CREATETEMP%"]==[""] (
SET PROFILEDIR=
SET PROFILE=-purgecaches
goto callexec
)
:createdirname
SET PROFILEDIR=%Temp%\slimerjs-!Random!!Random!!Random!
IF EXIST "%PROFILEDIR%" (
GOTO createdirname
)
mkdir %PROFILEDIR%
SET PROFILE=-profile %PROFILEDIR%
:callexec
if ["%HIDE_ERRORS%"]==[""] (
%SLIMERJSLAUNCHER% -app "%SLIMERDIR%application.ini" %PROFILE% -attach-console -no-remote %__SLIMER_ARGS%
) ELSE (
%SLIMERJSLAUNCHER% -app "%SLIMERDIR%application.ini" %PROFILE% -attach-console -no-remote %__SLIMER_ARGS% 2>NUL
)
if ["%CREATETEMP%"]==["Y"] (
rmdir /S /Q %PROFILEDIR%
)
ENDLOCAL
goto :eof
:helpMessage
REM in echo statements the escape character is ^
REM escape < > | and &
REM the character % is escaped by doubling it to %%
REM if delayed variable expansion is turned on then the character ! needs to be escaped as ^^!
echo Available options are:
echo.
echo --config=^<filename^> Load the given configuration file
echo (JSON formated)
echo --debug=[yes^|no] Prints additional warning and debug message
echo (default is no)
echo --disk-cache=[yes^|no] Enables disk cache (default is no).
echo --help or -h Show this help
REM echo --ignore-ssl-errors=[yes^|no] Ignores SSL errors (default is no).
echo --load-images=[yes^|no] Loads all inlined images (default is yes)
echo --local-storage-quota=^<number^> Sets the maximum size of the offline
echo local storage (in KB)
REM echo --local-to-remote-url-access=[yes^|no] Allows local content to access remote
REM echo URL (default is no)
echo --max-disk-cache-size=^<number^> Limits the size of the disk cache (in KB)
REM echo --output-encoding=^<enc^> Sets the encoding for the terminal output
REM echo (default is 'utf8')
REM echo --remote-debugger-port=^<number^> Starts the script in a debug harness and
REM echo listens on the specified port
REM echo --remote-debugger-autorun=[yes^|no] Runs the script in the debugger immediately
REM echo (default is no)
echo --proxy=^<proxy url^> Sets the proxy server
echo --proxy-auth=^<username:password^> Provides authentication information for the
echo proxy
echo --proxy-type=[http^|socks5^|none^|auto^|system^|config-url] Specifies the proxy type (default is http)
REM echo --script-encoding=^<enc^> Sets the encoding used for the starting
REM echo script (default is utf8)
REM echo --web-security=[yes^|no] Enables web security (default is yes)
echo --version or v Prints out SlimerJS version
REM echo --webdriver or --wd or -w Starts in 'Remote WebDriver mode' (embedded
REM echo GhostDriver) '127.0.0.1:8910'
REM echo --webdriver=[^<IP^>:]^<PORT^> Starts in 'Remote WebDriver mode' in the
REM echo specified network interface
REM echo --webdriver-logfile=^<file^> File where to write the WebDriver's Log
REM echo (default 'none') (NOTE: needs '--webdriver')
REM echo --webdriver-loglevel=[ERROR^|WARN^|INFO^|DEBUG^|] WebDriver Logging Level
REM echo (default is 'INFO') (NOTE: needs '--webdriver')
REM echo --webdriver-selenium-grid-hub=^<url^> URL to the Selenium Grid HUB (default is
REM echo 'none') (NOTE: needs '--webdriver')
echo --error-log-file=<file> Log all javascript errors in a file
echo -jsconsole Open a window to view all javascript errors
echo during the execution
echo.
echo *** About profiles: see details of these Mozilla options at
echo https://developer.mozilla.org/en-US/docs/Mozilla/Command_Line_Options#User_Profile
echo.
echo --createprofile name Create a new profile and exit
echo -P name Use the specified profile to execute the script
echo -profile path Use the profile stored in the specified
echo directory, to execute the script
echo By default, SlimerJS use a temporary profile
echo.
goto :eof
:findFirefox
if exist "%programfiles%\Mozilla Firefox\firefox.exe" (
SET SLIMERJSLAUNCHER="%programfiles%\Mozilla Firefox\firefox.exe"
)
if exist "%programfiles% (x86)\Mozilla Firefox\firefox.exe" (
SET SLIMERJSLAUNCHER="%programfiles% (x86)\Mozilla Firefox\firefox.exe"
)
echo SLIMERJSLAUNCHER is set to %SLIMERJSLAUNCHER%
goto :eof