• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

hazendaz / httpunit / 656

06 Dec 2025 09:11PM UTC coverage: 80.452% (+0.02%) from 80.435%
656

push

github

hazendaz
[maven-release-plugin] prepare for next development iteration

3213 of 4105 branches covered (78.27%)

Branch coverage included in aggregate %.

8245 of 10137 relevant lines covered (81.34%)

0.81 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

63.52
/src/main/java/com/meterware/httpunit/HttpUnitOptions.java
1
/*
2
 * MIT License
3
 *
4
 * Copyright 2011-2025 Russell Gold
5
 *
6
 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
7
 * documentation files (the "Software"), to deal in the Software without restriction, including without limitation
8
 * the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and
9
 * to permit persons to whom the Software is furnished to do so, subject to the following conditions:
10
 *
11
 * The above copyright notice and this permission notice shall be included in all copies or substantial portions
12
 * of the Software.
13
 *
14
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
15
 * THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
17
 * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
18
 * DEALINGS IN THE SOFTWARE.
19
 */
20
package com.meterware.httpunit;
21

22
import com.meterware.httpunit.parsing.HTMLParserFactory;
23
import com.meterware.httpunit.parsing.HTMLParserListener;
24
import com.meterware.httpunit.scripting.ScriptableDelegate;
25
import com.meterware.httpunit.scripting.ScriptingEngineFactory;
26
import com.meterware.httpunit.scripting.ScriptingHandler;
27

28
import java.lang.reflect.InvocationTargetException;
29
import java.nio.charset.StandardCharsets;
30
import java.util.HashSet;
31
import java.util.List;
32
import java.util.Set;
33

34
/**
35
 * A collection of global options to control HttpUnit's behavior.
36
 **/
