[HtmlUnit] SVN: [15524] trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit
rbri--- via HtmlUnit-develop <[email protected]> Thu, 16 Aug 2018 14:33:09 +0000
| Newsgroups | gmane.comp.java.htmlunit.devel |
|---|---|
| Message-ID | <[email protected]> |
Revision: 15524
http://sourceforge.net/p/htmlunit/code/15524
Author: rbri
Date: 2018-08-16 14:32:55 +0000 (Thu, 16 Aug 2018)
Log Message:
-----------
next step in event refactoring (wip)
Modified Paths:
--------------
trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlPage.java
trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/event/EventTarget.java
Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlPage.java
===================================================================
--- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlPage.java 2018-08-16 06:41:09 UTC (rev 15523)
+++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlPage.java 2018-08-16 14:32:55 UTC (rev 15524)
@@ -1223,7 +1223,16 @@
if (LOG.isDebugEnabled()) {
LOG.debug("Firing " + event);
}
- final EventTarget jsNode = this.getScriptableObject();
+
+ final EventTarget jsNode;
+ if (Event.TYPE_DOM_DOCUMENT_LOADED.equals(eventType)) {
+ jsNode = this.getScriptableObject();
+ }
+ else {
+ // The load/beforeunload/unload events target Document but paths Window only (tested in Chrome/FF)
+ jsNode = window.getScriptableObject();
+ }
+
final ContextFactory cf = ((JavaScriptEngine) getWebClient().getJavaScriptEngine()).getContextFactory();
final ScriptResult result = cf.call(cx -> jsNode.fireEvent(event));
Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/event/EventTarget.java
===================================================================
--- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/event/EventTarget.java 2018-08-16 06:41:09 UTC (rev 15523)
+++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/event/EventTarget.java 2018-08-16 14:32:55 UTC (rev 15524)
@@ -141,17 +141,9 @@
// The load event has some unnatural behaviour that we need to handle specially
if (Event.TYPE_LOAD.equals(event.getType())) {
-
- // The Window load event targets Document but paths Window only (tested in Chrome/FF)
- if (this instanceof Document) {
- propagationPath.clear();
- propagationPath.add(window);
- }
- else {
- // The load event for other elements target that element and but path only
- // up to Document and not Window, so do nothing here
- // (see Note in https://www.w3.org/TR/DOM-Level-3-Events/#event-type-load)
- }
+ // The load event for other elements target that element and but path only
+ // up to Document and not Window, so do nothing here
+ // (see Note in https://www.w3.org/TR/DOM-Level-3-Events/#event-type-load)
}
else {
// Add Window if the the propagation path reached Document
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot