View Javadoc
1   /*
2    * Copyright (c) 2002-2017 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    * http://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 com.gargoylesoftware.htmlunit.javascript.host.dom;
16  
17  import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.EVENT_ONCLOSE_DOCUMENT_CREATE_NOT_SUPPORTED;
18  import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.EVENT_TYPE_BEFOREUNLOADEVENT;
19  import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.EVENT_TYPE_HASHCHANGEEVENT;
20  import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.EVENT_TYPE_KEY_EVENTS;
21  import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.EVENT_TYPE_POINTEREVENT;
22  import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.EVENT_TYPE_PROGRESSEVENT;
23  import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.HTMLDOCUMENT_CHARSET_LOWERCASE;
24  import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.JS_ANCHORS_REQUIRES_NAME_OR_ID;
25  import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.JS_DOCUMENT_CREATE_ELEMENT_STRICT;
26  import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.JS_DOCUMENT_DESIGN_MODE_INHERIT;
27  import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.JS_DOCUMENT_FORMS_FUNCTION_SUPPORTED;
28  import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.JS_DOCUMENT_SELECTION_RANGE_COUNT;
29  import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.JS_DOCUMENT_SETTING_DOMAIN_THROWS_FOR_ABOUT_BLANK;
30  import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.JS_DOCUMENT_SET_LOCATION_EXECUTED_IN_ANCHOR;
31  import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.JS_TREEWALKER_EXPAND_ENTITY_REFERENCES_FALSE;
32  import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.JS_TREEWALKER_FILTER_FUNCTION_ONLY;
33  import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.QUERYSELECTORALL_NOT_IN_QUIRKS;
34  import static com.gargoylesoftware.htmlunit.javascript.configuration.SupportedBrowser.CHROME;
35  import static com.gargoylesoftware.htmlunit.javascript.configuration.SupportedBrowser.EDGE;
36  import static com.gargoylesoftware.htmlunit.javascript.configuration.SupportedBrowser.FF;
37  import static com.gargoylesoftware.htmlunit.javascript.configuration.SupportedBrowser.FF45;
38  import static com.gargoylesoftware.htmlunit.javascript.configuration.SupportedBrowser.FF52;
39  import static com.gargoylesoftware.htmlunit.javascript.configuration.SupportedBrowser.IE;
40  import static com.gargoylesoftware.htmlunit.util.StringUtils.parseHttpDate;
41  
42  import java.io.IOException;
43  import java.net.URL;
44  import java.nio.charset.Charset;
45  import java.text.SimpleDateFormat;
46  import java.util.Arrays;
47  import java.util.Collections;
48  import java.util.Date;
49  import java.util.HashMap;
50  import java.util.HashSet;
51  import java.util.List;
52  import java.util.Locale;
53  import java.util.Map;
54  import java.util.Set;
55  import java.util.regex.Matcher;
56  import java.util.regex.Pattern;
57  
58  import org.apache.commons.logging.Log;
59  import org.apache.commons.logging.LogFactory;
60  import org.apache.xml.utils.PrefixResolver;
61  import org.w3c.css.sac.CSSException;
62  import org.w3c.dom.DOMException;
63  import org.w3c.dom.DocumentType;
64  
65  import com.gargoylesoftware.htmlunit.BrowserVersion;
66  import com.gargoylesoftware.htmlunit.ElementNotFoundException;
67  import com.gargoylesoftware.htmlunit.Page;
68  import com.gargoylesoftware.htmlunit.SgmlPage;
69  import com.gargoylesoftware.htmlunit.WebClient;
70  import com.gargoylesoftware.htmlunit.WebResponse;
71  import com.gargoylesoftware.htmlunit.WebWindow;
72  import com.gargoylesoftware.htmlunit.html.BaseFrameElement;
73  import com.gargoylesoftware.htmlunit.html.DomComment;
74  import com.gargoylesoftware.htmlunit.html.DomDocumentFragment;
75  import com.gargoylesoftware.htmlunit.html.DomElement;
76  import com.gargoylesoftware.htmlunit.html.DomNode;
77  import com.gargoylesoftware.htmlunit.html.DomText;
78  import com.gargoylesoftware.htmlunit.html.FrameWindow;
79  import com.gargoylesoftware.htmlunit.html.HTMLParser;
80  import com.gargoylesoftware.htmlunit.html.HtmlAnchor;
81  import com.gargoylesoftware.htmlunit.html.HtmlApplet;
82  import com.gargoylesoftware.htmlunit.html.HtmlArea;
83  import com.gargoylesoftware.htmlunit.html.HtmlAttributeChangeEvent;
84  import com.gargoylesoftware.htmlunit.html.HtmlElement;
85  import com.gargoylesoftware.htmlunit.html.HtmlEmbed;
86  import com.gargoylesoftware.htmlunit.html.HtmlForm;
87  import com.gargoylesoftware.htmlunit.html.HtmlImage;
88  import com.gargoylesoftware.htmlunit.html.HtmlInput;
89  import com.gargoylesoftware.htmlunit.html.HtmlPage;
90  import com.gargoylesoftware.htmlunit.html.HtmlRp;
91  import com.gargoylesoftware.htmlunit.html.HtmlRt;
92  import com.gargoylesoftware.htmlunit.html.HtmlScript;
93  import com.gargoylesoftware.htmlunit.html.HtmlSvg;
94  import com.gargoylesoftware.htmlunit.html.HtmlUnknownElement;
95  import com.gargoylesoftware.htmlunit.html.UnknownElementFactory;
96  import com.gargoylesoftware.htmlunit.html.impl.SimpleRange;
97  import com.gargoylesoftware.htmlunit.javascript.SimpleScriptable;
98  import com.gargoylesoftware.htmlunit.javascript.configuration.CanSetReadOnly;
99  import com.gargoylesoftware.htmlunit.javascript.configuration.CanSetReadOnlyStatus;
100 import com.gargoylesoftware.htmlunit.javascript.configuration.JsxClass;
101 import com.gargoylesoftware.htmlunit.javascript.configuration.JsxConstructor;
102 import com.gargoylesoftware.htmlunit.javascript.configuration.JsxFunction;
103 import com.gargoylesoftware.htmlunit.javascript.configuration.JsxGetter;
104 import com.gargoylesoftware.htmlunit.javascript.configuration.JsxSetter;
105 import com.gargoylesoftware.htmlunit.javascript.host.Element;
106 import com.gargoylesoftware.htmlunit.javascript.host.Location;
107 import com.gargoylesoftware.htmlunit.javascript.host.NativeFunctionPrefixResolver;
108 import com.gargoylesoftware.htmlunit.javascript.host.Window;
109 import com.gargoylesoftware.htmlunit.javascript.host.css.StyleSheetList;
110 import com.gargoylesoftware.htmlunit.javascript.host.event.BeforeUnloadEvent;
111 import com.gargoylesoftware.htmlunit.javascript.host.event.CloseEvent;
112 import com.gargoylesoftware.htmlunit.javascript.host.event.CustomEvent;
113 import com.gargoylesoftware.htmlunit.javascript.host.event.Event;
114 import com.gargoylesoftware.htmlunit.javascript.host.event.HashChangeEvent;
115 import com.gargoylesoftware.htmlunit.javascript.host.event.KeyboardEvent;
116 import com.gargoylesoftware.htmlunit.javascript.host.event.MessageEvent;
117 import com.gargoylesoftware.htmlunit.javascript.host.event.MouseEvent;
118 import com.gargoylesoftware.htmlunit.javascript.host.event.MutationEvent;
119 import com.gargoylesoftware.htmlunit.javascript.host.event.PointerEvent;
120 import com.gargoylesoftware.htmlunit.javascript.host.event.PopStateEvent;
121 import com.gargoylesoftware.htmlunit.javascript.host.event.ProgressEvent;
122 import com.gargoylesoftware.htmlunit.javascript.host.event.UIEvent;
123 import com.gargoylesoftware.htmlunit.javascript.host.html.DocumentProxy;
124 import com.gargoylesoftware.htmlunit.javascript.host.html.HTMLAnchorElement;
125 import com.gargoylesoftware.htmlunit.javascript.host.html.HTMLCollection;
126 import com.gargoylesoftware.htmlunit.javascript.host.html.HTMLDocument;
127 import com.gargoylesoftware.htmlunit.javascript.host.html.HTMLElement;
128 import com.gargoylesoftware.htmlunit.util.EncodingSniffer;
129 
130 import net.sourceforge.htmlunit.corejs.javascript.Callable;
131 import net.sourceforge.htmlunit.corejs.javascript.Context;
132 import net.sourceforge.htmlunit.corejs.javascript.Function;
133 import net.sourceforge.htmlunit.corejs.javascript.FunctionObject;
134 import net.sourceforge.htmlunit.corejs.javascript.NativeFunction;
135 import net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime;
136 import net.sourceforge.htmlunit.corejs.javascript.Scriptable;
137 import net.sourceforge.htmlunit.corejs.javascript.ScriptableObject;
138 
139 /**
140  * A JavaScript object for {@code Document}.
141  *
142  * @author <a href="mailto:mbowler@GargoyleSoftware.com">Mike Bowler</a>
143  * @author David K. Taylor
144  * @author <a href="mailto:chen_jun@users.sourceforge.net">Chen Jun</a>
145  * @author <a href="mailto:cse@dynabean.de">Christian Sell</a>
146  * @author Chris Erskine
147  * @author Marc Guillemot
148  * @author Daniel Gredler
149  * @author Michael Ottati
150  * @author <a href="mailto:george@murnock.com">George Murnock</a>
151  * @author Ahmed Ashour
152  * @author Rob Di Marco
153  * @author Ronald Brill
154  * @author Chuck Dumont
155  * @author Frank Danek
156  * @author Madis Pärn
157  * @see <a href="http://msdn.microsoft.com/en-us/library/ms531073.aspx">MSDN documentation</a>
158  * @see <a href="http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/level-one-html.html#ID-7068919">W3C Dom Level 1</a>
159  */
160 @JsxClass
161 public class Document extends Node {
162 
163     private static final Log LOG = LogFactory.getLog(Document.class);
164     private static final Pattern TAG_NAME_PATTERN = Pattern.compile("\\w+");
165     // all as lowercase for performance
166     private static final Set<String> EXECUTE_CMDS_IE = new HashSet<>();
167     /** https://developer.mozilla.org/en/Rich-Text_Editing_in_Mozilla#Executing_Commands */
168     private static final Set<String> EXECUTE_CMDS_FF = new HashSet<>();
169     private static final Set<String> EXECUTE_CMDS_CHROME = new HashSet<>();
170     /** The format to use for the <tt>lastModified</tt> attribute. */
171     private static final String LAST_MODIFIED_DATE_FORMAT = "MM/dd/yyyy HH:mm:ss";
172 
173     /**
174      * Map<String, Class> which maps strings a caller may use when calling into
175      * {@link #createEvent(String)} to the associated event class. To support a new
176      * event creation type, the event type and associated class need to be added into this map in
177      * the static initializer. The map is unmodifiable. Any class that is a value in this map MUST
178      * have a no-arg constructor.
179      */
180     /** Contains all supported DOM level 2 events. */
181     private static final Map<String, Class<? extends Event>> SUPPORTED_DOM2_EVENT_TYPE_MAP;
182     /** Contains all supported DOM level 3 events. DOM level 2 events are not included. */
183     private static final Map<String, Class<? extends Event>> SUPPORTED_DOM3_EVENT_TYPE_MAP;
184     /** Contains all supported vendor specific events. */
185     private static final Map<String, Class<? extends Event>> SUPPORTED_VENDOR_EVENT_TYPE_MAP;
186 
187     /** Initializes the supported event type map. */
188     static {
189         final Map<String, Class<? extends Event>> dom2EventMap = new HashMap<>();
190         dom2EventMap.put("HTMLEvents", Event.class);
191         dom2EventMap.put("MouseEvents", MouseEvent.class);
192         dom2EventMap.put("MutationEvents", MutationEvent.class);
193         dom2EventMap.put("UIEvents", UIEvent.class);
194         SUPPORTED_DOM2_EVENT_TYPE_MAP = Collections.unmodifiableMap(dom2EventMap);
195 
196         final Map<String, Class<? extends Event>> dom3EventMap = new HashMap<>();
197         dom3EventMap.put("Event", Event.class);
198         dom3EventMap.put("KeyboardEvent", KeyboardEvent.class);
199         dom3EventMap.put("MouseEvent", MouseEvent.class);
200         dom3EventMap.put("MessageEvent", MessageEvent.class);
201         dom3EventMap.put("MutationEvent", MutationEvent.class);
202         dom3EventMap.put("UIEvent", UIEvent.class);
203         dom3EventMap.put("CustomEvent", CustomEvent.class);
204         dom3EventMap.put("CloseEvent", CloseEvent.class);
205         SUPPORTED_DOM3_EVENT_TYPE_MAP = Collections.unmodifiableMap(dom3EventMap);
206 
207         final Map<String, Class<? extends Event>> additionalEventMap = new HashMap<>();
208         additionalEventMap.put("BeforeUnloadEvent", BeforeUnloadEvent.class);
209         additionalEventMap.put("Events", Event.class);
210         additionalEventMap.put("HashChangeEvent", HashChangeEvent.class);
211         additionalEventMap.put("KeyEvents", KeyboardEvent.class);
212         additionalEventMap.put("PointerEvent", PointerEvent.class);
213         additionalEventMap.put("PopStateEvent", PopStateEvent.class);
214         additionalEventMap.put("ProgressEvent", ProgressEvent.class);
215         SUPPORTED_VENDOR_EVENT_TYPE_MAP = Collections.unmodifiableMap(additionalEventMap);
216     }
217 
218     /**
219      * Static counter for {@link #uniqueID_}.
220      */
221     private static int UniqueID_Counter_ = 1;
222 
223     private Window window_;
224     private DOMImplementation implementation_;
225     private String designMode_;
226     private String compatMode_;
227     private int documentMode_ = -1;
228     private String uniqueID_;
229     private String domain_;
230     private String lastModified_;
231     private ScriptableObject currentScript_;
232 
233     static {
234         // commands
235         List<String> cmds = Arrays.asList(
236             "2D-Position", "AbsolutePosition",
237             "BlockDirLTR", "BlockDirRTL", "BrowseMode",
238             "ClearAuthenticationCache", "CreateBookmark", "Copy", "Cut",
239             "DirLTR", "DirRTL",
240             "EditMode",
241             "InlineDirLTR", "InlineDirRTL", "InsertButton", "InsertFieldset",
242             "InsertIFrame", "InsertInputButton", "InsertInputCheckbox",
243             "InsertInputFileUpload", "InsertInputHidden", "InsertInputImage", "InsertInputPassword", "InsertInputRadio",
244             "InsertInputReset", "InsertInputSubmit", "InsertInputText", "InsertMarquee",
245             "InsertSelectDropdown", "InsertSelectListbox", "InsertTextArea",
246             "LiveResize", "MultipleSelection", "Open",
247             "OverWrite", "PlayImage",
248             "Refresh", "RemoveParaFormat", "SaveAs",
249             "SizeToControl", "SizeToControlHeight", "SizeToControlWidth", "Stop", "StopImage",
250             "UnBookmark",
251             "Paste"
252         );
253         for (final String cmd : cmds) {
254             EXECUTE_CMDS_IE.add(cmd.toLowerCase(Locale.ROOT));
255         }
256 
257         cmds = Arrays.asList(
258             "BackColor", "BackgroundImageCache" /* Undocumented */,
259             "Bold",
260             "CreateLink", "Delete",
261             "FontName", "FontSize", "ForeColor", "FormatBlock",
262             "Indent", "InsertHorizontalRule", "InsertImage",
263             "InsertOrderedList", "InsertParagraph", "InsertUnorderedList",
264             "Italic", "JustifyCenter", "JustifyFull", "JustifyLeft", "JustifyNone",
265             "JustifyRight",
266             "Outdent",
267             "Print",
268             "Redo", "RemoveFormat",
269             "SelectAll", "StrikeThrough", "Subscript", "Superscript",
270             "Underline", "Undo", "Unlink", "Unselect"
271         );
272         for (final String cmd : cmds) {
273             EXECUTE_CMDS_IE.add(cmd.toLowerCase(Locale.ROOT));
274             if (!"Bold".equals(cmd)) {
275                 EXECUTE_CMDS_CHROME.add(cmd.toLowerCase(Locale.ROOT));
276             }
277         }
278 
279         cmds = Arrays.asList(
280             "backColor", "bold", "contentReadOnly", "copy", "createLink", "cut", "decreaseFontSize", "delete",
281             "fontName", "fontSize", "foreColor", "formatBlock", "heading", "hiliteColor", "increaseFontSize",
282             "indent", "insertHorizontalRule", "insertHTML", "insertImage", "insertOrderedList", "insertUnorderedList",
283             "insertParagraph", "italic",
284             "justifyCenter", "JustifyFull", "justifyLeft", "justifyRight", "outdent", "paste", "redo",
285             "removeFormat", "selectAll", "strikeThrough", "subscript", "superscript", "underline", "undo", "unlink",
286             "useCSS", "styleWithCSS"
287         );
288         for (final String cmd : cmds) {
289             EXECUTE_CMDS_FF.add(cmd.toLowerCase(Locale.ROOT));
290             if (!"bold".equals(cmd)) {
291                 EXECUTE_CMDS_CHROME.add(cmd.toLowerCase(Locale.ROOT));
292             }
293         }
294     }
295 
296     /**
297      * Creates an instance.
298      */
299     @JsxConstructor({CHROME, FF, EDGE})
300     public Document() {
301     }
302 
303     /**
304      * Sets the Window JavaScript object that encloses this document.
305      * @param window the Window JavaScript object that encloses this document
306      */
307     public void setWindow(final Window window) {
308         window_ = window;
309     }
310 
311     /**
312      * Returns the value of the {@code location} property.
313      * @return the value of the {@code location} property
314      */
315     @JsxGetter
316     public Location getLocation() {
317         if (window_ == null) {
318             return null;
319         }
320         return window_.getLocation();
321     }
322 
323     /**
324      * Sets the value of the {@code location} property. The location's default property is "href",
325      * so setting "document.location='http://www.sf.net'" is equivalent to setting
326      * "document.location.href='http://www.sf.net'".
327      * @see <a href="http://msdn.microsoft.com/en-us/library/ms535866.aspx">MSDN documentation</a>
328      * @param location the location to navigate to
329      * @throws IOException when location loading fails
330      */
331     @JsxSetter
332     public void setLocation(final String location) throws IOException {
333         final Object event = getWindow().getEvent();
334         boolean setLocation = true;
335         if (event instanceof UIEvent) {
336             final Object target = ((UIEvent) event).getTarget();
337             if (target instanceof HTMLAnchorElement) {
338                 final String href = ((HTMLAnchorElement) target).getHref();
339                 if (!href.isEmpty()
340                         && !getBrowserVersion().hasFeature(JS_DOCUMENT_SET_LOCATION_EXECUTED_IN_ANCHOR)) {
341                     setLocation = false;
342                 }
343             }
344         }
345         if (setLocation) {
346             window_.setLocation(location);
347         }
348     }
349 
350     /**
351      * Returns the value of the {@code referrer} property.
352      * @return the value of the {@code referrer} property
353      */
354     @JsxGetter
355     public String getReferrer() {
356         String referrer = "";
357         final WebResponse webResponse = getPage().getWebResponse();
358         if (webResponse != null) {
359             referrer = webResponse.getWebRequest().getAdditionalHeaders().get("Referer");
360             if (referrer == null) {
361                 referrer = "";
362             }
363         }
364         return referrer;
365     }
366 
367     /**
368      * Gets the JavaScript property {@code documentElement} for the document.
369      * @return the root node for the document
370      */
371     @JsxGetter
372     public Element getDocumentElement() {
373         final Object documentElement = getPage().getDocumentElement();
374         if (documentElement == null) {
375             // for instance with an XML document with parsing error
376             return null;
377         }
378         return (Element) getScriptableFor(documentElement);
379     }
380 
381     /**
382      * Gets the JavaScript property {@code rootElement}.
383      * @return the root node for the document
384      */
385     @JsxGetter({CHROME, FF52, IE})
386     public Element getRootElement() {
387         return null;
388     }
389 
390     /**
391      * Gets the JavaScript property {@code doctype} for the document.
392      * @return the DocumentType of the document
393      */
394     @JsxGetter
395     public SimpleScriptable getDoctype() {
396         final Object documentType = getPage().getDoctype();
397         if (documentType == null) {
398             return null;
399         }
400         return getScriptableFor(documentType);
401     }
402 
403     /**
404      * Returns a value which indicates whether or not the document can be edited.
405      * @return a value which indicates whether or not the document can be edited
406      */
407     @JsxGetter({CHROME, IE})
408     public String getDesignMode() {
409         if (designMode_ == null) {
410             if (getBrowserVersion().hasFeature(JS_DOCUMENT_DESIGN_MODE_INHERIT)) {
411                 designMode_ = "inherit";
412             }
413             else {
414                 designMode_ = "off";
415             }
416         }
417         return designMode_;
418     }
419 
420     /**
421      * Sets a value which indicates whether or not the document can be edited.
422      * @param mode a value which indicates whether or not the document can be edited
423      */
424     @JsxSetter({CHROME, IE})
425     public void setDesignMode(final String mode) {
426         final BrowserVersion browserVersion = getBrowserVersion();
427         final boolean inherit = browserVersion.hasFeature(JS_DOCUMENT_DESIGN_MODE_INHERIT);
428         if (inherit) {
429             if (!"on".equalsIgnoreCase(mode) && !"off".equalsIgnoreCase(mode) && !"inherit".equalsIgnoreCase(mode)) {
430                 throw Context.reportRuntimeError("Invalid document.designMode value '" + mode + "'.");
431             }
432 
433             if ("on".equalsIgnoreCase(mode)) {
434                 designMode_ = "on";
435             }
436             else if ("off".equalsIgnoreCase(mode)) {
437                 designMode_ = "off";
438             }
439             else if ("inherit".equalsIgnoreCase(mode)) {
440                 designMode_ = "inherit";
441             }
442         }
443         else {
444             if ("on".equalsIgnoreCase(mode)) {
445                 designMode_ = "on";
446                 final SgmlPage page = getPage();
447                 if (page != null && page.isHtmlPage()
448                         && getBrowserVersion().hasFeature(JS_DOCUMENT_SELECTION_RANGE_COUNT)) {
449                     final HtmlPage htmlPage = (HtmlPage) page;
450                     final DomNode child = htmlPage.getBody().getFirstChild();
451                     final DomNode rangeNode = child == null ? htmlPage.getBody() : child;
452                     htmlPage.setSelectionRange(new SimpleRange(rangeNode, 0));
453                 }
454             }
455             else if ("off".equalsIgnoreCase(mode)) {
456                 designMode_ = "off";
457             }
458         }
459     }
460 
461     /**
462      * Returns the page that this document is modeling.
463      * @return the page that this document is modeling
464      */
465     public SgmlPage getPage() {
466         return (SgmlPage) getDomNodeOrDie();
467     }
468 
469     /**
470      * Gets the window in which this document is contained.
471      * @return the window
472      */
473     @JsxGetter
474     public Object getDefaultView() {
475         return getWindow();
476     }
477 
478     /**
479      * Creates a new document fragment.
480      * @return a newly created document fragment
481      */
482     @JsxFunction
483     public Object createDocumentFragment() {
484         final DomDocumentFragment fragment = getDomNodeOrDie().getPage().createDocumentFragment();
485         final DocumentFragment node = new DocumentFragment();
486         node.setParentScope(getParentScope());
487         node.setPrototype(getPrototype(node.getClass()));
488         node.setDomNode(fragment);
489         return getScriptableFor(fragment);
490     }
491 
492     /**
493      * Creates a new HTML attribute with the specified name.
494      *
495      * @param attributeName the name of the attribute to create
496      * @return an attribute with the specified name
497      */
498     @JsxFunction
499     public Attr createAttribute(final String attributeName) {
500         return (Attr) getPage().createAttribute(attributeName).getScriptableObject();
501     }
502 
503     /**
504      * Imports a node from another document to this document.
505      * The source node is not altered or removed from the original document;
506      * this method creates a new copy of the source node.
507      *
508      * @param importedNode the node to import
509      * @param deep Whether to recursively import the subtree under the specified node; or not
510      * @return the imported node that belongs to this Document
511      */
512     @JsxFunction
513     public Object importNode(final Node importedNode, final boolean deep) {
514         DomNode domNode = importedNode.getDomNodeOrDie();
515         domNode = domNode.cloneNode(deep);
516         domNode.processImportNode(this);
517         for (final DomNode childNode : domNode.getDescendants()) {
518             childNode.processImportNode(this);
519         }
520         return domNode.getScriptableObject();
521     }
522 
523     /**
524      * Adopts a node from an external document.
525      * The node and its subtree is removed from the document it's in (if any),
526      * and its ownerDocument is changed to the current document.
527      * The node can then be inserted into the current document.
528      *
529      * @param externalNode the node from another document to be adopted
530      * @return the adopted node that can be used in the current document
531      */
532     @JsxFunction
533     public Object adoptNode(final Node externalNode) {
534         externalNode.remove();
535         return importNode(externalNode, true);
536     }
537 
538     /**
539      * Returns the implementation object of the current document.
540      * @return implementation-specific object
541      */
542     @JsxGetter
543     public DOMImplementation getImplementation() {
544         if (implementation_ == null) {
545             implementation_ = new DOMImplementation();
546             implementation_.setParentScope(getWindow());
547             implementation_.setPrototype(getPrototype(implementation_.getClass()));
548         }
549         return implementation_;
550     }
551 
552     /**
553      * Adapts any DOM node to resolve namespaces so that an XPath expression can be easily
554      * evaluated relative to the context of the node where it appeared within the document.
555      * @param nodeResolver the node to be used as a context for namespace resolution
556      * @return an XPathNSResolver which resolves namespaces with respect to the definitions
557      *         in scope for a specified node
558      */
559     @JsxFunction({CHROME, FF})
560     public XPathNSResolver createNSResolver(final Node nodeResolver) {
561         final XPathNSResolver resolver = new XPathNSResolver();
562         resolver.setElement(nodeResolver);
563         resolver.setParentScope(getWindow());
564         resolver.setPrototype(getPrototype(resolver.getClass()));
565         return resolver;
566     }
567 
568     /**
569      * Create a new DOM text node with the given data.
570      *
571      * @param newData the string value for the text node
572      * @return the new text node or NOT_FOUND if there is an error
573      */
574     @JsxFunction
575     public Object createTextNode(final String newData) {
576         Object result = NOT_FOUND;
577         try {
578             final DomNode domNode = new DomText(getDomNodeOrDie().getPage(), newData);
579             final Object jsElement = getScriptableFor(domNode);
580 
581             if (jsElement == NOT_FOUND) {
582                 if (LOG.isDebugEnabled()) {
583                     LOG.debug("createTextNode(" + newData
584                             + ") cannot return a result as there isn't a JavaScript object for the DOM node "
585                             + domNode.getClass().getName());
586                 }
587             }
588             else {
589                 result = jsElement;
590             }
591         }
592         catch (final ElementNotFoundException e) {
593             // Just fall through - result is already set to NOT_FOUND
594         }
595         return result;
596     }
597 
598     /**
599      * Creates a new Comment.
600      * @param comment the comment text
601      * @return the new Comment
602      */
603     @JsxFunction
604     public Object createComment(final String comment) {
605         final DomNode domNode = new DomComment(getDomNodeOrDie().getPage(), comment);
606         return getScriptableFor(domNode);
607     }
608 
609     /**
610      * Evaluates an XPath expression string and returns a result of the specified type if possible.
611      * @param expression the XPath expression string to be parsed and evaluated
612      * @param contextNode the context node for the evaluation of this XPath expression
613      * @param resolver the resolver permits translation of all prefixes, including the XML namespace prefix,
614      *        within the XPath expression into appropriate namespace URIs.
615      * @param type If a specific type is specified, then the result will be returned as the corresponding type
616      * @param result the result object which may be reused and returned by this method
617      * @return the result of the evaluation of the XPath expression
618      */
619     @JsxFunction({CHROME, FF})
620     public XPathResult evaluate(final String expression, final Node contextNode,
621             final Object resolver, final int type, final Object result) {
622         XPathResult xPathResult = (XPathResult) result;
623         if (xPathResult == null) {
624             xPathResult = new XPathResult();
625             xPathResult.setParentScope(getParentScope());
626             xPathResult.setPrototype(getPrototype(xPathResult.getClass()));
627         }
628 
629         PrefixResolver prefixResolver = null;
630         if (resolver instanceof NativeFunction) {
631             prefixResolver = new NativeFunctionPrefixResolver((NativeFunction) resolver, contextNode.getParentScope());
632         }
633         else if (resolver instanceof PrefixResolver) {
634             prefixResolver = (PrefixResolver) resolver;
635         }
636         xPathResult.init(contextNode.getDomNodeOrDie().getByXPath(expression, prefixResolver), type);
637         return xPathResult;
638     }
639 
640     /**
641      * Creates a new element with the given tag name.
642      *
643      * @param tagName the tag name
644      * @return the new HTML element, or NOT_FOUND if the tag is not supported
645      */
646     @JsxFunction
647     public Object createElement(String tagName) {
648         Object result = NOT_FOUND;
649         try {
650             final BrowserVersion browserVersion = getBrowserVersion();
651 
652             if (browserVersion.hasFeature(JS_DOCUMENT_CREATE_ELEMENT_STRICT)
653                   && (tagName.contains("<") || tagName.contains(">"))) {
654                 LOG.info("createElement: Provided string '"
655                             + tagName + "' contains an invalid character; '<' and '>' are not allowed");
656                 throw Context.reportRuntimeError("String contains an invalid character");
657             }
658             else if (tagName.startsWith("<") && tagName.endsWith(">")) {
659                 tagName = tagName.substring(1, tagName.length() - 1);
660 
661                 final Matcher matcher = TAG_NAME_PATTERN.matcher(tagName);
662                 if (!matcher.matches()) {
663                     LOG.info("createElement: Provided string '" + tagName + "' contains an invalid character");
664                     throw Context.reportRuntimeError("String contains an invalid character");
665                 }
666             }
667 
668             final SgmlPage page = getPage();
669             org.w3c.dom.Node element = page.createElement(tagName);
670 
671             if (element instanceof BaseFrameElement) {
672                 ((BaseFrameElement) element).markAsCreatedByJavascript();
673             }
674             else if (element instanceof HtmlInput) {
675                 ((HtmlInput) element).markAsCreatedByJavascript();
676             }
677             else if (element instanceof HtmlImage) {
678                 ((HtmlImage) element).markAsCreatedByJavascript();
679             }
680             else if (element instanceof HtmlRp) {
681                 ((HtmlRp) element).markAsCreatedByJavascript();
682             }
683             else if (element instanceof HtmlRt) {
684                 ((HtmlRt) element).markAsCreatedByJavascript();
685             }
686             else if (element instanceof HtmlScript) {
687                 ((HtmlScript) element).markAsCreatedByJavascript();
688             }
689             else if (element instanceof HtmlUnknownElement) {
690                 ((HtmlUnknownElement) element).markAsCreatedByJavascript();
691             }
692             else if (element instanceof HtmlSvg) {
693                 element = UnknownElementFactory.instance.createElementNS(page, "", "svg", null);
694                 ((HtmlUnknownElement) element).markAsCreatedByJavascript();
695             }
696             final Object jsElement = getScriptableFor(element);
697 
698             if (jsElement == NOT_FOUND) {
699                 if (LOG.isDebugEnabled()) {
700                     LOG.debug("createElement(" + tagName
701                         + ") cannot return a result as there isn't a JavaScript object for the element "
702                         + element.getClass().getName());
703                 }
704             }
705             else {
706                 result = jsElement;
707             }
708         }
709         catch (final ElementNotFoundException e) {
710             // Just fall through - result is already set to NOT_FOUND
711         }
712         return result;
713     }
714 
715     /**
716      * Creates a new HTML element with the given tag name, and name.
717      *
718      * @param namespaceURI the URI that identifies an XML namespace
719      * @param qualifiedName the qualified name of the element type to instantiate
720      * @return the new HTML element, or NOT_FOUND if the tag is not supported
721      */
722     @JsxFunction
723     public Object createElementNS(final String namespaceURI, final String qualifiedName) {
724         final org.w3c.dom.Element element;
725         if ("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul".equals(namespaceURI)) {
726             throw Context.reportRuntimeError("XUL not available");
727         }
728 
729         if (HTMLParser.XHTML_NAMESPACE.equals(namespaceURI)
730                 || HTMLParser.SVG_NAMESPACE.equals(namespaceURI)) {
731             element = getPage().createElementNS(namespaceURI, qualifiedName);
732         }
733         else {
734             element = new DomElement(namespaceURI, qualifiedName, getPage(), null);
735         }
736         return getScriptableFor(element);
737     }
738 
739     /**
740      * Returns all the descendant elements with the specified tag name.
741      * @param tagName the name to search for
742      * @return all the descendant elements with the specified tag name
743      */
744     @JsxFunction
745     public HTMLCollection getElementsByTagName(final String tagName) {
746         final HTMLCollection collection;
747         if ("*".equals(tagName)) {
748             collection = new HTMLCollection(getDomNodeOrDie(), false) {
749                 @Override
750                 protected boolean isMatching(final DomNode node) {
751                     return true;
752                 }
753             };
754         }
755         else {
756             collection = new HTMLCollection(getDomNodeOrDie(), false) {
757                 @Override
758                 protected boolean isMatching(final DomNode node) {
759                     return tagName.equalsIgnoreCase(node.getNodeName());
760                 }
761             };
762         }
763 
764         return collection;
765     }
766 
767     /**
768      * Returns a list of elements with the given tag name belonging to the given namespace.
769      * @param namespaceURI the namespace URI of elements to look for
770      * @param localName is either the local name of elements to look for or the special value "*",
771      *                  which matches all elements.
772      * @return a live NodeList of found elements in the order they appear in the tree
773      */
774     @JsxFunction
775     public Object getElementsByTagNameNS(final Object namespaceURI, final String localName) {
776         final HTMLCollection collection = new HTMLCollection(getDomNodeOrDie(), false) {
777             @Override
778             protected boolean isMatching(final DomNode node) {
779                 return localName.equals(node.getLocalName());
780             }
781         };
782 
783         return collection;
784     }
785 
786     /**
787      * Returns the value of the {@code activeElement} property.
788      * @see <a href="http://msdn.microsoft.com/en-us/library/ms533065.aspx">MSDN documentation</a>
789      * @return the value of the {@code activeElement} property
790      */
791     @JsxGetter
792     public Object getActiveElement() {
793         return null;
794     }
795 
796     /**
797      * Returns the character encoding of the current document.
798      * @return the character encoding of the current document
799      */
800     @JsxGetter
801     public String getCharacterSet() {
802         if (!(getPage() instanceof HtmlPage)) {
803             // TODO: implement XmlPage.getCharset
804             return "";
805         }
806         final Charset charset = getPage().getCharset();
807         if (charset != null && getBrowserVersion().hasFeature(HTMLDOCUMENT_CHARSET_LOWERCASE)) {
808             return charset.name().toLowerCase(Locale.ROOT);
809         }
810         return EncodingSniffer.translateEncodingLabel(charset);
811     }
812 
813     /**
814      * Retrieves the character set used to encode the document.
815      * @return the character set used to encode the document
816      */
817     @JsxGetter
818     public String getCharset() {
819         if (!(getPage() instanceof HtmlPage)) {
820             // TODO: implement XmlPage.getCharset
821             return "";
822         }
823         final Charset charset = getPage().getCharset();
824         if (getBrowserVersion().hasFeature(HTMLDOCUMENT_CHARSET_LOWERCASE)) {
825             return charset.name().toLowerCase(Locale.ROOT);
826         }
827         return EncodingSniffer.translateEncodingLabel(charset);
828     }
829 
830     /**
831      * Gets the default character set from the current regional language settings.
832      * @return the default character set from the current regional language settings
833      */
834     @JsxGetter(IE)
835     public String getDefaultCharset() {
836         return "windows-1252";
837     }
838 
839     /**
840      * Returns the value of the JavaScript property {@code anchors}.
841      * @see <a href="http://msdn.microsoft.com/en-us/library/ms537435.aspx">MSDN documentation</a>
842      * @see <a href="http://www.mozilla.org/docs/dom/domref/dom_doc_ref4.html#1024543">
843      * Gecko DOM reference</a>
844      * @return the value of this property
845      */
846     @JsxGetter({CHROME, IE})
847     public Object getAnchors() {
848         return new HTMLCollection(getDomNodeOrDie(), true) {
849             @Override
850             protected boolean isMatching(final DomNode node) {
851                 if (!(node instanceof HtmlAnchor)) {
852                     return false;
853                 }
854                 final HtmlAnchor anchor = (HtmlAnchor) node;
855                 if (getBrowserVersion().hasFeature(JS_ANCHORS_REQUIRES_NAME_OR_ID)) {
856                     return anchor.hasAttribute("name") || anchor.hasAttribute("id");
857                 }
858                 return anchor.hasAttribute("name");
859             }
860 
861             @Override
862             protected EffectOnCache getEffectOnCache(final HtmlAttributeChangeEvent event) {
863                 final HtmlElement node = event.getHtmlElement();
864                 if (!(node instanceof HtmlAnchor)) {
865                     return EffectOnCache.NONE;
866                 }
867                 if ("name".equals(event.getName()) || "id".equals(event.getName())) {
868                     return EffectOnCache.RESET;
869                 }
870                 return EffectOnCache.NONE;
871             }
872         };
873     }
874 
875     /**
876      * Returns the value of the JavaScript property {@code applets}.
877      * @see <a href="http://msdn.microsoft.com/en-us/library/ms537436.aspx">
878      * MSDN documentation</a>
879      * @see <a href="https://developer.mozilla.org/En/DOM:document.applets">
880      * Gecko DOM reference</a>
881      * @return the value of this property
882      */
883     @JsxGetter({CHROME, IE})
884     public Object getApplets() {
885         return new HTMLCollection(getDomNodeOrDie(), false) {
886             @Override
887             protected boolean isMatching(final DomNode node) {
888                 return node instanceof HtmlApplet;
889             }
890         };
891     }
892 
893     /**
894      * Returns this document's {@code body} element.
895      * @return this document's {@code body} element
896      */
897     @JsxGetter({CHROME, IE})
898     @CanSetReadOnly(CanSetReadOnlyStatus.EXCEPTION)
899     public HTMLElement getBody() {
900         final Page page = getPage();
901         if (page instanceof HtmlPage) {
902             final HtmlElement body = ((HtmlPage) page).getBody();
903             if (body != null) {
904                 return (HTMLElement) body.getScriptableObject();
905             }
906         }
907         return null;
908     }
909 
910     /**
911      * JavaScript function {@code close}.
912      *
913      * See http://www.whatwg.org/specs/web-apps/current-work/multipage/section-dynamic.html for
914      * a good description of the semantics of open(), write(), writeln() and close().
915      *
916      * @throws IOException if an IO problem occurs
917      */
918     @JsxFunction({CHROME, IE})
919     public void close() throws IOException {
920     }
921 
922     /**
923      * Returns the {@code compatMode} property.
924      * @return the {@code compatMode} property
925      */
926     @JsxGetter
927     public String getCompatMode() {
928         // initialize the modes
929         getDocumentMode();
930         return compatMode_;
931     }
932 
933     /**
934      * Returns the {@code documentMode} property.
935      * @return the {@code documentMode} property
936      */
937     @JsxGetter(IE)
938     public int getDocumentMode() {
939         if (documentMode_ != -1) {
940             return documentMode_;
941         }
942 
943         compatMode_ = "CSS1Compat";
944 
945         if (isQuirksDocType()) {
946             compatMode_ = "BackCompat";
947         }
948 
949         final float version = getBrowserVersion().getBrowserVersionNumeric();
950         documentMode_ = (int) Math.floor(version);
951         return documentMode_;
952     }
953 
954     private boolean isQuirksDocType() {
955         final DocumentType docType = getPage().getDoctype();
956         if (docType != null) {
957             final String systemId = docType.getSystemId();
958             if (systemId != null) {
959                 if ("http://www.w3.org/TR/html4/strict.dtd".equals(systemId)) {
960                     return false;
961                 }
962 
963                 if ("http://www.w3.org/TR/html4/loose.dtd".equals(systemId)) {
964                     final String publicId = docType.getPublicId();
965                     if ("-//W3C//DTD HTML 4.01 Transitional//EN".equals(publicId)) {
966                         return false;
967                     }
968                 }
969 
970                 if ("http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd".equals(systemId)
971                     || "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd".equals(systemId)) {
972                     return false;
973                 }
974             }
975             else if (docType.getPublicId() == null) {
976                 if (docType.getName() != null) {
977                     return false;
978                 }
979                 return true;
980             }
981         }
982         return true;
983     }
984 
985     /**
986      * <span style="color:red">INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.</span><br>
987      *
988      * Called from the HTMLParser if a 'X-UA-Compatible' meta tag found.
989      * @param documentMode the mode forced by the meta tag
990      */
991     public void forceDocumentMode(final int documentMode) {
992         documentMode_ = documentMode;
993         compatMode_ = documentMode == 5 ? "BackCompat" : "CSS1Compat";
994     }
995 
996     /**
997      * Returns the first element within the document that matches the specified group of selectors.
998      * @param selectors the selectors
999      * @return null if no matches are found; otherwise, it returns the first matching element
1000      */
1001     @JsxFunction
1002     public Node querySelector(final String selectors) {
1003         try {
1004             final DomNode node = getDomNodeOrDie().querySelector(selectors);
1005             if (node != null) {
1006                 return (Node) node.getScriptableObject();
1007             }
1008             return null;
1009         }
1010         catch (final CSSException e) {
1011             throw Context.reportRuntimeError("An invalid or illegal selector was specified (selector: '"
1012                     + selectors + "' error: " + e.getMessage() + ").");
1013         }
1014     }
1015 
1016     /**
1017      * Retrieves all element nodes from descendants of the starting element node that match any selector
1018      * within the supplied selector strings.
1019      * The NodeList object returned by the querySelectorAll() method must be static, not live.
1020      * @param selectors the selectors
1021      * @return the static node list
1022      */
1023     @JsxFunction
1024     public NodeList querySelectorAll(final String selectors) {
1025         try {
1026             return NodeList.staticNodeList(this, getDomNodeOrDie().querySelectorAll(selectors));
1027         }
1028         catch (final CSSException e) {
1029             throw Context.reportRuntimeError("An invalid or illegal selector was specified (selector: '"
1030                     + selectors + "' error: " + e.getMessage() + ").");
1031         }
1032     }
1033 
1034     /**
1035      * Indicates if the command is supported.
1036      * @see <a href="http://msdn2.microsoft.com/en-us/library/ms536681.aspx">MSDN documentation</a>
1037      * @param cmd the command identifier
1038      * @return {@code true} if the command is supported
1039      */
1040     @JsxFunction({CHROME, IE})
1041     public boolean queryCommandSupported(final String cmd) {
1042         return hasCommand(cmd, true);
1043     }
1044 
1045     private boolean hasCommand(final String cmd, final boolean includeBold) {
1046         if (null == cmd) {
1047             return false;
1048         }
1049 
1050         final String cmdLC = cmd.toLowerCase(Locale.ROOT);
1051         if (getBrowserVersion().isIE()) {
1052             return EXECUTE_CMDS_IE.contains(cmdLC);
1053         }
1054         if (getBrowserVersion().isChrome()) {
1055             return EXECUTE_CMDS_CHROME.contains(cmdLC) || (includeBold && "bold".equalsIgnoreCase(cmd));
1056         }
1057         return EXECUTE_CMDS_FF.contains(cmdLC);
1058     }
1059 
1060     /**
1061      * Indicates if the command can be successfully executed using <tt>execCommand</tt>, given
1062      * the current state of the document.
1063      * @param cmd the command identifier
1064      * @return {@code true} if the command can be successfully executed
1065      */
1066     @JsxFunction({CHROME, IE})
1067     public boolean queryCommandEnabled(final String cmd) {
1068         return hasCommand(cmd, true);
1069     }
1070 
1071     /**
1072      * Executes a command.
1073      * @see <a href="http://msdn2.microsoft.com/en-us/library/ms536419.aspx">MSDN documentation</a>
1074      * @param cmd the command identifier
1075      * @param userInterface display a user interface if the command supports one
1076      * @param value the string, number, or other value to assign (possible values depend on the command)
1077      * @return {@code true} if the command was successful, {@code false} otherwise
1078      */
1079     @JsxFunction({CHROME, IE})
1080     public boolean execCommand(final String cmd, final boolean userInterface, final Object value) {
1081         if (!hasCommand(cmd, false)) {
1082             return false;
1083         }
1084         LOG.warn("Nothing done for execCommand(" + cmd + ", ...) (feature not implemented)");
1085         return true;
1086     }
1087 
1088     /**
1089      * Retrieves an auto-generated, unique identifier for the object.
1090      * <b>Note</b> The unique ID generated is not guaranteed to be the same every time the page is loaded.
1091      * @return an auto-generated, unique identifier for the object
1092      */
1093     @JsxGetter(IE)
1094     public String getUniqueID() {
1095         if (uniqueID_ == null) {
1096             uniqueID_ = "ms__id" + UniqueID_Counter_++;
1097         }
1098         return uniqueID_;
1099     }
1100 
1101     /**
1102      * Returns the value of the {@code URL} property.
1103      * @return the value of the {@code URL} property
1104      */
1105     @JsxGetter(propertyName = "URL")
1106     public String getURL() {
1107         if (!(getPage() instanceof HtmlPage)) {
1108             // TODO: implement XmlPage.getUrl
1109             return "";
1110         }
1111         return getPage().getUrl().toExternalForm();
1112     }
1113 
1114     /**
1115      * Returns the value of the {@code documentURI} property.
1116      * @return the value of the {@code documentURI} property
1117      */
1118     @JsxGetter({CHROME, FF})
1119     public String getDocumentURI() {
1120         return getURL();
1121     }
1122 
1123     /**
1124      * Returns the value of the {@code URLUnencoded} property.
1125      * @return the value of the {@code URLUnencoded} property
1126      */
1127     @JsxGetter(value = IE, propertyName = "URLUnencoded")
1128     public String getURLUnencoded() {
1129         return getURL();
1130     }
1131 
1132     /**
1133      * {@inheritDoc}
1134      */
1135     @Override
1136     public Object get(final String name, final Scriptable start) {
1137         final Object response = super.get(name, start);
1138 
1139         // IE support .querySelector(All) but not in quirks mode
1140         // => TODO: find a better way to handle this!
1141         if (response instanceof FunctionObject
1142             && ("querySelectorAll".equals(name) || "querySelector".equals(name))
1143             && getBrowserVersion().hasFeature(QUERYSELECTORALL_NOT_IN_QUIRKS)) {
1144             Document document = null;
1145             if (start instanceof DocumentProxy) {
1146                 // if in prototype no domNode is set -> use start
1147                 document = ((DocumentProxy) start).getDelegee();
1148             }
1149             else if (start instanceof HTMLDocument) {
1150                 final DomNode page = ((HTMLDocument) start).getDomNodeOrNull();
1151                 if (page != null) {
1152                     document = (Document) page.getScriptableObject();
1153                 }
1154             }
1155             if (document instanceof HTMLDocument && ((HTMLDocument) document).getDocumentMode() < 8) {
1156                 return NOT_FOUND;
1157             }
1158         }
1159 
1160         return response;
1161     }
1162 
1163     /**
1164      * Returns the {@code cookie} property.
1165      * @return the {@code cookie} property
1166      */
1167     @JsxGetter({CHROME, IE})
1168     public String getCookie() {
1169         return "";
1170     }
1171 
1172     /**
1173      * Implementation of the {@link org.w3c.dom.events.DocumentEvent} interface's
1174      * {@link org.w3c.dom.events.DocumentEvent#createEvent(String)} method. The method creates an
1175      * uninitialized event of the specified type.
1176      *
1177      * @see <a href="http://www.w3.org/TR/DOM-Level-2-Events/events.html#Events-DocumentEvent">DocumentEvent</a>
1178      * @param eventType the event type to create
1179      * @return an event object for the specified type
1180      * @throws DOMException if the event type is not supported (will have a type of
1181      *         DOMException.NOT_SUPPORTED_ERR)
1182      */
1183     @JsxFunction
1184     public Event createEvent(final String eventType) throws DOMException {
1185         Class<? extends Event> clazz = null;
1186         clazz = SUPPORTED_DOM2_EVENT_TYPE_MAP.get(eventType);
1187         if (clazz == null) {
1188             clazz = SUPPORTED_DOM3_EVENT_TYPE_MAP.get(eventType);
1189             if (CloseEvent.class == clazz
1190                     && getBrowserVersion().hasFeature(EVENT_ONCLOSE_DOCUMENT_CREATE_NOT_SUPPORTED)) {
1191                 clazz = null;
1192             }
1193         }
1194         if (clazz == null
1195                 && ("Events".equals(eventType)
1196                 || "KeyEvents".equals(eventType) && getBrowserVersion().hasFeature(EVENT_TYPE_KEY_EVENTS)
1197                 || "HashChangeEvent".equals(eventType)
1198                 && getBrowserVersion().hasFeature(EVENT_TYPE_HASHCHANGEEVENT)
1199                 || "BeforeUnloadEvent".equals(eventType)
1200                 && getBrowserVersion().hasFeature(EVENT_TYPE_BEFOREUNLOADEVENT)
1201                 || "PointerEvent".equals(eventType)
1202                 && getBrowserVersion().hasFeature(EVENT_TYPE_POINTEREVENT)
1203                 || "PopStateEvent".equals(eventType)
1204                 || "ProgressEvent".equals(eventType)
1205                 && getBrowserVersion().hasFeature(EVENT_TYPE_PROGRESSEVENT))) {
1206             clazz = SUPPORTED_VENDOR_EVENT_TYPE_MAP.get(eventType);
1207         }
1208         if (clazz == null) {
1209             Context.throwAsScriptRuntimeEx(new DOMException(DOMException.NOT_SUPPORTED_ERR,
1210                 "Event Type is not supported: " + eventType));
1211             return null; // to stop eclipse warning
1212         }
1213         try {
1214             final Event event = clazz.newInstance();
1215             event.setParentScope(getWindow());
1216             event.setPrototype(getPrototype(clazz));
1217             event.eventCreated();
1218             return event;
1219         }
1220         catch (final InstantiationException e) {
1221             throw Context.reportRuntimeError("Failed to instantiate event: class ='" + clazz.getName()
1222                             + "' for event type of '" + eventType + "': " + e.getMessage());
1223         }
1224         catch (final IllegalAccessException e) {
1225             throw Context.reportRuntimeError("Failed to instantiate event: class ='" + clazz.getName()
1226                             + "' for event type of '" + eventType + "': " + e.getMessage());
1227         }
1228     }
1229 
1230     /**
1231      * Returns a new NodeIterator object.
1232      *
1233      * @param root The root node at which to begin the NodeIterator's traversal.
1234      * @param whatToShow an optional long representing a bitmask created by combining
1235      * the constant properties of {@link NodeFilter}
1236      * @param filter an object implementing the {@link NodeFilter} interface
1237      * @return a new NodeIterator object
1238      */
1239     @JsxFunction
1240     public NodeIterator createNodeIterator(final Node root, final int whatToShow, final Scriptable filter) {
1241         final org.w3c.dom.traversal.NodeFilter filterWrapper = createFilterWrapper(filter, false);
1242         final NodeIterator iterator = new NodeIterator(getPage(), root, whatToShow, filterWrapper);
1243         iterator.setParentScope(getParentScope());
1244         iterator.setPrototype(getPrototype(iterator.getClass()));
1245         return iterator;
1246     }
1247 
1248     private static org.w3c.dom.traversal.NodeFilter createFilterWrapper(final Scriptable filter,
1249             final boolean filterFunctionOnly) {
1250         org.w3c.dom.traversal.NodeFilter filterWrapper = null;
1251         if (filter != null) {
1252             filterWrapper = new org.w3c.dom.traversal.NodeFilter() {
1253                 @Override
1254                 public short acceptNode(final org.w3c.dom.Node n) {
1255                     final Object[] args = new Object[] {((DomNode) n).getScriptableObject()};
1256                     final Object response;
1257                     if (filter instanceof Callable) {
1258                         response = ((Callable) filter).call(Context.getCurrentContext(), filter, filter, args);
1259                     }
1260                     else {
1261                         if (filterFunctionOnly) {
1262                             throw Context.reportRuntimeError("only a function is allowed as filter");
1263                         }
1264                         response = ScriptableObject.callMethod(filter, "acceptNode", args);
1265                     }
1266                     return (short) Context.toNumber(response);
1267                 }
1268             };
1269         }
1270         return filterWrapper;
1271     }
1272 
1273     /**
1274      * Creates and returns a new TreeWalker. The following JavaScript parameters are passed into this method:
1275      * <ul>
1276      *   <li>JavaScript param 1: The root node of the TreeWalker. Must not be {@code null}.</li>
1277      *   <li>JavaScript param 2: Flag specifying which types of nodes appear in the logical view of the TreeWalker.
1278      *       See {@link NodeFilter} for the set of possible Show_ values.</li>
1279      *   <li>JavaScript param 3: The {@link NodeFilter} to be used with this TreeWalker, or {@code null}
1280      *       to indicate no filter.</li>
1281      *   <li>JavaScript param 4: If {@code false}, the contents of EntityReference nodes are not present
1282      *       in the logical view.</li>
1283      * </ul>
1284      *
1285      * @see <a href="http://www.w3.org/TR/DOM-Level-2-Traversal-Range/traversal.html">DOM-Level-2-Traversal-Range</a>
1286      * @param root the node which will serve as the root for the TreeWalker
1287      * @param whatToShow specifies which node types may appear in the logical view of the tree presented
1288      * @param filter the NodeFilter to be used with this TreeWalker, or null to indicate no filter
1289      * @param expandEntityReferences If false,
1290      *        the contents of EntityReference nodes are not presented in the logical view
1291      * @throws DOMException on attempt to create a TreeWalker with a root that is {@code null}
1292      * @return a new TreeWalker
1293      */
1294     @JsxFunction
1295     public Object createTreeWalker(final Node root, final double whatToShow, final Scriptable filter,
1296             boolean expandEntityReferences) throws DOMException {
1297 
1298         // seems that Rhino doesn't like long as parameter type
1299         final int whatToShowI = (int) Double.valueOf(whatToShow).longValue();
1300 
1301         if (getBrowserVersion().hasFeature(JS_TREEWALKER_EXPAND_ENTITY_REFERENCES_FALSE)) {
1302             expandEntityReferences = false;
1303         }
1304 
1305         final boolean filterFunctionOnly = getBrowserVersion().hasFeature(JS_TREEWALKER_FILTER_FUNCTION_ONLY);
1306         final org.w3c.dom.traversal.NodeFilter filterWrapper = createFilterWrapper(filter, filterFunctionOnly);
1307         final TreeWalker t = new TreeWalker(getPage(), root, whatToShowI, filterWrapper, expandEntityReferences);
1308         t.setParentScope(getWindow(this));
1309         t.setPrototype(staticGetPrototype(getWindow(this), TreeWalker.class));
1310         return t;
1311     }
1312 
1313     @SuppressWarnings("unchecked")
1314     private static Scriptable staticGetPrototype(final Window window,
1315             final Class<? extends SimpleScriptable> javaScriptClass) {
1316         final Scriptable prototype = window.getPrototype(javaScriptClass);
1317         if (prototype == null && javaScriptClass != SimpleScriptable.class) {
1318             return staticGetPrototype(window, (Class<? extends SimpleScriptable>) javaScriptClass.getSuperclass());
1319         }
1320         return prototype;
1321     }
1322 
1323     /**
1324      * Creates and returns a new range.
1325      * @return a new range
1326      * @see <a href="http://www.xulplanet.com/references/objref/HTMLDocument.html#method_createRange">XUL Planet</a>
1327      */
1328     @JsxFunction
1329     public Range createRange() {
1330         final Range r = new Range(this);
1331         r.setParentScope(getWindow());
1332         r.setPrototype(getPrototype(Range.class));
1333         return r;
1334     }
1335 
1336     /**
1337      * Returns the domain name of the server that served the document, or {@code null} if the server
1338      * cannot be identified by a domain name.
1339      * @return the domain name of the server that served the document
1340      * @see <a href="http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/level-one-html.html#ID-2250147">
1341      * W3C documentation</a>
1342      */
1343     @JsxGetter({CHROME, IE})
1344     public String getDomain() {
1345         if (domain_ == null && getPage().getWebResponse() != null) {
1346             URL url = getPage().getUrl();
1347             if (url == WebClient.URL_ABOUT_BLANK) {
1348                 final WebWindow w = getWindow().getWebWindow();
1349                 if (w instanceof FrameWindow) {
1350                     url = ((FrameWindow) w).getEnclosingPage().getUrl();
1351                 }
1352                 else {
1353                     return null;
1354                 }
1355             }
1356             domain_ = url.getHost().toLowerCase(Locale.ROOT);
1357         }
1358 
1359         return domain_;
1360     }
1361 
1362     /**
1363      * Sets the domain of this document.
1364      *
1365      * Domains can only be set to suffixes of the existing domain
1366      * with the exception of setting the domain to itself.
1367      * <p>
1368      * The domain will be set according to the following rules:
1369      * <ol>
1370      * <li>If the newDomain.equalsIgnoreCase(currentDomain) the method returns with no error.</li>
1371      * <li>If the browser version is netscape, the newDomain is downshifted.</li>
1372      * <li>The change will take place if and only if the suffixes of the
1373      *       current domain and the new domain match AND there are at least
1374      *       two domain qualifiers e.g. the following transformations are legal
1375      *       d1.d2.d3.gargoylesoftware.com may be transformed to itself or:
1376      *          d2.d3.gargoylesoftware.com
1377      *             d3.gargoylesoftware.com
1378      *                gargoylesoftware.com
1379      *
1380      *        transformation to:        com
1381      *        will fail
1382      * </li>
1383      * </ol>
1384      * <p>
1385      * TODO This code could be modified to understand country domain suffixes.
1386      * The domain www.bbc.co.uk should be trimmable only down to bbc.co.uk
1387      * trimming to co.uk should not be possible.
1388      * @param newDomain the new domain to set
1389      */
1390     @JsxSetter({CHROME, IE})
1391     public void setDomain(String newDomain) {
1392         final BrowserVersion browserVersion = getBrowserVersion();
1393 
1394         // IE (at least 6) doesn't allow to set domain of about:blank
1395         if (WebClient.URL_ABOUT_BLANK == getPage().getUrl()
1396             && browserVersion.hasFeature(JS_DOCUMENT_SETTING_DOMAIN_THROWS_FOR_ABOUT_BLANK)) {
1397             throw Context.reportRuntimeError("Illegal domain value, cannot set domain from \""
1398                     + WebClient.URL_ABOUT_BLANK + "\" to: \""
1399                     + newDomain + "\".");
1400         }
1401 
1402         newDomain = newDomain.toLowerCase(Locale.ROOT);
1403 
1404         final String currentDomain = getDomain();
1405         if (currentDomain.equalsIgnoreCase(newDomain)) {
1406             return;
1407         }
1408 
1409         if (newDomain.indexOf('.') == -1) {
1410             throw Context.reportRuntimeError("Illegal domain value, cannot set domain from: \""
1411                     + currentDomain + "\" to: \"" + newDomain + "\" (new domain has to contain a dot).");
1412         }
1413 
1414         if (currentDomain.indexOf('.') > -1
1415                 && !currentDomain.toLowerCase(Locale.ROOT).endsWith("." + newDomain.toLowerCase(Locale.ROOT))) {
1416             throw Context.reportRuntimeError("Illegal domain value, cannot set domain from: \""
1417                     + currentDomain + "\" to: \"" + newDomain + "\"");
1418         }
1419 
1420         domain_ = newDomain;
1421     }
1422 
1423     /**
1424      * Sets the {@code onclick} event handler for this element.
1425      * @param handler the {@code onclick} event handler for this element
1426      */
1427     @JsxSetter
1428     public void setOnclick(final Object handler) {
1429         setEventHandler(MouseEvent.TYPE_CLICK, handler);
1430     }
1431 
1432     /**
1433      * Returns the {@code onclick} event handler for this element.
1434      * @return the {@code onclick} event handler for this element
1435      */
1436     @JsxGetter
1437     public Object getOnclick() {
1438         return getEventHandler(MouseEvent.TYPE_CLICK);
1439     }
1440 
1441     /**
1442      * Sets the {@code ondblclick} event handler for this element.
1443      * @param handler the {@code ondblclick} event handler for this element
1444      */
1445     @JsxSetter
1446     public void setOndblclick(final Object handler) {
1447         setEventHandler(MouseEvent.TYPE_DBL_CLICK, handler);
1448     }
1449 
1450     /**
1451      * Returns the {@code ondblclick} event handler for this element.
1452      * @return the {@code ondblclick} event handler for this element
1453      */
1454     @JsxGetter
1455     public Object getOndblclick() {
1456         return getEventHandler(MouseEvent.TYPE_DBL_CLICK);
1457     }
1458 
1459     /**
1460      * Sets the {@code onblur} event handler for this element.
1461      * @param handler the {@code onblur} event handler for this element
1462      */
1463     @JsxSetter
1464     public void setOnblur(final Object handler) {
1465         setEventHandler(Event.TYPE_BLUR, handler);
1466     }
1467 
1468     /**
1469      * Returns the {@code onblur} event handler for this element.
1470      * @return the {@code onblur} event handler for this element
1471      */
1472     @JsxGetter
1473     public Object getOnblur() {
1474         return getEventHandler(Event.TYPE_BLUR);
1475     }
1476 
1477     /**
1478      * Sets the {@code onfocus} event handler for this element.
1479      * @param handler the {@code onfocus} event handler for this element
1480      */
1481     @JsxSetter
1482     public void setOnfocus(final Object handler) {
1483         setEventHandler(Event.TYPE_FOCUS, handler);
1484     }
1485 
1486     /**
1487      * Returns the {@code onfocus} event handler for this element.
1488      * @return the {@code onfocus} event handler for this element
1489      */
1490     @JsxGetter
1491     public Object getOnfocus() {
1492         return getEventHandler(Event.TYPE_FOCUS);
1493     }
1494 
1495     /**
1496      * Sets the {@code onfocusin} event handler for this element.
1497      * @param handler the {@code onfocusin} event handler for this element
1498      */
1499     @JsxSetter(IE)
1500     public void setOnfocusin(final Object handler) {
1501         setEventHandler(Event.TYPE_FOCUS_IN, handler);
1502     }
1503 
1504     /**
1505      * Returns the {@code onfocusin} event handler for this element.
1506      * @return the {@code onfocusin} event handler for this element
1507      */
1508     @JsxGetter(IE)
1509     public Object getOnfocusin() {
1510         return getEventHandler(Event.TYPE_FOCUS_IN);
1511     }
1512 
1513     /**
1514      * Sets the {@code onfocusout} event handler for this element.
1515      * @param handler the {@code onfocusout} event handler for this element
1516      */
1517     @JsxSetter(IE)
1518     public void setOnfocusout(final Object handler) {
1519         setEventHandler(Event.TYPE_FOCUS_OUT, handler);
1520     }
1521 
1522     /**
1523      * Returns the {@code onfocusout} event handler for this element.
1524      * @return the {@code onfocusout} event handler for this element
1525      */
1526     @JsxGetter(IE)
1527     public Object getOnfocusout() {
1528         return getEventHandler(Event.TYPE_FOCUS_OUT);
1529     }
1530 
1531     /**
1532      * Sets the {@code onkeydown} event handler for this element.
1533      * @param handler the {@code onkeydown} event handler for this element
1534      */
1535     @JsxSetter
1536     public void setOnkeydown(final Object handler) {
1537         setEventHandler(Event.TYPE_KEY_DOWN, handler);
1538     }
1539 
1540     /**
1541      * Returns the {@code onkeydown} event handler for this element.
1542      * @return the {@code onkeydown} event handler for this element
1543      */
1544     @JsxGetter
1545     public Object getOnkeydown() {
1546         return getEventHandler(Event.TYPE_KEY_DOWN);
1547     }
1548 
1549     /**
1550      * Sets the {@code onkeypress} event handler for this element.
1551      * @param handler the {@code onkeypress} event handler for this element
1552      */
1553     @JsxSetter
1554     public void setOnkeypress(final Object handler) {
1555         setEventHandler(Event.TYPE_KEY_PRESS, handler);
1556     }
1557 
1558     /**
1559      * Returns the {@code onkeypress} event handler for this element.
1560      * @return the {@code onkeypress} event handler for this element
1561      */
1562     @JsxGetter
1563     public Object getOnkeypress() {
1564         return getEventHandler(Event.TYPE_KEY_PRESS);
1565     }
1566 
1567     /**
1568      * Sets the {@code onkeyup} event handler for this element.
1569      * @param handler the {@code onkeyup} event handler for this element
1570      */
1571     @JsxSetter
1572     public void setOnkeyup(final Object handler) {
1573         setEventHandler(Event.TYPE_KEY_UP, handler);
1574     }
1575 
1576     /**
1577      * Returns the {@code onkeyup} event handler for this element.
1578      * @return the {@code onkeyup} event handler for this element
1579      */
1580     @JsxGetter
1581     public Object getOnkeyup() {
1582         return getEventHandler(Event.TYPE_KEY_UP);
1583     }
1584 
1585     /**
1586      * Sets the {@code onmousedown} event handler for this element.
1587      * @param handler the {@code onmousedown} event handler for this element
1588      */
1589     @JsxSetter
1590     public void setOnmousedown(final Object handler) {
1591         setEventHandler(MouseEvent.TYPE_MOUSE_DOWN, handler);
1592     }
1593 
1594     /**
1595      * Returns the {@code onmousedown} event handler for this element.
1596      * @return the {@code onmousedown} event handler for this element
1597      */
1598     @JsxGetter
1599     public Object getOnmousedown() {
1600         return getEventHandler(MouseEvent.TYPE_MOUSE_DOWN);
1601     }
1602 
1603     /**
1604      * Sets the {@code onmousemove} event handler for this element.
1605      * @param handler the {@code onmousemove} event handler for this element
1606      */
1607     @JsxSetter
1608     public void setOnmousemove(final Object handler) {
1609         setEventHandler(MouseEvent.TYPE_MOUSE_MOVE, handler);
1610     }
1611 
1612     /**
1613      * Returns the {@code onmousemove} event handler for this element.
1614      * @return the {@code onmousemove} event handler for this element
1615      */
1616     @JsxGetter
1617     public Object getOnmousemove() {
1618         return getEventHandler(MouseEvent.TYPE_MOUSE_MOVE);
1619     }
1620 
1621     /**
1622      * Sets the {@code onmouseout} event handler for this element.
1623      * @param handler the {@code onmouseout} event handler for this element
1624      */
1625     @JsxSetter
1626     public void setOnmouseout(final Object handler) {
1627         setEventHandler(MouseEvent.TYPE_MOUSE_OUT, handler);
1628     }
1629 
1630     /**
1631      * Returns the {@code onmouseout} event handler for this element.
1632      * @return the {@code onmouseout} event handler for this element
1633      */
1634     @JsxGetter
1635     public Object getOnmouseout() {
1636         return getEventHandler(MouseEvent.TYPE_MOUSE_OUT);
1637     }
1638 
1639     /**
1640      * Sets the {@code onmouseover} event handler for this element.
1641      * @param handler the {@code onmouseover} event handler for this element
1642      */
1643     @JsxSetter
1644     public void setOnmouseover(final Object handler) {
1645         setEventHandler(MouseEvent.TYPE_MOUSE_OVER, handler);
1646     }
1647 
1648     /**
1649      * Returns the {@code onmouseover} event handler for this element.
1650      * @return the {@code onmouseover} event handler for this element
1651      */
1652     @JsxGetter
1653     public Object getOnmouseover() {
1654         return getEventHandler(MouseEvent.TYPE_MOUSE_OVER);
1655     }
1656 
1657     /**
1658      * Sets the {@code onmouseup} event handler for this element.
1659      * @param handler the {@code onmouseup} event handler for this element
1660      */
1661     @JsxSetter
1662     public void setOnmouseup(final Object handler) {
1663         setEventHandler(MouseEvent.TYPE_MOUSE_UP, handler);
1664     }
1665 
1666     /**
1667      * Returns the {@code onmouseup} event handler for this element.
1668      * @return the {@code onmouseup} event handler for this element
1669      */
1670     @JsxGetter
1671     public Object getOnmouseup() {
1672         return getEventHandler(MouseEvent.TYPE_MOUSE_UP);
1673     }
1674 
1675     /**
1676      * Sets the {@code oncontextmenu} event handler for this element.
1677      * @param handler the {@code oncontextmenu} event handler for this element
1678      */
1679     @JsxSetter
1680     public void setOncontextmenu(final Object handler) {
1681         setEventHandler(MouseEvent.TYPE_CONTEXT_MENU, handler);
1682     }
1683 
1684     /**
1685      * Returns the {@code oncontextmenu} event handler for this element.
1686      * @return the {@code oncontextmenu} event handler for this element
1687      */
1688     @JsxGetter
1689     public Object getOncontextmenu() {
1690         return getEventHandler(MouseEvent.TYPE_CONTEXT_MENU);
1691     }
1692 
1693     /**
1694      * Sets the {@code onresize} event handler for this element.
1695      * @param handler the {@code onresize} event handler for this element
1696      */
1697     @JsxSetter({CHROME, FF})
1698     public void setOnresize(final Object handler) {
1699         setEventHandler("resize", handler);
1700     }
1701 
1702     /**
1703      * Returns the {@code onresize} event handler for this element.
1704      * @return the {@code onresize} event handler for this element
1705      */
1706     @JsxGetter({CHROME, FF})
1707     public Object getOnresize() {
1708         return getEventHandler("resize");
1709     }
1710 
1711     /**
1712      * Sets the {@code onerror} event handler for this element.
1713      * @param handler the {@code onerror} event handler for this element
1714      */
1715     @JsxSetter
1716     public void setOnerror(final Object handler) {
1717         setEventHandler(Event.TYPE_ERROR, handler);
1718     }
1719 
1720     /**
1721      * Returns the {@code onerror} event handler for this element.
1722      * @return the {@code onerror} event handler for this element
1723      */
1724     @JsxGetter
1725     public Object getOnerror() {
1726         return getEventHandler(Event.TYPE_ERROR);
1727     }
1728 
1729     /**
1730      * Returns the {@code oninput} event handler for this element.
1731      * @return the {@code oninput} event handler for this element
1732      */
1733     @JsxGetter
1734     public Function getOninput() {
1735         return getEventHandler(Event.TYPE_INPUT);
1736     }
1737 
1738     /**
1739      * Sets the {@code oninput} event handler for this element.
1740      * @param oninput the {@code oninput} event handler for this element
1741      */
1742     @JsxSetter
1743     public void setOninput(final Object oninput) {
1744         setEventHandler(Event.TYPE_INPUT, oninput);
1745     }
1746 
1747     /**
1748      * Returns the {@code hidden} property.
1749      * @return the {@code hidden} property
1750      */
1751     @JsxGetter
1752     public boolean getHidden() {
1753         return false;
1754     }
1755 
1756     /**
1757      * {@inheritDoc}
1758      */
1759     @Override
1760     @JsxGetter({CHROME, FF})
1761     public int getChildElementCount() {
1762         int counter = 0;
1763         if (getPage().getDocumentElement() != null) {
1764             counter++;
1765         }
1766         return counter;
1767     }
1768 
1769     /**
1770      * Returns the element for the specified x coordinate and the specified y coordinate.
1771      * The current implementation always returns the &lt;body&gt; element.
1772      *
1773      * @param x the x offset, in pixels
1774      * @param y the y offset, in pixels
1775      * @return the element for the specified x coordinate and the specified y coordinate
1776      */
1777     @JsxFunction
1778     public Object elementFromPoint(final int x, final int y) {
1779         return null;
1780     }
1781 
1782     /**
1783      * Returns the value of the {@code forms} property.
1784      * @return the value of the {@code forms} property
1785      */
1786     @JsxGetter({CHROME, IE})
1787     public Object getForms() {
1788         return new HTMLCollection(getDomNodeOrDie(), false) {
1789             @Override
1790             protected boolean isMatching(final DomNode node) {
1791                 return node instanceof HtmlForm && node.getPrefix() == null;
1792             }
1793 
1794             @Override
1795             public Object call(final Context cx, final Scriptable scope,
1796                     final Scriptable thisObj, final Object[] args) {
1797                 if (getBrowserVersion().hasFeature(JS_DOCUMENT_FORMS_FUNCTION_SUPPORTED)) {
1798                     return super.call(cx, scope, thisObj, args);
1799                 }
1800                 throw Context.reportRuntimeError("TypeError: document.forms is not a function");
1801             }
1802         };
1803     }
1804 
1805     /**
1806      * Returns the value of the {@code embeds} property.
1807      * @return the value of the {@code embeds} property
1808      */
1809     @JsxGetter({CHROME, IE})
1810     public Object getEmbeds() {
1811         return new HTMLCollection(getDomNodeOrDie(), false) {
1812             @Override
1813             protected boolean isMatching(final DomNode node) {
1814                 return node instanceof HtmlEmbed;
1815             }
1816 
1817             @Override
1818             public Object call(final Context cx, final Scriptable scope,
1819                     final Scriptable thisObj, final Object[] args) {
1820                 if (getBrowserVersion().hasFeature(JS_DOCUMENT_FORMS_FUNCTION_SUPPORTED)) {
1821                     return super.call(cx, scope, thisObj, args);
1822                 }
1823                 throw Context.reportRuntimeError("TypeError: document.embeds is not a function");
1824             }
1825         };
1826     }
1827 
1828     /**
1829      * Returns the value of the {@code embeds} property.
1830      * @return the value of the {@code embeds} property
1831      */
1832     @JsxGetter({CHROME, IE})
1833     public Object getImages() {
1834         return new HTMLCollection(getDomNodeOrDie(), false) {
1835             @Override
1836             protected boolean isMatching(final DomNode node) {
1837                 return node instanceof HtmlImage;
1838             }
1839 
1840             @Override
1841             public Object call(final Context cx, final Scriptable scope,
1842                     final Scriptable thisObj, final Object[] args) {
1843                 if (getBrowserVersion().hasFeature(JS_DOCUMENT_FORMS_FUNCTION_SUPPORTED)) {
1844                     return super.call(cx, scope, thisObj, args);
1845                 }
1846                 throw Context.reportRuntimeError("TypeError: document.images is not a function");
1847             }
1848         };
1849     }
1850 
1851     /**
1852      * Returns the value of the {@code scripts} property.
1853      * @return the value of the {@code scripts} property
1854      */
1855     @JsxGetter({CHROME, IE})
1856     public Object getScripts() {
1857         return new HTMLCollection(getDomNodeOrDie(), false) {
1858             @Override
1859             protected boolean isMatching(final DomNode node) {
1860                 return node instanceof HtmlScript;
1861             }
1862 
1863             @Override
1864             public Object call(final Context cx, final Scriptable scope,
1865                     final Scriptable thisObj, final Object[] args) {
1866                 if (getBrowserVersion().hasFeature(JS_DOCUMENT_FORMS_FUNCTION_SUPPORTED)) {
1867                     return super.call(cx, scope, thisObj, args);
1868                 }
1869                 throw Context.reportRuntimeError("TypeError: document.scripts is not a function");
1870             }
1871         };
1872     }
1873 
1874     /**
1875      * Retrieves a collection of stylesheet objects representing the style sheets that correspond
1876      * to each instance of a Link or
1877      * {@link com.gargoylesoftware.htmlunit.javascript.host.css.CSSStyleDeclaration} object in the document.
1878      *
1879      * @return styleSheet collection
1880      */
1881     @JsxGetter
1882     public StyleSheetList getStyleSheets() {
1883         return new StyleSheetList(this);
1884     }
1885 
1886     /**
1887      * Returns the value of the {@code plugins} property.
1888      * @return the value of the {@code plugins} property
1889      */
1890     @JsxGetter({CHROME, IE})
1891     public Object getPlugins() {
1892         return getEmbeds();
1893     }
1894 
1895     /**
1896      * Returns the value of the JavaScript property {@code links}. Refer also to the
1897      * <a href="http://msdn.microsoft.com/en-us/library/ms537465.aspx">MSDN documentation</a>.
1898      * @return the value of this property
1899      */
1900     @JsxGetter({CHROME, IE})
1901     public Object getLinks() {
1902         return new HTMLCollection(getDomNodeOrDie(), true) {
1903             @Override
1904             protected boolean isMatching(final DomNode node) {
1905                 return (node instanceof HtmlAnchor || node instanceof HtmlArea)
1906                         && ((HtmlElement) node).hasAttribute("href");
1907             }
1908 
1909             @Override
1910             protected EffectOnCache getEffectOnCache(final HtmlAttributeChangeEvent event) {
1911                 final HtmlElement node = event.getHtmlElement();
1912                 if ((node instanceof HtmlAnchor || node instanceof HtmlArea) && "href".equals(event.getName())) {
1913                     return EffectOnCache.RESET;
1914                 }
1915                 return EffectOnCache.NONE;
1916             }
1917         };
1918     }
1919 
1920     /**
1921      * Returns all the descendant elements with the specified class name.
1922      * @param className the name to search for
1923      * @return all the descendant elements with the specified class name
1924      * @see <a href="https://developer.mozilla.org/en/DOM/document.getElementsByClassName">Mozilla doc</a>
1925      */
1926     @JsxFunction
1927     public HTMLCollection getElementsByClassName(final String className) {
1928         return null;
1929     }
1930 
1931     /**
1932      * Returns all HTML elements that have a {@code name} attribute with the specified value.
1933      *
1934      * Refer to <a href="http://www.w3.org/TR/DOM-Level-2-HTML/html.html#ID-71555259">
1935      * The DOM spec</a> for details.
1936      *
1937      * @param elementName - value of the {@code name} attribute to look for
1938      * @return all HTML elements that have a {@code name} attribute with the specified value
1939      */
1940     @JsxFunction({CHROME, IE})
1941     public HTMLCollection getElementsByName(final String elementName) {
1942         return null;
1943     }
1944 
1945     /**
1946      * Returns {@code false} if the active element in the document has no focus;
1947      * {@code true} if the active element in the document has focus.
1948      * @return whether the active element in the document has focus or not
1949      */
1950     @JsxFunction
1951     public boolean hasFocus() {
1952         return false;
1953     }
1954 
1955     /**
1956      * Returns this document's title.
1957      * @return this document's title
1958      */
1959     @JsxGetter
1960     public String getTitle() {
1961         return "";
1962     }
1963 
1964     /**
1965      * Sets this document's title.
1966      * @param title the new title
1967      */
1968     @JsxSetter
1969     public void setTitle(final String title) {
1970     }
1971 
1972     /**
1973      * {@inheritDoc}
1974      */
1975     @Override
1976     @JsxGetter({CHROME, FF})
1977     public HTMLCollection getChildren() {
1978         return super.getChildren();
1979     }
1980 
1981     /**
1982      * Returns the {@code contentType} property.
1983      * @return the {@code contentType} property
1984      */
1985     @JsxGetter({CHROME, FF})
1986     public String getContentType() {
1987         return getPage().getContentType();
1988     }
1989 
1990     /**
1991      * Returns the current selection.
1992      * @return the current selection
1993      */
1994     @JsxFunction(CHROME)
1995     public Selection getSelection() {
1996         return null;
1997     }
1998 
1999     /**
2000      * Returns this document's {@code head} element.
2001      * @return this document's {@code head} element
2002      */
2003     @JsxGetter({CHROME, IE})
2004     public Object getHead() {
2005         return null;
2006     }
2007 
2008     /**
2009      * Returns a string representing the encoding under which the document was parsed.
2010      * @return a string representing the encoding under which the document was parsed
2011      */
2012     @JsxGetter
2013     public String getInputEncoding() {
2014         final Charset encoding = getPage().getCharset();
2015         if (getBrowserVersion().hasFeature(HTMLDOCUMENT_CHARSET_LOWERCASE)) {
2016             return encoding.name();
2017         }
2018         return EncodingSniffer.translateEncodingLabel(encoding);
2019     }
2020 
2021     /**
2022      * Returns the last modification date of the document.
2023      * @see <a href="https://developer.mozilla.org/en/DOM/document.lastModified">Mozilla documentation</a>
2024      * @return the date as string
2025      */
2026     @JsxGetter
2027     public String getLastModified() {
2028         if (lastModified_ == null) {
2029             final WebResponse webResponse = getPage().getWebResponse();
2030             final Date lastModified;
2031             if (webResponse != null) {
2032                 String stringDate = webResponse.getResponseHeaderValue("Last-Modified");
2033                 if (stringDate == null) {
2034                     stringDate = webResponse.getResponseHeaderValue("Date");
2035                 }
2036                 lastModified = parseDateOrNow(stringDate);
2037             }
2038             else {
2039                 lastModified = new Date();
2040             }
2041             lastModified_ = new SimpleDateFormat(LAST_MODIFIED_DATE_FORMAT, Locale.ROOT).format(lastModified);
2042         }
2043         return lastModified_;
2044     }
2045 
2046     private static Date parseDateOrNow(final String stringDate) {
2047         final Date date = parseHttpDate(stringDate);
2048         if (date == null) {
2049             return new Date();
2050         }
2051         return date;
2052     }
2053 
2054     /**
2055      * Mock for the moment.
2056      * @return true for success
2057      */
2058     @JsxFunction({FF, IE})
2059     public boolean releaseCapture() {
2060         return true;
2061     }
2062 
2063     /**
2064      * Returns the ready state of the document.
2065      * @return the ready state of the document
2066      *
2067      * @see DomNode#READY_STATE_UNINITIALIZED
2068      * @see DomNode#READY_STATE_LOADING
2069      * @see DomNode#READY_STATE_LOADED
2070      * @see DomNode#READY_STATE_INTERACTIVE
2071      * @see DomNode#READY_STATE_COMPLETE
2072      */
2073     @JsxGetter
2074     public String getReadyState() {
2075         return getDomNodeOrDie().getReadyState();
2076     }
2077 
2078     /**
2079      * Does nothing special anymore.
2080      *
2081      * @param type the type of events to capture
2082      * @see Window#captureEvents(String)
2083      */
2084     @JsxFunction(IE)
2085     public void captureEvents(final String type) {
2086         // Empty.
2087     }
2088 
2089     /**
2090      * Does nothing special anymore.
2091      *
2092      * @param type the type of events to capture
2093      * @see Window#releaseEvents(String)
2094      */
2095     @JsxFunction(IE)
2096     public void releaseEvents(final String type) {
2097         // Empty.
2098     }
2099 
2100     /**
2101      * Returns the value of the {@code alinkColor} property.
2102      * @return the value of the {@code alinkColor} property
2103      */
2104     @JsxGetter(IE)
2105     public String getAlinkColor() {
2106         return "#0000ff";
2107     }
2108 
2109     /**
2110      * Sets the value of the {@code alinkColor} property.
2111      * @param color the value of the {@code alinkColor} property
2112      */
2113     @JsxSetter(IE)
2114     public void setAlinkColor(final String color) {
2115     }
2116 
2117     /**
2118      * Returns the value of the {@code bgColor} property.
2119      * @return the value of the {@code bgColor} property
2120      * @see <a href="http://msdn.microsoft.com/en-us/library/ms533505.aspx">MSDN Documentation</a>
2121      */
2122     @JsxGetter(IE)
2123     public String getBgColor() {
2124         return "#ffffff";
2125     }
2126 
2127     /**
2128      * Sets the value of the {@code bgColor} property.
2129      * @param color the value of the {@code bgColor} property
2130      * @see <a href="http://msdn.microsoft.com/en-us/library/ms533505.aspx">MSDN Documentation</a>
2131      */
2132     @JsxSetter(IE)
2133     public void setBgColor(final String color) {
2134     }
2135 
2136     /**
2137      * Returns the value of the {@code fgColor} property.
2138      * @return the value of the {@code fgColor} property
2139      */
2140     @JsxGetter(IE)
2141     public String getFgColor() {
2142         return "#000000";
2143     }
2144 
2145     /**
2146      * Sets the value of the {@code fgColor} property.
2147      * @param color the value of the {@code fgColor} property
2148      */
2149     @JsxSetter(IE)
2150     public void setFgColor(final String color) {
2151     }
2152 
2153     /**
2154      * Returns the value of the {@code linkColor} property.
2155      * @return the value of the {@code linkColor} property
2156      */
2157     @JsxGetter(IE)
2158     public String getLinkColor() {
2159         return "#0000ff";
2160     }
2161 
2162     /**
2163      * Sets the value of the {@code linkColor} property.
2164      * @param color the value of the {@code linkColor} property
2165      */
2166     @JsxSetter(IE)
2167     public void setLinkColor(final String color) {
2168     }
2169 
2170     /**
2171      * Returns the value of the {@code vlinkColor} property.
2172      * @return the value of the {@code vlinkColor} property
2173      */
2174     @JsxGetter(IE)
2175     public String getVlinkColor() {
2176         return "#800080";
2177     }
2178 
2179     /**
2180      * Sets the value of the {@code vlinkColor} property.
2181      * @param color the value of the {@code vlinkColor} property
2182      */
2183     @JsxSetter(IE)
2184     public void setVlinkColor(final String color) {
2185     }
2186 
2187     /**
2188      * Returns the value of the {@code frames} property.
2189      * @see <a href="http://msdn.microsoft.com/en-us/library/ms537459.aspx">MSDN documentation</a>
2190      * @return the live collection of frames contained by this document
2191      */
2192     @JsxGetter(IE)
2193     public Object getFrames() {
2194         if (ScriptableObject.getTopLevelScope(this) == null) {
2195             throw ScriptRuntime.constructError("Error", "Not implemented");
2196         }
2197         return getWindow().getFrames_js();
2198     }
2199 
2200     /**
2201      * {@inheritDoc}
2202      */
2203     @Override
2204     @JsxGetter({CHROME, FF})
2205     public Element getLastElementChild() {
2206         return super.getLastElementChild();
2207     }
2208 
2209     /**
2210      * {@inheritDoc}
2211      */
2212     @Override
2213     @JsxGetter({CHROME, FF})
2214     public Element getFirstElementChild() {
2215         return super.getFirstElementChild();
2216     }
2217 
2218     /**
2219      * Returns the {@code xmlEncoding} property.
2220      * @return the {@code xmlEncoding} property
2221      */
2222     @JsxGetter({CHROME, IE})
2223     public String getXmlEncoding() {
2224         String encoding = getPage().getXmlEncoding();
2225         if (encoding == null && getBrowserVersion().hasFeature(HTMLDOCUMENT_CHARSET_LOWERCASE)) {
2226             encoding = "";
2227         }
2228         return encoding;
2229     }
2230 
2231     /**
2232      * Returns the {@code xmlStandalone} property.
2233      * @return the {@code xmlStandalone} property
2234      */
2235     @JsxGetter({CHROME, IE})
2236     public boolean isXmlStandalone() {
2237         return getPage().getXmlStandalone();
2238     }
2239 
2240     /**
2241      * Returns the {@code xmlVersion} property.
2242      * @return the {@code xmlVersion} property
2243      */
2244     @JsxGetter({CHROME, IE})
2245     public String getXmlVersion() {
2246         String version = getPage().getXmlVersion();
2247         if (version == null && getBrowserVersion().hasFeature(HTMLDOCUMENT_CHARSET_LOWERCASE)) {
2248             version = "";
2249         }
2250         return version;
2251     }
2252 
2253     /**
2254      * Returns the {@code onabort} event handler for this element.
2255      * @return the {@code onabort} event handler for this element
2256      */
2257     @JsxGetter
2258     public Function getOnabort() {
2259         return getEventHandler("abort");
2260     }
2261 
2262     /**
2263      * Sets the {@code onabort} event handler for this element.
2264      * @param onabort the {@code onabort} event handler for this element
2265      */
2266     @JsxSetter
2267     public void setOnabort(final Object onabort) {
2268         setEventHandler("abort", onabort);
2269     }
2270 
2271     /**
2272      * Returns the {@code onauxclick} event handler for this element.
2273      * @return the {@code onauxclick} event handler for this element
2274      */
2275     @JsxGetter(CHROME)
2276     public Function getOnauxclick() {
2277         return getEventHandler("auxclick");
2278     }
2279 
2280     /**
2281      * Sets the {@code onauxclick} event handler for this element.
2282      * @param onauxclick the {@code onauxclick} event handler for this element
2283      */
2284     @JsxSetter(CHROME)
2285     public void setOnauxclick(final Object onauxclick) {
2286         setEventHandler("auxclick", onauxclick);
2287     }
2288 
2289     /**
2290      * Returns the {@code onbeforecopy} event handler for this element.
2291      * @return the {@code onbeforecopy} event handler for this element
2292      */
2293     @JsxGetter(CHROME)
2294     public Function getOnbeforecopy() {
2295         return getEventHandler("beforecopy");
2296     }
2297 
2298     /**
2299      * Sets the {@code onbeforecopy} event handler for this element.
2300      * @param onbeforecopy the {@code onbeforecopy} event handler for this element
2301      */
2302     @JsxSetter(CHROME)
2303     public void setOnbeforecopy(final Object onbeforecopy) {
2304         setEventHandler("beforecopy", onbeforecopy);
2305     }
2306 
2307     /**
2308      * Returns the {@code onbeforecut} event handler for this element.
2309      * @return the {@code onbeforecut} event handler for this element
2310      */
2311     @JsxGetter(CHROME)
2312     public Function getOnbeforecut() {
2313         return getEventHandler("beforecut");
2314     }
2315 
2316     /**
2317      * Sets the {@code onbeforecut} event handler for this element.
2318      * @param onbeforecut the {@code onbeforecut} event handler for this element
2319      */
2320     @JsxSetter(CHROME)
2321     public void setOnbeforecut(final Object onbeforecut) {
2322         setEventHandler("beforecut", onbeforecut);
2323     }
2324 
2325     /**
2326      * Returns the {@code onbeforepaste} event handler for this element.
2327      * @return the {@code onbeforepaste} event handler for this element
2328      */
2329     @JsxGetter(CHROME)
2330     public Function getOnbeforepaste() {
2331         return getEventHandler("beforepaste");
2332     }
2333 
2334     /**
2335      * Sets the {@code onbeforepaste} event handler for this element.
2336      * @param onbeforepaste the {@code onbeforepaste} event handler for this element
2337      */
2338     @JsxSetter(CHROME)
2339     public void setOnbeforepaste(final Object onbeforepaste) {
2340         setEventHandler("beforepaste", onbeforepaste);
2341     }
2342 
2343     /**
2344      * Returns the {@code oncancel} event handler for this element.
2345      * @return the {@code oncancel} event handler for this element
2346      */
2347     @JsxGetter(CHROME)
2348     public Function getOncancel() {
2349         return getEventHandler("cancel");
2350     }
2351 
2352     /**
2353      * Sets the {@code oncancel} event handler for this element.
2354      * @param oncancel the {@code oncancel} event handler for this element
2355      */
2356     @JsxSetter(CHROME)
2357     public void setOncancel(final Object oncancel) {
2358         setEventHandler("cancel", oncancel);
2359     }
2360 
2361     /**
2362      * Returns the {@code oncanplay} event handler for this element.
2363      * @return the {@code oncanplay} event handler for this element
2364      */
2365     @JsxGetter
2366     public Function getOncanplay() {
2367         return getEventHandler("canplay");
2368     }
2369 
2370     /**
2371      * Sets the {@code oncanplay} event handler for this element.
2372      * @param oncanplay the {@code oncanplay} event handler for this element
2373      */
2374     @JsxSetter
2375     public void setOncanplay(final Object oncanplay) {
2376         setEventHandler("canplay", oncanplay);
2377     }
2378 
2379     /**
2380      * Returns the {@code oncanplaythrough} event handler for this element.
2381      * @return the {@code oncanplaythrough} event handler for this element
2382      */
2383     @JsxGetter
2384     public Function getOncanplaythrough() {
2385         return getEventHandler("canplaythrough");
2386     }
2387 
2388     /**
2389      * Sets the {@code oncanplaythrough} event handler for this element.
2390      * @param oncanplaythrough the {@code oncanplaythrough} event handler for this element
2391      */
2392     @JsxSetter
2393     public void setOncanplaythrough(final Object oncanplaythrough) {
2394         setEventHandler("canplaythrough", oncanplaythrough);
2395     }
2396 
2397     /**
2398      * Returns the {@code onchange} event handler for this element.
2399      * @return the {@code onchange} event handler for this element
2400      */
2401     @JsxGetter
2402     public Function getOnchange() {
2403         return getEventHandler(Event.TYPE_CHANGE);
2404     }
2405 
2406     /**
2407      * Sets the {@code onchange} event handler for this element.
2408      * @param onchange the {@code onchange} event handler for this element
2409      */
2410     @JsxSetter
2411     public void setOnchange(final Object onchange) {
2412         setEventHandler(Event.TYPE_CHANGE, onchange);
2413     }
2414 
2415     /**
2416      * Returns the {@code onclose} event handler for this element.
2417      * @return the {@code onclose} event handler for this element
2418      */
2419     @JsxGetter(CHROME)
2420     public Function getOnclose() {
2421         return getEventHandler(Event.TYPE_CLOSE);
2422     }
2423 
2424     /**
2425      * Sets the {@code onclose} event handler for this element.
2426      * @param onclose the {@code onclose} event handler for this element
2427      */
2428     @JsxSetter(CHROME)
2429     public void setOnclose(final Object onclose) {
2430         setEventHandler(Event.TYPE_CLOSE, onclose);
2431     }
2432 
2433     /**
2434      * Returns the {@code oncopy} event handler for this element.
2435      * @return the {@code oncopy} event handler for this element
2436      */
2437     @JsxGetter({CHROME, FF})
2438     public Function getOncopy() {
2439         return getEventHandler("copy");
2440     }
2441 
2442     /**
2443      * Sets the {@code oncopy} event handler for this element.
2444      * @param oncopy the {@code oncopy} event handler for this element
2445      */
2446     @JsxSetter({CHROME, FF})
2447     public void setOncopy(final Object oncopy) {
2448         setEventHandler("copy", oncopy);
2449     }
2450 
2451     /**
2452      * Returns the {@code oncuechange} event handler for this element.
2453      * @return the {@code oncuechange} event handler for this element
2454      */
2455     @JsxGetter(CHROME)
2456     public Function getOncuechange() {
2457         return getEventHandler("cuechange");
2458     }
2459 
2460     /**
2461      * Sets the {@code oncuechange} event handler for this element.
2462      * @param oncuechange the {@code oncuechange} event handler for this element
2463      */
2464     @JsxSetter(CHROME)
2465     public void setOncuechange(final Object oncuechange) {
2466         setEventHandler("cuechange", oncuechange);
2467     }
2468 
2469     /**
2470      * Returns the {@code oncut} event handler for this element.
2471      * @return the {@code oncut} event handler for this element
2472      */
2473     @JsxGetter({CHROME, FF})
2474     public Function getOncut() {
2475         return getEventHandler("cut");
2476     }
2477 
2478     /**
2479      * Sets the {@code oncut} event handler for this element.
2480      * @param oncut the {@code oncut} event handler for this element
2481      */
2482     @JsxSetter({CHROME, FF})
2483     public void setOncut(final Object oncut) {
2484         setEventHandler("cut", oncut);
2485     }
2486 
2487     /**
2488      * Returns the {@code ondrag} event handler for this element.
2489      * @return the {@code ondrag} event handler for this element
2490      */
2491     @JsxGetter
2492     public Function getOndrag() {
2493         return getEventHandler("drag");
2494     }
2495 
2496     /**
2497      * Sets the {@code ondrag} event handler for this element.
2498      * @param ondrag the {@code ondrag} event handler for this element
2499      */
2500     @JsxSetter
2501     public void setOndrag(final Object ondrag) {
2502         setEventHandler("drag", ondrag);
2503     }
2504 
2505     /**
2506      * Returns the {@code ondragend} event handler for this element.
2507      * @return the {@code ondragend} event handler for this element
2508      */
2509     @JsxGetter
2510     public Function getOndragend() {
2511         return getEventHandler("dragend");
2512     }
2513 
2514     /**
2515      * Sets the {@code ondragend} event handler for this element.
2516      * @param ondragend the {@code ondragend} event handler for this element
2517      */
2518     @JsxSetter
2519     public void setOndragend(final Object ondragend) {
2520         setEventHandler("dragend", ondragend);
2521     }
2522 
2523     /**
2524      * Returns the {@code ondragenter} event handler for this element.
2525      * @return the {@code ondragenter} event handler for this element
2526      */
2527     @JsxGetter
2528     public Function getOndragenter() {
2529         return getEventHandler("dragenter");
2530     }
2531 
2532     /**
2533      * Sets the {@code ondragenter} event handler for this element.
2534      * @param ondragenter the {@code ondragenter} event handler for this element
2535      */
2536     @JsxSetter
2537     public void setOndragenter(final Object ondragenter) {
2538         setEventHandler("dragenter", ondragenter);
2539     }
2540 
2541     /**
2542      * Returns the {@code ondragleave} event handler for this element.
2543      * @return the {@code ondragleave} event handler for this element
2544      */
2545     @JsxGetter
2546     public Function getOndragleave() {
2547         return getEventHandler("dragleave");
2548     }
2549 
2550     /**
2551      * Sets the {@code ondragleave} event handler for this element.
2552      * @param ondragleave the {@code ondragleave} event handler for this element
2553      */
2554     @JsxSetter
2555     public void setOndragleave(final Object ondragleave) {
2556         setEventHandler("dragleave", ondragleave);
2557     }
2558 
2559     /**
2560      * Returns the {@code ondragover} event handler for this element.
2561      * @return the {@code ondragover} event handler for this element
2562      */
2563     @JsxGetter
2564     public Function getOndragover() {
2565         return getEventHandler("dragover");
2566     }
2567 
2568     /**
2569      * Sets the {@code ondragover} event handler for this element.
2570      * @param ondragover the {@code ondragover} event handler for this element
2571      */
2572     @JsxSetter
2573     public void setOndragover(final Object ondragover) {
2574         setEventHandler("dragover", ondragover);
2575     }
2576 
2577     /**
2578      * Returns the {@code ondragstart} event handler for this element.
2579      * @return the {@code ondragstart} event handler for this element
2580      */
2581     @JsxGetter
2582     public Function getOndragstart() {
2583         return getEventHandler("dragstart");
2584     }
2585 
2586     /**
2587      * Sets the {@code ondragstart} event handler for this element.
2588      * @param ondragstart the {@code ondragstart} event handler for this element
2589      */
2590     @JsxSetter
2591     public void setOndragstart(final Object ondragstart) {
2592         setEventHandler("dragstart", ondragstart);
2593     }
2594 
2595     /**
2596      * Returns the {@code ondrop} event handler for this element.
2597      * @return the {@code ondrop} event handler for this element
2598      */
2599     @JsxGetter
2600     public Function getOndrop() {
2601         return getEventHandler("drop");
2602     }
2603 
2604     /**
2605      * Sets the {@code ondrop} event handler for this element.
2606      * @param ondrop the {@code ondrop} event handler for this element
2607      */
2608     @JsxSetter
2609     public void setOndrop(final Object ondrop) {
2610         setEventHandler("drop", ondrop);
2611     }
2612 
2613     /**
2614      * Returns the {@code ondurationchange} event handler for this element.
2615      * @return the {@code ondurationchange} event handler for this element
2616      */
2617     @JsxGetter
2618     public Function getOndurationchange() {
2619         return getEventHandler("durationchange");
2620     }
2621 
2622     /**
2623      * Sets the {@code ondurationchange} event handler for this element.
2624      * @param ondurationchange the {@code ondurationchange} event handler for this element
2625      */
2626     @JsxSetter
2627     public void setOndurationchange(final Object ondurationchange) {
2628         setEventHandler("durationchange", ondurationchange);
2629     }
2630 
2631     /**
2632      * Returns the {@code onemptied} event handler for this element.
2633      * @return the {@code onemptied} event handler for this element
2634      */
2635     @JsxGetter
2636     public Function getOnemptied() {
2637         return getEventHandler("emptied");
2638     }
2639 
2640     /**
2641      * Sets the {@code onemptied} event handler for this element.
2642      * @param onemptied the {@code onemptied} event handler for this element
2643      */
2644     @JsxSetter
2645     public void setOnemptied(final Object onemptied) {
2646         setEventHandler("emptied", onemptied);
2647     }
2648 
2649     /**
2650      * Returns the {@code onended} event handler for this element.
2651      * @return the {@code onended} event handler for this element
2652      */
2653     @JsxGetter
2654     public Function getOnended() {
2655         return getEventHandler("ended");
2656     }
2657 
2658     /**
2659      * Sets the {@code onended} event handler for this element.
2660      * @param onended the {@code onended} event handler for this element
2661      */
2662     @JsxSetter
2663     public void setOnended(final Object onended) {
2664         setEventHandler("ended", onended);
2665     }
2666 
2667     /**
2668      * Returns the {@code ongotpointercapture} event handler for this element.
2669      * @return the {@code ongotpointercapture} event handler for this element
2670      */
2671     @JsxGetter(CHROME)
2672     public Function getOngotpointercapture() {
2673         return getEventHandler("gotpointercapture");
2674     }
2675 
2676     /**
2677      * Sets the {@code ongotpointercapture} event handler for this element.
2678      * @param ongotpointercapture the {@code ongotpointercapture} event handler for this element
2679      */
2680     @JsxSetter(CHROME)
2681     public void setOngotpointercapture(final Object ongotpointercapture) {
2682         setEventHandler("gotpointercapture", ongotpointercapture);
2683     }
2684 
2685     /**
2686      * Returns the {@code oninvalid} event handler for this element.
2687      * @return the {@code oninvalid} event handler for this element
2688      */
2689     @JsxGetter({CHROME, FF})
2690     public Function getOninvalid() {
2691         return getEventHandler("invalid");
2692     }
2693 
2694     /**
2695      * Sets the {@code oninvalid} event handler for this element.
2696      * @param oninvalid the {@code oninvalid} event handler for this element
2697      */
2698     @JsxSetter({CHROME, FF})
2699     public void setOninvalid(final Object oninvalid) {
2700         setEventHandler("invalid", oninvalid);
2701     }
2702 
2703     /**
2704      * Returns the {@code onload} event handler for this element.
2705      * @return the {@code onload} event handler for this element
2706      */
2707     @JsxGetter
2708     public Function getOnload() {
2709         return getEventHandler(Event.TYPE_LOAD);
2710     }
2711 
2712     /**
2713      * Sets the {@code onload} event handler for this element.
2714      * @param onload the {@code onload} event handler for this element
2715      */
2716     @JsxSetter
2717     public void setOnload(final Object onload) {
2718         setEventHandler(Event.TYPE_LOAD, onload);
2719     }
2720 
2721     /**
2722      * Returns the {@code onloadeddata} event handler for this element.
2723      * @return the {@code onloadeddata} event handler for this element
2724      */
2725     @JsxGetter
2726     public Function getOnloadeddata() {
2727         return getEventHandler("loadeddata");
2728     }
2729 
2730     /**
2731      * Sets the {@code onloadeddata} event handler for this element.
2732      * @param onloadeddata the {@code onloadeddata} event handler for this element
2733      */
2734     @JsxSetter
2735     public void setOnloadeddata(final Object onloadeddata) {
2736         setEventHandler("loadeddata", onloadeddata);
2737     }
2738 
2739     /**
2740      * Returns the {@code onloadedmetadata} event handler for this element.
2741      * @return the {@code onloadedmetadata} event handler for this element
2742      */
2743     @JsxGetter
2744     public Function getOnloadedmetadata() {
2745         return getEventHandler("loadedmetadata");
2746     }
2747 
2748     /**
2749      * Sets the {@code onloadedmetadata} event handler for this element.
2750      * @param onloadedmetadata the {@code onloadedmetadata} event handler for this element
2751      */
2752     @JsxSetter
2753     public void setOnloadedmetadata(final Object onloadedmetadata) {
2754         setEventHandler("loadedmetadata", onloadedmetadata);
2755     }
2756 
2757     /**
2758      * Returns the {@code onloadstart} event handler for this element.
2759      * @return the {@code onloadstart} event handler for this element
2760      */
2761     @JsxGetter
2762     public Function getOnloadstart() {
2763         return getEventHandler("loadstart");
2764     }
2765 
2766     /**
2767      * Sets the {@code onloadstart} event handler for this element.
2768      * @param onloadstart the {@code onloadstart} event handler for this element
2769      */
2770     @JsxSetter
2771     public void setOnloadstart(final Object onloadstart) {
2772         setEventHandler("loadstart", onloadstart);
2773     }
2774 
2775     /**
2776      * Returns the {@code onlostpointercapture} event handler for this element.
2777      * @return the {@code onlostpointercapture} event handler for this element
2778      */
2779     @JsxGetter(CHROME)
2780     public Function getOnlostpointercapture() {
2781         return getEventHandler("lostpointercapture");
2782     }
2783 
2784     /**
2785      * Sets the {@code onlostpointercapture} event handler for this element.
2786      * @param onlostpointercapture the {@code onlostpointercapture} event handler for this element
2787      */
2788     @JsxSetter(CHROME)
2789     public void setOnlostpointercapture(final Object onlostpointercapture) {
2790         setEventHandler("lostpointercapture", onlostpointercapture);
2791     }
2792 
2793     /**
2794      * Returns the {@code onmouseenter} event handler for this element.
2795      * @return the {@code onmouseenter} event handler for this element
2796      */
2797     @JsxGetter({CHROME, FF})
2798     public Function getOnmouseenter() {
2799         return getEventHandler("mouseenter");
2800     }
2801 
2802     /**
2803      * Sets the {@code onmouseenter} event handler for this element.
2804      * @param onmouseenter the {@code onmouseenter} event handler for this element
2805      */
2806     @JsxSetter({CHROME, FF})
2807     public void setOnmouseenter(final Object onmouseenter) {
2808         setEventHandler("mouseenter", onmouseenter);
2809     }
2810 
2811     /**
2812      * Returns the {@code onmouseleave} event handler for this element.
2813      * @return the {@code onmouseleave} event handler for this element
2814      */
2815     @JsxGetter({CHROME, FF})
2816     public Function getOnmouseleave() {
2817         return getEventHandler("mouseleave");
2818     }
2819 
2820     /**
2821      * Sets the {@code onmouseleave} event handler for this element.
2822      * @param onmouseleave the {@code onmouseleave} event handler for this element
2823      */
2824     @JsxSetter({CHROME, FF})
2825     public void setOnmouseleave(final Object onmouseleave) {
2826         setEventHandler("mouseleave", onmouseleave);
2827     }
2828 
2829     /**
2830      * Returns the {@code onmousewheel} event handler for this element.
2831      * @return the {@code onmousewheel} event handler for this element
2832      */
2833     @JsxGetter({CHROME, IE})
2834     public Function getOnmousewheel() {
2835         return getEventHandler("mousewheel");
2836     }
2837 
2838     /**
2839      * Sets the {@code onmousewheel} event handler for this element.
2840      * @param onmousewheel the {@code onmousewheel} event handler for this element
2841      */
2842     @JsxSetter({CHROME, IE})
2843     public void setOnmousewheel(final Object onmousewheel) {
2844         setEventHandler("mousewheel", onmousewheel);
2845     }
2846 
2847     /**
2848      * Returns the {@code onpaste} event handler for this element.
2849      * @return the {@code onpaste} event handler for this element
2850      */
2851     @JsxGetter({CHROME, FF})
2852     public Function getOnpaste() {
2853         return getEventHandler("paste");
2854     }
2855 
2856     /**
2857      * Sets the {@code onpaste} event handler for this element.
2858      * @param onpaste the {@code onpaste} event handler for this element
2859      */
2860     @JsxSetter({CHROME, FF})
2861     public void setOnpaste(final Object onpaste) {
2862         setEventHandler("paste", onpaste);
2863     }
2864 
2865     /**
2866      * Returns the {@code onpause} event handler for this element.
2867      * @return the {@code onpause} event handler for this element
2868      */
2869     @JsxGetter
2870     public Function getOnpause() {
2871         return getEventHandler("pause");
2872     }
2873 
2874     /**
2875      * Sets the {@code onpause} event handler for this element.
2876      * @param onpause the {@code onpause} event handler for this element
2877      */
2878     @JsxSetter
2879     public void setOnpause(final Object onpause) {
2880         setEventHandler("pause", onpause);
2881     }
2882 
2883     /**
2884      * Returns the {@code onplay} event handler for this element.
2885      * @return the {@code onplay} event handler for this element
2886      */
2887     @JsxGetter
2888     public Function getOnplay() {
2889         return getEventHandler("play");
2890     }
2891 
2892     /**
2893      * Sets the {@code onplay} event handler for this element.
2894      * @param onplay the {@code onplay} event handler for this element
2895      */
2896     @JsxSetter
2897     public void setOnplay(final Object onplay) {
2898         setEventHandler("play", onplay);
2899     }
2900 
2901     /**
2902      * Returns the {@code onplaying} event handler for this element.
2903      * @return the {@code onplaying} event handler for this element
2904      */
2905     @JsxGetter
2906     public Function getOnplaying() {
2907         return getEventHandler("playing");
2908     }
2909 
2910     /**
2911      * Sets the {@code onplaying} event handler for this element.
2912      * @param onplaying the {@code onplaying} event handler for this element
2913      */
2914     @JsxSetter
2915     public void setOnplaying(final Object onplaying) {
2916         setEventHandler("playing", onplaying);
2917     }
2918 
2919     /**
2920      * Returns the {@code onpointercancel} event handler for this element.
2921      * @return the {@code onpointercancel} event handler for this element
2922      */
2923     @JsxGetter({CHROME, IE})
2924     public Function getOnpointercancel() {
2925         return getEventHandler("pointercancel");
2926     }
2927 
2928     /**
2929      * Sets the {@code onpointercancel} event handler for this element.
2930      * @param onpointercancel the {@code onpointercancel} event handler for this element
2931      */
2932     @JsxSetter({CHROME, IE})
2933     public void setOnpointercancel(final Object onpointercancel) {
2934         setEventHandler("pointercancel", onpointercancel);
2935     }
2936 
2937     /**
2938      * Returns the {@code onpointerdown} event handler for this element.
2939      * @return the {@code onpointerdown} event handler for this element
2940      */
2941     @JsxGetter({CHROME, IE})
2942     public Function getOnpointerdown() {
2943         return getEventHandler("pointerdown");
2944     }
2945 
2946     /**
2947      * Sets the {@code onpointerdown} event handler for this element.
2948      * @param onpointerdown the {@code onpointerdown} event handler for this element
2949      */
2950     @JsxSetter({CHROME, IE})
2951     public void setOnpointerdown(final Object onpointerdown) {
2952         setEventHandler("pointerdown", onpointerdown);
2953     }
2954 
2955     /**
2956      * Returns the {@code onpointerenter} event handler for this element.
2957      * @return the {@code onpointerenter} event handler for this element
2958      */
2959     @JsxGetter({CHROME, IE})
2960     public Function getOnpointerenter() {
2961         return getEventHandler("pointerenter");
2962     }
2963 
2964     /**
2965      * Sets the {@code onpointerenter} event handler for this element.
2966      * @param onpointerenter the {@code onpointerenter} event handler for this element
2967      */
2968     @JsxSetter({CHROME, IE})
2969     public void setOnpointerenter(final Object onpointerenter) {
2970         setEventHandler("pointerenter", onpointerenter);
2971     }
2972 
2973     /**
2974      * Returns the {@code onpointerleave} event handler for this element.
2975      * @return the {@code onpointerleave} event handler for this element
2976      */
2977     @JsxGetter({CHROME, IE})
2978     public Function getOnpointerleave() {
2979         return getEventHandler("pointerleave");
2980     }
2981 
2982     /**
2983      * Sets the {@code onpointerleave} event handler for this element.
2984      * @param onpointerleave the {@code onpointerleave} event handler for this element
2985      */
2986     @JsxSetter({CHROME, IE})
2987     public void setOnpointerleave(final Object onpointerleave) {
2988         setEventHandler("pointerleave", onpointerleave);
2989     }
2990 
2991     /**
2992      * Returns the {@code onpointerlockchange} event handler for this element.
2993      * @return the {@code onpointerlockchange} event handler for this element
2994      */
2995     @JsxGetter({CHROME, FF52})
2996     public Function getOnpointerlockchange() {
2997         return getEventHandler("pointerlockchange");
2998     }
2999 
3000     /**
3001      * Sets the {@code onpointerlockchange} event handler for this element.
3002      * @param onpointerlockchange the {@code onpointerlockchange} event handler for this element
3003      */
3004     @JsxSetter({CHROME, FF52})
3005     public void setOnpointerlockchange(final Object onpointerlockchange) {
3006         setEventHandler("pointerlockchange", onpointerlockchange);
3007     }
3008 
3009     /**
3010      * Returns the {@code onpointerlockerror} event handler for this element.
3011      * @return the {@code onpointerlockerror} event handler for this element
3012      */
3013     @JsxGetter({CHROME, FF52})
3014     public Function getOnpointerlockerror() {
3015         return getEventHandler("pointerlockerror");
3016     }
3017 
3018     /**
3019      * Sets the {@code onpointerlockerror} event handler for this element.
3020      * @param onpointerlockerror the {@code onpointerlockerror} event handler for this element
3021      */
3022     @JsxSetter({CHROME, FF52})
3023     public void setOnpointerlockerror(final Object onpointerlockerror) {
3024         setEventHandler("pointerlockerror", onpointerlockerror);
3025     }
3026 
3027     /**
3028      * Returns the {@code onpointermove} event handler for this element.
3029      * @return the {@code onpointermove} event handler for this element
3030      */
3031     @JsxGetter({CHROME, IE})
3032     public Function getOnpointermove() {
3033         return getEventHandler("pointermove");
3034     }
3035 
3036     /**
3037      * Sets the {@code onpointermove} event handler for this element.
3038      * @param onpointermove the {@code onpointermove} event handler for this element
3039      */
3040     @JsxSetter({CHROME, IE})
3041     public void setOnpointermove(final Object onpointermove) {
3042         setEventHandler("pointermove", onpointermove);
3043     }
3044 
3045     /**
3046      * Returns the {@code onpointerout} event handler for this element.
3047      * @return the {@code onpointerout} event handler for this element
3048      */
3049     @JsxGetter({CHROME, IE})
3050     public Function getOnpointerout() {
3051         return getEventHandler("pointerout");
3052     }
3053 
3054     /**
3055      * Sets the {@code onpointerout} event handler for this element.
3056      * @param onpointerout the {@code onpointerout} event handler for this element
3057      */
3058     @JsxSetter({CHROME, IE})
3059     public void setOnpointerout(final Object onpointerout) {
3060         setEventHandler("pointerout", onpointerout);
3061     }
3062 
3063     /**
3064      * Returns the {@code onpointerover} event handler for this element.
3065      * @return the {@code onpointerover} event handler for this element
3066      */
3067     @JsxGetter({CHROME, IE})
3068     public Function getOnpointerover() {
3069         return getEventHandler("pointerover");
3070     }
3071 
3072     /**
3073      * Sets the {@code onpointerover} event handler for this element.
3074      * @param onpointerover the {@code onpointerover} event handler for this element
3075      */
3076     @JsxSetter({CHROME, IE})
3077     public void setOnpointerover(final Object onpointerover) {
3078         setEventHandler("pointerover", onpointerover);
3079     }
3080 
3081     /**
3082      * Returns the {@code onpointerup} event handler for this element.
3083      * @return the {@code onpointerup} event handler for this element
3084      */
3085     @JsxGetter({CHROME, IE})
3086     public Function getOnpointerup() {
3087         return getEventHandler("pointerup");
3088     }
3089 
3090     /**
3091      * Sets the {@code onpointerup} event handler for this element.
3092      * @param onpointerup the {@code onpointerup} event handler for this element
3093      */
3094     @JsxSetter({CHROME, IE})
3095     public void setOnpointerup(final Object onpointerup) {
3096         setEventHandler("pointerup", onpointerup);
3097     }
3098 
3099     /**
3100      * Returns the {@code onprogress} event handler for this element.
3101      * @return the {@code onprogress} event handler for this element
3102      */
3103     @JsxGetter
3104     public Function getOnprogress() {
3105         return getEventHandler("progress");
3106     }
3107 
3108     /**
3109      * Sets the {@code onprogress} event handler for this element.
3110      * @param onprogress the {@code onprogress} event handler for this element
3111      */
3112     @JsxSetter
3113     public void setOnprogress(final Object onprogress) {
3114         setEventHandler("progress", onprogress);
3115     }
3116 
3117     /**
3118      * Returns the {@code onratechange} event handler for this element.
3119      * @return the {@code onratechange} event handler for this element
3120      */
3121     @JsxGetter
3122     public Function getOnratechange() {
3123         return getEventHandler("ratechange");
3124     }
3125 
3126     /**
3127      * Sets the {@code onratechange} event handler for this element.
3128      * @param onratechange the {@code onratechange} event handler for this element
3129      */
3130     @JsxSetter
3131     public void setOnratechange(final Object onratechange) {
3132         setEventHandler("ratechange", onratechange);
3133     }
3134 
3135     /**
3136      * Returns the {@code onreadystatechange} event handler for this element.
3137      * @return the {@code onreadystatechange} event handler for this element
3138      */
3139     @JsxGetter
3140     public Function getOnreadystatechange() {
3141         return getEventHandler(Event.TYPE_READY_STATE_CHANGE);
3142     }
3143 
3144     /**
3145      * Sets the {@code onreadystatechange} event handler for this element.
3146      * @param onreadystatechange the {@code onreadystatechange} event handler for this element
3147      */
3148     @JsxSetter
3149     public void setOnreadystatechange(final Object onreadystatechange) {
3150         setEventHandler(Event.TYPE_READY_STATE_CHANGE, onreadystatechange);
3151     }
3152 
3153     /**
3154      * Returns the {@code onreset} event handler for this element.
3155      * @return the {@code onreset} event handler for this element
3156      */
3157     @JsxGetter
3158     public Function getOnreset() {
3159         return getEventHandler(Event.TYPE_RESET);
3160     }
3161 
3162     /**
3163      * Sets the {@code onreset} event handler for this element.
3164      * @param onreset the {@code onreset} event handler for this element
3165      */
3166     @JsxSetter
3167     public void setOnreset(final Object onreset) {
3168         setEventHandler(Event.TYPE_RESET, onreset);
3169     }
3170 
3171     /**
3172      * Returns the {@code onscroll} event handler for this element.
3173      * @return the {@code onscroll} event handler for this element
3174      */
3175     @JsxGetter
3176     public Function getOnscroll() {
3177         return getEventHandler("scroll");
3178     }
3179 
3180     /**
3181      * Sets the {@code onscroll} event handler for this element.
3182      * @param onscroll the {@code onscroll} event handler for this element
3183      */
3184     @JsxSetter
3185     public void setOnscroll(final Object onscroll) {
3186         setEventHandler("scroll", onscroll);
3187     }
3188 
3189     /**
3190      * Returns the {@code onsearch} event handler for this element.
3191      * @return the {@code onsearch} event handler for this element
3192      */
3193     @JsxGetter(CHROME)
3194     public Function getOnsearch() {
3195         return getEventHandler("search");
3196     }
3197 
3198     /**
3199      * Sets the {@code onsearch} event handler for this element.
3200      * @param onsearch the {@code onsearch} event handler for this element
3201      */
3202     @JsxSetter(CHROME)
3203     public void setOnsearch(final Object onsearch) {
3204         setEventHandler("search", onsearch);
3205     }
3206 
3207     /**
3208      * Returns the {@code onseeked} event handler for this element.
3209      * @return the {@code onseeked} event handler for this element
3210      */
3211     @JsxGetter
3212     public Function getOnseeked() {
3213         return getEventHandler("seeked");
3214     }
3215 
3216     /**
3217      * Sets the {@code onseeked} event handler for this element.
3218      * @param onseeked the {@code onseeked} event handler for this element
3219      */
3220     @JsxSetter
3221     public void setOnseeked(final Object onseeked) {
3222         setEventHandler("seeked", onseeked);
3223     }
3224 
3225     /**
3226      * Returns the {@code onseeking} event handler for this element.
3227      * @return the {@code onseeking} event handler for this element
3228      */
3229     @JsxGetter
3230     public Function getOnseeking() {
3231         return getEventHandler("seeking");
3232     }
3233 
3234     /**
3235      * Sets the {@code onseeking} event handler for this element.
3236      * @param onseeking the {@code onseeking} event handler for this element
3237      */
3238     @JsxSetter
3239     public void setOnseeking(final Object onseeking) {
3240         setEventHandler("seeking", onseeking);
3241     }
3242 
3243     /**
3244      * Returns the {@code onselect} event handler for this element.
3245      * @return the {@code onselect} event handler for this element
3246      */
3247     @JsxGetter
3248     public Function getOnselect() {
3249         return getEventHandler("select");
3250     }
3251 
3252     /**
3253      * Sets the {@code onselect} event handler for this element.
3254      * @param onselect the {@code onselect} event handler for this element
3255      */
3256     @JsxSetter
3257     public void setOnselect(final Object onselect) {
3258         setEventHandler("select", onselect);
3259     }
3260 
3261     /**
3262      * Returns the {@code onselectionchange} event handler for this element.
3263      * @return the {@code onselectionchange} event handler for this element
3264      */
3265     @JsxGetter({CHROME, IE, FF52})
3266     public Function getOnselectionchange() {
3267         return getEventHandler("selectionchange");
3268     }
3269 
3270     /**
3271      * Sets the {@code onselectionchange} event handler for this element.
3272      * @param onselectionchange the {@code onselectionchange} event handler for this element
3273      */
3274     @JsxSetter({CHROME, IE, FF52})
3275     public void setOnselectionchange(final Object onselectionchange) {
3276         setEventHandler("selectionchange", onselectionchange);
3277     }
3278 
3279     /**
3280      * Returns the {@code onselectstart} event handler for this element.
3281      * @return the {@code onselectstart} event handler for this element
3282      */
3283     @JsxGetter({CHROME, IE, FF52})
3284     public Function getOnselectstart() {
3285         return getEventHandler("selectstart");
3286     }
3287 
3288     /**
3289      * Sets the {@code onselectstart} event handler for this element.
3290      * @param onselectstart the {@code onselectstart} event handler for this element
3291      */
3292     @JsxSetter({CHROME, IE, FF52})
3293     public void setOnselectstart(final Object onselectstart) {
3294         setEventHandler("selectstart", onselectstart);
3295     }
3296 
3297     /**
3298      * Returns the {@code onshow} event handler for this element.
3299      * @return the {@code onshow} event handler for this element
3300      */
3301     @JsxGetter({CHROME, FF})
3302     public Function getOnshow() {
3303         return getEventHandler("show");
3304     }
3305 
3306     /**
3307      * Sets the {@code onshow} event handler for this element.
3308      * @param onshow the {@code onshow} event handler for this element
3309      */
3310     @JsxSetter({CHROME, FF})
3311     public void setOnshow(final Object onshow) {
3312         setEventHandler("show", onshow);
3313     }
3314 
3315     /**
3316      * Returns the {@code onstalled} event handler for this element.
3317      * @return the {@code onstalled} event handler for this element
3318      */
3319     @JsxGetter
3320     public Function getOnstalled() {
3321         return getEventHandler("stalled");
3322     }
3323 
3324     /**
3325      * Sets the {@code onstalled} event handler for this element.
3326      * @param onstalled the {@code onstalled} event handler for this element
3327      */
3328     @JsxSetter
3329     public void setOnstalled(final Object onstalled) {
3330         setEventHandler("stalled", onstalled);
3331     }
3332 
3333     /**
3334      * Returns the {@code onsubmit} event handler for this element.
3335      * @return the {@code onsubmit} event handler for this element
3336      */
3337     @JsxGetter
3338     public Function getOnsubmit() {
3339         return getEventHandler(Event.TYPE_SUBMIT);
3340     }
3341 
3342     /**
3343      * Sets the {@code onsubmit} event handler for this element.
3344      * @param onsubmit the {@code onsubmit} event handler for this element
3345      */
3346     @JsxSetter
3347     public void setOnsubmit(final Object onsubmit) {
3348         setEventHandler(Event.TYPE_SUBMIT, onsubmit);
3349     }
3350 
3351     /**
3352      * Returns the {@code onsuspend} event handler for this element.
3353      * @return the {@code onsuspend} event handler for this element
3354      */
3355     @JsxGetter
3356     public Function getOnsuspend() {
3357         return getEventHandler("suspend");
3358     }
3359 
3360     /**
3361      * Sets the {@code onsuspend} event handler for this element.
3362      * @param onsuspend the {@code onsuspend} event handler for this element
3363      */
3364     @JsxSetter
3365     public void setOnsuspend(final Object onsuspend) {
3366         setEventHandler("suspend", onsuspend);
3367     }
3368 
3369     /**
3370      * Returns the {@code ontimeupdate} event handler for this element.
3371      * @return the {@code ontimeupdate} event handler for this element
3372      */
3373     @JsxGetter
3374     public Function getOntimeupdate() {
3375         return getEventHandler("timeupdate");
3376     }
3377 
3378     /**
3379      * Sets the {@code ontimeupdate} event handler for this element.
3380      * @param ontimeupdate the {@code ontimeupdate} event handler for this element
3381      */
3382     @JsxSetter
3383     public void setOntimeupdate(final Object ontimeupdate) {
3384         setEventHandler("timeupdate", ontimeupdate);
3385     }
3386 
3387     /**
3388      * Returns the {@code ontoggle} event handler for this element.
3389      * @return the {@code ontoggle} event handler for this element
3390      */
3391     @JsxGetter({CHROME, FF52})
3392     public Function getOntoggle() {
3393         return getEventHandler("toggle");
3394     }
3395 
3396     /**
3397      * Sets the {@code ontoggle} event handler for this element.
3398      * @param ontoggle the {@code ontoggle} event handler for this element
3399      */
3400     @JsxSetter({CHROME, FF52})
3401     public void setOntoggle(final Object ontoggle) {
3402         setEventHandler("toggle", ontoggle);
3403     }
3404 
3405     /**
3406      * Returns the {@code onvolumechange} event handler for this element.
3407      * @return the {@code onvolumechange} event handler for this element
3408      */
3409     @JsxGetter
3410     public Function getOnvolumechange() {
3411         return getEventHandler("volumechange");
3412     }
3413 
3414     /**
3415      * Sets the {@code onvolumechange} event handler for this element.
3416      * @param onvolumechange the {@code onvolumechange} event handler for this element
3417      */
3418     @JsxSetter
3419     public void setOnvolumechange(final Object onvolumechange) {
3420         setEventHandler("volumechange", onvolumechange);
3421     }
3422 
3423     /**
3424      * Returns the {@code onwaiting} event handler for this element.
3425      * @return the {@code onwaiting} event handler for this element
3426      */
3427     @JsxGetter
3428     public Function getOnwaiting() {
3429         return getEventHandler("waiting");
3430     }
3431 
3432     /**
3433      * Sets the {@code onwaiting} event handler for this element.
3434      * @param onwaiting the {@code onwaiting} event handler for this element
3435      */
3436     @JsxSetter
3437     public void setOnwaiting(final Object onwaiting) {
3438         setEventHandler("waiting", onwaiting);
3439     }
3440 
3441     /**
3442      * Returns the {@code onwebkitfullscreenchange} event handler for this element.
3443      * @return the {@code onwebkitfullscreenchange} event handler for this element
3444      */
3445     @JsxGetter(CHROME)
3446     public Function getOnwebkitfullscreenchange() {
3447         return getEventHandler("webkitfullscreenchange");
3448     }
3449 
3450     /**
3451      * Sets the {@code onwebkitfullscreenchange} event handler for this element.
3452      * @param onwebkitfullscreenchange the {@code onwebkitfullscreenchange} event handler for this element
3453      */
3454     @JsxSetter(CHROME)
3455     public void setOnwebkitfullscreenchange(final Object onwebkitfullscreenchange) {
3456         setEventHandler("webkitfullscreenchange", onwebkitfullscreenchange);
3457     }
3458 
3459     /**
3460      * Returns the {@code onwebkitfullscreenerror} event handler for this element.
3461      * @return the {@code onwebkitfullscreenerror} event handler for this element
3462      */
3463     @JsxGetter(CHROME)
3464     public Function getOnwebkitfullscreenerror() {
3465         return getEventHandler("webkitfullscreenerror");
3466     }
3467 
3468     /**
3469      * Sets the {@code onwebkitfullscreenerror} event handler for this element.
3470      * @param onwebkitfullscreenerror the {@code onwebkitfullscreenerror} event handler for this element
3471      */
3472     @JsxSetter
3473     public void setOnwebkitfullscreenerror(final Object onwebkitfullscreenerror) {
3474         setEventHandler("webkitfullscreenerror", onwebkitfullscreenerror);
3475     }
3476 
3477     /**
3478      * Returns the {@code onwheel} event handler for this element.
3479      * @return the {@code onwheel} event handler for this element
3480      */
3481     @JsxGetter({CHROME, FF})
3482     public Function getOnwheel() {
3483         return getEventHandler("wheel");
3484     }
3485 
3486     /**
3487      * Sets the {@code onwheel} event handler for this element.
3488      * @param onwheel the {@code onwheel} event handler for this element
3489      */
3490     @JsxSetter({CHROME, FF})
3491     public void setOnwheel(final Object onwheel) {
3492         setEventHandler("wheel", onwheel);
3493     }
3494 
3495     /**
3496      * Returns the {@code onafterscriptexecute} event handler for this element.
3497      * @return the {@code onafterscriptexecute} event handler for this element
3498      */
3499     @JsxGetter(FF)
3500     public Function getOnafterscriptexecute() {
3501         return getEventHandler("afterscriptexecute");
3502     }
3503 
3504     /**
3505      * Sets the {@code onafterscriptexecute} event handler for this element.
3506      * @param onafterscriptexecute the {@code onafterscriptexecute} event handler for this element
3507      */
3508     @JsxSetter(FF)
3509     public void setOnafterscriptexecute(final Object onafterscriptexecute) {
3510         setEventHandler("afterscriptexecute", onafterscriptexecute);
3511     }
3512 
3513     /**
3514      * Returns the {@code onbeforescriptexecute} event handler for this element.
3515      * @return the {@code onbeforescriptexecute} event handler for this element
3516      */
3517     @JsxGetter(FF)
3518     public Function getOnbeforescriptexecute() {
3519         return getEventHandler("beforescriptexecute");
3520     }
3521 
3522     /**
3523      * Sets the {@code onbeforescriptexecute} event handler for this element.
3524      * @param onbeforescriptexecute the {@code onbeforescriptexecute} event handler for this element
3525      */
3526     @JsxSetter(FF)
3527     public void setOnbeforescriptexecute(final Object onbeforescriptexecute) {
3528         setEventHandler("beforescriptexecute", onbeforescriptexecute);
3529     }
3530 
3531     /**
3532      * Returns the {@code onmozfullscreenchange} event handler for this element.
3533      * @return the {@code onmozfullscreenchange} event handler for this element
3534      */
3535     @JsxGetter(FF)
3536     public Function getOnmozfullscreenchange() {
3537         return getEventHandler("mozfullscreenchange");
3538     }
3539 
3540     /**
3541      * Sets the {@code onmozfullscreenchange} event handler for this element.
3542      * @param onmozfullscreenchange the {@code onmozfullscreenchange} event handler for this element
3543      */
3544     @JsxSetter(FF)
3545     public void setOnmozfullscreenchange(final Object onmozfullscreenchange) {
3546         setEventHandler("mozfullscreenchange", onmozfullscreenchange);
3547     }
3548 
3549     /**
3550      * Returns the {@code onmozfullscreenerror} event handler for this element.
3551      * @return the {@code onmozfullscreenerror} event handler for this element
3552      */
3553     @JsxGetter(FF)
3554     public Function getOnmozfullscreenerror() {
3555         return getEventHandler("mozfullscreenerror");
3556     }
3557 
3558     /**
3559      * Sets the {@code onmozfullscreenerror} event handler for this element.
3560      * @param onmozfullscreenerror the {@code onmozfullscreenerror} event handler for this element
3561      */
3562     @JsxSetter(FF)
3563     public void setOnmozfullscreenerror(final Object onmozfullscreenerror) {
3564         setEventHandler("mozfullscreenerror", onmozfullscreenerror);
3565     }
3566 
3567     /**
3568      * Returns the {@code onmozpointerlockchange} event handler for this element.
3569      * @return the {@code onmozpointerlockchange} event handler for this element
3570      */
3571     @JsxGetter(FF45)
3572     public Function getOnmozpointerlockchange() {
3573         return getEventHandler("mozpointerlockchange");
3574     }
3575 
3576     /**
3577      * Sets the {@code onmozpointerlockchange} event handler for this element.
3578      * @param onmozpointerlockchange the {@code onmozpointerlockchange} event handler for this element
3579      */
3580     @JsxSetter(FF45)
3581     public void setOnmozpointerlockchange(final Object onmozpointerlockchange) {
3582         setEventHandler("mozpointerlockchange", onmozpointerlockchange);
3583     }
3584 
3585     /**
3586      * Returns the {@code onmozpointerlockerror} event handler for this element.
3587      * @return the {@code onmozpointerlockerror} event handler for this element
3588      */
3589     @JsxGetter(FF45)
3590     public Function getOnmozpointerlockerror() {
3591         return getEventHandler("mozpointerlockerror");
3592     }
3593 
3594     /**
3595      * Sets the {@code onmozpointerlockerror} event handler for this element.
3596      * @param onmozpointerlockerror the {@code onmozpointerlockerror} event handler for this element
3597      */
3598     @JsxSetter(FF45)
3599     public void setOnmozpointerlockerror(final Object onmozpointerlockerror) {
3600         setEventHandler("mozpointerlockerror", onmozpointerlockerror);
3601     }
3602 
3603     /**
3604      * Returns the {@code onhelp} event handler for this element.
3605      * @return the {@code onhelp} event handler for this element
3606      */
3607     @JsxGetter(IE)
3608     public Function getOnhelp() {
3609         return getEventHandler("help");
3610     }
3611 
3612     /**
3613      * Sets the {@code onhelp} event handler for this element.
3614      * @param onhelp the {@code onhelp} event handler for this element
3615      */
3616     @JsxSetter(IE)
3617     public void setOnhelp(final Object onhelp) {
3618         setEventHandler("help", onhelp);
3619     }
3620 
3621     /**
3622      * Returns the {@code onmscontentzoom} event handler for this element.
3623      * @return the {@code onmscontentzoom} event handler for this element
3624      */
3625     @JsxGetter(IE)
3626     public Function getOnmscontentzoom() {
3627         return getEventHandler("mscontentzoom");
3628     }
3629 
3630     /**
3631      * Sets the {@code onmscontentzoom} event handler for this element.
3632      * @param onmscontentzoom the {@code onmscontentzoom} event handler for this element
3633      */
3634     @JsxSetter(IE)
3635     public void setOnmscontentzoom(final Object onmscontentzoom) {
3636         setEventHandler("mscontentzoom", onmscontentzoom);
3637     }
3638 
3639     /**
3640      * Returns the {@code onmsfullscreenchange} event handler for this element.
3641      * @return the {@code onmsfullscreenchange} event handler for this element
3642      */
3643     @JsxGetter(IE)
3644     public Function getOnmsfullscreenchange() {
3645         return getEventHandler("msfullscreenchange");
3646     }
3647 
3648     /**
3649      * Sets the {@code onmsfullscreenchange} event handler for this element.
3650      * @param onmsfullscreenchange the {@code onmsfullscreenchange} event handler for this element
3651      */
3652     @JsxSetter(IE)
3653     public void setOnmsfullscreenchange(final Object onmsfullscreenchange) {
3654         setEventHandler("msfullscreenchange", onmsfullscreenchange);
3655     }
3656 
3657     /**
3658      * Returns the {@code onmsfullscreenerror} event handler for this element.
3659      * @return the {@code onmsfullscreenerror} event handler for this element
3660      */
3661     @JsxGetter(IE)
3662     public Function getOnmsfullscreenerror() {
3663         return getEventHandler("msfullscreenerror");
3664     }
3665 
3666     /**
3667      * Sets the {@code onmsfullscreenerror} event handler for this element.
3668      * @param onmsfullscreenerror the {@code onmsfullscreenerror} event handler for this element
3669      */
3670     @JsxSetter(IE)
3671     public void setOnmsfullscreenerror(final Object onmsfullscreenerror) {
3672         setEventHandler("msfullscreenerror", onmsfullscreenerror);
3673     }
3674 
3675     /**
3676      * Returns the {@code onmsgesturechange} event handler for this element.
3677      * @return the {@code onmsgesturechange} event handler for this element
3678      */
3679     @JsxGetter(IE)
3680     public Function getOnmsgesturechange() {
3681         return getEventHandler("msgesturechange");
3682     }
3683 
3684     /**
3685      * Sets the {@code onmsgesturechange} event handler for this element.
3686      * @param onmsgesturechange the {@code onmsgesturechange} event handler for this element
3687      */
3688     @JsxSetter(IE)
3689     public void setOnmsgesturechange(final Object onmsgesturechange) {
3690         setEventHandler("msgesturechange", onmsgesturechange);
3691     }
3692 
3693     /**
3694      * Returns the {@code onmsgesturedoubletap} event handler for this element.
3695      * @return the {@code onmsgesturedoubletap} event handler for this element
3696      */
3697     @JsxGetter(IE)
3698     public Function getOnmsgesturedoubletap() {
3699         return getEventHandler("msgesturedoubletap");
3700     }
3701 
3702     /**
3703      * Sets the {@code onmsgesturedoubletap} event handler for this element.
3704      * @param onmsgesturedoubletap the {@code onmsgesturedoubletap} event handler for this element
3705      */
3706     @JsxSetter(IE)
3707     public void setOnmsgesturedoubletap(final Object onmsgesturedoubletap) {
3708         setEventHandler("msgesturedoubletap", onmsgesturedoubletap);
3709     }
3710 
3711     /**
3712      * Returns the {@code onmsgestureend} event handler for this element.
3713      * @return the {@code onmsgestureend} event handler for this element
3714      */
3715     @JsxGetter(IE)
3716     public Function getOnmsgestureend() {
3717         return getEventHandler("msgestureend");
3718     }
3719 
3720     /**
3721      * Sets the {@code onmsgestureend} event handler for this element.
3722      * @param onmsgestureend the {@code onmsgestureend} event handler for this element
3723      */
3724     @JsxSetter(IE)
3725     public void setOnmsgestureend(final Object onmsgestureend) {
3726         setEventHandler("msgestureend", onmsgestureend);
3727     }
3728 
3729     /**
3730      * Returns the {@code onmsgesturehold} event handler for this element.
3731      * @return the {@code onmsgesturehold} event handler for this element
3732      */
3733     @JsxGetter(IE)
3734     public Function getOnmsgesturehold() {
3735         return getEventHandler("msgesturehold");
3736     }
3737 
3738     /**
3739      * Sets the {@code onmsgesturehold} event handler for this element.
3740      * @param onmsgesturehold the {@code onmsgesturehold} event handler for this element
3741      */
3742     @JsxSetter(IE)
3743     public void setOnmsgesturehold(final Object onmsgesturehold) {
3744         setEventHandler("msgesturehold", onmsgesturehold);
3745     }
3746 
3747     /**
3748      * Returns the {@code onmsgesturestart} event handler for this element.
3749      * @return the {@code onmsgesturestart} event handler for this element
3750      */
3751     @JsxGetter(IE)
3752     public Function getOnmsgesturestart() {
3753         return getEventHandler("msgesturestart");
3754     }
3755 
3756     /**
3757      * Sets the {@code onmsgesturestart} event handler for this element.
3758      * @param onmsgesturestart the {@code onmsgesturestart} event handler for this element
3759      */
3760     @JsxSetter(IE)
3761     public void setOnmsgesturestart(final Object onmsgesturestart) {
3762         setEventHandler("msgesturestart", onmsgesturestart);
3763     }
3764 
3765     /**
3766      * Returns the {@code onmsgesturetap} event handler for this element.
3767      * @return the {@code onmsgesturetap} event handler for this element
3768      */
3769     @JsxGetter(IE)
3770     public Function getOnmsgesturetap() {
3771         return getEventHandler("msgesturetap");
3772     }
3773 
3774     /**
3775      * Sets the {@code onmsgesturetap} event handler for this element.
3776      * @param onmsgesturetap the {@code onmsgesturetap} event handler for this element
3777      */
3778     @JsxSetter(IE)
3779     public void setOnmsgesturetap(final Object onmsgesturetap) {
3780         setEventHandler("msgesturetap", onmsgesturetap);
3781     }
3782 
3783     /**
3784      * Returns the {@code onmsinertiastart} event handler for this element.
3785      * @return the {@code onmsinertiastart} event handler for this element
3786      */
3787     @JsxGetter(IE)
3788     public Function getOnmsinertiastart() {
3789         return getEventHandler("msinertiastart");
3790     }
3791 
3792     /**
3793      * Sets the {@code onmsinertiastart} event handler for this element.
3794      * @param onmsinertiastart the {@code onmsinertiastart} event handler for this element
3795      */
3796     @JsxSetter(IE)
3797     public void setOnmsinertiastart(final Object onmsinertiastart) {
3798         setEventHandler("msinertiastart", onmsinertiastart);
3799     }
3800 
3801     /**
3802      * Returns the {@code onmsmanipulationstatechanged} event handler for this element.
3803      * @return the {@code onmsmanipulationstatechanged} event handler for this element
3804      */
3805     @JsxGetter(IE)
3806     public Function getOnmsmanipulationstatechanged() {
3807         return getEventHandler("msmanipulationstatechanged");
3808     }
3809 
3810     /**
3811      * Sets the {@code onmsmanipulationstatechanged} event handler for this element.
3812      * @param onmsmanipulationstatechanged the {@code onmsmanipulationstatechanged} event handler for this element
3813      */
3814     @JsxSetter(IE)
3815     public void setOnmsmanipulationstatechanged(final Object onmsmanipulationstatechanged) {
3816         setEventHandler("msmanipulationstatechanged", onmsmanipulationstatechanged);
3817     }
3818 
3819     /**
3820      * Returns the {@code onmspointercancel} event handler for this element.
3821      * @return the {@code onmspointercancel} event handler for this element
3822      */
3823     @JsxGetter(IE)
3824     public Function getOnmspointercancel() {
3825         return getEventHandler("mspointercancel");
3826     }
3827 
3828     /**
3829      * Sets the {@code onmspointercancel} event handler for this element.
3830      * @param onmspointercancel the {@code onmspointercancel} event handler for this element
3831      */
3832     @JsxSetter(IE)
3833     public void setOnmspointercancel(final Object onmspointercancel) {
3834         setEventHandler("mspointercancel", onmspointercancel);
3835     }
3836 
3837     /**
3838      * Returns the {@code onmspointerdown} event handler for this element.
3839      * @return the {@code onmspointerdown} event handler for this element
3840      */
3841     @JsxGetter(IE)
3842     public Function getOnmspointerdown() {
3843         return getEventHandler("mspointerdown");
3844     }
3845 
3846     /**
3847      * Sets the {@code onmspointerdown} event handler for this element.
3848      * @param onmspointerdown the {@code onmspointerdown} event handler for this element
3849      */
3850     @JsxSetter(IE)
3851     public void setOnmspointerdown(final Object onmspointerdown) {
3852         setEventHandler("mspointerdown", onmspointerdown);
3853     }
3854 
3855     /**
3856      * Returns the {@code onmspointerenter} event handler for this element.
3857      * @return the {@code onmspointerenter} event handler for this element
3858      */
3859     @JsxGetter(IE)
3860     public Function getOnmspointerenter() {
3861         return getEventHandler("mspointerenter");
3862     }
3863 
3864     /**
3865      * Sets the {@code onmspointerenter} event handler for this element.
3866      * @param onmspointerenter the {@code onmspointerenter} event handler for this element
3867      */
3868     @JsxSetter(IE)
3869     public void setOnmspointerenter(final Object onmspointerenter) {
3870         setEventHandler("mspointerenter", onmspointerenter);
3871     }
3872 
3873     /**
3874      * Returns the {@code onmspointerleave} event handler for this element.
3875      * @return the {@code onmspointerleave} event handler for this element
3876      */
3877     @JsxGetter(IE)
3878     public Function getOnmspointerleave() {
3879         return getEventHandler("mspointerleave");
3880     }
3881 
3882     /**
3883      * Sets the {@code onmspointerleave} event handler for this element.
3884      * @param onmspointerleave the {@code onmspointerleave} event handler for this element
3885      */
3886     @JsxSetter(IE)
3887     public void setOnmspointerleave(final Object onmspointerleave) {
3888         setEventHandler("mspointerleave", onmspointerleave);
3889     }
3890 
3891     /**
3892      * Returns the {@code onmspointermove} event handler for this element.
3893      * @return the {@code onmspointermove} event handler for this element
3894      */
3895     @JsxGetter(IE)
3896     public Function getOnmspointermove() {
3897         return getEventHandler("mspointermove");
3898     }
3899 
3900     /**
3901      * Sets the {@code onmspointermove} event handler for this element.
3902      * @param onmspointermove the {@code onmspointermove} event handler for this element
3903      */
3904     @JsxSetter(IE)
3905     public void setOnmspointermove(final Object onmspointermove) {
3906         setEventHandler("mspointermove", onmspointermove);
3907     }
3908 
3909     /**
3910      * Returns the {@code onmspointerout} event handler for this element.
3911      * @return the {@code onmspointerout} event handler for this element
3912      */
3913     @JsxGetter(IE)
3914     public Function getOnmspointerout() {
3915         return getEventHandler("mspointerout");
3916     }
3917 
3918     /**
3919      * Sets the {@code onmspointerout} event handler for this element.
3920      * @param onmspointerout the {@code onmspointerout} event handler for this element
3921      */
3922     @JsxSetter(IE)
3923     public void setOnmspointerout(final Object onmspointerout) {
3924         setEventHandler("mspointerout", onmspointerout);
3925     }
3926 
3927     /**
3928      * Returns the {@code onmspointerover} event handler for this element.
3929      * @return the {@code onmspointerover} event handler for this element
3930      */
3931     @JsxGetter(IE)
3932     public Function getOnmspointerover() {
3933         return getEventHandler("mspointerover");
3934     }
3935 
3936     /**
3937      * Sets the {@code onmspointerover} event handler for this element.
3938      * @param onmspointerover the {@code onmspointerover} event handler for this element
3939      */
3940     @JsxSetter(IE)
3941     public void setOnmspointerover(final Object onmspointerover) {
3942         setEventHandler("mspointerover", onmspointerover);
3943     }
3944 
3945     /**
3946      * Returns the {@code onmspointerup} event handler for this element.
3947      * @return the {@code onmspointerup} event handler for this element
3948      */
3949     @JsxGetter(IE)
3950     public Function getOnmspointerup() {
3951         return getEventHandler("mspointerup");
3952     }
3953 
3954     /**
3955      * Sets the {@code onmspointerup} event handler for this element.
3956      * @param onmspointerup the {@code onmspointerup} event handler for this element
3957      */
3958     @JsxSetter(IE)
3959     public void setOnmspointerup(final Object onmspointerup) {
3960         setEventHandler("mspointerup", onmspointerup);
3961     }
3962 
3963     /**
3964      * Returns the {@code onmssitemodejumplistitemremoved} event handler for this element.
3965      * @return the {@code onmssitemodejumplistitemremoved} event handler for this element
3966      */
3967     @JsxGetter(IE)
3968     public Function getOnmssitemodejumplistitemremoved() {
3969         return getEventHandler("mssitemodejumplistitemremoved");
3970     }
3971 
3972     /**
3973      * Sets the {@code onmssitemodejumplistitemremoved} event handler for this element.
3974      * @param onmssitemodejumplistitemremoved the {@code onmssitemodejumplistitemremoved} event handler for this element
3975      */
3976     @JsxSetter(IE)
3977     public void setOnmssitemodejumplistitemremoved(final Object onmssitemodejumplistitemremoved) {
3978         setEventHandler("mssitemodejumplistitemremoved", onmssitemodejumplistitemremoved);
3979     }
3980 
3981     /**
3982      * Returns the {@code onmsthumbnailclick} event handler for this element.
3983      * @return the {@code onmsthumbnailclick} event handler for this element
3984      */
3985     @JsxGetter(IE)
3986     public Function getOnmsthumbnailclick() {
3987         return getEventHandler("msthumbnailclick");
3988     }
3989 
3990     /**
3991      * Sets the {@code onmsthumbnailclick} event handler for this element.
3992      * @param onmsthumbnailclick the {@code onmsthumbnailclick} event handler for this element
3993      */
3994     @JsxSetter(IE)
3995     public void setOnmsthumbnailclick(final Object onmsthumbnailclick) {
3996         setEventHandler("msthumbnailclick", onmsthumbnailclick);
3997     }
3998 
3999     /**
4000      * Returns the {@code onstop} event handler for this element.
4001      * @return the {@code onstop} event handler for this element
4002      */
4003     @JsxGetter(IE)
4004     public Function getOnstop() {
4005         return getEventHandler("stop");
4006     }
4007 
4008     /**
4009      * Sets the {@code onstop} event handler for this element.
4010      * @param onstop the {@code onstop} event handler for this element
4011      */
4012     @JsxSetter(IE)
4013     public void setOnstop(final Object onstop) {
4014         setEventHandler("stop", onstop);
4015     }
4016 
4017     /**
4018      * Returns the {@code onstoragecommit} event handler for this element.
4019      * @return the {@code onstoragecommit} event handler for this element
4020      */
4021     @JsxGetter(IE)
4022     public Function getOnstoragecommit() {
4023         return getEventHandler("storagecommit");
4024     }
4025 
4026     /**
4027      * Sets the {@code onstoragecommit} event handler for this element.
4028      * @param onstoragecommit the {@code onstoragecommit} event handler for this element
4029      */
4030     @JsxSetter(IE)
4031     public void setOnstoragecommit(final Object onstoragecommit) {
4032         setEventHandler("storagecommit", onstoragecommit);
4033     }
4034 
4035     /**
4036      * Returns the {@code onactivate} event handler for this element.
4037      * @return the {@code onactivate} event handler for this element
4038      */
4039     @JsxGetter(IE)
4040     public Function getOnactivate() {
4041         return getEventHandler("activate");
4042     }
4043 
4044     /**
4045      * Sets the {@code onactivate} event handler for this element.
4046      * @param onactivate the {@code onactivate} event handler for this element
4047      */
4048     @JsxSetter(IE)
4049     public void setOnactivate(final Object onactivate) {
4050         setEventHandler("activate", onactivate);
4051     }
4052 
4053     /**
4054      * Returns the {@code onbeforeactivate} event handler for this element.
4055      * @return the {@code onbeforeactivate} event handler for this element
4056      */
4057     @JsxGetter(IE)
4058     public Function getOnbeforeactivate() {
4059         return getEventHandler("beforeactivate");
4060     }
4061 
4062     /**
4063      * Sets the {@code onbeforeactivate} event handler for this element.
4064      * @param onbeforeactivate the {@code onbeforeactivate} event handler for this element
4065      */
4066     @JsxSetter(IE)
4067     public void setOnbeforeactivate(final Object onbeforeactivate) {
4068         setEventHandler("beforeactivate", onbeforeactivate);
4069     }
4070 
4071     /**
4072      * Returns the {@code onbeforedeactivate} event handler for this element.
4073      * @return the {@code onbeforedeactivate} event handler for this element
4074      */
4075     @JsxGetter(IE)
4076     public Function getOnbeforedeactivate() {
4077         return getEventHandler("beforedeactivate");
4078     }
4079 
4080     /**
4081      * Sets the {@code onbeforedeactivate} event handler for this element.
4082      * @param onbeforedeactivate the {@code onbeforedeactivate} event handler for this element
4083      */
4084     @JsxSetter(IE)
4085     public void setOnbeforedeactivate(final Object onbeforedeactivate) {
4086         setEventHandler("beforedeactivate", onbeforedeactivate);
4087     }
4088 
4089     /**
4090      * Returns the {@code ondeactivate} event handler for this element.
4091      * @return the {@code ondeactivate} event handler for this element
4092      */
4093     @JsxGetter(IE)
4094     public Function getOndeactivate() {
4095         return getEventHandler("deactivate");
4096     }
4097 
4098     /**
4099      * Sets the {@code ondeactivate} event handler for this element.
4100      * @param ondeactivate the {@code ondeactivate} event handler for this element
4101      */
4102     @JsxSetter(IE)
4103     public void setOndeactivate(final Object ondeactivate) {
4104         setEventHandler("deactivate", ondeactivate);
4105     }
4106 
4107     /**
4108      * Returns the {@code onanimationend} event handler.
4109      * @return the {@code onanimationend} event handler
4110      */
4111     @JsxGetter(FF52)
4112     public Function getOnanimationend() {
4113         return getEventHandler("animationend");
4114     }
4115 
4116     /**
4117      * Sets the {@code onanimationend} event handler.
4118      * @param animationend the {@code onanimationend} event handler
4119      */
4120     @JsxSetter(FF52)
4121     public void setOnanimationend(final Object animationend) {
4122         setEventHandler("animationend", animationend);
4123     }
4124 
4125     /**
4126      * Returns the {@code onanimationiteration} event handler.
4127      * @return the {@code onanimationiteration} event handler
4128      */
4129     @JsxGetter(FF52)
4130     public Function getOnanimationiteration() {
4131         return getEventHandler("animationiteration");
4132     }
4133 
4134     /**
4135      * Sets the {@code onanimationiteration} event handler.
4136      * @param animationiteration the {@code onanimationiteration} event handler
4137      */
4138     @JsxSetter(FF52)
4139     public void setOnanimationiteration(final Object animationiteration) {
4140         setEventHandler("animationiteration", animationiteration);
4141     }
4142 
4143     /**
4144      * Returns the {@code onanimationstart} event handler.
4145      * @return the {@code onanimationstart} event handler
4146      */
4147     @JsxGetter(FF52)
4148     public Function getOnanimationstart() {
4149         return getEventHandler("animationstart");
4150     }
4151 
4152     /**
4153      * Sets the {@code onanimationstart} event handler.
4154      * @param animationstart the {@code onanimationstart} event handler
4155      */
4156     @JsxSetter(FF52)
4157     public void setOnanimationstart(final Object animationstart) {
4158         setEventHandler("animationstart", animationstart);
4159     }
4160 
4161     /**
4162      * Returns the {@code ondragexit} event handler.
4163      * @return the {@code ondragexit} event handler
4164      */
4165     @JsxGetter(FF52)
4166     public Function getOndragexit() {
4167         return getEventHandler("dragexit");
4168     }
4169 
4170     /**
4171      * Sets the {@code ondragexit} event handler.
4172      * @param dragexit the {@code ondragexit} event handler
4173      */
4174     @JsxSetter(FF52)
4175     public void setOndragexit(final Object dragexit) {
4176         setEventHandler("dragexit", dragexit);
4177     }
4178 
4179     /**
4180      * Returns the {@code onloadend} event handler.
4181      * @return the {@code onloadend} event handler
4182      */
4183     @JsxGetter(FF52)
4184     public Function getOnloadend() {
4185         return getEventHandler("loadend");
4186     }
4187 
4188     /**
4189      * Sets the {@code onloadend} event handler.
4190      * @param loadend the {@code onloadend} event handler
4191      */
4192     @JsxSetter(FF52)
4193     public void setOnloadend(final Object loadend) {
4194         setEventHandler("loadend", loadend);
4195     }
4196 
4197     /**
4198      * Returns the {@code ontransitionend} event handler.
4199      * @return the {@code ontransitionend} event handler
4200      */
4201     @JsxGetter(FF52)
4202     public Function getOntransitionend() {
4203         return getEventHandler("transitionend");
4204     }
4205 
4206     /**
4207      * Sets the {@code ontransitionend} event handler.
4208      * @param transitionend the {@code ontransitionend} event handler
4209      */
4210     @JsxSetter(FF52)
4211     public void setOntransitionend(final Object transitionend) {
4212         setEventHandler("transitionend", transitionend);
4213     }
4214 
4215     /**
4216      * Returns the {@code onwebkitanimationend} event handler.
4217      * @return the {@code onwebkitanimationend} event handler
4218      */
4219     @JsxGetter(FF52)
4220     public Function getOnwebkitanimationend() {
4221         return getEventHandler("webkitanimationend");
4222     }
4223 
4224     /**
4225      * Sets the {@code onwebkitanimationend} event handler.
4226      * @param webkitanimationend the {@code onwebkitanimationend} event handler
4227      */
4228     @JsxSetter(FF52)
4229     public void setOnwebkitanimationend(final Object webkitanimationend) {
4230         setEventHandler("webkitanimationend", webkitanimationend);
4231     }
4232 
4233     /**
4234      * Returns the {@code onwebkitanimationiteration} event handler.
4235      * @return the {@code onwebkitanimationiteration} event handler
4236      */
4237     @JsxGetter(FF52)
4238     public Function getOnwebkitanimationiteration() {
4239         return getEventHandler("webkitanimationiteration");
4240     }
4241 
4242     /**
4243      * Sets the {@code onwebkitanimationiteration} event handler.
4244      * @param webkitanimationiteration the {@code onwebkitanimationiteration} event handler
4245      */
4246     @JsxSetter(FF52)
4247     public void setOnwebkitanimationiteration(final Object webkitanimationiteration) {
4248         setEventHandler("webkitanimationiteration", webkitanimationiteration);
4249     }
4250 
4251     /**
4252      * Returns the {@code onwebkitanimationstart} event handler.
4253      * @return the {@code onwebkitanimationstart} event handler
4254      */
4255     @JsxGetter(FF52)
4256     public Function getOnwebkitanimationstart() {
4257         return getEventHandler("webkitanimationstart");
4258     }
4259 
4260     /**
4261      * Sets the {@code onwebkitanimationstart} event handler.
4262      * @param webkitanimationstart the {@code onwebkitanimationstart} event handler
4263      */
4264     @JsxSetter(FF52)
4265     public void setOnwebkitanimationstart(final Object webkitanimationstart) {
4266         setEventHandler("webkitanimationstart", webkitanimationstart);
4267     }
4268 
4269     /**
4270      * Returns the {@code onwebkittransitionend} event handler.
4271      * @return the {@code onwebkittransitionend} event handler
4272      */
4273     @JsxGetter(FF52)
4274     public Function getOnwebkittransitionend() {
4275         return getEventHandler("webkittransitionend");
4276     }
4277 
4278     /**
4279      * Sets the {@code onwebkittransitionend} event handler.
4280      * @param webkittransitionend the {@code onwebkittransitionend} event handler
4281      */
4282     @JsxSetter(FF52)
4283     public void setOnwebkittransitionend(final Object webkittransitionend) {
4284         setEventHandler("webkittransitionend", webkittransitionend);
4285     }
4286 
4287     /**
4288      * @return the {@code currentScript}
4289      */
4290     @JsxGetter({CHROME, FF})
4291     public ScriptableObject getCurrentScript() {
4292         return currentScript_;
4293     }
4294 
4295     /**
4296      * @param script the {@code currentScript}
4297      */
4298     public void setCurrentScript(final ScriptableObject script) {
4299         currentScript_ = script;
4300     }
4301 }