37
public abstract class HttpUnitOptions {
×
38

39
    /** The Constant ORIGINAL_SCRIPTING_ENGINE_FACTORY. */
40
    public static final String ORIGINAL_SCRIPTING_ENGINE_FACTORY = "com.meterware.httpunit.javascript.JavaScriptEngineFactory";
41
    // comment out the scripting engine not to be used by allowing the appropriate number of asterisks in the comment on
42
    // the next line (1 or 2)
43
    /** The Constant DEFAULT_SCRIPT_ENGINE_FACTORY. */
44
    /**/
45
    public static final String DEFAULT_SCRIPT_ENGINE_FACTORY = ORIGINAL_SCRIPTING_ENGINE_FACTORY;
46
    /*
47
     * / public static final String DEFAULT_SCRIPT_ENGINE_FACTORY = NEW_SCRIPTING_ENGINE_FACTORY; /
48
     */
49

50
    /**
51
     * Resets all options to their default values.
52
     */
53
    public static void reset() {
54
        _exceptionsOnErrorStatus = true;
1✔
55
        _parameterValuesValidated = true;
1✔
56
        _imagesTreatedAsAltText = false;
1✔
57
        _loggingHttpHeaders = false;
1✔
58
        _matchesIgnoreCase = true;
1✔
59
        _checkContentLength = false;
1✔
60
        _redirectDelay = 0; // TODO move this to ClientProperties
1✔
61
        _characterSet = StandardCharsets.ISO_8859_1.name();
1✔
62
        _contentType = DEFAULT_CONTENT_TYPE;
1✔
63
        _postIncludesCharset = false;
1✔
64
        _exceptionsThrownOnScriptError = true;
1✔
65
        _customAttributes = null;
1✔
66
        _javaScriptOptimizationLevel = -1;
1✔
67
        _checkHtmlContentType = false;
1✔
68
        setScriptEngineClassName(DEFAULT_SCRIPT_ENGINE_FACTORY);
1✔
69
        setScriptingEnabled(true);
1✔
70
    }
1✔
71

72
    /**
73
     * Returns true if HttpUnit is accepting and saving cookies. The default is to accept them.
74
     *
75
     * @return true, if is accept cookies
76
     *
77
     * @deprecated as of 1.5.3, use ClientProperties#isAcceptCookies();
78
     */
79
    @Deprecated
80
    public static boolean isAcceptCookies() {
81
        return ClientProperties.getDefaultProperties().isAcceptCookies();
×
82
    }
83

84
    /**
85
     * Specifies whether HttpUnit should accept and send cookies.
86
     *
87
     * @param acceptCookies
88
     *            the new accept cookies
89
     *
90
     * @deprecated as of 1.5.3, use ClientProperties#setAcceptCookies();
91
     */
92
    @Deprecated
93
    public static void setAcceptCookies(boolean acceptCookies) {
94
        ClientProperties.getDefaultProperties().setAcceptCookies(acceptCookies);
×
95
    }
×
96

97
    /**
98
     * Returns true if any WebClient created will accept GZIP encoding of responses. The default is to accept GZIP
99
     * encoding.
100
     *
101
     * @return true, if is accept gzip
102
     *
103
     * @deprecated as of 1.5.3, use ClientProperties#isAcceptGzip();
104
     */
105
    @Deprecated
106
    public static boolean isAcceptGzip() {
107
        return ClientProperties.getDefaultProperties().isAcceptGzip();
×
108
    }
109

110
    /**
111
     * Specifies whether a WebClient will be initialized to accept GZIP encoded responses. The default is true.
112
     *
113
     * @param acceptGzip
114
     *            the new accept gzip
115
     *
116
     * @deprecated as of 1.5.3, use ClientProperties#setAcceptGzip();
117
     */
118
    @Deprecated
119
    public static void setAcceptGzip(boolean acceptGzip) {
120
        ClientProperties.getDefaultProperties().setAcceptGzip(acceptGzip);
×
121
    }
×
122

123
    /**
124
     * Resets the default character set to the HTTP default encoding.
125
     **/
126
    public static void resetDefaultCharacterSet() {
127
        _characterSet = StandardCharsets.ISO_8859_1.name();
×
128
    }
×
129

130
    /**
131
     * Resets the default content type to plain text.
132
     **/
133
    public static void resetDefaultContentType() {
134
        _contentType = DEFAULT_CONTENT_TYPE;
×
135
    }
×
136

137
    /**
138
     * Sets the default character set for pages which do not specify one and for requests created without HTML sources.
139
     * By default, HttpUnit uses the HTTP default encoding, ISO-8859-1.
140
     *
141
     * @param characterSet
142
     *            the new default character set
143
     */
144
    public static void setDefaultCharacterSet(String characterSet) {
145
        _characterSet = characterSet;
1✔
146
    }
1✔
147

148
    /**
149
     * Returns the character set to be used for pages which do not specify one.
150
     *
151
     * @return the default character set
152
     */
153
    public static String getDefaultCharacterSet() {
154
        return _characterSet;
1✔
155
    }
156

157
    /**
158
     * Returns true if HttpUnit will throw an exception when a message is only partially received. The default is to
159
     * avoid such checks.
160
     *
161
     * @return true, if is check content length
162
     */
163
    public static boolean isCheckContentLength() {
164
        return _checkContentLength;
1✔
165
    }
166

167
    /**
168
     * Specifies whether HttpUnit should throw an exception when the content length of a message does not match its
169
     * actual received length. Defaults to false.
170
     *
171
     * @param checkContentLength
172
     *            the new check content length
173
     */
174
    public static void setCheckContentLength(boolean checkContentLength) {
175
        _checkContentLength = checkContentLength;
1✔
176
    }
1✔
177

178
    /**
179
     * Determines whether a normal POST request will include the character set in the content-type header. The default
180
     * is to include it; however, some older servlet engines (most notably Tomcat 3.1) get confused when they see it.
181
     *
182
     * @param postIncludesCharset
183
     *            the new post includes charset
184
     */
185
    public static void setPostIncludesCharset(boolean postIncludesCharset) {
186
        _postIncludesCharset = postIncludesCharset;
×
187
    }
×
188

189
    /**
190
     * Returns true if POST requests should include the character set in the content-type header.
191
     *
192
     * @return true, if is post includes charset
193
     */
194
    public static boolean isPostIncludesCharset() {
195
        return _postIncludesCharset;
1✔
196
    }
197

198
    /**
199
     * Sets the default content type for pages which do not specify one.
200
     *
201
     * @param contentType
202
     *            the new default content type
203
     */
204
    public static void setDefaultContentType(String contentType) {
205
        _contentType = contentType;
×
206
    }
×
207

208
    /**
209
     * Returns the content type to be used for pages which do not specify one.
210
     *
211
     * @return the default content type
212
     */
213
    public static String getDefaultContentType() {
214
        return _contentType;
×
215
    }
216

217
    /**
218
     * Returns true if parser warnings are enabled.
219
     *
220
     * @return the parser warnings enabled
221
     *
222
     * @deprecated as of 1.5.2, use HTMLParserFactory#isParserWarningsEnabled
223
     */
224
    @Deprecated
225
    public static boolean getParserWarningsEnabled() {
226
        return HTMLParserFactory.isParserWarningsEnabled();
×
227
    }
228

229
    /**
230
     * If true, tells the parser to display warning messages. The default is false (warnings are not shown).
231
     *
232
     * @param enabled
233
     *            the new parser warnings enabled
234
     *
235
     * @deprecated as of 1.5.2, use HTMLParserFactory#setParserWarningsEnabled
236
     */
237
    @Deprecated
238
    public static void setParserWarningsEnabled(boolean enabled) {
239
        HTMLParserFactory.setParserWarningsEnabled(enabled);
×
240
    }
×
241

242
    /**
243
     * If true, WebClient.getResponse throws an exception when it receives an error status. Defaults to true.
244
     *
245
     * @param enabled
246
     *            the new exceptions thrown on error status
247
     */
248
    public static void setExceptionsThrownOnErrorStatus(boolean enabled) {
249
        _exceptionsOnErrorStatus = enabled;
1✔
250
    }
1✔
251

252
    /**
253
     * Returns true if WebClient.getResponse throws exceptions when detected an error status.
254
     *
255
     * @return the exceptions thrown on error status
256
     */
257
    public static boolean getExceptionsThrownOnErrorStatus() {
258
        return _exceptionsOnErrorStatus;
1✔
259
    }
260

261
    /**
262
     * Returns true if form parameter settings are checked.
263
     *
264
     * @return the parameter values validated
265
     *
266
     * @deprecated as of 1.6, use WebForm#newUnvalidatedRequest() to obtain a request without parameter validation.
267
     */
268
    @Deprecated
269
    public static boolean getParameterValuesValidated() {
270
        return _parameterValuesValidated;
1✔
271
    }
272

273
    /**
274
     * If true, tells HttpUnit to throw an exception on any attempt to set a form parameter to a value which could not
275
     * be set via the browser. The default is true (parameters are validated).<br>
276
     * <b>Note:</b> this only applies to a WebRequest created after this setting is changed. A request created with this
277
     * option disabled will not only not be checked for correctness, its parameter submission order will not be
278
     * guaranteed, and changing parameters will not trigger Javascript onChange / onClick events.
279
     *
280
     * @param validated
281
     *            the new parameter values validated
282
     *
283
     * @deprecated as of 1.6, use WebForm#newUnvalidatedRequest() to obtain a request without parameter validation.
284
     */
285
    @Deprecated
286
    public static void setParameterValuesValidated(boolean validated) {
287
        _parameterValuesValidated = validated;
1✔
288
    }
1✔
289

290
    /**
291
     * Returns true if images are treated as text, using their alt attributes.
292
     *
293
     * @return the images treated as alt text
294
     */
295
    public static boolean getImagesTreatedAsAltText() {
296
        return _imagesTreatedAsAltText;
1✔
297
    }
298

299
    /**
300
     * If true, tells HttpUnit to treat images with alt attributes as though they were the text value of that attribute
301
     * in all searches and displays. The default is false (image text is generally ignored).
302
     *
303
     * @param asText
304
     *            the new images treated as alt text
305
     */
306
    public static void setImagesTreatedAsAltText(boolean asText) {
307
        _imagesTreatedAsAltText = asText;
1✔
308
    }
1✔
309

310
    /**
311
     * If true, text matches in methods such as {@link HTMLSegment#getLinkWith} are case insensitive. The default is
312
     * true (matches ignore case).
313
     *
314
     * @return the matches ignore case
315
     */
316
    public static boolean getMatchesIgnoreCase() {
317
        return _matchesIgnoreCase;
1✔
318
    }
319

320
    /**
321
     * If true, text matches in methods such as {@link HTMLSegment#getLinkWith} are case insensitive. The default is
322
     * true (matches ignore case).
323
     *
324
     * @param ignoreCase
325
     *            the new matches ignore case
326
     */
327
    public static void setMatchesIgnoreCase(boolean ignoreCase) {
328
        _matchesIgnoreCase = ignoreCase;
×
329
    }
×
330

331
    /**
332
     * Returns true if HTTP headers are to be dumped to system output.
333
     *
334
     * @return true, if is logging http headers
335
     */
336
    public static boolean isLoggingHttpHeaders() {
337
        return _loggingHttpHeaders;
1✔
338
    }
339

340
    /**
341
     * If true, tells HttpUnit to log HTTP headers to system output. The default is false.
342
     *
343
     * @param enabled
344
     *            the new logging http headers
345
     */
346
    public static void setLoggingHttpHeaders(boolean enabled) {
347
        _loggingHttpHeaders = enabled;
1✔
348
    }
1✔
349

350
    /**
351
     * Returns true if HttpUnit throws an exception when attempting to parse as HTML a response whose content type is
352
     * not HTML. The default is false (content type is ignored).
353
     *
354
     * @return true, if is check html content type
355
     */
356
    public static boolean isCheckHtmlContentType() {
357
        return _checkHtmlContentType;
1✔
358
    }
359

360
    /**
361
     * If true, HttpUnit throws an exception when attempting to parse as HTML a response whose content type is not HTML.
362
     * The default is false (content type is ignored).
363
     *
364
     * @param checkHtmlContentType
365
     *            the new check html content type
366
     */
367
    public static void setCheckHtmlContentType(boolean checkHtmlContentType) {
368
        _checkHtmlContentType = checkHtmlContentType;
1✔
369
    }
1✔
370

371
    /**
372
     * Returns true if HttpUnit should automatically follow page redirect requests (status 3xx). By default, this is
373
     * true.
374
     *
375
     * @return the auto redirect
376
     *
377
     * @deprecated as of 1.5.3, use ClientProperties#isAutoRedirect();
378
     */
379
    @Deprecated
380
    public static boolean getAutoRedirect() {
381
        return ClientProperties.getDefaultProperties().isAutoRedirect();
×
382
    }
383

384
    /**
385
     * Determines whether HttpUnit should automatically follow page redirect requests (status 3xx). By default, this is
386
     * true in order to simulate normal browser operation.
387
     *
388
     * @param autoRedirect
389
     *            the new auto redirect
390
     *
391
     * @deprecated as of 1.5.3, use ClientProperties#setAutoRedirect();
392
     */
393
    @Deprecated
394
    public static void setAutoRedirect(boolean autoRedirect) {
395
        ClientProperties.getDefaultProperties().setAutoRedirect(autoRedirect);
×
396
    }
×
397

398
    /**
399
     * Returns the delay, in milliseconds, before a redirect request is issues.
400
     *
401
     * @return the redirect delay
402
     */
403
    public static int getRedirectDelay() {
404
        return _redirectDelay;
1✔
405
    }
406

407
    /**
408
     * Sets the delay, in milliseconds, before a redirect request is issued. This may be necessary if the server under
409
     * some cases where the server performs asynchronous processing which must be completed before the new request can
410
     * be handled properly, and is taking advantage of slower processing by most user agents. It almost always indicates
411
     * an error in the server design, and therefore the default delay is zero.
412
     *
413
     * @param delayInMilliseconds
414
     *            the new redirect delay
415
     */
416
    public static void setRedirectDelay(int delayInMilliseconds) {
417
        _redirectDelay = delayInMilliseconds;
×
418
    }
×
419

420
    /**
421
     * Returns true if HttpUnit should automatically follow page refresh requests. By default, this is false, so that
422
     * programs can verify the redirect page presented to users before the browser switches to the new page.
423
     *
424
     * @return the auto refresh
425
     *
426
     * @deprecated as of 1.5.3, use ClientProperties#isAutoRefresh();
427
     */
428
    @Deprecated
429
    public static boolean getAutoRefresh() {
430
        return ClientProperties.getDefaultProperties().isAutoRefresh();
×
431
    }
432

433
    /**
434
     * Specifies whether HttpUnit should automatically follow page refresh requests. By default, this is false, so that
435
     * programs can verify the redirect page presented to users before the browser switches to the new page. Setting
436
     * this to true can cause an infinite loop on pages that refresh themselves.
437
     *
438
     * @param autoRefresh
439
     *            the new auto refresh
440
     *
441
     * @deprecated as of 1.5.3, use ClientProperties#setAutoRefresh();
442
     */
443
    @Deprecated
444
    public static void setAutoRefresh(boolean autoRefresh) {
445
        ClientProperties.getDefaultProperties().setAutoRefresh(autoRefresh);
×
446
    }
×
447

448
    /**
449
     * Remove an Html error listener.
450
     *
451
     * @param el
452
     *            the el
453
     *
454
     * @deprecated as of 1.5.2, use HTMLParserfactory#removeHTMLParserListener
455
     */
456
    @Deprecated
457
    public static void removeHtmlErrorListener(HTMLParserListener el) {
458
        HTMLParserFactory.removeHTMLParserListener(el);
×
459
    }
×
460

461
    /**
462
     * Add an Html error listener.
463
     *
464
     * @param el
465
     *            the el
466
     *
467
     * @deprecated as of 1.5.2, use HTMLParserfactory#addHTMLParserListener
468
     */
469
    @Deprecated
470
    public static void addHtmlErrorListener(HTMLParserListener el) {
471
        HTMLParserFactory.addHTMLParserListener(el);
×
472
    }
×
473

474
    /**
475
     * Get the list of Html Error Listeners.
476
     *
477
     * @return the html error listeners
478
     *
479
     * @deprecated as of 1.5.2, removed with no replacement
480
     */
481
    @Deprecated
482
    public static List getHtmlErrorListeners() {
483
        return null;
×
484
    }
485

486
    /**
487
     * Gets the script engine class name.
488
     *
489
     * @return the script engine class name
490
     */
491
    public static String getScriptEngineClassName() {
492
        return _scriptEngineClassName;
×
493
    }
494

495
    /**
496
     * Sets the script engine class name.
497
     *
498
     * @param scriptEngineClassName
499
     *            the new script engine class name
500
     */
501
    public static void setScriptEngineClassName(String scriptEngineClassName) {
502
        if (_scriptEngineClassName == null || !_scriptEngineClassName.equals(scriptEngineClassName)) {
1!
503
            _scriptingEngine = null;
1✔
504
        }
505
        _scriptEngineClassName = scriptEngineClassName;
1✔
506
    }
1✔
507

508
    /**
509
     * Gets the scripting engine.
510
     *
511
     * @return the scripting engine
512
     */
513
    public static ScriptingEngineFactory getScriptingEngine() {
514
        if (_scriptingEngine == null) {
1✔
515
            try {
516
                Class factoryClass = Class.forName(_scriptEngineClassName);
1✔
517
                final ScriptingEngineFactory factory = (ScriptingEngineFactory) factoryClass.getDeclaredConstructor()
1✔
518
                        .newInstance();
1✔
519
                _scriptingEngine = factory.isEnabled() ? factory : NULL_SCRIPTING_ENGINE_FACTORY;
1!
520
                _scriptingEngine.setThrowExceptionsOnError(_exceptionsThrownOnScriptError);
1✔
521
            } catch (ClassNotFoundException e) {
×
522
                disableScripting(e, "Unable to find scripting engine factory class ");
×
523
            } catch (InstantiationException e) {
×
524
                disableScripting(e, "Unable to instantiate scripting engine factory class ");
×
525
            } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException
×
526
                    | NoSuchMethodException | SecurityException e) {
527
                disableScripting(e, "Unable to create scripting engine factory class ");
×
528
            }
1✔
529
        }
530
        return _scriptingEngine;
1✔
531
    }
