[HtmlUnit] SVN: [15529] trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit
rbri--- via HtmlUnit-develop <[email protected]> Fri, 17 Aug 2018 19:49:02 +0000
| Newsgroups | gmane.comp.java.htmlunit.devel |
|---|---|
| Message-ID | <[email protected]> |
Revision: 15529
http://sourceforge.net/p/htmlunit/code/15529
Author: rbri
Date: 2018-08-17 19:48:56 +0000 (Fri, 17 Aug 2018)
Log Message:
-----------
some cleanup
Modified Paths:
--------------
trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlPage.java
trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/event/BeforeUnloadEvent.java
trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/event/Event.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-17 19:28:08 UTC (rev 15528)
+++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlPage.java 2018-08-17 19:48:56 UTC (rev 15529)
@@ -1288,8 +1288,8 @@
private boolean isOnbeforeunloadAccepted(final HtmlPage page, final Event event, final ScriptResult result) {
if (event instanceof BeforeUnloadEvent) {
- if (((BeforeUnloadEvent) event).isBeforeUnloadMessageSet()) {
- final String message = Context.toString(event.getReturnValue());
+ final BeforeUnloadEvent beforeUnloadEvent = (BeforeUnloadEvent) event;
+ if (beforeUnloadEvent.isBeforeUnloadMessageSet()) {
final OnbeforeunloadHandler handler = getWebClient().getOnbeforeunloadHandler();
if (handler == null) {
LOG.warn("document.onbeforeunload() returned a string in event.returnValue,"
@@ -1296,6 +1296,7 @@
+ " but no onbeforeunload handler installed.");
}
else {
+ final String message = Context.toString(beforeUnloadEvent.getReturnValue());
return handler.handleEvent(page, message);
}
}
Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/event/BeforeUnloadEvent.java
===================================================================
--- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/event/BeforeUnloadEvent.java 2018-08-17 19:28:08 UTC (rev 15528)
+++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/event/BeforeUnloadEvent.java 2018-08-17 19:48:56 UTC (rev 15529)
@@ -41,6 +41,7 @@
*/
@JsxClass
public class BeforeUnloadEvent extends Event {
+ private Object returnValue_;
/**
* Creates a new event instance.
@@ -84,11 +85,6 @@
return Undefined.instance;
}
- @Override
- protected boolean isReturnValueBackedByPreventDefault() {
- return false;
- }
-
/**
* @return {@code true} if returnValue holds the beforeunload message
*/
@@ -99,10 +95,9 @@
/**
* @return the return value associated with the event
*/
- @Override
@JsxGetter
public Object getReturnValue() {
- return super.getReturnValue();
+ return returnValue_;
}
/**
@@ -109,10 +104,9 @@
* Sets the return value associated with the event.
* @param returnValue the return value associated with the event
*/
- @Override
@JsxSetter
public void setReturnValue(final Object returnValue) {
- super.setReturnValue(returnValue);
+ returnValue_ = returnValue;
}
@Override
Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/event/Event.java
===================================================================
--- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/event/Event.java 2018-08-17 19:28:08 UTC (rev 15528)
+++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/event/Event.java 2018-08-17 19:48:56 UTC (rev 15529)
@@ -16,7 +16,6 @@
import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.EVENT_FOCUS_FOCUS_IN_BLUR_OUT;
import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.EVENT_ONLOAD_CANCELABLE_FALSE;
-import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.EVENT_RETURN_VALUE_IS_PREVENT_DEFAULT;
import static com.gargoylesoftware.htmlunit.javascript.configuration.SupportedBrowser.CHROME;
import static com.gargoylesoftware.htmlunit.javascript.configuration.SupportedBrowser.EDGE;
import static com.gargoylesoftware.htmlunit.javascript.configuration.SupportedBrowser.FF;
@@ -36,7 +35,6 @@
import com.gargoylesoftware.htmlunit.javascript.configuration.JsxSetter;
import net.sourceforge.htmlunit.corejs.javascript.Context;
-import net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime;
import net.sourceforge.htmlunit.corejs.javascript.Scriptable;
import net.sourceforge.htmlunit.corejs.javascript.ScriptableObject;
import net.sourceforge.htmlunit.corejs.javascript.Undefined;
@@ -182,9 +180,8 @@
private String propertyName_;
private boolean stopPropagation_;
private boolean stopImmediatePropagation_;
- private Object returnValue_;
private boolean preventDefault_;
- private Boolean returnValueIsPreventDefault_;
+
/**
* The current event phase. This is a W3C standard attribute. One of {@link #NONE},
* {@link #CAPTURING_PHASE}, {@link #AT_TARGET} or {@link #BUBBLING_PHASE}.
@@ -584,40 +581,6 @@
}
/**
- * @return true if returnValue is backed by the same storage as preventDefault.
- */
- protected boolean isReturnValueBackedByPreventDefault() {
- if (returnValueIsPreventDefault_ == null) {
- returnValueIsPreventDefault_ = getBrowserVersion().hasFeature(EVENT_RETURN_VALUE_IS_PREVENT_DEFAULT);
- }
- return returnValueIsPreventDefault_;
- }
-
- /**
- * Returns the return value associated with the event.
- * @return the return value associated with the event
- */
- public Object getReturnValue() {
- if (isReturnValueBackedByPreventDefault()) {
- return !preventDefault_;
- }
- return returnValue_;
- }
-
- /**
- * Sets the return value associated with the event.
- * @param returnValue the return value associated with the event
- */
- public void setReturnValue(final Object returnValue) {
- if (isReturnValueBackedByPreventDefault()) {
- preventDefault_ = !ScriptRuntime.toBoolean(returnValue);
- }
- else {
- returnValue_ = returnValue;
- }
- }
-
- /**
* Handles the return values of property handlers.
* @param returnValue the return value returned by the property handler
*/
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot