View Javadoc
1   /*
2    * Copyright (c) 2002-2025 Gargoyle Software Inc.
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    * https://www.apache.org/licenses/LICENSE-2.0
8    *
9    * Unless required by applicable law or agreed to in writing, software
10   * distributed under the License is distributed on an "AS IS" BASIS,
11   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12   * See the License for the specific language governing permissions and
13   * limitations under the License.
14   */
15  package org.htmlunit.html;
16  
17  /**
18   * An element which can handle scripts.
19   *
20   * @author Ahmed Ashour
21   * @author Ronald Brill
22   */
23  public interface ScriptElement {
24  
25      /**
26       * Returns if executed.
27       * @return if executed
28       */
29      boolean isExecuted();
30  
31      /**
32       * Returns {@code true} if this script is deferred.
33       * @return {@code true} if this script is deferred
34       */
35      boolean isDeferred();
36  
37      /**
38       * Sets if executed.
39       * @param executed if executed
40       */
41      void setExecuted(boolean executed);
42  
43      /**
44       * @return the script source url
45       */
46      String getScriptSource();
47  
48      /**
49       * @return the charset used for the script encoding
50       */
51      String getScriptCharset();
52  
53      /**
54       * <span style="color:red">INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.</span><br>
55       *
56       * Marks this script as created by javascript.
57       * Spec: The following scripts will not execute: scripts in XMLHttpRequest's responseXML documents,
58       * scripts in DOMParser-created documents, scripts in documents created by XSLTProcessor's
59       * transformToDocument feature, and scripts that are first inserted by a script into a Document
60       * that was created using the createDocument() API
61       */
62      void markAsCreatedByDomParser();
63  
64      /**
65       * <span style="color:red">INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.</span><br>
66       *
67       * Returns true if this frame was created by javascript.
68       * @return true or false
69       */
70      boolean wasCreatedByDomParser();
71  }