532

533
    /**
534
     * change the scriptingEnabled flag.
535
     *
536
     * @param scriptingEnabled
537
     *            the new scripting enabled
538
     */
539
    public static void setScriptingEnabled(boolean scriptingEnabled) {
540
        if (scriptingEnabled != _scriptingEnabled) {
1✔
541
            _scriptingEngine = scriptingEnabled ? null : NULL_SCRIPTING_ENGINE_FACTORY;
1✔
542
        }
543
        _scriptingEnabled = scriptingEnabled;
1✔
544
    }
1✔
545

546
    /**
547
     * Checks if is scripting enabled.
548
     *
549
     * @return true, if is scripting enabled
550
     */
551
    public static boolean isScriptingEnabled() {
552
        return _scriptingEnabled;
1✔
553
    }
554

555
    /**
556
     * Determines whether script errors result in exceptions or warning messages.
557
     *
558
     * @param throwExceptions
559
     *            the throw exceptions
560
     *
561
     * @return the current state
562
     */
563
    public static boolean setExceptionsThrownOnScriptError(boolean throwExceptions) {
564
        boolean current = _exceptionsThrownOnScriptError;
1✔
565
        _exceptionsThrownOnScriptError = throwExceptions;
1✔
566
        getScriptingEngine().setThrowExceptionsOnError(throwExceptions);
1✔
567
        return current;
1✔
568
    }
569

570
    /**
571
     * Returns true if script errors cause exceptions to be thrown.
572
     *
573
     * @return the exceptions thrown on script error
574
     */
575
    public static boolean getExceptionsThrownOnScriptError() {
576
        return _exceptionsThrownOnScriptError;
1✔
577
    }
578

579
    /**
580
     * Returns the accumulated script error messages encountered. Error messages are accumulated only if
581
     * 'throwExceptionsOnError' is disabled.
582
     *
583
     * @return the script error messages
584
     */
585
    public static String[] getScriptErrorMessages() {
586
        return getScriptingEngine().getErrorMessages();
1✔
587
    }
588

589
    /**
590
     * Clears the accumulated script error messages.
591
     */
592
    public static void clearScriptErrorMessages() {
593
        getScriptingEngine().clearErrorMessages();
1✔
594
    }
1✔
595

596
    /**
597
     * Disable scripting.
598
     *
599
     * @param e
600
     *            the e
601
     * @param errorMessage
602
     *            the error message
603
     */
604
    private static void disableScripting(Exception e, String errorMessage) {
605
        System.err.println(errorMessage + _scriptEngineClassName);
×
606
        System.err.println("" + e);
×
607
        System.err.println("JavaScript execution disabled");
×
608
        _scriptingEngine = NULL_SCRIPTING_ENGINE_FACTORY;
×
609
    }
×
610

611
    // --------------------------------- private members --------------------------------------
612

613
    /** The Constant DEFAULT_CONTENT_TYPE. */
614
    private static final String DEFAULT_CONTENT_TYPE = "text/html";
615

616
    /** The Constant NULL_SCRIPTING_ENGINE_FACTORY. */
617
    private static final ScriptingEngineFactory NULL_SCRIPTING_ENGINE_FACTORY = new ScriptingEngineFactory() {
1✔
618
        @Override
619
        public boolean isEnabled() {
620
            return false;
×
621
        }
622

623
        @Override
624
        public void associate(WebResponse response) {
625
        }
1✔
626

627
        @Override
628
        public void load(WebResponse response) {
629
        }
1✔
630

631
        @Override
632
        public void setThrowExceptionsOnError(boolean throwExceptions) {
633
        }
×
634

635
        @Override
636
        public boolean isThrowExceptionsOnError() {
637
            return false;
×
638
        }
639

640
        @Override
641
        public String[] getErrorMessages() {
642
            return new String[0];
×
643
        }
644

645
        @Override
646
        public void clearErrorMessages() {
647
        }
×
648

649
        @Override
650
        public ScriptingHandler createHandler(HTMLElement element) {
651
            return ScriptableDelegate.NULL_SCRIPT_ENGINE;
1✔
652
        }
653

654
        @Override
655
        public ScriptingHandler createHandler(WebResponse response) {
656
            return ScriptableDelegate.NULL_SCRIPT_ENGINE;
×
657
        }
658

659
        @Override
660
        public void handleScriptException(Exception e, String badScript) {
661
            // happily ignore and exception
662
        }
×
663
    };
664

665
    /**
666
     * Add the name of a custom attribute that should be supported for form controls.
667
     *
668
     * @param attributeName
669
     *            the attribute name
670
     *
671
     * @deprecated for new Scripting engine
672
     */
673
    @Deprecated
674
    public static void addCustomAttribute(String attributeName) {
675
        if (_customAttributes == null) {
1!
676
            _customAttributes = new HashSet<>();
1✔
677
        }
678
        _customAttributes.add(attributeName);
1✔
679
    }
1✔
680

681
    /**
682
     * Get the Set of custom attribute names to be supported by form controls.
683
     *
684
     * @return the custom attributes
685
     *
686
     * @deprecated for new scripting engine
687
     */
688
    @Deprecated
689
    static Set getCustomAttributes() {
690
        return _customAttributes;
1✔
691
    }
692

693
    /** The custom attributes. */
694
    private static Set _customAttributes = null;
1✔
695

696
    /** The exceptions on error status. */
697
    private static boolean _exceptionsOnErrorStatus = true;
1✔
698

699
    /** The parameter values validated. */
700
    private static boolean _parameterValuesValidated = true;
1✔
701

702
    /** The images treated as alt text. */
703
    private static boolean _imagesTreatedAsAltText;
704

705
    /** The logging http headers. */
706
    private static boolean _loggingHttpHeaders;
707

708
    /** The matches ignore case. */
709
    private static boolean _matchesIgnoreCase = true;
1✔
710

711
    /** The post includes charset. */
712
    private static boolean _postIncludesCharset = false;
1✔
713

714
    /** The check content length. */
715
    private static boolean _checkContentLength = false;
1✔
716

717
    /** The redirect delay. */
718
    private static int _redirectDelay;
719

720
    /** The character set. */
721
    private static String _characterSet = StandardCharsets.ISO_8859_1.name();
1✔
722

723
    /** The content type. */
724
    private static String _contentType = DEFAULT_CONTENT_TYPE;
1✔
725

726
    /** The script engine class name. */
727
    private static String _scriptEngineClassName;
728

729
    /** The scripting engine. */
730
    private static ScriptingEngineFactory _scriptingEngine;
731

732
    /** The scripting enabled. */
733
    private static boolean _scriptingEnabled = true;
1✔
734

735
    /** The exceptions thrown on script error. */
736
    private static boolean _exceptionsThrownOnScriptError = true;
1✔
737

738
    /** The java script optimization level. */
739
    private static int _javaScriptOptimizationLevel = -1;
1✔
740

741
    /** The check html content type. */
742
    private static boolean _checkHtmlContentType = false;
1✔
743

744
    static {
745
        reset();
1✔
746

747
    }
1✔
748

749
    /**
750
     * getter for Java Script optimization level.
751
     *
752
     * @return the javaScriptOptimizationLevel to be use for running scripts
753
     */
754
    public static int getJavaScriptOptimizationLevel() {
755
        return _javaScriptOptimizationLevel;
1✔
756
    }
757

758
    /**
759
     * setter for Java Script optimization level.
760
     *
761
     * @param scriptOptimizationLevel
762
     *            the _javaScriptOptimizationLevel to set see rhino documentation for valid values: -2: with
763
     *            continuation -1: interpret 0: compile to Java bytecode, don't optimize 1..9: compile to Java bytecode,
764
     *            optimize *
765
     */
766
    public static void setJavaScriptOptimizationLevel(int scriptOptimizationLevel) {
767
        _javaScriptOptimizationLevel = scriptOptimizationLevel;
×
768
    }
×
769
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc