You can subscribe to this list here.
2002 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
(10) |
Aug
(30) |
Sep
(15) |
Oct
(26) |
Nov
(12) |
Dec
(17) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2003 |
Jan
(7) |
Feb
(27) |
Mar
(73) |
Apr
(17) |
May
(17) |
Jun
(78) |
Jul
(67) |
Aug
(60) |
Sep
(89) |
Oct
(140) |
Nov
(173) |
Dec
(46) |
2004 |
Jan
(39) |
Feb
(7) |
Mar
(21) |
Apr
(31) |
May
(13) |
Jun
(86) |
Jul
(14) |
Aug
(14) |
Sep
(53) |
Oct
(184) |
Nov
(186) |
Dec
(319) |
2005 |
Jan
(336) |
Feb
(274) |
Mar
(226) |
Apr
(102) |
May
(196) |
Jun
(130) |
Jul
(119) |
Aug
(143) |
Sep
(76) |
Oct
(85) |
Nov
(70) |
Dec
(159) |
2006 |
Jan
(125) |
Feb
(100) |
Mar
(80) |
Apr
(39) |
May
(55) |
Jun
(58) |
Jul
(50) |
Aug
(76) |
Sep
(55) |
Oct
(101) |
Nov
(163) |
Dec
(85) |
2007 |
Jan
(56) |
Feb
(53) |
Mar
(180) |
Apr
(221) |
May
(290) |
Jun
(199) |
Jul
(322) |
Aug
(515) |
Sep
(121) |
Oct
(297) |
Nov
(177) |
Dec
(103) |
2008 |
Jan
(516) |
Feb
(315) |
Mar
(586) |
Apr
(615) |
May
(197) |
Jun
(381) |
Jul
(390) |
Aug
(195) |
Sep
(603) |
Oct
(499) |
Nov
(622) |
Dec
(350) |
2009 |
Jan
(313) |
Feb
(338) |
Mar
(507) |
Apr
(317) |
May
(197) |
Jun
(375) |
Jul
(235) |
Aug
(424) |
Sep
(410) |
Oct
(338) |
Nov
(286) |
Dec
(306) |
2010 |
Jan
(367) |
Feb
(339) |
Mar
(371) |
Apr
(172) |
May
(233) |
Jun
(264) |
Jul
(421) |
Aug
(110) |
Sep
(218) |
Oct
(189) |
Nov
(185) |
Dec
(168) |
2011 |
Jan
(145) |
Feb
(213) |
Mar
(205) |
Apr
(64) |
May
(159) |
Jun
(67) |
Jul
(104) |
Aug
(126) |
Sep
(144) |
Oct
(106) |
Nov
(154) |
Dec
(225) |
2012 |
Jan
(111) |
Feb
(87) |
Mar
(131) |
Apr
(102) |
May
(180) |
Jun
(160) |
Jul
(412) |
Aug
(315) |
Sep
(311) |
Oct
(369) |
Nov
(464) |
Dec
(284) |
2013 |
Jan
(343) |
Feb
(165) |
Mar
(174) |
Apr
(120) |
May
(153) |
Jun
(134) |
Jul
(202) |
Aug
(105) |
Sep
(228) |
Oct
(332) |
Nov
(192) |
Dec
(219) |
2014 |
Jan
(348) |
Feb
(194) |
Mar
(189) |
Apr
(188) |
May
(297) |
Jun
(206) |
Jul
(79) |
Aug
(279) |
Sep
(111) |
Oct
(159) |
Nov
(61) |
Dec
(78) |
2015 |
Jan
(152) |
Feb
(145) |
Mar
(239) |
Apr
(223) |
May
(248) |
Jun
(296) |
Jul
(172) |
Aug
(189) |
Sep
(338) |
Oct
(217) |
Nov
(131) |
Dec
(184) |
2016 |
Jan
(118) |
Feb
(221) |
Mar
(414) |
Apr
(412) |
May
(303) |
Jun
(133) |
Jul
(129) |
Aug
(121) |
Sep
(136) |
Oct
(67) |
Nov
(89) |
Dec
(245) |
2017 |
Jan
(349) |
Feb
(90) |
Mar
(328) |
Apr
(430) |
May
(284) |
Jun
(199) |
Jul
(164) |
Aug
(120) |
Sep
(57) |
Oct
(105) |
Nov
(108) |
Dec
(146) |
2018 |
Jan
(85) |
Feb
(48) |
Mar
(97) |
Apr
(62) |
May
(64) |
Jun
(136) |
Jul
(123) |
Aug
(87) |
Sep
(17) |
Oct
(27) |
Nov
(9) |
Dec
(16) |
2019 |
Jan
(9) |
Feb
(17) |
Mar
(18) |
Apr
(14) |
May
(8) |
Jun
|
Jul
(6) |
Aug
(12) |
Sep
(5) |
Oct
|
Nov
(2) |
Dec
|
2020 |
Jan
(8) |
Feb
|
Mar
(6) |
Apr
|
May
|
Jun
|
Jul
(2) |
Aug
|
Sep
(4) |
Oct
(1) |
Nov
|
Dec
|
2021 |
Jan
|
Feb
|
Mar
|
Apr
(2) |
May
(4) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(1) |
Nov
(4) |
Dec
|
2022 |
Jan
|
Feb
|
Mar
|
Apr
(1) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(2) |
Dec
|
2023 |
Jan
|
Feb
(6) |
Mar
(9) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2024 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(2) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: <rb...@us...> - 2018-08-28 17:35:55
|
Revision: 15547 http://sourceforge.net/p/htmlunit/code/15547 Author: rbri Date: 2018-08-28 17:35:53 +0000 (Tue, 28 Aug 2018) Log Message: ----------- Added Paths: ----------- tags/htmlunit/ |
From: <rb...@us...> - 2018-08-28 17:32:29
|
Revision: 15546 http://sourceforge.net/p/htmlunit/code/15546 Author: rbri Date: 2018-08-28 17:32:26 +0000 (Tue, 28 Aug 2018) Log Message: ----------- fix test Modified Paths: -------------- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/css/ComputedCSSStyleDeclaration.java Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/css/ComputedCSSStyleDeclaration.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/css/ComputedCSSStyleDeclaration.java 2018-08-27 18:41:21 UTC (rev 15545) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/css/ComputedCSSStyleDeclaration.java 2018-08-28 17:32:26 UTC (rev 15546) @@ -1506,7 +1506,7 @@ // We need to calculate the horizontal displacement caused by *previous* siblings. left = 0; DomNode prev = getElement().getDomNodeOrDie().getPreviousSibling(); - while (prev != null) { + while (prev != null && !(prev instanceof HtmlTableRow)) { final Scriptable prevScriptable = prev.getScriptableObject(); if (prevScriptable instanceof HTMLElement) { final HTMLElement e = (HTMLElement) prevScriptable; @@ -1525,9 +1525,6 @@ left += content.trim().length() * getBrowserVersion().getPixesPerChar(); } } - if (prev instanceof HtmlTableRow) { - break; - } prev = prev.getPreviousSibling(); } } |
From: RBRi <rb...@us...> - 2018-08-27 18:46:26
|
Hi Bogdan, please keep in mind HtmlUnit is an headless browser; there is no layouting and result the calculated layout properties are not comparable with real browsers. Have done a small fix - pleae check if this makes the situation better for you. --- ** [bugs:#1986] getPosX, getPosY, getBoundingClientRect return incorrect values** **Status:** accepted **Group:** 2.32 **Created:** Thu Aug 23, 2018 08:39 AM UTC by Bogdan **Last Updated:** Mon Aug 27, 2018 06:39 PM UTC **Owner:** RBRi Im running htmlunit 2.32, all dependecies are checked. To reproduce I compare GoogleChrome console result with the HmlUnit: load for test the HTML page at: https://www.le.ac.uk/oerresources/bdra/html/page_09.htm In Google Chrome Console run: document.getElementById("toc").getBoundingClientRect() result: DOMRect {x: 1, y: 63.609375, width: 180, height: 458.609375, top: 63.609375, …} bottom:522.21875 height:458.609375 left:1 right:181 top:63.609375 width:180 x:1 y:63.609375 In HtmlUnit: webClient = new WebClient(BrowserVersion.CHROME)); webClient.getOptions().setJavaScriptEnabled(true); webClient.getOptions().setRedirectEnabled(true); webClient.getOptions().setThrowExceptionOnFailingStatusCode(false); webClient.getOptions().setThrowExceptionOnScriptError(false); webClient.setRefreshHandler(new RefreshHandler() { public void handleRefresh(Page page, URL url, int seconds) throws IOException { } }); webClient.getOptions().setCssEnabled(true); webClient.getOptions().setTimeout(timeout * 1000); webClient.setJavaScriptTimeout(1000); Page somepage = webClient.getPage(url); then: HtmlDivision div = (HtmlDivision) page.getElementById("toc"); ClientRect rect = ((HTMLElement) (div).getScriptableObject()).getBoundingClientRect(); rect values: bottom: 90 left: 9195 right : 10451 top: 90 getPosX and GetPosY return: x: 9195 y: 90 --- Sent from sourceforge.net because htm...@li... is subscribed to https://sourceforge.net/p/htmlunit/bugs/ To unsubscribe from further messages, a project admin can change settings at https://sourceforge.net/p/htmlunit/admin/bugs/options. Or, if this is a mailing list, you can unsubscribe from the mailing list. |
From: <rb...@us...> - 2018-08-27 18:41:26
|
Revision: 15545 http://sourceforge.net/p/htmlunit/code/15545 Author: rbri Date: 2018-08-27 18:41:21 +0000 (Mon, 27 Aug 2018) Log Message: ----------- improved calculation of the left offset Issue 1986 Modified Paths: -------------- trunk/htmlunit/src/changes/changes.xml trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/css/ComputedCSSStyleDeclaration.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/css/ComputedCSSStyleDeclarationTest.java Modified: trunk/htmlunit/src/changes/changes.xml =================================================================== --- trunk/htmlunit/src/changes/changes.xml 2018-08-24 18:34:16 UTC (rev 15544) +++ trunk/htmlunit/src/changes/changes.xml 2018-08-27 18:41:21 UTC (rev 15545) @@ -8,6 +8,9 @@ <body> <release version="2.33" date="xxxx, 2018" description="Bugfixes"> + <action type="update" dev="rbri" issue="1986"> + Improved calculation of the left offset. + </action> <action type="update" dev="rbri"> We are using the typed array implementation from Rhino now, our own impl is gone. </action> Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/css/ComputedCSSStyleDeclaration.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/css/ComputedCSSStyleDeclaration.java 2018-08-24 18:34:16 UTC (rev 15544) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/css/ComputedCSSStyleDeclaration.java 2018-08-27 18:41:21 UTC (rev 15545) @@ -131,6 +131,7 @@ import com.gargoylesoftware.htmlunit.javascript.host.html.HTMLElement; import net.sourceforge.htmlunit.corejs.javascript.Context; +import net.sourceforge.htmlunit.corejs.javascript.Scriptable; /** * An object for a CSSStyleDeclaration, which is computed. @@ -1504,9 +1505,11 @@ else if (STATIC.equals(p)) { // We need to calculate the horizontal displacement caused by *previous* siblings. left = 0; - for (DomNode n = getDomNodeOrDie(); n != null; n = n.getPreviousSibling()) { - if (n.getScriptableObject() instanceof HTMLElement) { - final HTMLElement e = n.getScriptableObject(); + DomNode prev = getElement().getDomNodeOrDie().getPreviousSibling(); + while (prev != null) { + final Scriptable prevScriptable = prev.getScriptableObject(); + if (prevScriptable instanceof HTMLElement) { + final HTMLElement e = (HTMLElement) prevScriptable; final ComputedCSSStyleDeclaration style = e.getWindow().getComputedStyle(e, null); final String d = style.getDisplay(); if ("block".equals(d)) { @@ -1516,12 +1519,16 @@ left += style.getCalculatedWidth(true, true); } } - else if (n.getScriptableObject() instanceof Text) { - left += n.getTextContent().length() * getBrowserVersion().getPixesPerChar(); + else if (prevScriptable instanceof Text) { + final String content = prev.getTextContent(); + if (content != null) { + left += content.trim().length() * getBrowserVersion().getPixesPerChar(); + } } - if (n instanceof HtmlTableRow) { + if (prev instanceof HtmlTableRow) { break; } + prev = prev.getPreviousSibling(); } } else { @@ -1857,5 +1864,4 @@ } return pixelValue(element, value) + "px"; } - } Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/css/ComputedCSSStyleDeclarationTest.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/css/ComputedCSSStyleDeclarationTest.java 2018-08-24 18:34:16 UTC (rev 15544) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/css/ComputedCSSStyleDeclarationTest.java 2018-08-27 18:41:21 UTC (rev 15545) @@ -2202,4 +2202,24 @@ loadPageWithAlerts2(html); } + + /** + * @throws Exception if an error occurs + */ + @Test + @Alerts("true") + public void boundingClientRectIgnoreSiblingWhitespace() throws Exception { + final String html = "<html><body>\n" + + "<table>\n" + + "<tr>\n" + + " <td> \n\t <div id='a'>a</div></td>\n" + + "</tr>\n" + + "</table>\n" + + "<script>\n" + + " var e = document.getElementById('a');\n" + + " alert(e.getBoundingClientRect().left < 12);\n" + + "</script>\n" + + "</body></html>"; + loadPageWithAlerts2(html); + } } |
From: RBRi <rb...@us...> - 2018-08-27 18:39:29
|
- **status**: open --> accepted - **assigned_to**: RBRi --- ** [bugs:#1986] getPosX, getPosY, getBoundingClientRect return incorrect values** **Status:** accepted **Group:** 2.32 **Created:** Thu Aug 23, 2018 08:39 AM UTC by Bogdan **Last Updated:** Mon Aug 27, 2018 07:48 AM UTC **Owner:** RBRi Im running htmlunit 2.32, all dependecies are checked. To reproduce I compare GoogleChrome console result with the HmlUnit: load for test the HTML page at: https://www.le.ac.uk/oerresources/bdra/html/page_09.htm In Google Chrome Console run: document.getElementById("toc").getBoundingClientRect() result: DOMRect {x: 1, y: 63.609375, width: 180, height: 458.609375, top: 63.609375, …} bottom:522.21875 height:458.609375 left:1 right:181 top:63.609375 width:180 x:1 y:63.609375 In HtmlUnit: webClient = new WebClient(BrowserVersion.CHROME)); webClient.getOptions().setJavaScriptEnabled(true); webClient.getOptions().setRedirectEnabled(true); webClient.getOptions().setThrowExceptionOnFailingStatusCode(false); webClient.getOptions().setThrowExceptionOnScriptError(false); webClient.setRefreshHandler(new RefreshHandler() { public void handleRefresh(Page page, URL url, int seconds) throws IOException { } }); webClient.getOptions().setCssEnabled(true); webClient.getOptions().setTimeout(timeout * 1000); webClient.setJavaScriptTimeout(1000); Page somepage = webClient.getPage(url); then: HtmlDivision div = (HtmlDivision) page.getElementById("toc"); ClientRect rect = ((HTMLElement) (div).getScriptableObject()).getBoundingClientRect(); rect values: bottom: 90 left: 9195 right : 10451 top: 90 getPosX and GetPosY return: x: 9195 y: 90 --- Sent from sourceforge.net because htm...@li... is subscribed to https://sourceforge.net/p/htmlunit/bugs/ To unsubscribe from further messages, a project admin can change settings at https://sourceforge.net/p/htmlunit/admin/bugs/options. Or, if this is a mailing list, you can unsubscribe from the mailing list. |
From: <rb...@us...> - 2018-08-24 18:34:19
|
Revision: 15544 http://sourceforge.net/p/htmlunit/code/15544 Author: rbri Date: 2018-08-24 18:34:16 +0000 (Fri, 24 Aug 2018) Log Message: ----------- next step in event refactoring (wip) Modified Paths: -------------- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlImage.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/event/Event.java Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlImage.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlImage.java 2018-08-24 17:43:24 UTC (rev 15543) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlImage.java 2018-08-24 18:34:16 UTC (rev 15544) @@ -46,7 +46,6 @@ import com.gargoylesoftware.htmlunit.WebRequest; import com.gargoylesoftware.htmlunit.WebResponse; import com.gargoylesoftware.htmlunit.javascript.PostponedAction; -import com.gargoylesoftware.htmlunit.javascript.host.dom.Node; import com.gargoylesoftware.htmlunit.javascript.host.event.Event; /** @@ -80,7 +79,7 @@ private int height_ = -1; private boolean downloaded_; private boolean isComplete_; - private boolean onloadInvoked_; + private boolean onloadProcessed_; private boolean createdByJavascript_; /** @@ -137,7 +136,7 @@ notifyMutationObservers); // onload handlers may need to be invoked again, and a new image may need to be downloaded - onloadInvoked_ = false; + onloadProcessed_ = false; downloaded_ = false; isComplete_ = false; width_ = -1; @@ -170,20 +169,20 @@ /** * <p><span style="color:red">INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.</span></p> * - * <p>Executes this element's <tt>onload</tt> handler if it has one. This method also downloads the image - * if this element has an <tt>onload</tt> handler (prior to invoking said handler), because applications - * sometimes use images to send information to the server and use the <tt>onload</tt> handler to get notified - * when the information has been received by the server.</p> + * <p>Executes this element's <tt>onload</tt> or <tt>onerror</tt> handler. This method downloads the image + * if either of these handlers are present (prior to invoking the resulting handler), because applications + * sometimes use images to send information to the server and use these handlers to get notified when the + * information has been received by the server.</p> * * <p>See <a href="http://www.nabble.com/How-should-we-handle-image.onload--tt9850876.html">here</a> and * <a href="http://www.nabble.com/Image-Onload-Support-td18895781.html">here</a> for the discussion which * lead up to this method.</p> * - * <p>This method may be called multiple times, but will only attempt to execute the <tt>onload</tt> - * handler the first time it is invoked.</p> + * <p>This method may be called multiple times, but will only attempt to execute the <tt>onload</tt> or + * <tt>onerror</tt> handler the first time it is invoked.</p> */ public void doOnLoad() { - if (onloadInvoked_) { + if (onloadProcessed_) { return; } @@ -194,47 +193,48 @@ final WebClient client = htmlPage.getWebClient(); if (!client.getOptions().isJavaScriptEnabled()) { - onloadInvoked_ = true; + onloadProcessed_ = true; return; } - if (hasEventHandlers("onload") && !getSrcAttribute().isEmpty()) { - // An onload handler and source are defined; we need to download the image and then call the onload handler. - onloadInvoked_ = true; - try { - downloadImageIfNeeded(); - final int i = imageWebResponse_.getStatusCode(); - if ((i >= HttpStatus.SC_OK && i < HttpStatus.SC_MULTIPLE_CHOICES) - || i == HttpStatus.SC_USE_PROXY) { - - // If the download was a success, trigger the onload handler. - final Event event = new Event(this, Event.TYPE_LOAD); - final Node scriptObject = getScriptableObject(); - - final String readyState = htmlPage.getReadyState(); - if (READY_STATE_LOADING.equals(readyState)) { - final PostponedAction action = new PostponedAction(getPage()) { - @Override - public void execute() throws Exception { - scriptObject.executeEventLocally(event); - } - }; - htmlPage.addAfterLoadAction(action); + if ((hasEventHandlers("onload") || hasEventHandlers("onerror")) && hasAttribute("src")) { + onloadProcessed_ = true; + boolean loadSuccessful = false; + if (!getSrcAttribute().isEmpty()) { + // We need to download the image and then call the resulting handler. + try { + downloadImageIfNeeded(); + final int i = imageWebResponse_.getStatusCode(); + // if the download was a success + if ((i >= HttpStatus.SC_OK && i < HttpStatus.SC_MULTIPLE_CHOICES) + || i == HttpStatus.SC_USE_PROXY) { + loadSuccessful = true; // Trigger the onload handler } - else { - scriptObject.executeEventLocally(event); + } + catch (final IOException e) { + if (LOG.isDebugEnabled()) { + LOG.debug("IOException while downloading image for '" + this + "' : " + e.getMessage()); } } - return; } - catch (final IOException e) { - if (LOG.isDebugEnabled()) { - LOG.debug("IOException while downloading image for '" + this + "' : " + e.getMessage()); - } - } + + final Event event = new Event(this, loadSuccessful ? Event.TYPE_LOAD : Event.TYPE_ERROR); if (LOG.isDebugEnabled()) { - LOG.debug("Unable to download image for '" + this + "'; not firing onload event."); + LOG.debug("Firing the " + event.getType() + " event for '" + this + "'."); } + + if (READY_STATE_LOADING.equals(htmlPage.getReadyState())) { + final PostponedAction action = new PostponedAction(getPage()) { + @Override + public void execute() throws Exception { + HtmlImage.this.fireEvent(event); + } + }; + htmlPage.addAfterLoadAction(action); + } + else { + fireEvent(event); + } } } 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-24 17:43:24 UTC (rev 15543) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/event/Event.java 2018-08-24 18:34:16 UTC (rev 15544) @@ -241,6 +241,10 @@ cancelable_ = false; } } + else if (TYPE_ERROR.equals(type)) { + // https://www.w3.org/TR/DOM-Level-3-Events/#event-type-error + bubbles_ = false; + } } /** |
From: RBRi <rb...@us...> - 2018-08-24 17:59:41
|
Hope i have merged the whole rest. Will have a look at the remaining tests next week. For the next patches it will be great if we have smaller test cases testing only one feature/problem; there is no restriction for the number of cases but if a test later on fails it is really tricky to figure out the reason. Again many thanks for all the provided stuff. --- ** [bugs:#1984] Reworking the JS Event listeners implementation** **Status:** accepted **Group:** Latest SVN **Created:** Tue Aug 14, 2018 01:38 PM UTC by Atsushi Nakagawa **Last Updated:** Tue Aug 21, 2018 09:51 AM UTC **Owner:** RBRi **Attachments:** - [EventListenersContainer.java](https://sourceforge.net/p/htmlunit/bugs/1984/attachment/EventListenersContainer.java) (16.9 kB; application/octet-stream) - [EventListenersContainer.java-2.32.txt](https://sourceforge.net/p/htmlunit/bugs/1984/attachment/EventListenersContainer.java-2.32.txt) (15.5 kB; text/plain) - [EventTarget.java](https://sourceforge.net/p/htmlunit/bugs/1984/attachment/EventTarget.java) (14.7 kB; application/octet-stream) - [EventTarget.java-2.32.txt](https://sourceforge.net/p/htmlunit/bugs/1984/attachment/EventTarget.java-2.32.txt) (13.4 kB; text/plain) ### Problem in brief Thorough testing has revealed event listeners in HtmlUnit are implemented quite liberally in a few places with regards to how they should work. It's somewhat surprising they're working so well in practice. This bug report attempts to address the problems and tackle at fixing them. Scope includes `xyz.addListenerEvent('foo', function () { ... })` listeners and `xyz.onfoo = function () { ... }` property handlers. ##### Problems noticed * Ordering of listeners called during the *at target* phase should honour the order in which the listeners were added, but does not. * Ordering of property handlers such as `window.onload` should honour the timing at which the property was set, with respect to other event listeners, but does not. * Events where `event.bubbles` is `false` should not have a *bubbling* phase, but does. * The load event for `Window`should only traverse `Window` but traverses `Window, Document` instead. * The load event for everything else should traverse from `Document` to all levels down to the element in question, but traverses the element in question only. (Every place using `EventTarget.executeEventLocally()` potentially applies to this and should probably be using the standard `EventTarget.fireEvent()` instead.) * The load event for the `<frame>` element should be treated like "everything else" above, but is not. (On the other hand, the `onload` property for `<body>` and `<frameset>` is correctly tied to `Window`.) * The propagation path of events should not be affected by changes to the DOM tree by intermediate listeners, and therefore the *bubbling* phase should always traverse the same nodes as the *capturing* phase only in reverse, but is and does not. * The return value of event listeners should be ignored (really? it looks that way.. maybe it was different in older IE) and only that of the property handler should be used, but is not. ### Test cases There are five tests which I'm putting in the comments because it's quite long. * `test_onload.html` * `test_frame.html` * `test_click.html` * `test_nested_click.html` * `test_event_return_value.html` These extra two I'm including but haven't fixed yet. They're limited to the load/error behaviour of `<script>` and `<img>` and require fixing up some implementation in `HtmlScript` and `HtmlImage`. * `test_script_onload.html` * `test_img_onload.html` ### Possible fix The fix spans three files: * `html/HtmlPage.java` * `javascript/host/event/EventListenersContainer.java` * `javascript/host/event/EventTarget.java` Changes to `HtmlPage` is the diff below. The changes for `EventListenersContainer.java` and `EventTarget.java` are rather extensive so I'm attaching the modified files along with their respective base versions suffixed with `-2.32.txt`. ```diff --- a/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlPage.java +++ b/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlPage.java @@ -86,15 +86,16 @@ import com.gargoylesoftware.htmlunit.javascript.PostponedAction; import com.gargoylesoftware.htmlunit.javascript.SimpleScriptable; import com.gargoylesoftware.htmlunit.javascript.host.Window; -import com.gargoylesoftware.htmlunit.javascript.host.dom.Node; import com.gargoylesoftware.htmlunit.javascript.host.event.BeforeUnloadEvent; import com.gargoylesoftware.htmlunit.javascript.host.event.Event; +import com.gargoylesoftware.htmlunit.javascript.host.event.EventTarget; import com.gargoylesoftware.htmlunit.javascript.host.html.HTMLDocument; import com.gargoylesoftware.htmlunit.protocol.javascript.JavaScriptURLConnection; import com.gargoylesoftware.htmlunit.util.EncodingSniffer; import com.gargoylesoftware.htmlunit.util.UrlUtils; import net.sourceforge.htmlunit.corejs.javascript.Context; +import net.sourceforge.htmlunit.corejs.javascript.ContextFactory; import net.sourceforge.htmlunit.corejs.javascript.Function; import net.sourceforge.htmlunit.corejs.javascript.Script; import net.sourceforge.htmlunit.corejs.javascript.Scriptable; @@ -1214,18 +1215,28 @@ private boolean executeEventHandlersIfNeeded(final String eventType) { // Execute the specified event on the document element. final WebWindow window = getEnclosingWindow(); if (window.getScriptableObject() instanceof Window) { - final DomElement element = getDocumentElement(); - if (element == null) { // happens for instance if document.documentElement has been removed from parent - return true; - } + // We need the 'Document' node for these load events but getDocumentElement() returns + // <html> (HtmlHtml) which is one below that. The 'Document' node is incidentally just + // us (HtmlPage). (Some tidbits at https://www.w3.org/TR/DOM-Level-3-Events/#event-flow) + final DomNode node = this; final Event event; if (eventType.equals(Event.TYPE_BEFORE_UNLOAD)) { - event = new BeforeUnloadEvent(element, eventType); + event = new BeforeUnloadEvent(node, eventType); } else { - event = new Event(element, eventType); + event = new Event(node, eventType); + } + + // This is the same as DomElement.fireEvent() and was copied + // here so it could be used with HtmlPage. + if (LOG.isDebugEnabled()) { + LOG.debug("Firing " + event); } - final ScriptResult result = element.fireEvent(event); + + final EventTarget jsNode = node.getScriptableObject(); + final ContextFactory cf = ((JavaScriptEngine) getWebClient().getJavaScriptEngine()).getContextFactory(); + final ScriptResult result = cf.call(cx -> jsNode.fireEvent(event)); + if (!isOnbeforeunloadAccepted(this, event, result)) { return false; } @@ -1253,7 +1264,12 @@ private boolean executeEventHandlersIfNeeded(final String eventType) { else { event = new Event(frame, eventType); } - final ScriptResult result = ((Node) frame.getScriptableObject()).executeEventLocally(event); + + // This fires the "load" event for the <frame> element which, like all non-window + // load events, propagates up to Document but not Window. The "load" event for + // <frameset> on the other hand, like that of <body>, is handled above where it is + // fired against Document and directed to Window. + final ScriptResult result = frame.fireEvent(event); if (!isOnbeforeunloadAccepted((HtmlPage) frame.getPage(), event, result)) { return false; } ``` --- Sent from sourceforge.net because htm...@li... is subscribed to https://sourceforge.net/p/htmlunit/bugs/ To unsubscribe from further messages, a project admin can change settings at https://sourceforge.net/p/htmlunit/admin/bugs/options. Or, if this is a mailing list, you can unsubscribe from the mailing list. |
From: <rb...@us...> - 2018-08-24 17:43:27
|
Revision: 15543 http://sourceforge.net/p/htmlunit/code/15543 Author: rbri Date: 2018-08-24 17:43:24 +0000 (Fri, 24 Aug 2018) Log Message: ----------- next step in event refactoring (wip) Modified Paths: -------------- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/Window3Test.java Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/Window3Test.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/Window3Test.java 2018-08-24 17:12:10 UTC (rev 15542) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/Window3Test.java 2018-08-24 17:43:24 UTC (rev 15543) @@ -18,11 +18,16 @@ import java.io.InputStream; import java.net.URL; +import java.util.Arrays; import java.util.Collections; +import java.util.Comparator; import java.util.List; import java.util.Map; +import java.util.regex.Pattern; +import java.util.stream.Collectors; import org.apache.commons.io.IOUtils; +import org.apache.commons.lang3.StringUtils; import org.junit.Test; import org.junit.runner.RunWith; import org.openqa.selenium.By; @@ -29,10 +34,10 @@ import org.openqa.selenium.WebDriver; import com.gargoylesoftware.htmlunit.BrowserRunner; -import com.gargoylesoftware.htmlunit.HttpHeader; import com.gargoylesoftware.htmlunit.BrowserRunner.Alerts; import com.gargoylesoftware.htmlunit.BrowserRunner.BuggyWebDriver; import com.gargoylesoftware.htmlunit.BrowserRunner.NotYetImplemented; +import com.gargoylesoftware.htmlunit.HttpHeader; import com.gargoylesoftware.htmlunit.WebDriverTestCase; import com.gargoylesoftware.htmlunit.html.HtmlPageTest; import com.gargoylesoftware.htmlunit.util.NameValuePair; @@ -1709,7 +1714,9 @@ "window at load", "window at load capture", "body onload"}, - IE = {"document at load capture", + IE = {"window at error", + "window at error capture", + "document at load capture", "element 1 onload", "window at error capture", "document at error capture", @@ -1766,37 +1773,38 @@ * @throws Exception if the test fails */ @Test - @Alerts(DEFAULT = {"window at error capture", - "document at error capture", - "element 2 onerror", - "document DOMContentLoaded", - "window DOMContentLoaded", - "document at load capture", - "element 1 onload", - "window at load", - "window at load capture", - "body onload"}, - CHROME = {"document DOMContentLoaded", - "window DOMContentLoaded", - "window at error capture", - "document at error capture", - "element 2 onerror", - "document at load capture", - "element 1 onload", - "window at load", - "window at load capture", - "body onload"}, - IE = {"document at load capture", - "element 1 onload", - "document DOMContentLoaded", - "window DOMContentLoaded", - "window at load", - "window at load capture", - "body onload", - "document at load capture", - "window at error capture", - "document at error capture", - "element 2 onerror"}) + @Alerts(DEFAULT = {"img2: window at error capture", + "img2: document at error capture", + "img2: element 2 onerror", + "#document: document DOMContentLoaded", + "#document: window DOMContentLoaded", + "img1: document at load capture", + "img1: element 1 onload", + "#document: window at load", + "#document: window at load capture", + "#document: body onload"}, + CHROME = {"#document: document DOMContentLoaded", + "#document: window DOMContentLoaded", + "img2: window at error capture", + "img2: document at error capture", + "img2: element 2 onerror", + "img1: document at load capture", + "img1: element 1 onload", + "#document: window at load", + "#document: window at load capture", + "#document: body onload"}, + IE = {"img1: document at load capture", + "img1: element 1 onload", + "#document: document DOMContentLoaded", + "#document: window DOMContentLoaded", + "#document: window at load", + "#document: window at load capture", + "#document: body onload", + "SCRIPT: document at load capture", + "img2: window at error capture", + "img2: document at error capture", + "img2: element 2 onerror"}) + @NotYetImplemented(IE) // The extra SCRIPT is not yet handled (waiting on onloadScript()) public void onloadImg() throws Exception { final URL urlImage = new URL(URL_FIRST, "img.jpg"); try (InputStream is = getClass().getClassLoader().getResourceAsStream("testfiles/tiny-jpg.img")) { @@ -1808,36 +1816,56 @@ final String html = HtmlPageTest.STANDARDS_MODE_PREFIX_ + "<html><head>\n" + "<script>\n" - + " function log(msg) {\n" + + " function log(msg, target) {\n" + + " if (target) msg = (target.id ? target.id : target.nodeName) + ': ' + msg\n" + " window.parent.document.title += msg + ';';\n" + " }\n" - + " window.addEventListener('load', function () { log('window at load') })\n" - + " window.addEventListener('load', function () { log('window at load capture') }, true)\n" - + " window.addEventListener('error', function () { log('window at error') })\n" - + " window.addEventListener('error', function () { log('window at error capture') }, true)\n" - + " window.addEventListener('DOMContentLoaded', function () { log('window DOMContentLoaded') })\n" + + " window.addEventListener('load', function (event) { log('window at load', event.target) })\n" + + " window.addEventListener('load', function (event) { " + + "log('window at load capture', event.target) }, true)\n" + + " window.addEventListener('error', function (event) { log('window at error', event.target) })\n" + + " window.addEventListener('error', function (event) { " + + "log('window at error capture', event.target) }, true)\n" + + " window.addEventListener('DOMContentLoaded', function (event) { " + + "log('window DOMContentLoaded', event.target) })\n" - + " document.addEventListener('load', function () { log('document at load') })\n" - + " document.addEventListener('load', function () { log('document at load capture') }, true)\n" - + " document.addEventListener('error', function () { log('document at error') })\n" - + " document.addEventListener('error', function () { log('document at error capture') }, true)\n" - + " document.addEventListener('DOMContentLoaded', function () { log('document DOMContentLoaded') })\n" + + " document.addEventListener('load', function (event) { log('document at load', event.target) })\n" + + " document.addEventListener('load', function (event) { " + + "log('document at load capture', event.target) }, true)\n" + + " document.addEventListener('error', function (event) { log('document at error', event.target) })\n" + + " document.addEventListener('error', function (event) { " + + "log('document at error capture', event.target) }, true)\n" + + " document.addEventListener('DOMContentLoaded', function (event) { " + + "log('document DOMContentLoaded', event.target) })\n" + "</script>\n" + "</head>\n" - + "<body onload='log(\"body onload\")'>\n" - + " <img src='" + urlImage + "' onload='log(\"element 1 onload\")' " - + "onerror='log(\"element 1 onerror\")'>\n" - + " <img src='' onload='log(\"element 2 onload\")' " - + "onerror='log(\"element 2 onerror\")'>\n" + + "<body onload='log(\"body onload\", document)'>\n" + + " <img id='img1' src='" + urlImage + "' onload='log(\"element 1 onload\", this)' " + + "onerror='log(\"element 1 onerror\", this)'>\n" + + " <img id='img2' src='' onload='log(\"element 2 onload\", this)' " + + "onerror='log(\"element 2 onerror\", this)'>\n" + "</body></html>"; + // Image loads are usually asynchronous in browsers and ordering of these results are somewhat coincidental. + // + // Chrome/FF/Edge appears be synchronizing 'body.onload' so that it comes after all image loads, while Chrome + // alone also seems to be synchronizing 'DOMContentLoaded' so that it fires before image loads. IE11 is a mess + // with no clear synchronization between 'body.onload' and image loads. + // + // To preserve a semblance of sanity, we're sorting the results because this test isn't concerned with the + // ordering of img1 vs img2 vs #document (or even images vs 'body.onload'), and instead are only concerned + // the events propagate in correct order once triggered. + final Comparator<String> sorter = Comparator.comparing(s -> StringUtils.substringBefore(s, ":")); + final WebDriver driver = loadPage2(html); Thread.sleep(200); - final String text = driver.getTitle().trim().replaceAll(";", "\n").trim(); - assertEquals(String.join("\n", getExpectedAlerts()), text); + final String text = Pattern.compile(";").splitAsStream(driver.getTitle()) + .map(String::trim).sorted(sorter).collect(Collectors.joining("\n")); + final String expected = Arrays.stream(getExpectedAlerts()).sorted(sorter).collect(Collectors.joining("\n")); + assertEquals(expected, text); } /** |
From: <rb...@us...> - 2018-08-24 17:12:14
|
Revision: 15542 http://sourceforge.net/p/htmlunit/code/15542 Author: rbri Date: 2018-08-24 17:12:10 +0000 (Fri, 24 Aug 2018) Log Message: ----------- nyi for now Modified Paths: -------------- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/Window3Test.java Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/Window3Test.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/Window3Test.java 2018-08-24 17:08:01 UTC (rev 15541) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/Window3Test.java 2018-08-24 17:12:10 UTC (rev 15542) @@ -1622,6 +1622,7 @@ "document at load 1 capture", "document at load 2 capture", "after"}) + @NotYetImplemented(IE) // The extra 'document at load' from <script> not yet handled (waiting on onloadScript()) public void onload() throws Exception { final String html = HtmlPageTest.STANDARDS_MODE_PREFIX_ + "<html><head>\n" @@ -1719,6 +1720,7 @@ "window at load capture", "body onload", "document at load capture"}) + @NotYetImplemented public void onloadScript() throws Exception { getMockWebConnection().setResponse(URL_SECOND, ""); @@ -1895,6 +1897,7 @@ "document at load 1 capture", "document at load 2 capture", "after"}) + @NotYetImplemented(IE) // The extra 'document at load' from <script> not yet handled (waiting on onloadScript()) public void onloadFrame() throws Exception { final String content = HtmlPageTest.STANDARDS_MODE_PREFIX_ + "<html><head>\n" |
From: <rb...@us...> - 2018-08-24 17:08:03
|
Revision: 15541 http://sourceforge.net/p/htmlunit/code/15541 Author: rbri Date: 2018-08-24 17:08:01 +0000 (Fri, 24 Aug 2018) Log Message: ----------- test fix Modified Paths: -------------- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/event/BeforeUnloadEvent2Test.java Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/event/BeforeUnloadEvent2Test.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/event/BeforeUnloadEvent2Test.java 2018-08-24 16:53:34 UTC (rev 15540) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/event/BeforeUnloadEvent2Test.java 2018-08-24 17:08:01 UTC (rev 15541) @@ -116,8 +116,7 @@ * @throws Exception if the test fails */ @Test - @Alerts(DEFAULT = "First", - IE = "Second") + @Alerts("First") public void setNullReturnString() throws Exception { onbeforeunload("e.returnValue = null;\n" + "return 'Hello'"); |
From: <rb...@us...> - 2018-08-24 16:53:38
|
Revision: 15540 http://sourceforge.net/p/htmlunit/code/15540 Author: rbri Date: 2018-08-24 16:53:34 +0000 (Fri, 24 Aug 2018) Log Message: ----------- next step in event refactoring (wip) Modified Paths: -------------- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersion.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersionFeatures.java 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/EventListenersContainer.java Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersion.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersion.java 2018-08-23 13:38:51 UTC (rev 15539) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersion.java 2018-08-24 16:53:34 UTC (rev 15540) @@ -210,8 +210,8 @@ EDGE.scriptAcceptHeader_ = "application/javascript, */*;q=0.8"; // CHROME - CHROME.applicationVersion_ = "5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.75 Safari/537.36"; - CHROME.userAgent_ = "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.75 Safari/537.36"; + CHROME.applicationVersion_ = "5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36"; + CHROME.userAgent_ = "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36"; CHROME.applicationCodeName_ = "Mozilla"; CHROME.vendor_ = "Google Inc."; Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersionFeatures.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersionFeatures.java 2018-08-23 13:38:51 UTC (rev 15539) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersionFeatures.java 2018-08-24 16:53:34 UTC (rev 15540) @@ -154,9 +154,9 @@ @BrowserFeature(IE) DOM_NORMALIZE_REMOVE_CHILDREN, - /** Indicates handler return value is only used if returnValue is the default value. */ + /** Indicates whether returnValue behaves HTML5-like with an empty string default. */ @BrowserFeature({CHROME, FF}) - EVENT_BEFORE_UNLOAD_USES_HANDLER_RETURN_ONLY_IF_FIRST, + EVENT_BEFORE_UNLOAD_RETURN_VALUE_IS_HTML5_LIKE, /** Triggers the onfocus onfocusin blur onfocusout events in this order. */ @BrowserFeature(CHROME) @@ -166,6 +166,10 @@ @BrowserFeature(IE) EVENT_FOCUS_IN_FOCUS_OUT_BLUR, + /** Indicates whether returning 'null' from a property handler is meaningful. */ + @BrowserFeature(IE) + EVENT_HANDLER_NULL_RETURN_IS_MEANINGFUL, + /** Mouse events are triggered on disabled elements also. */ @BrowserFeature(FF) EVENT_MOUSE_ON_DISABLED, 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-23 13:38:51 UTC (rev 15539) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlPage.java 2018-08-24 16:53:34 UTC (rev 15540) @@ -98,6 +98,7 @@ import net.sourceforge.htmlunit.corejs.javascript.Script; import net.sourceforge.htmlunit.corejs.javascript.Scriptable; import net.sourceforge.htmlunit.corejs.javascript.ScriptableObject; +import net.sourceforge.htmlunit.corejs.javascript.Undefined; /** * A representation of an HTML page returned from a server. @@ -908,7 +909,7 @@ */ public ScriptResult executeJavaScript(String sourceCode, final String sourceName, final int startLine) { if (!getWebClient().getOptions().isJavaScriptEnabled()) { - return new ScriptResult(null, this); + return new ScriptResult(Undefined.instance, this); } if (StringUtils.startsWithIgnoreCase(sourceCode, JavaScriptURLConnection.JAVASCRIPT_PREFIX)) { 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-23 13:38:51 UTC (rev 15539) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/event/BeforeUnloadEvent.java 2018-08-24 16:53:34 UTC (rev 15540) @@ -14,7 +14,8 @@ */ package com.gargoylesoftware.htmlunit.javascript.host.event; -import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.EVENT_BEFORE_UNLOAD_USES_HANDLER_RETURN_ONLY_IF_FIRST; +import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.EVENT_BEFORE_UNLOAD_RETURN_VALUE_IS_HTML5_LIKE; +import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.EVENT_HANDLER_NULL_RETURN_IS_MEANINGFUL; 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; @@ -79,7 +80,9 @@ } private static Object getReturnValueDefault(final BrowserVersion browserVersion) { - if (browserVersion.isChrome() || browserVersion.isFirefox()) { + if (browserVersion.hasFeature(EVENT_BEFORE_UNLOAD_RETURN_VALUE_IS_HTML5_LIKE)) { + // Empty string default is specified by HTML5 + // https://www.w3.org/TR/html5/browsers.html#the-beforeunloadevent-interface return ""; } return Undefined.instance; @@ -115,8 +118,10 @@ final BrowserVersion browserVersion = getBrowserVersion(); - if (!Undefined.isUndefined(returnValue) && (returnValue != null || browserVersion.isIE())) { - if (!browserVersion.hasFeature(EVENT_BEFORE_UNLOAD_USES_HANDLER_RETURN_ONLY_IF_FIRST) + // Most browsers ignore null return values of property handlers + if (returnValue != null || browserVersion.hasFeature(EVENT_HANDLER_NULL_RETURN_IS_MEANINGFUL)) { + // Chrome/Firefox only accept the return value if returnValue is equal to default + if (!browserVersion.hasFeature(EVENT_BEFORE_UNLOAD_RETURN_VALUE_IS_HTML5_LIKE) || getReturnValueDefault(browserVersion).equals(getReturnValue())) { setReturnValue(returnValue); } Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/event/EventListenersContainer.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/event/EventListenersContainer.java 2018-08-23 13:38:51 UTC (rev 15539) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/event/EventListenersContainer.java 2018-08-24 16:53:34 UTC (rev 15540) @@ -344,8 +344,7 @@ final ScriptResult result = page.executeJavaScriptFunction(function, thisObject, args, node); // Return value is only honored for property handlers (Tested in Chrome/FF/IE11) - if (isPropertyHandler) { - allResult = result; + if (isPropertyHandler && !ScriptResult.isUndefined(result)) { event.handlePropertyHandlerReturnValue(result.getJavaScriptResult()); // This return value is now all but unused and can be refactored away |
From: <rb...@us...> - 2018-08-23 13:39:01
|
Revision: 15539 http://sourceforge.net/p/htmlunit/code/15539 Author: rbri Date: 2018-08-23 13:38:51 +0000 (Thu, 23 Aug 2018) Log Message: ----------- test fixes Modified Paths: -------------- trunk/htmlunit/src/changes/changes.xml trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/ExternalTest.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/TextEncoderTest.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/arrays/Float32ArrayTest.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/arrays/Float64ArrayTest.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/arrays/Int16ArrayTest.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/arrays/Int32ArrayTest.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/arrays/Int8ArrayTest.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/arrays/Uint16ArrayTest.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/arrays/Uint32ArrayTest.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/arrays/Uint8ArrayTest.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/arrays/Uint8ClampedArrayTest.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/crypto/CryptoTest.java Modified: trunk/htmlunit/src/changes/changes.xml =================================================================== --- trunk/htmlunit/src/changes/changes.xml 2018-08-23 07:21:40 UTC (rev 15538) +++ trunk/htmlunit/src/changes/changes.xml 2018-08-23 13:38:51 UTC (rev 15539) @@ -9,6 +9,9 @@ <body> <release version="2.33" date="xxxx, 2018" description="Bugfixes"> <action type="update" dev="rbri"> + We are using the typed array implementation from Rhino now, our own impl is gone. + </action> + <action type="update" dev="rbri"> Method Date.toUTCString() is available in Rhino; remove our own impl. </action> <action type="fix" dev="rbri" issue="1979" due-to="Atsushi Nakagawa"> Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/ExternalTest.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/ExternalTest.java 2018-08-23 07:21:40 UTC (rev 15538) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/ExternalTest.java 2018-08-23 13:38:51 UTC (rev 15539) @@ -54,7 +54,7 @@ /** Gecko driver. */ static String GECKO_DRIVER_ = "0.21.0"; /** IE driver. */ - static String IE_DRIVER_ = "3.13.0.0"; + static String IE_DRIVER_ = "3.14.0.0"; /** * Tests that POM dependencies are the latest. Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/TextEncoderTest.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/TextEncoderTest.java 2018-08-23 07:21:40 UTC (rev 15538) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/TextEncoderTest.java 2018-08-23 13:38:51 UTC (rev 15539) @@ -85,7 +85,7 @@ + "<body onload='doTest()'>\n" + "</body></html>"; - loadPageWithAlerts2(html, 7777777); + loadPageWithAlerts2(html); } /** Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/arrays/Float32ArrayTest.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/arrays/Float32ArrayTest.java 2018-08-23 07:21:40 UTC (rev 15538) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/arrays/Float32ArrayTest.java 2018-08-23 13:38:51 UTC (rev 15539) @@ -14,11 +14,15 @@ */ package com.gargoylesoftware.htmlunit.javascript.host.arrays; +import static com.gargoylesoftware.htmlunit.BrowserRunner.TestedBrowser.IE; + import org.junit.Test; import org.junit.runner.RunWith; import com.gargoylesoftware.htmlunit.BrowserRunner; import com.gargoylesoftware.htmlunit.BrowserRunner.Alerts; +import com.gargoylesoftware.htmlunit.BrowserRunner.NotYetImplemented; +import com.gargoylesoftware.htmlunit.BrowserRunner.TestedBrowser; import com.gargoylesoftware.htmlunit.WebDriverTestCase; /** @@ -161,9 +165,10 @@ * @throws Exception if the test fails */ @Test - @Alerts(DEFAULT = "exception", - CHROME = "0", - FF60 = "0") + @Alerts(DEFAULT = "0", + FF52 = "exception", + IE = "exception") + @NotYetImplemented({TestedBrowser.FF52, IE}) public void nullConstructor() throws Exception { final String html = "<html><head><title>foo</title><script>\n" @@ -185,7 +190,11 @@ * @throws Exception if the test fails */ @Test - @Alerts({"", "0", "1", "1,3", "1,3,4,7,11,0,123"}) + @Alerts(DEFAULT = {"", "0", "1", "1,3", "1,3,4,7,11,0,123"}, + IE = {"[object Float32Array]", "[object Float32Array]", + "[object Float32Array]", "[object Float32Array]", + "[object Float32Array]"}) + @NotYetImplemented(IE) public void asString() throws Exception { final String html = "<html><head><title>foo</title><script>\n" @@ -215,7 +224,9 @@ * @throws Exception if the test fails */ @Test - @Alerts("Float32Array") + @Alerts(DEFAULT = "Float32Array", + IE = "undefined") + @NotYetImplemented(IE) public void name() throws Exception { final String html = "<html><head><title>foo</title><script>\n" Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/arrays/Float64ArrayTest.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/arrays/Float64ArrayTest.java 2018-08-23 07:21:40 UTC (rev 15538) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/arrays/Float64ArrayTest.java 2018-08-23 13:38:51 UTC (rev 15539) @@ -14,11 +14,15 @@ */ package com.gargoylesoftware.htmlunit.javascript.host.arrays; +import static com.gargoylesoftware.htmlunit.BrowserRunner.TestedBrowser.FF52; +import static com.gargoylesoftware.htmlunit.BrowserRunner.TestedBrowser.IE; + import org.junit.Test; import org.junit.runner.RunWith; import com.gargoylesoftware.htmlunit.BrowserRunner; import com.gargoylesoftware.htmlunit.BrowserRunner.Alerts; +import com.gargoylesoftware.htmlunit.BrowserRunner.NotYetImplemented; import com.gargoylesoftware.htmlunit.WebDriverTestCase; /** @@ -161,9 +165,10 @@ * @throws Exception if the test fails */ @Test - @Alerts(DEFAULT = "exception", - CHROME = "0", - FF60 = "0") + @Alerts(DEFAULT = "0", + FF52 = "exception", + IE = "exception") + @NotYetImplemented({FF52, IE}) public void nullConstructor() throws Exception { final String html = "<html><head><title>foo</title><script>\n" @@ -185,7 +190,11 @@ * @throws Exception if the test fails */ @Test - @Alerts({"", "0", "1", "1,3", "1,3,4,7,11,0,123"}) + @Alerts(DEFAULT = {"", "0", "1", "1,3", "1,3,4,7,11,0,123"}, + IE = {"[object Float64Array]", "[object Float64Array]", + "[object Float64Array]", "[object Float64Array]", + "[object Float64Array]"}) + @NotYetImplemented(IE) public void asString() throws Exception { final String html = "<html><head><title>foo</title><script>\n" @@ -215,7 +224,9 @@ * @throws Exception if the test fails */ @Test - @Alerts("Float64Array") + @Alerts(DEFAULT = "Float64Array", + IE = "undefined") + @NotYetImplemented(IE) public void name() throws Exception { final String html = "<html><head><title>foo</title><script>\n" Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/arrays/Int16ArrayTest.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/arrays/Int16ArrayTest.java 2018-08-23 07:21:40 UTC (rev 15538) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/arrays/Int16ArrayTest.java 2018-08-23 13:38:51 UTC (rev 15539) @@ -14,11 +14,15 @@ */ package com.gargoylesoftware.htmlunit.javascript.host.arrays; +import static com.gargoylesoftware.htmlunit.BrowserRunner.TestedBrowser.FF52; +import static com.gargoylesoftware.htmlunit.BrowserRunner.TestedBrowser.IE; + import org.junit.Test; import org.junit.runner.RunWith; import com.gargoylesoftware.htmlunit.BrowserRunner; import com.gargoylesoftware.htmlunit.BrowserRunner.Alerts; +import com.gargoylesoftware.htmlunit.BrowserRunner.NotYetImplemented; import com.gargoylesoftware.htmlunit.WebDriverTestCase; /** @@ -255,9 +259,10 @@ * @throws Exception if the test fails */ @Test - @Alerts(DEFAULT = "exception", - CHROME = "0", - FF60 = "0") + @Alerts(DEFAULT = "0", + FF52 = "exception", + IE = "exception") + @NotYetImplemented({FF52, IE}) public void nullConstructor() throws Exception { final String html = "<html><head><title>foo</title><script>\n" @@ -279,7 +284,11 @@ * @throws Exception if the test fails */ @Test - @Alerts({"", "0", "1", "1,3", "1,3,4,7,11,0,123"}) + @Alerts(DEFAULT = {"", "0", "1", "1,3", "1,3,4,7,11,0,123"}, + IE = {"[object Int16Array]", "[object Int16Array]", + "[object Int16Array]", "[object Int16Array]", + "[object Int16Array]"}) + @NotYetImplemented(IE) public void asString() throws Exception { final String html = "<html><head><title>foo</title><script>\n" @@ -309,7 +318,9 @@ * @throws Exception if the test fails */ @Test - @Alerts("Int16Array") + @Alerts(DEFAULT = "Int16Array", + IE = "undefined") + @NotYetImplemented(IE) public void name() throws Exception { final String html = "<html><head><title>foo</title><script>\n" Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/arrays/Int32ArrayTest.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/arrays/Int32ArrayTest.java 2018-08-23 07:21:40 UTC (rev 15538) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/arrays/Int32ArrayTest.java 2018-08-23 13:38:51 UTC (rev 15539) @@ -14,11 +14,15 @@ */ package com.gargoylesoftware.htmlunit.javascript.host.arrays; +import static com.gargoylesoftware.htmlunit.BrowserRunner.TestedBrowser.FF52; +import static com.gargoylesoftware.htmlunit.BrowserRunner.TestedBrowser.IE; + import org.junit.Test; import org.junit.runner.RunWith; import com.gargoylesoftware.htmlunit.BrowserRunner; import com.gargoylesoftware.htmlunit.BrowserRunner.Alerts; +import com.gargoylesoftware.htmlunit.BrowserRunner.NotYetImplemented; import com.gargoylesoftware.htmlunit.WebDriverTestCase; /** @@ -161,9 +165,10 @@ * @throws Exception if the test fails */ @Test - @Alerts(DEFAULT = "exception", - CHROME = "0", - FF60 = "0") + @Alerts(DEFAULT = "0", + FF52 = "exception", + IE = "exception") + @NotYetImplemented({FF52, IE}) public void nullConstructor() throws Exception { final String html = "<html><head><title>foo</title><script>\n" @@ -185,7 +190,11 @@ * @throws Exception if the test fails */ @Test - @Alerts({"", "0", "1", "1,3", "1,3,4,7,11,0,123"}) + @Alerts(DEFAULT = {"", "0", "1", "1,3", "1,3,4,7,11,0,123"}, + IE = {"[object Int32Array]", "[object Int32Array]", + "[object Int32Array]", "[object Int32Array]", + "[object Int32Array]"}) + @NotYetImplemented(IE) public void asString() throws Exception { final String html = "<html><head><title>foo</title><script>\n" @@ -215,7 +224,9 @@ * @throws Exception if the test fails */ @Test - @Alerts("Int32Array") + @Alerts(DEFAULT = "Int32Array", + IE = "undefined") + @NotYetImplemented(IE) public void name() throws Exception { final String html = "<html><head><title>foo</title><script>\n" Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/arrays/Int8ArrayTest.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/arrays/Int8ArrayTest.java 2018-08-23 07:21:40 UTC (rev 15538) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/arrays/Int8ArrayTest.java 2018-08-23 13:38:51 UTC (rev 15539) @@ -14,11 +14,15 @@ */ package com.gargoylesoftware.htmlunit.javascript.host.arrays; +import static com.gargoylesoftware.htmlunit.BrowserRunner.TestedBrowser.FF52; +import static com.gargoylesoftware.htmlunit.BrowserRunner.TestedBrowser.IE; + import org.junit.Test; import org.junit.runner.RunWith; import com.gargoylesoftware.htmlunit.BrowserRunner; import com.gargoylesoftware.htmlunit.BrowserRunner.Alerts; +import com.gargoylesoftware.htmlunit.BrowserRunner.NotYetImplemented; import com.gargoylesoftware.htmlunit.WebDriverTestCase; /** @@ -229,9 +233,10 @@ * @throws Exception if the test fails */ @Test - @Alerts(DEFAULT = "exception", - CHROME = "0", - FF60 = "0") + @Alerts(DEFAULT = "0", + FF52 = "exception", + IE = "exception") + @NotYetImplemented({FF52, IE}) public void nullConstructor() throws Exception { final String html = "<html><head><title>foo</title><script>\n" @@ -253,7 +258,11 @@ * @throws Exception if the test fails */ @Test - @Alerts({"", "0", "1", "1,3", "1,3,4,7,11,0,123"}) + @Alerts(DEFAULT = {"", "0", "1", "1,3", "1,3,4,7,11,0,123"}, + IE = {"[object Int8Array]", "[object Int8Array]", + "[object Int8Array]", "[object Int8Array]", + "[object Int8Array]"}) + @NotYetImplemented(IE) public void asString() throws Exception { final String html = "<html><head><title>foo</title><script>\n" @@ -283,7 +292,9 @@ * @throws Exception if the test fails */ @Test - @Alerts("Int8Array") + @Alerts(DEFAULT = "Int8Array", + IE = "undefined") + @NotYetImplemented(IE) public void name() throws Exception { final String html = "<html><head><title>foo</title><script>\n" Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/arrays/Uint16ArrayTest.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/arrays/Uint16ArrayTest.java 2018-08-23 07:21:40 UTC (rev 15538) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/arrays/Uint16ArrayTest.java 2018-08-23 13:38:51 UTC (rev 15539) @@ -14,11 +14,15 @@ */ package com.gargoylesoftware.htmlunit.javascript.host.arrays; +import static com.gargoylesoftware.htmlunit.BrowserRunner.TestedBrowser.FF52; +import static com.gargoylesoftware.htmlunit.BrowserRunner.TestedBrowser.IE; + import org.junit.Test; import org.junit.runner.RunWith; import com.gargoylesoftware.htmlunit.BrowserRunner; import com.gargoylesoftware.htmlunit.BrowserRunner.Alerts; +import com.gargoylesoftware.htmlunit.BrowserRunner.NotYetImplemented; import com.gargoylesoftware.htmlunit.WebDriverTestCase; /** @@ -162,9 +166,10 @@ * @throws Exception if the test fails */ @Test - @Alerts(DEFAULT = "exception", - CHROME = "0", - FF60 = "0") + @Alerts(DEFAULT = "0", + FF52 = "exception", + IE = "exception") + @NotYetImplemented({FF52, IE}) public void nullConstructor() throws Exception { final String html = "<html><head><title>foo</title><script>\n" @@ -186,7 +191,11 @@ * @throws Exception if the test fails */ @Test - @Alerts({"", "0", "1", "1,3", "1,3,4,7,11,0,123"}) + @Alerts(DEFAULT = {"", "0", "1", "1,3", "1,3,4,7,11,0,123"}, + IE = {"[object Uint16Array]", "[object Uint16Array]", + "[object Uint16Array]", "[object Uint16Array]", + "[object Uint16Array]"}) + @NotYetImplemented(IE) public void asString() throws Exception { final String html = "<html><head><title>foo</title><script>\n" @@ -216,7 +225,9 @@ * @throws Exception if the test fails */ @Test - @Alerts("Uint16Array") + @Alerts(DEFAULT = "Uint16Array", + IE = "undefined") + @NotYetImplemented(IE) public void name() throws Exception { final String html = "<html><head><title>foo</title><script>\n" Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/arrays/Uint32ArrayTest.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/arrays/Uint32ArrayTest.java 2018-08-23 07:21:40 UTC (rev 15538) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/arrays/Uint32ArrayTest.java 2018-08-23 13:38:51 UTC (rev 15539) @@ -14,11 +14,15 @@ */ package com.gargoylesoftware.htmlunit.javascript.host.arrays; +import static com.gargoylesoftware.htmlunit.BrowserRunner.TestedBrowser.FF52; +import static com.gargoylesoftware.htmlunit.BrowserRunner.TestedBrowser.IE; + import org.junit.Test; import org.junit.runner.RunWith; import com.gargoylesoftware.htmlunit.BrowserRunner; import com.gargoylesoftware.htmlunit.BrowserRunner.Alerts; +import com.gargoylesoftware.htmlunit.BrowserRunner.NotYetImplemented; import com.gargoylesoftware.htmlunit.WebDriverTestCase; /** @@ -183,9 +187,10 @@ * @throws Exception if the test fails */ @Test - @Alerts(DEFAULT = "exception", - CHROME = "0", - FF60 = "0") + @Alerts(DEFAULT = "0", + FF52 = "exception", + IE = "exception") + @NotYetImplemented({FF52, IE}) public void nullConstructor() throws Exception { final String html = "<html><head><title>foo</title><script>\n" @@ -207,7 +212,11 @@ * @throws Exception if the test fails */ @Test - @Alerts({"", "0", "1", "1,3", "1,3,4,7,11,0,123"}) + @Alerts(DEFAULT = {"", "0", "1", "1,3", "1,3,4,7,11,0,123"}, + IE = {"[object Uint32Array]", "[object Uint32Array]", + "[object Uint32Array]", "[object Uint32Array]", + "[object Uint32Array]"}) + @NotYetImplemented(IE) public void asString() throws Exception { final String html = "<html><head><title>foo</title><script>\n" @@ -237,7 +246,9 @@ * @throws Exception if the test fails */ @Test - @Alerts("Uint32Array") + @Alerts(DEFAULT = "Uint32Array", + IE = "undefined") + @NotYetImplemented(IE) public void name() throws Exception { final String html = "<html><head><title>foo</title><script>\n" Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/arrays/Uint8ArrayTest.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/arrays/Uint8ArrayTest.java 2018-08-23 07:21:40 UTC (rev 15538) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/arrays/Uint8ArrayTest.java 2018-08-23 13:38:51 UTC (rev 15539) @@ -14,11 +14,15 @@ */ package com.gargoylesoftware.htmlunit.javascript.host.arrays; +import static com.gargoylesoftware.htmlunit.BrowserRunner.TestedBrowser.IE; + import org.junit.Test; import org.junit.runner.RunWith; import com.gargoylesoftware.htmlunit.BrowserRunner; import com.gargoylesoftware.htmlunit.BrowserRunner.Alerts; +import com.gargoylesoftware.htmlunit.BrowserRunner.NotYetImplemented; +import com.gargoylesoftware.htmlunit.BrowserRunner.TestedBrowser; import com.gargoylesoftware.htmlunit.WebDriverTestCase; /** @@ -162,9 +166,10 @@ * @throws Exception if the test fails */ @Test - @Alerts(DEFAULT = "exception", - CHROME = "0", - FF60 = "0") + @Alerts(DEFAULT = "0", + FF52 = "exception", + IE = "exception") + @NotYetImplemented({TestedBrowser.FF52, IE}) public void nullConstructor() throws Exception { final String html = "<html><head><title>foo</title><script>\n" @@ -237,7 +242,11 @@ * @throws Exception if the test fails */ @Test - @Alerts({"", "0", "1", "1,3", "1,3,4,7,11,0,123"}) + @Alerts(DEFAULT = {"", "0", "1", "1,3", "1,3,4,7,11,0,123"}, + IE = {"[object Uint8Array]", "[object Uint8Array]", + "[object Uint8Array]", "[object Uint8Array]", + "[object Uint8Array]"}) + @NotYetImplemented(IE) public void asString() throws Exception { final String html = "<html><head><title>foo</title><script>\n" @@ -267,7 +276,9 @@ * @throws Exception if the test fails */ @Test - @Alerts("Uint8Array") + @Alerts(DEFAULT = "Uint8Array", + IE = "undefined") + @NotYetImplemented(IE) public void name() throws Exception { final String html = "<html><head><title>foo</title><script>\n" Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/arrays/Uint8ClampedArrayTest.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/arrays/Uint8ClampedArrayTest.java 2018-08-23 07:21:40 UTC (rev 15538) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/arrays/Uint8ClampedArrayTest.java 2018-08-23 13:38:51 UTC (rev 15539) @@ -14,11 +14,15 @@ */ package com.gargoylesoftware.htmlunit.javascript.host.arrays; +import static com.gargoylesoftware.htmlunit.BrowserRunner.TestedBrowser.FF52; +import static com.gargoylesoftware.htmlunit.BrowserRunner.TestedBrowser.IE; + import org.junit.Test; import org.junit.runner.RunWith; import com.gargoylesoftware.htmlunit.BrowserRunner; import com.gargoylesoftware.htmlunit.BrowserRunner.Alerts; +import com.gargoylesoftware.htmlunit.BrowserRunner.NotYetImplemented; import com.gargoylesoftware.htmlunit.WebDriverTestCase; /** @@ -163,9 +167,10 @@ * @throws Exception if the test fails */ @Test - @Alerts(DEFAULT = "exception", - CHROME = "0", - FF60 = "0") + @Alerts(DEFAULT = "0", + FF52 = "exception", + IE = "exception") + @NotYetImplemented({FF52, IE}) public void nullConstructor() throws Exception { final String html = "<html><head><title>foo</title><script>\n" @@ -187,7 +192,11 @@ * @throws Exception if the test fails */ @Test - @Alerts({"", "0", "1", "1,3", "1,3,4,7,11,0,123"}) + @Alerts(DEFAULT = {"", "0", "1", "1,3", "1,3,4,7,11,0,123"}, + IE = {"[object Uint8ClampedArray]", "[object Uint8ClampedArray]", + "[object Uint8ClampedArray]", "[object Uint8ClampedArray]", + "[object Uint8ClampedArray]"}) + @NotYetImplemented(IE) public void asString() throws Exception { final String html = "<html><head><title>foo</title><script>\n" @@ -217,7 +226,9 @@ * @throws Exception if the test fails */ @Test - @Alerts("Uint8ClampedArray") + @Alerts(DEFAULT = "Uint8ClampedArray", + IE = "undefined") + @NotYetImplemented(IE) public void name() throws Exception { final String html = "<html><head><title>foo</title><script>\n" Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/crypto/CryptoTest.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/crypto/CryptoTest.java 2018-08-23 07:21:40 UTC (rev 15538) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/crypto/CryptoTest.java 2018-08-23 13:38:51 UTC (rev 15539) @@ -35,7 +35,7 @@ */ @Test @Alerts(DEFAULT = {"true", "true", "true", "false", "false", "false"}, - IE = {"true", "exception"}) + IE = {"true", "true", "true", "exception"}) public void getRandomValues() throws Exception { final String html = "<html><head><script>\n" + "try {\n" @@ -51,7 +51,7 @@ + "catch(e) { alert('exception'); }\n" + "</script></head></html>"; - loadPageWithAlerts2(html, 777777); + loadPageWithAlerts2(html); } /** |
From: <rb...@us...> - 2018-08-23 07:21:44
|
Revision: 15538 http://sourceforge.net/p/htmlunit/code/15538 Author: rbri Date: 2018-08-23 07:21:40 +0000 (Thu, 23 Aug 2018) Log Message: ----------- switch to rhino for the typed arrays Modified Paths: -------------- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/Set.java Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/Set.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/Set.java 2018-08-23 07:21:10 UTC (rev 15537) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/Set.java 2018-08-23 07:21:40 UTC (rev 15538) @@ -26,7 +26,6 @@ import com.gargoylesoftware.htmlunit.javascript.configuration.JsxConstructor; import com.gargoylesoftware.htmlunit.javascript.configuration.JsxFunction; import com.gargoylesoftware.htmlunit.javascript.configuration.JsxGetter; -import com.gargoylesoftware.htmlunit.javascript.host.arrays.ArrayBufferViewBase; import net.sourceforge.htmlunit.corejs.javascript.Context; import net.sourceforge.htmlunit.corejs.javascript.Delegator; @@ -39,6 +38,7 @@ import net.sourceforge.htmlunit.corejs.javascript.SymbolKey; import net.sourceforge.htmlunit.corejs.javascript.SymbolScriptable; import net.sourceforge.htmlunit.corejs.javascript.Undefined; +import net.sourceforge.htmlunit.corejs.javascript.typedarrays.NativeTypedArrayView; /** * A JavaScript object for {@code Set}. @@ -82,9 +82,9 @@ return; } - if (iterable instanceof ArrayBufferViewBase) { - final ArrayBufferViewBase array = (ArrayBufferViewBase) iterable; - for (int i = 0; i < array.getLength(); i++) { + if (iterable instanceof NativeTypedArrayView) { + final NativeTypedArrayView<?> array = (NativeTypedArrayView<?>) iterable; + for (int i = 0; i < array.getByteLength() / array.getBytesPerElement(); i++) { add(ScriptableObject.getProperty(array, i)); } return; |
From: <rb...@us...> - 2018-08-23 07:21:24
|
Revision: 15537 http://sourceforge.net/p/htmlunit/code/15537 Author: rbri Date: 2018-08-23 07:21:10 +0000 (Thu, 23 Aug 2018) Log Message: ----------- switch to rhino for the typed arrays Modified Paths: -------------- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersionFeatures.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/configuration/JavaScriptConfiguration.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/TextDecoder.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/TextEncoder.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/WebSocket.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/canvas/ImageData.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/crypto/Crypto.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/file/FileReader.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/configuration/JavaScriptConfigurationTest.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/TextEncoderTest.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/crypto/CryptoTest.java Removed Paths: ------------- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/arrays/ArrayBuffer.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/arrays/ArrayBufferView.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/arrays/ArrayBufferViewBase.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/arrays/DataView.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/arrays/Float32Array.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/arrays/Float64Array.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/arrays/Int16Array.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/arrays/Int32Array.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/arrays/Int8Array.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/arrays/Uint16Array.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/arrays/Uint32Array.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/arrays/Uint8Array.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/arrays/Uint8ClampedArray.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/arrays/ArrayBuffer2Test.java Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersionFeatures.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersionFeatures.java 2018-08-21 05:38:42 UTC (rev 15536) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersionFeatures.java 2018-08-23 07:21:10 UTC (rev 15537) @@ -1363,10 +1363,6 @@ @BrowserFeature(IE) JS_TREEWALKER_FILTER_FUNCTION_ONLY, - /** Types arrays can be constructed with {@code null}. */ - @BrowserFeature({CHROME, FF60}) - JS_TYPED_ARRAYS_NULL, - /** Setting the property align to arbitrary values is allowed. */ @BrowserFeature({CHROME, FF}) JS_TYPE_ACCEPTS_ARBITRARY_VALUES, Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/configuration/JavaScriptConfiguration.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/configuration/JavaScriptConfiguration.java 2018-08-21 05:38:42 UTC (rev 15536) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/configuration/JavaScriptConfiguration.java 2018-08-23 07:21:10 UTC (rev 15537) @@ -81,19 +81,6 @@ import com.gargoylesoftware.htmlunit.javascript.host.Window; import com.gargoylesoftware.htmlunit.javascript.host.XPathExpression; import com.gargoylesoftware.htmlunit.javascript.host.webkitURL; -import com.gargoylesoftware.htmlunit.javascript.host.arrays.ArrayBuffer; -import com.gargoylesoftware.htmlunit.javascript.host.arrays.ArrayBufferView; -import com.gargoylesoftware.htmlunit.javascript.host.arrays.ArrayBufferViewBase; -import com.gargoylesoftware.htmlunit.javascript.host.arrays.DataView; -import com.gargoylesoftware.htmlunit.javascript.host.arrays.Float32Array; -import com.gargoylesoftware.htmlunit.javascript.host.arrays.Float64Array; -import com.gargoylesoftware.htmlunit.javascript.host.arrays.Int16Array; -import com.gargoylesoftware.htmlunit.javascript.host.arrays.Int32Array; -import com.gargoylesoftware.htmlunit.javascript.host.arrays.Int8Array; -import com.gargoylesoftware.htmlunit.javascript.host.arrays.Uint16Array; -import com.gargoylesoftware.htmlunit.javascript.host.arrays.Uint32Array; -import com.gargoylesoftware.htmlunit.javascript.host.arrays.Uint8Array; -import com.gargoylesoftware.htmlunit.javascript.host.arrays.Uint8ClampedArray; import com.gargoylesoftware.htmlunit.javascript.host.budget.BudgetService; import com.gargoylesoftware.htmlunit.javascript.host.canvas.CanvasCaptureMediaStream; import com.gargoylesoftware.htmlunit.javascript.host.canvas.CanvasCaptureMediaStreamTrack; @@ -614,14 +601,7 @@ WebSocket.class, WheelEvent.class, Window.class, Worker.class, XMLDocument.class, XMLHttpRequest.class, XMLHttpRequestEventTarget.class, XMLHttpRequestUpload.class, XMLSerializer.class, XPathEvaluator.class, XPathExpression.class, - XPathNSResolver.class, XPathResult.class, XSLTProcessor.class, - - // we will use the Rhino stuff as soon as possible - ArrayBuffer.class, ArrayBufferView.class, ArrayBufferViewBase.class, - DataView.class, - Float32Array.class, Float64Array.class, - Int16Array.class, Int32Array.class, Int8Array.class, - Uint16Array.class, Uint32Array.class, Uint8Array.class, Uint8ClampedArray.class + XPathNSResolver.class, XPathResult.class, XSLTProcessor.class }; /** Cache of browser versions and their corresponding JavaScript configurations. */ Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/TextDecoder.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/TextDecoder.java 2018-08-21 05:38:42 UTC (rev 15536) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/TextDecoder.java 2018-08-23 07:21:10 UTC (rev 15537) @@ -26,12 +26,12 @@ import com.gargoylesoftware.htmlunit.javascript.configuration.JsxConstructor; import com.gargoylesoftware.htmlunit.javascript.configuration.JsxFunction; import com.gargoylesoftware.htmlunit.javascript.configuration.JsxGetter; -import com.gargoylesoftware.htmlunit.javascript.host.arrays.ArrayBuffer; -import com.gargoylesoftware.htmlunit.javascript.host.arrays.ArrayBufferView; import net.sourceforge.htmlunit.corejs.javascript.Context; import net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime; import net.sourceforge.htmlunit.corejs.javascript.Undefined; +import net.sourceforge.htmlunit.corejs.javascript.typedarrays.NativeArrayBuffer; +import net.sourceforge.htmlunit.corejs.javascript.typedarrays.NativeArrayBufferView; /** * A JavaScript object for {@code TextDecoder}. @@ -388,16 +388,16 @@ return ""; } - ArrayBuffer arrayBuffer = null; - if (buffer instanceof ArrayBuffer) { - arrayBuffer = (ArrayBuffer) buffer; + NativeArrayBuffer arrayBuffer = null; + if (buffer instanceof NativeArrayBuffer) { + arrayBuffer = (NativeArrayBuffer) buffer; } - else if (buffer instanceof ArrayBufferView) { - arrayBuffer = ((ArrayBufferView) buffer).getBuffer(); + else if (buffer instanceof NativeArrayBufferView) { + arrayBuffer = ((NativeArrayBufferView) buffer).getBuffer(); } if (arrayBuffer != null) { - return new String(arrayBuffer.getBytes(), Charset.forName(encoding_)); + return new String(arrayBuffer.getBuffer(), Charset.forName(encoding_)); } throw ScriptRuntime.typeError("Argument 1 of TextDecoder.decode could not be" Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/TextEncoder.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/TextEncoder.java 2018-08-21 05:38:42 UTC (rev 15536) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/TextEncoder.java 2018-08-23 07:21:10 UTC (rev 15537) @@ -24,10 +24,12 @@ import com.gargoylesoftware.htmlunit.javascript.configuration.JsxConstructor; import com.gargoylesoftware.htmlunit.javascript.configuration.JsxFunction; import com.gargoylesoftware.htmlunit.javascript.configuration.JsxGetter; -import com.gargoylesoftware.htmlunit.javascript.host.arrays.Uint8Array; import net.sourceforge.htmlunit.corejs.javascript.Context; +import net.sourceforge.htmlunit.corejs.javascript.ScriptableObject; import net.sourceforge.htmlunit.corejs.javascript.Undefined; +import net.sourceforge.htmlunit.corejs.javascript.typedarrays.NativeArrayBuffer; +import net.sourceforge.htmlunit.corejs.javascript.typedarrays.NativeUint8Array; /** * A JavaScript object for {@code TextEncoder}. @@ -58,9 +60,12 @@ * @return returns a Uint8Array containing the text given encoded . */ @JsxFunction - public Uint8Array encode(final Object toEncode) { + public NativeUint8Array encode(final Object toEncode) { if (Undefined.instance == toEncode) { - return new Uint8Array(new byte[0], getWindow()); + final NativeUint8Array result = new NativeUint8Array(0); + result.setParentScope(getParentScope()); + result.setPrototype(ScriptableObject.getClassPrototype(getWindow(this), result.getClassName())); + return result; } final String txt; @@ -72,6 +77,13 @@ } final byte[] bytes = txt.getBytes(StandardCharsets.UTF_8); - return new Uint8Array(bytes, getWindow()); + + final NativeArrayBuffer arrayBuffer = new NativeArrayBuffer(bytes.length); + System.arraycopy(bytes, 0, arrayBuffer.getBuffer(), 0, bytes.length); + + final NativeUint8Array result = new NativeUint8Array(arrayBuffer, 0, bytes.length); + result.setParentScope(getParentScope()); + result.setPrototype(ScriptableObject.getClassPrototype(getWindow(this), result.getClassName())); + return result; } } Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/WebSocket.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/WebSocket.java 2018-08-21 05:38:42 UTC (rev 15536) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/WebSocket.java 2018-08-23 07:21:10 UTC (rev 15537) @@ -17,7 +17,6 @@ import java.io.IOException; import java.net.URI; import java.nio.ByteBuffer; -import java.util.Arrays; import java.util.concurrent.Future; import org.apache.commons.lang3.ArrayUtils; @@ -41,7 +40,6 @@ import com.gargoylesoftware.htmlunit.javascript.configuration.JsxFunction; import com.gargoylesoftware.htmlunit.javascript.configuration.JsxGetter; import com.gargoylesoftware.htmlunit.javascript.configuration.JsxSetter; -import com.gargoylesoftware.htmlunit.javascript.host.arrays.ArrayBuffer; import com.gargoylesoftware.htmlunit.javascript.host.event.CloseEvent; import com.gargoylesoftware.htmlunit.javascript.host.event.Event; import com.gargoylesoftware.htmlunit.javascript.host.event.EventTarget; @@ -51,7 +49,9 @@ import net.sourceforge.htmlunit.corejs.javascript.Function; 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; +import net.sourceforge.htmlunit.corejs.javascript.typedarrays.NativeArrayBuffer; /** * A JavaScript object for {@code WebSocket}. @@ -391,8 +391,8 @@ if (content instanceof String) { outgoingSession_.getRemote().sendString((String) content); } - else if (content instanceof ArrayBuffer) { - final byte[] bytes = ((ArrayBuffer) content).getBytes(); + else if (content instanceof NativeArrayBuffer) { + final byte[] bytes = ((NativeArrayBuffer) content).getBuffer(); final ByteBuffer buffer = ByteBuffer.wrap(bytes); outgoingSession_.getRemote().sendBytes(buffer); } @@ -460,9 +460,10 @@ } super.onWebSocketBinary(data, offset, length); - final ArrayBuffer buffer = new ArrayBuffer(Arrays.copyOfRange(data, offset, length)); + final NativeArrayBuffer buffer = new NativeArrayBuffer(length); + System.arraycopy(data, offset, buffer.getBuffer(), 0, length); buffer.setParentScope(getParentScope()); - buffer.setPrototype(getPrototype(buffer.getClass())); + buffer.setPrototype(ScriptableObject.getClassPrototype(getWindow(), buffer.getClassName())); final MessageEvent msgEvent = new MessageEvent(buffer); msgEvent.setOrigin(getUrl()); Deleted: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/arrays/ArrayBuffer.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/arrays/ArrayBuffer.java 2018-08-21 05:38:42 UTC (rev 15536) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/arrays/ArrayBuffer.java 2018-08-23 07:21:10 UTC (rev 15537) @@ -1,148 +0,0 @@ -/* - * Copyright (c) 2002-2018 Gargoyle Software Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.gargoylesoftware.htmlunit.javascript.host.arrays; - -import com.gargoylesoftware.htmlunit.javascript.SimpleScriptable; -import com.gargoylesoftware.htmlunit.javascript.configuration.JsxClass; -import com.gargoylesoftware.htmlunit.javascript.configuration.JsxConstructor; -import com.gargoylesoftware.htmlunit.javascript.configuration.JsxFunction; -import com.gargoylesoftware.htmlunit.javascript.configuration.JsxGetter; - -import net.sourceforge.htmlunit.corejs.javascript.Context; -import net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime; -import net.sourceforge.htmlunit.corejs.javascript.Undefined; - -/** - * A data type that is used to represent a generic, fixed-length binary data buffer. - * - * @author Ahmed Ashour - * @author Frank Danek - * @author Ronald Brill - */ -@JsxClass -public class ArrayBuffer extends SimpleScriptable { - - private byte[] bytes_; - - /** - * Ctor. - */ - public ArrayBuffer() { - } - - /** - * Ctor with given bytes. - * @param bytes the initial bytes - */ - public ArrayBuffer(final byte[] bytes) { - bytes_ = bytes; - } - - /** - * The constructor. - * @param length the size, in bytes, of the array buffer to create. - */ - @JsxConstructor - public void constructor(final int length) { - if (length < 0) { - throw ScriptRuntime.rangeError("invalid array length '" + length + "'."); - } - bytes_ = new byte[length]; - } - - /** - * Returns the size, in bytes, of the array. This is established during construction and cannot be changed. - * @return the byte length. - */ - @JsxGetter - public int getByteLength() { - return bytes_.length; - } - - /** - * Returns a new ArrayBuffer whose contents are a copy of this ArrayBuffer's bytes - * from begin, inclusive, up to end, exclusive. - * @param begin byte index to start slicing - * @param end (optional) byte index to end slicing - * @return the newly created ArrayBuffer - */ - @JsxFunction - public ArrayBuffer slice(final Object begin, final Object end) { - if (begin == Undefined.instance || begin instanceof Boolean) { - throw Context.reportRuntimeError("Invalid type " + begin.getClass().getName()); - } - - final double beginNumber = Context.toNumber(begin); - final int beginInt; - if (Double.isNaN(beginNumber)) { - beginInt = 0; - } - else if (Double.isInfinite(beginNumber)) { - if (beginNumber > 0) { - final byte[] byteArray = new byte[0]; - return new ArrayBuffer(byteArray); - } - beginInt = 0; - } - else { - beginInt = (int) beginNumber; - if (beginInt != beginNumber) { - throw Context.reportRuntimeError("Invalid type " + begin.getClass().getName()); - } - } - - double endNumber; - if (end == Undefined.instance) { - endNumber = getByteLength(); - } - else { - endNumber = Context.toNumber(end); - } - - if (Double.isNaN(endNumber) || Double.isInfinite(endNumber) || endNumber < beginInt) { - endNumber = beginInt; - } - - final byte[] byteArray = new byte[(int) endNumber - beginInt]; - System.arraycopy(bytes_, beginInt, byteArray, 0, byteArray.length); - return new ArrayBuffer(byteArray); - } - - byte getByte(final int index) { - return bytes_[index]; - } - - /** - * Sets the bytes. - * @param index the starting index - * @param array the array - */ - public void setBytes(final int index, final byte[] array) { - int i = array.length - 1; - if (index + i >= bytes_.length) { - i = bytes_.length - index - 1; - } - for ( ; i >= 0; i--) { - bytes_[index + i] = array[i]; - } - } - - /** - * @return the bytes - */ - public byte[] getBytes() { - return bytes_; - } -} Deleted: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/arrays/ArrayBufferView.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/arrays/ArrayBufferView.java 2018-08-21 05:38:42 UTC (rev 15536) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/arrays/ArrayBufferView.java 2018-08-23 07:21:10 UTC (rev 15537) @@ -1,88 +0,0 @@ -/* - * Copyright (c) 2002-2018 Gargoyle Software Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.gargoylesoftware.htmlunit.javascript.host.arrays; - -import com.gargoylesoftware.htmlunit.javascript.SimpleScriptable; -import com.gargoylesoftware.htmlunit.javascript.configuration.JsxClass; -import com.gargoylesoftware.htmlunit.javascript.configuration.JsxGetter; - -/** - * The ArrayBufferView type describes a particular view on the contents of an {@link ArrayBuffer}'s data. - * - * @author Ahmed Ashour - * @author Frank Danek - */ -@JsxClass(isJSObject = false) -public class ArrayBufferView extends SimpleScriptable { - - private ArrayBuffer buffer_; - private int byteLength_; - private int byteOffset_; - - /** - * The constructor. - * @param buffer the array buffer - * @param byteOffset the byte offset - * @param length the length - */ - protected void constructor(final ArrayBuffer buffer, final int byteOffset, final int length) { - buffer_ = buffer; - byteOffset_ = byteOffset; - byteLength_ = length; - } - - /** - * Returns the buffer this view references. - * @return the buffer - */ - @JsxGetter - public ArrayBuffer getBuffer() { - return buffer_; - } - - /** - * Sets the buffer. - * @param buffer the buffer - */ - protected void setBuffer(final ArrayBuffer buffer) { - buffer_ = buffer; - } - - /** - * Returns the length, in bytes, of the view. - * @return the length - */ - @JsxGetter - public int getByteLength() { - return byteLength_; - } - - /** - * Sets the bytes length. - * @param byteLength the bytes length - */ - protected void setByteLength(final int byteLength) { - byteLength_ = byteLength; - } - - /** - * Returns the offset, in bytes, to the first byte of the view within the {@link ArrayBuffer}. - * @return the offset - */ - @JsxGetter - public int getByteOffset() { - return byteOffset_; - } -} Deleted: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/arrays/ArrayBufferViewBase.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/arrays/ArrayBufferViewBase.java 2018-08-21 05:38:42 UTC (rev 15536) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/arrays/ArrayBufferViewBase.java 2018-08-23 07:21:10 UTC (rev 15537) @@ -1,245 +0,0 @@ -/* - * Copyright (c) 2002-2018 Gargoyle Software Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.gargoylesoftware.htmlunit.javascript.host.arrays; - -import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.JS_TYPED_ARRAYS_NULL; - -import com.gargoylesoftware.htmlunit.javascript.configuration.JsxClass; -import com.gargoylesoftware.htmlunit.javascript.configuration.JsxFunction; -import com.gargoylesoftware.htmlunit.javascript.configuration.JsxGetter; - -import net.sourceforge.htmlunit.corejs.javascript.Context; -import net.sourceforge.htmlunit.corejs.javascript.NativeArray; -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; -import net.sourceforge.htmlunit.corejs.javascript.Wrapper; - -/** - * The parent class of all typed arrays, {@link DataView} is not included. - * - * @author Ahmed Ashour - * @author Marc Guillemot - * @author Frank Danek - * @author Ronald Brill - */ -@JsxClass(isJSObject = false) -public class ArrayBufferViewBase extends ArrayBufferView { - - /** - * The constructor. - * - * @param object the object - * @param byteOffset optional byteOffset - * @param length optional length - */ - public void constructor(final Object object, final Object byteOffset, final Object length) { - if (object instanceof Number) { - constructor(((Number) object).intValue()); - } - else if (object instanceof NativeArray) { - constructor((NativeArray) object); - } - else if (object instanceof ArrayBufferViewBase) { - constructor((ArrayBufferViewBase) object); - } - else if (object instanceof ArrayBuffer) { - final ArrayBuffer array = (ArrayBuffer) object; - - double dbByteOffset = Context.toNumber(byteOffset); - if (Double.isNaN(dbByteOffset)) { - dbByteOffset = 0; - } - - double dbLength = Context.toNumber(length); - if (Double.isNaN(dbLength)) { - dbLength = array.getByteLength(); - } - super.constructor(array, (int) dbByteOffset, (int) dbLength); - } - else if (object == Undefined.instance || getBrowserVersion().hasFeature(JS_TYPED_ARRAYS_NULL)) { - constructor(0); - } - else { - throw ScriptRuntime.typeError("invalid arguments"); - } - } - - private void constructor(final int length) { - final int byteLength = length * getBytesPerElement(); - setByteLength(byteLength); - initBuffer(byteLength); - } - - private void constructor(final NativeArray array) { - final int byteLength = (int) array.getLength() * getBytesPerElement(); - setByteLength(byteLength); - initBuffer(byteLength); - set(array, 0); - } - - private void constructor(final ArrayBufferViewBase array) { - final int byteLength = array.getLength() * getBytesPerElement(); - setByteLength(byteLength); - initBuffer(byteLength); - set(array, 0); - } - - private void initBuffer(final int lengthInBytes) { - final ArrayBuffer buffer = new ArrayBuffer(); - buffer.constructor(lengthInBytes); - buffer.setPrototype(getPrototype(buffer.getClass())); - buffer.setParentScope(getParentScope()); - setBuffer(buffer); - } - - /** - * Returns the number of entries in the array. - * @return the number of entries - */ - @JsxGetter - public int getLength() { - return getByteLength() / getBytesPerElement(); - } - - /** - * Sets multiple values in the typed array, reading input values from a specified array. - * @param sourceArray the source array - * @param offset the offset into the target array at which to begin writing values from the source one - */ - @JsxFunction - public void set(final ScriptableObject sourceArray, final int offset) { - final Object lengthProperty = ScriptableObject.getProperty(sourceArray, "length"); - if (lengthProperty instanceof Number) { - final int length = ((Number) lengthProperty).intValue(); - for (int i = 0; i < length; i++) { - final Object value = sourceArray.get(i, sourceArray); - if (value == Scriptable.NOT_FOUND || value == Undefined.instance) { - put(i + offset, this, Double.NaN); - } - else if (value == null) { - put(i + offset, this, 0); - } - else if (value instanceof Wrapper) { - put(i + offset, this, ((Wrapper) value).unwrap()); - } - else { - put(i + offset, this, value); - } - } - } - } - - /** - * {@inheritDoc} - */ - @Override - public Object get(final int index, final Scriptable start) { - final int offset = index * getBytesPerElement() + getByteOffset(); - final ArrayBuffer buffer = getBuffer(); - if (buffer == null) { - return Scriptable.NOT_FOUND; - } - return fromArray(buffer.getBytes(), offset); - } - - /** - * {@inheritDoc} - */ - @Override - public void put(final int index, final Scriptable start, final Object value) { - getBuffer().setBytes(index * getBytesPerElement() + getByteOffset(), - value == null ? toByteArray(null) : toByteArray(Context.toNumber(value))); - } - - /** - * Converts the provided number to byte array. - * @param number the number - * @return the byte array - */ - protected byte[] toByteArray(final Number number) { - return null; - } - - /** - * Converts the provided byte array to number. - * @param array the array - * @param offset the offset - * @return the byte array - */ - protected Object fromArray(final byte[] array, final int offset) { - return null; - } - - /** - * Returns a new view on the ArrayBuffer store for this object. - * @param begin the offset to the first element in the array to be referenced by the new object - * @param end the end offset (exclusive), optional to return at the end. - * @return the newly created array - */ - @JsxFunction - public ArrayBufferView subarray(final int begin, Object end) { - if (end == Undefined.instance) { - end = getLength(); - } - try { - final ArrayBufferView object = getClass().newInstance(); - object.setPrototype(getPrototype()); - object.setParentScope(getParentScope()); - object.constructor(getBuffer(), begin, ((Number) end).intValue() - begin); - return object; - } - catch (final Exception e) { - throw new RuntimeException(e); - } - } - - /** - * Returns the size in bytes of an item in this array. - * @return the size of bytes of an item - */ - protected int getBytesPerElement() { - return 1; - } - - /** - * @return the string version - */ - @JsxFunction(functionName = "toString") - public String jsToString() { - final int arrayLength = getLength(); - final StringBuilder builder = new StringBuilder(); - if (arrayLength > 0) { - builder.append(ScriptRuntime.toString(get(0, this))); - } - for (int i = 1; i < arrayLength; i++) { - builder.append(','); - builder.append(ScriptRuntime.toString(get(i, this))); - } - return builder.toString(); - } - - /** - * {@inheritDoc} - */ - @Override - public Object getDefaultValue(final Class<?> hint) { - if (String.class.equals(hint) || hint == null) { - return jsToString(); - } - return super.getDefaultValue(hint); - } -} Deleted: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/arrays/DataView.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/arrays/DataView.java 2018-08-21 05:38:42 UTC (rev 15536) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/arrays/DataView.java 2018-08-23 07:21:10 UTC (rev 15537) @@ -1,265 +0,0 @@ -/* - * Copyright (c) 2002-2018 Gargoyle Software Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.gargoylesoftware.htmlunit.javascript.host.arrays; - -import java.nio.ByteBuffer; -import java.nio.ByteOrder; - -import com.gargoylesoftware.htmlunit.javascript.configuration.JsxClass; -import com.gargoylesoftware.htmlunit.javascript.configuration.JsxConstructor; -import com.gargoylesoftware.htmlunit.javascript.configuration.JsxFunction; - -import net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime; -import net.sourceforge.htmlunit.corejs.javascript.Undefined; - -/** - * The ArrayBufferView type describes a particular view on the contents of an {@link ArrayBuffer}'s data. - * - * @author Ahmed Ashour - * @author Frank Danek - */ -@JsxClass -public class DataView extends ArrayBufferView { - - /** - * JavaScript constructor. - * @param array the array - * @param byteOffset the byte offset - * @param length the length - */ - @JsxConstructor - public void constructor(final Object array, final int byteOffset, Object length) { - if (!(array instanceof ArrayBuffer)) { - throw ScriptRuntime.typeError("First argument to DataView constructor must be an ArrayBuffer"); - } - if (length == Undefined.instance) { - length = ((ArrayBuffer) array).getByteLength(); - } - super.constructor((ArrayBuffer) array, byteOffset, ((Number) length).intValue()); - } - - /** - * Gets a signed 8-bit integer at the specified byte offset from the start of the view. - * @param byteOffset the byte offset - * @return the byte - */ - @JsxFunction - public byte getInt8(final int byteOffset) { - return getBuffer().getBytes()[getByteOffset() + byteOffset]; - } - - /** - * Sets the given signed 8-bit integer at the specified offset. - * @param byteOffset the byte offset - * @param value the value - */ - @JsxFunction - public void setInt8(final int byteOffset, final int value) { - final byte[] array = getBuffer().getBytes(); - array[getByteOffset() + byteOffset] = (byte) value; - } - - /** - * Gets a signed 16-bit integer at the specified byte offset from the start of the view. - * @param byteOffset the byte offset - * @param littleEndian whether the value is stored in little- or big-endian format - * @return the value - */ - @JsxFunction - public short getInt16(final int byteOffset, final boolean littleEndian) { - final ByteBuffer buff = ByteBuffer.wrap(getBuffer().getBytes()); - if (littleEndian) { - buff.order(ByteOrder.LITTLE_ENDIAN); - } - return buff.getShort(getByteOffset() + byteOffset); - } - - /** - * Sets the given signed 16-bit integer at the specified offset. - * @param byteOffset the byte offset - * @param value the value - * @param littleEndian whether the value is stored in little- or big-endian format - */ - @JsxFunction - public void setInt16(final int byteOffset, final int value, final boolean littleEndian) { - final ByteBuffer buff = ByteBuffer.wrap(getBuffer().getBytes()); - if (littleEndian) { - buff.order(ByteOrder.LITTLE_ENDIAN); - } - buff.putShort(getByteOffset() + byteOffset, (short) value); - } - - /** - * Gets a signed 32-bit integer at the specified byte offset from the start of the view. - * @param byteOffset the byte offset - * @param littleEndian whether the value is stored in little- or big-endian format - * @return the value - */ - @JsxFunction - public int getInt32(final int byteOffset, final boolean littleEndian) { - final ByteBuffer buff = ByteBuffer.wrap(getBuffer().getBytes()); - if (littleEndian) { - buff.order(ByteOrder.LITTLE_ENDIAN); - } - return buff.getInt(getByteOffset() + byteOffset); - } - - /** - * Sets the given signed 32-bit integer at the specified offset. - * @param byteOffset the byte offset - * @param value the value - * @param littleEndian whether the value is stored in little- or big-endian format - */ - @JsxFunction - public void setInt32(final int byteOffset, final int value, final boolean littleEndian) { - final ByteBuffer buff = ByteBuffer.wrap(getBuffer().getBytes()); - if (littleEndian) { - buff.order(ByteOrder.LITTLE_ENDIAN); - } - buff.putInt(getByteOffset() + byteOffset, value); - } - - /** - * Gets an unsigned 8-bit integer at the specified byte offset from the start of the view. - * @param byteOffset the byte offset - * @return the value - */ - @JsxFunction - public int getUint8(final int byteOffset) { - return getBuffer().getBytes()[getByteOffset() + byteOffset] & 0xFF; - } - - /** - * Sets the given unsigned 8-bit integer at the specified offset. - * @param byteOffset the byte offset - * @param value the value - */ - @JsxFunction - public void setUint8(final int byteOffset, final int value) { - setInt8(byteOffset, value); - } - - /** - * Gets an unsigned 16-bit integer at the specified byte offset from the start of the view. - * @param byteOffset the byte offset - * @param littleEndian whether the value is stored in little- or big-endian format - * @return the value - */ - @JsxFunction - public int getUint16(final int byteOffset, final boolean littleEndian) { - final ByteBuffer buff = ByteBuffer.wrap(getBuffer().getBytes()); - if (littleEndian) { - buff.order(ByteOrder.LITTLE_ENDIAN); - } - return buff.getShort(getByteOffset() + byteOffset) & 0xFFFF; - } - - /** - * Sets the given unsigned 16-bit integer at the specified offset. - * @param byteOffset the byte offset - * @param value the value - * @param littleEndian whether the value is stored in little- or big-endian format - */ - @JsxFunction - public void setUint16(final int byteOffset, final int value, final boolean littleEndian) { - setInt16(byteOffset, value, littleEndian); - } - - /** - * Gets an unsigned 32-bit integer at the specified byte offset from the start of the view. - * @param byteOffset the byte offset - * @param littleEndian whether the value is stored in little- or big-endian format - * @return the value - */ - @JsxFunction - public long getUint32(final int byteOffset, final boolean littleEndian) { - final ByteBuffer buff = ByteBuffer.wrap(getBuffer().getBytes()); - if (littleEndian) { - buff.order(ByteOrder.LITTLE_ENDIAN); - } - return buff.getInt(getByteOffset() + byteOffset) & 0xFFFFFFFFL; - } - - /** - * Sets the given unsigned 32-bit integer at the specified offset. - * @param byteOffset the byte offset - * @param value the value - * @param littleEndian whether the value is stored in little- or big-endian format - */ - @JsxFunction - public void setUint32(final int byteOffset, final int value, final boolean littleEndian) { - setInt32(byteOffset, value, littleEndian); - } - - /** - * Gets a 32-bit floating point number at the specified byte offset from the start of the view. - * @param byteOffset the byte offset - * @param littleEndian whether the value is stored in little- or big-endian format - * @return the value - */ - @JsxFunction - public float getFloat32(final int byteOffset, final boolean littleEndian) { - final ByteBuffer buff = ByteBuffer.wrap(getBuffer().getBytes()); - if (littleEndian) { - buff.order(ByteOrder.LITTLE_ENDIAN); - } - return buff.getFloat(getByteOffset() + byteOffset); - } - - /** - * Sets the given 32-bit floating point number at the specified offset. - * @param byteOffset the byte offset - * @param value the value - * @param littleEndian whether the value is stored in little- or big-endian format - */ - @JsxFunction - public void setFloat32(final int byteOffset, final double value, final boolean littleEndian) { - final ByteBuffer buff = ByteBuffer.wrap(getBuffer().getBytes()); - if (littleEndian) { - buff.order(ByteOrder.LITTLE_ENDIAN); - } - buff.putFloat(getByteOffset() + byteOffset, (float) value); - } - - /** - * Gets a 64-bit floating point number at the specified byte offset from the start of the view. - * @param byteOffset the byte offset - * @param littleEndian whether the value is stored in little- or big-endian format - * @return the value - */ - @JsxFunction - public double getFloat64(final int byteOffset, final boolean littleEndian) { - final ByteBuffer buff = ByteBuffer.wrap(getBuffer().getBytes()); - if (littleEndian) { - buff.order(ByteOrder.LITTLE_ENDIAN); - } - return buff.getDouble(getByteOffset() + byteOffset); - } - - /** - * Sets the given 32-bit floating point number at the specified offset. - * @param byteOffset the byte offset - * @param value the value - * @param littleEndian whether the value is stored in little- or big-endian format - */ - @JsxFunction - public void setFloat64(final int byteOffset, final double value, final boolean littleEndian) { - final ByteBuffer buff = ByteBuffer.wrap(getBuffer().getBytes()); - if (littleEndian) { - buff.order(ByteOrder.LITTLE_ENDIAN); - } - buff.putDouble(getByteOffset() + byteOffset, value); - } -} Deleted: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/arrays/Float32Array.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/arrays/Float32Array.java 2018-08-21 05:38:42 UTC (rev 15536) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/arrays/Float32Array.java 2018-08-23 07:21:10 UTC (rev 15537) @@ -1,82 +0,0 @@ -/* - * Copyright (c) 2002-2018 Gargoyle Software Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.gargoylesoftware.htmlunit.javascript.host.arrays; - -import java.nio.ByteBuffer; -import java.nio.ByteOrder; - -import com.gargoylesoftware.htmlunit.javascript.configuration.JsxClass; -import com.gargoylesoftware.htmlunit.javascript.configuration.JsxConstant; -import com.gargoylesoftware.htmlunit.javascript.configuration.JsxConstructor; - -import net.sourceforge.htmlunit.corejs.javascript.Scriptable; - -/** - * Represents an array of 32-bit floating point numbers. - * - * @author Ahmed Ashour - * @author Frank Danek - * @author Ronald Brill - * @author Michael Rimov - */ -@JsxClass -public class Float32Array extends ArrayBufferViewBase { - - /** The size, in bytes, of each array element. */ - @JsxConstant - public static final int BYTES_PER_ELEMENT = 4; - - /** - * {@inheritDoc} - */ - @Override - @JsxConstructor - public void constructor(final Object object, final Object byteOffset, final Object length) { - super.constructor(object, byteOffset, length); - } - - /** - * {@inheritDoc} - */ - @Override - protected byte[] toByteArray(final Number number) { - final ByteBuffer buff = ByteBuffer.allocate(BYTES_PER_ELEMENT); - buff.order(ByteOrder.LITTLE_ENDIAN); - buff.putFloat(number != null ? number.floatValue() : Float.NaN); - return buff.array(); - } - - /** - * {@inheritDoc} - */ - @Override - protected Object fromArray(final byte[] array, final int offset) { - if (offset < 0 || offset >= array.length) { - return Scriptable.NOT_FOUND; - } - final ByteBuffer buff = ByteBuffer.wrap(array); - buff.order(ByteOrder.LITTLE_ENDIAN); - return buff.getFloat(offset); - } - - /** - * {@inheritDoc} - */ - @Override - protected int getBytesPerElement() { - return BYTES_PER_ELEMENT; - } - -} Deleted: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/arrays/Float64Array.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/arrays/Float64Array.java 2018-08-21 05:38:42 UTC (rev 15536) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/arrays/Float64Array.java 2018-08-23 07:21:10 UTC (rev 15537) @@ -1,82 +0,0 @@ -/* - * Copyright (c) 2002-2018 Gargoyle Software Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.gargoylesoftware.htmlunit.javascript.host.arrays; - -import java.nio.ByteBuffer; -import java.nio.ByteOrder; - -import com.gargoylesoftware.htmlunit.javascript.configuration.JsxClass; -import com.gargoylesoftware.htmlunit.javascript.configuration.JsxConstant; -import com.gargoylesoftware.htmlunit.javascript.configuration.JsxConstructor; - -import net.sourceforge.htmlunit.corejs.javascript.Scriptable; - -/** - * Represents an array of 64-bit floating point numbers. - * - * @author Ahmed Ashour - * @author Frank Danek - * @author Ronald Brill - * @author Michael Rimov - */ -@JsxClass -public class Float64Array extends ArrayBufferViewBase { - - /** The size, in bytes, of each array element. */ - @JsxConstant - public static final int BYTES_PER_ELEMENT = 8; - - /** - * {@inheritDoc} - */ - @Override - @JsxConstructor - public void constructor(final Object object, final Object byteOffset, final Object length) { - super.constructor(object, byteOffset, length); - } - - /** - * {@inheritDoc} - */ - @Override - protected byte[] toByteArray(final Number number) { - final ByteBuffer buff = ByteBuffer.allocate(BYTES_PER_ELEMENT); - buff.order(ByteOrder.LITTLE_ENDIAN); - buff.putDouble(number != null ? number.doubleValue() : Double.NaN); - return buff.array(); - } - - /** - * {@inheritDoc} - */ - @Override - protected Object fromArray(final byte[] array, final int offset) { - if (offset < 0 || offset >= array.length) { - return Scriptable.NOT_FOUND; - } - final ByteBuffer buff = ByteBuffer.wrap(array); - buff.order(ByteOrder.LITTLE_ENDIAN); - return buff.getDouble(offset); - } - - /** - * {@inheritDoc} - */ - @Override - protected int getBytesPerElement() { - return BYTES_PER_ELEMENT; - } - -} Deleted: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/arrays/Int16Array.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/arrays/Int16Array.java 2018-08-21 05:38:42 UTC (rev 15536) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/arrays/Int16Array.java 2018-08-23 07:21:10 UTC (rev 15537) @@ -1,86 +0,0 @@ -/* - * Copyright (c) 2002-2018 Gargoyle Software Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.gargoylesoftware.htmlunit.javascript.host.arrays; - -import java.nio.ByteBuffer; -import java.nio.ByteOrder; - -import com.gargoylesoftware.htmlunit.javascript.configuration.JsxClass; -import com.gargoylesoftware.htmlunit.javascript.configuration.JsxConstant; -import com.gargoylesoftware.htmlunit.javascript.configuration.JsxConstructor; - -import net.sourceforge.htmlunit.corejs.javascript.Scriptable; - -/** - * Represents an array of twos-complement 16-bit signed integers. - * - * @author Ahmed Ashour - * @author Frank Danek - * @author Ronald Brill - * @author Michael Rimov - */ -@JsxClass -public class Int16Array extends ArrayBufferViewBase { - - /** The size, in bytes, of each array element. */ - @JsxConstant - public static final int BYTES_PER_ELEMENT = 2; - - /** - * {@inheritDoc} - */ - @Override - @JsxConstructor - public void constructor(final Object object, final Object byteOffset, final Object length) { - super.constructor(object, byteOffset, length); - } - - /** - * {@inheritDoc} - */ - @Override - protected byte[] toByteArray(final Number number) { - final ByteBuffer buff = ByteBuffer.allocate(BYTES_PER_ELEMENT); - buff.order(ByteOrder.LITTLE_ENDIAN); - if (number == null || Double.isInfinite(number.doubleValue())) { - buff.putShort((short) 0); - return buff.array(); - } - buff.putShort(number.shortValue()); - return buff.array(); - } - - /** - * {@inheritDoc} - */ - @Override - protected Object fromArray(final byte[] array, final int offset) { - if (offset < 0 || offset >= array.length) { - return Scriptable.NOT_FOUND; - } - final ByteBuffer buff = ByteBuffer.wrap(array); - buff.order(ByteOrder.LITTLE_ENDIAN); - return buff.getShort(offset); - } - - /** - * {@inheritDoc} - */ - @Override - protected int getBytesPerElement() { - return BYTES_PER_ELEMENT; - } - -} Deleted: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/arrays/Int32Array.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/arrays/Int32Array.java 2018-08-21 05:38:42 UTC (rev 15536) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/arrays/Int32Array.java 2018-08-23 07:21:10 UTC (rev 15537) @@ -1,86 +0,0 @@ -/* - * Copyright (c) 2002-2018 Gargoyle Software Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.gargoylesoftware.htmlunit.javascript.host.arrays; - -import java.nio.ByteBuffer; -import java.nio.ByteOrder; - -import com.gargoylesoftware.htmlunit.javascript.configuration.JsxClass; -import com.gargoylesoftware.htmlunit.javascript.configuration.JsxConstant; -import com.gargoylesoftware.htmlunit.javascript.configuration.JsxConstructor; - -import net.sourceforge.htmlunit.corejs.javascript.Scriptable; - -/** - * Represents an array of twos-complement 32-bit signed integers. - * - * @author Ahmed Ashour - * @author Frank Danek - * @author Ronald Brill - * @author Michael Rimov - */ -@JsxClass -public class Int32Array extends ArrayBufferViewBase { - - /** The size, in bytes, of each array element. */ - @JsxConstant - public static final int BYTES_PER_ELEMENT = 4; - - /** - * {@inheritDoc} - */ - @Override - @JsxConstructor - public void constructor(final Object object, final Object byteOffset, final Object length) { - super.constructor(object, byteOffset, length); - } - - /** - * {@inheritDoc} - */ - @Override - protected byte[] toByteArray(final Number number) { - final ByteBuffer buff = ByteBuffer.allocate(BYTES_PER_ELEMENT); - buff.order(ByteOrder.LITTLE_ENDIAN); - if (number == null || Double.isInfinite(number.doubleValue())) { - buff.putInt(0); - return buff.array(); - } - buff.putInt(number.intValue()); - return buff.array(); - } - - /** - * {@inheritDoc} - */ - @Override - protected Object fromArray(final byte[] array, final int offset) { - if (offset < 0 || offset >= array.length) { - return Scriptable.NOT_FOUND; - } - final ByteBuffer buff = ByteBuffer.wrap(array); - buff.order(ByteOrder.LITTLE_ENDIAN); - return buff.getInt(offset); - } - - /** - * {@inheritDoc} - */ - @Override - protected int getBytesPerElement() { - return BYTES_PER_ELEMENT; - } - -} Deleted: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/arrays/Int8Array.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/arrays/Int8Array.java 2018-08-21 05:38:42 UTC (rev 15536) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/arrays/Int8Array.java 2018-08-23 07:21:10 UTC (rev 15537) @@ -1,77 +0,0 @@ -/* - * Copyright (c) 2002-2018 Gargoyle Software Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.gargoylesoftware.htmlunit.javascript.host.arrays; - -import com.gargoylesoftware.htmlunit.javascript.configuration.JsxClass; -import com.gargoylesoftware.htmlunit.javascript.configuration.JsxConstant; -import com.gargoylesoftware.htmlunit.javascript.configuration.JsxConstructor; - -import net.sourceforge.htmlunit.corejs.javascript.Scriptable; - -/** - * Represents an array of twos-complement 8-bit signed integers. - * - * @author Ahmed Ashour - * @author Frank Danek - * @author Ronald Brill - * @author Michael Rimov - */ -@JsxClass -public class Int8Array extends ArrayBufferViewBase { - - /** The size, in bytes, of each array element. */ - @JsxConstant - public static final int BYTES_PER_ELEMENT = 1; - - /** - * {@inheritDoc} - */ - @Override - @JsxConstructor - public void constructor(final Object object, final Object byteOffset, final Object length) { - super.constructor(object, byteOffset, length); - } - - /** - * {@inheritDoc} - */ - @Override - protected byte[] toByteArray(final Number number) { - if (number == null || Double.isInfinite(number.doubleValue())) { - return new byte[] {0}; - } - return new byte[] {number.byteValue()}; - } - - /** - * {@inheritDoc} - */ - @Override - protected Object fromArray(final byte[] array, final int offset) { - if (offset < 0 || offset >= array.length) { - return Scriptable.NOT_FOUND; - } - return array[offset]; - } - - /** - * {@inheritDoc} - */ - @Override - protected int getBytesPerElement() { - return BYTES_PER_ELEMENT; - } - -} Deleted: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/arrays/Uint16Array.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/arrays/Uint16Array.java 2018-08-21 05:38:42 UTC (rev 15536) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/arrays/Uint16Array.java 2018-08-23 07:21:10 UTC (rev 15537) @@ -1,86 +0,0 @@ -/* - * Copyright (c) 2002-2018 Gargoyle Software Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.gargoylesoftware.htmlunit.javascript.host.arrays; - -import java.nio.ByteBuffer; -import java.nio.ByteOrder; - -import com.gargoylesoftware.htmlunit.javascript.configuration.JsxClass; -import com.gargoylesoftware.htmlunit.javascript.configuration.JsxConstant; -import com.gargoylesoftware.htmlunit.javascript.configuration.JsxConstructor; - -import net.sourceforge.htmlunit.corejs.javascript.Scriptable; - -/** - * Represents an array of unsigned 16-bit integers. - * - * @author Ahmed Ashour - * @author Frank Danek - * @author Ronald Brill - * @author Michael Rimov - */ -@JsxClass -public class Uint16Array extends ArrayBufferViewBase { - - /** The size, in bytes, of each array element. */ - @JsxConstant - public static final int BYTES_PER_ELEMENT = 2; - - /** - * {@inheritDoc} - */ - @Override - @JsxConstructor - public void constructor(final Object object, final Object byteOffset, final Object length) { - super.constructor(object, byteOffset, length); - } - - /** - * {@inheritDoc} - */ - @Override - protected byte[] toByteArray(final Number number) { - final ByteBuffer buff = ByteBuffer.allocate(BYTES_PER_ELEMENT); - buff.order(ByteOrder.LITTLE_ENDIAN); - if (number == null || Double.isInfinite(number.doubleValue())) { - buff.putShort((short) 0); - return buff.array(); - } - buff.putShort(number.shortValue()); - return buff.array(); - } - - /** - * {@inheritDoc} - */ - @Override - protected Object fromArray(final byte[] array, final int offset) { - if (offset < 0 || offset >= array.length) { - return Scriptable.NOT_FOUND; - } - final ByteBuffer buff = ByteBuffer.wrap(array); - buff.order(ByteOrder.LITTLE_ENDIAN); - return buff.getShort(offset) & 0xFFFF; - } - - /** - * {@inheritDoc} - */ - @Override - protected int getBytesPerElement() { - return BYTES_PER_ELEMENT; - } - -} Deleted: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/arrays/Uint32Array.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/arrays/Uint32Array.java 2018-08-21 05:38:42 UTC (rev 15536) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/arrays/Uint32Array.java 2018-08-23 07:21:10 UTC (rev 15537) @@ -1,86 +0,0 @@ -/* - * Copyright (c) 2002-2018 Garg... [truncated message content] |
From: rbri <rb...@rb...> - 2018-08-22 18:06:35
|
Branch: refs/heads/master Home: https://github.com/HtmlUnit/htmlunit-rhino-fork Commit: 54a5442d9482288ba29da8f5abb0dcc9b3d4644e https://github.com/HtmlUnit/htmlunit-rhino-fork/commit/54a5442d9482288ba29da8f5abb0dcc9b3d4644e Author: Gregory Brail <gre...@go...> Date: 2018-08-17 (Fri, 17 Aug 2018) Changed paths: M src/org/mozilla/javascript/IdScriptableObject.java A testsrc/jstests/es6/prototype-symbols.js A testsrc/org/mozilla/javascript/tests/es6/PrototypeSymbolTest.java Log Message: ----------- Fix a problem with standard objects that have Symbols in their prototypes. This affects standard types that inherit from IdScriptableObject and have slots in their prototype with Symbol keys. For instance, Symbol.prototype[Symbol.toStringTag]. This came up while working on passing test262 tests for some new types. Commit: 66e8cfa06d2dc3591ced47b6298e1bb035d65180 https://github.com/HtmlUnit/htmlunit-rhino-fork/commit/66e8cfa06d2dc3591ced47b6298e1bb035d65180 Author: rbri <rb...@rb...> Date: 2018-08-22 (Wed, 22 Aug 2018) Changed paths: M src/org/mozilla/javascript/typedarrays/NativeTypedArrayView.java M testsrc/jstests/harmony/typed-array-ctor.js Log Message: ----------- fix native array constructor called with null and same for the setter Commit: c960cec357fc227f5d2b4bae279d01b98e467e54 https://github.com/HtmlUnit/htmlunit-rhino-fork/commit/c960cec357fc227f5d2b4bae279d01b98e467e54 Author: rbri <rb...@rb...> Date: 2018-08-22 (Wed, 22 Aug 2018) Changed paths: M src/org/mozilla/javascript/IdScriptableObject.java M src/org/mozilla/javascript/typedarrays/NativeTypedArrayView.java A testsrc/jstests/es6/prototype-symbols.js M testsrc/jstests/harmony/typed-array-ctor.js A testsrc/org/mozilla/javascript/tests/es6/PrototypeSymbolTest.java Log Message: ----------- Merge remote-tracking branch 'rhino/master' Compare: https://github.com/HtmlUnit/htmlunit-rhino-fork/compare/b3d450810da3...c960cec357fc **NOTE:** This service has been marked for deprecation: https://developer.github.com/changes/2018-04-25-github-services-deprecation/ Functionality will be removed from GitHub.com on January 31st, 2019. |
From: RBRi <rb...@us...> - 2018-08-21 05:40:19
|
Thanks, another simplification - looks like we are getting closer now. Will have a look at this faiing TypingTest next. --- ** [bugs:#1984] Reworking the JS Event listeners implementation** **Status:** accepted **Group:** Latest SVN **Created:** Tue Aug 14, 2018 01:38 PM UTC by Atsushi Nakagawa **Last Updated:** Tue Aug 21, 2018 03:05 AM UTC **Owner:** RBRi **Attachments:** - [EventListenersContainer.java](https://sourceforge.net/p/htmlunit/bugs/1984/attachment/EventListenersContainer.java) (16.9 kB; application/octet-stream) - [EventListenersContainer.java-2.32.txt](https://sourceforge.net/p/htmlunit/bugs/1984/attachment/EventListenersContainer.java-2.32.txt) (15.5 kB; text/plain) - [EventTarget.java](https://sourceforge.net/p/htmlunit/bugs/1984/attachment/EventTarget.java) (14.7 kB; application/octet-stream) - [EventTarget.java-2.32.txt](https://sourceforge.net/p/htmlunit/bugs/1984/attachment/EventTarget.java-2.32.txt) (13.4 kB; text/plain) ### Problem in brief Thorough testing has revealed event listeners in HtmlUnit are implemented quite liberally in a few places with regards to how they should work. It's somewhat surprising they're working so well in practice. This bug report attempts to address the problems and tackle at fixing them. Scope includes `xyz.addListenerEvent('foo', function () { ... })` listeners and `xyz.onfoo = function () { ... }` property handlers. ##### Problems noticed * Ordering of listeners called during the *at target* phase should honour the order in which the listeners were added, but does not. * Ordering of property handlers such as `window.onload` should honour the timing at which the property was set, with respect to other event listeners, but does not. * Events where `event.bubbles` is `false` should not have a *bubbling* phase, but does. * The load event for `Window`should only traverse `Window` but traverses `Window, Document` instead. * The load event for everything else should traverse from `Document` to all levels down to the element in question, but traverses the element in question only. (Every place using `EventTarget.executeEventLocally()` potentially applies to this and should probably be using the standard `EventTarget.fireEvent()` instead.) * The load event for the `<frame>` element should be treated like "everything else" above, but is not. (On the other hand, the `onload` property for `<body>` and `<frameset>` is correctly tied to `Window`.) * The propagation path of events should not be affected by changes to the DOM tree by intermediate listeners, and therefore the *bubbling* phase should always traverse the same nodes as the *capturing* phase only in reverse, but is and does not. * The return value of event listeners should be ignored (really? it looks that way.. maybe it was different in older IE) and only that of the property handler should be used, but is not. ### Test cases There are five tests which I'm putting in the comments because it's quite long. * `test_onload.html` * `test_frame.html` * `test_click.html` * `test_nested_click.html` * `test_event_return_value.html` These extra two I'm including but haven't fixed yet. They're limited to the load/error behaviour of `<script>` and `<img>` and require fixing up some implementation in `HtmlScript` and `HtmlImage`. * `test_script_onload.html` * `test_img_onload.html` ### Possible fix The fix spans three files: * `html/HtmlPage.java` * `javascript/host/event/EventListenersContainer.java` * `javascript/host/event/EventTarget.java` Changes to `HtmlPage` is the diff below. The changes for `EventListenersContainer.java` and `EventTarget.java` are rather extensive so I'm attaching the modified files along with their respective base versions suffixed with `-2.32.txt`. ```diff --- a/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlPage.java +++ b/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlPage.java @@ -86,15 +86,16 @@ import com.gargoylesoftware.htmlunit.javascript.PostponedAction; import com.gargoylesoftware.htmlunit.javascript.SimpleScriptable; import com.gargoylesoftware.htmlunit.javascript.host.Window; -import com.gargoylesoftware.htmlunit.javascript.host.dom.Node; import com.gargoylesoftware.htmlunit.javascript.host.event.BeforeUnloadEvent; import com.gargoylesoftware.htmlunit.javascript.host.event.Event; +import com.gargoylesoftware.htmlunit.javascript.host.event.EventTarget; import com.gargoylesoftware.htmlunit.javascript.host.html.HTMLDocument; import com.gargoylesoftware.htmlunit.protocol.javascript.JavaScriptURLConnection; import com.gargoylesoftware.htmlunit.util.EncodingSniffer; import com.gargoylesoftware.htmlunit.util.UrlUtils; import net.sourceforge.htmlunit.corejs.javascript.Context; +import net.sourceforge.htmlunit.corejs.javascript.ContextFactory; import net.sourceforge.htmlunit.corejs.javascript.Function; import net.sourceforge.htmlunit.corejs.javascript.Script; import net.sourceforge.htmlunit.corejs.javascript.Scriptable; @@ -1214,18 +1215,28 @@ private boolean executeEventHandlersIfNeeded(final String eventType) { // Execute the specified event on the document element. final WebWindow window = getEnclosingWindow(); if (window.getScriptableObject() instanceof Window) { - final DomElement element = getDocumentElement(); - if (element == null) { // happens for instance if document.documentElement has been removed from parent - return true; - } + // We need the 'Document' node for these load events but getDocumentElement() returns + // <html> (HtmlHtml) which is one below that. The 'Document' node is incidentally just + // us (HtmlPage). (Some tidbits at https://www.w3.org/TR/DOM-Level-3-Events/#event-flow) + final DomNode node = this; final Event event; if (eventType.equals(Event.TYPE_BEFORE_UNLOAD)) { - event = new BeforeUnloadEvent(element, eventType); + event = new BeforeUnloadEvent(node, eventType); } else { - event = new Event(element, eventType); + event = new Event(node, eventType); + } + + // This is the same as DomElement.fireEvent() and was copied + // here so it could be used with HtmlPage. + if (LOG.isDebugEnabled()) { + LOG.debug("Firing " + event); } - final ScriptResult result = element.fireEvent(event); + + final EventTarget jsNode = node.getScriptableObject(); + final ContextFactory cf = ((JavaScriptEngine) getWebClient().getJavaScriptEngine()).getContextFactory(); + final ScriptResult result = cf.call(cx -> jsNode.fireEvent(event)); + if (!isOnbeforeunloadAccepted(this, event, result)) { return false; } @@ -1253,7 +1264,12 @@ private boolean executeEventHandlersIfNeeded(final String eventType) { else { event = new Event(frame, eventType); } - final ScriptResult result = ((Node) frame.getScriptableObject()).executeEventLocally(event); + + // This fires the "load" event for the <frame> element which, like all non-window + // load events, propagates up to Document but not Window. The "load" event for + // <frameset> on the other hand, like that of <body>, is handled above where it is + // fired against Document and directed to Window. + final ScriptResult result = frame.fireEvent(event); if (!isOnbeforeunloadAccepted((HtmlPage) frame.getPage(), event, result)) { return false; } ``` --- Sent from sourceforge.net because htm...@li... is subscribed to https://sourceforge.net/p/htmlunit/bugs/ To unsubscribe from further messages, a project admin can change settings at https://sourceforge.net/p/htmlunit/admin/bugs/options. Or, if this is a mailing list, you can unsubscribe from the mailing list. |
From: <rb...@us...> - 2018-08-21 05:38:45
|
Revision: 15536 http://sourceforge.net/p/htmlunit/code/15536 Author: rbri Date: 2018-08-21 05:38:42 +0000 (Tue, 21 Aug 2018) Log Message: ----------- simplify code Modified Paths: -------------- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/event/Event.java 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-20 18:22:32 UTC (rev 15535) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/event/Event.java 2018-08-21 05:38:42 UTC (rev 15536) @@ -180,7 +180,6 @@ private boolean stopPropagation_; private boolean stopImmediatePropagation_; private boolean preventDefault_; - private boolean returnValue_; /** * The current event phase. This is a W3C standard attribute. One of {@link #NONE}, @@ -229,7 +228,6 @@ target_ = target; currentTarget_ = target; type_ = type; - returnValue_ = true; setParentScope(target); setPrototype(getPrototype(getClass())); @@ -270,7 +268,6 @@ public void eventCreated() { setBubbles(false); setCancelable(false); - returnValue_ = true; } /** @@ -612,7 +609,6 @@ type_ = type; bubbles_ = bubbles; cancelable_ = cancelable; - returnValue_ = true; } /** @@ -667,7 +663,7 @@ */ @JsxGetter(CHROME) public Object getReturnValue() { - return returnValue_; + return !preventDefault_; } /** @@ -675,7 +671,6 @@ */ @JsxSetter(CHROME) public void setReturnValue(final Object newValue) { - returnValue_ = ScriptRuntime.toBoolean(newValue); - preventDefault_ = !returnValue_; + preventDefault_ = !ScriptRuntime.toBoolean(newValue); } } |
From: <rb...@us...> - 2018-08-20 18:22:38
|
Revision: 15535 http://sourceforge.net/p/htmlunit/code/15535 Author: rbri Date: 2018-08-20 18:22:32 +0000 (Mon, 20 Aug 2018) Log Message: ----------- updates Modified Paths: -------------- trunk/htmlunit/pom.xml trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersionFeatures.java Modified: trunk/htmlunit/pom.xml =================================================================== --- trunk/htmlunit/pom.xml 2018-08-20 18:12:06 UTC (rev 15534) +++ trunk/htmlunit/pom.xml 2018-08-20 18:22:32 UTC (rev 15535) @@ -18,10 +18,10 @@ <maven.build.timestamp.format>yyyy-MM-dd HH:mm</maven.build.timestamp.format> <additionalparam>-Xdoclint:none</additionalparam> <jetty.version>9.4.11.v20180605</jetty.version> - <selenium.version>3.13.0</selenium.version> - <htmlunitdriver.version>2.32.0</htmlunitdriver.version> + <selenium.version>3.14.0</selenium.version> + <htmlunitdriver.version>2.32.1</htmlunitdriver.version> <!-- As a property, as it is included in Checkstyle build --> - <checkstyle.version>8.11</checkstyle.version> + <checkstyle.version>8.12</checkstyle.version> </properties> <build> Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersionFeatures.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersionFeatures.java 2018-08-20 18:12:06 UTC (rev 15534) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersionFeatures.java 2018-08-20 18:22:32 UTC (rev 15535) @@ -234,10 +234,6 @@ @BrowserFeature(FF60) EVENT_ONPOPSTATE_DOCUMENT_CREATE_NOT_SUPPORTED, - /** Indicates if event.returnValue is backed by !event.defaultPrevented. */ - @BrowserFeature({CHROME, EDGE}) - EVENT_RETURN_VALUE_IS_PREVENT_DEFAULT, - /** Supports event type 'BeforeUnloadEvent'. */ @BrowserFeature({CHROME, FF}) EVENT_TYPE_BEFOREUNLOADEVENT, |
From: <rb...@us...> - 2018-08-20 18:12:09
|
Revision: 15534 http://sourceforge.net/p/htmlunit/code/15534 Author: rbri Date: 2018-08-20 18:12:06 +0000 (Mon, 20 Aug 2018) Log Message: ----------- fix test Modified Paths: -------------- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/event/EventTest.java Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/event/EventTest.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/event/EventTest.java 2018-08-20 17:57:58 UTC (rev 15533) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/event/EventTest.java 2018-08-20 18:12:06 UTC (rev 15534) @@ -392,20 +392,20 @@ * @throws Exception if the test fails */ @Test - @Alerts(DEFAULT = "frame1", - CHROME = {}) + @Alerts("frame1") public void thisInEventHandler() throws Exception { final String html - = "<html><head></head>\n" + = "<html>\n" + "<body>\n" - + "<button name='button1' id='button1' onclick='alert(this.name)'>1</button>\n" - + "<iframe src='about:blank' name='frame1' id='frame1'></iframe>\n" - + "<script>\n" - + " var e = document.getElementById('frame1');\n" - + " e.onload = document.getElementById('button1').onclick;\n" - + "</script>\n" + + " <button name='button1' id='button1' onclick='alert(this.name)'>1</button>\n" + + " <iframe src='default' name='frame1' id='frame1'></iframe>\n" + + " <script>\n" + + " var e = document.getElementById('frame1');\n" + + " e.onload = document.getElementById('button1').onclick;\n" + + " </script>\n" + "</body></html>"; + getMockWebConnection().setDefaultResponse("<html><body></body></html>"); loadPageWithAlerts2(html); } @@ -413,8 +413,7 @@ * @throws Exception if the test fails */ @Test - @Alerts(DEFAULT = "called", - CHROME = {}) + @Alerts("called") public void iframeOnload() throws Exception { final String html = "<html><head>\n" @@ -425,7 +424,7 @@ + "</script>\n" + "</head>\n" + "<body>\n" - + "<iframe src='about:blank' name='frame1' id='frame1'></iframe>\n" + + "<iframe src='default' name='frame1' id='frame1'></iframe>\n" + "<script>\n" + " var e = document.getElementById('frame1');\n" + " e.onload = test;\n" @@ -432,6 +431,7 @@ + "</script>\n" + "</body></html>"; + getMockWebConnection().setDefaultResponse("<html><body></body></html>"); loadPageWithAlerts2(html); } @@ -506,7 +506,8 @@ @Test @Alerts("null") public void nullEventHandler() throws Exception { - final String html = "<html><head><title>foo</title><script>\n" + final String html = "<html><head>\n" + + "<script>\n" + " function test() {\n" + " var div = document.getElementById('myDiv');\n" + " alert(div.onclick);\n" |
From: <rb...@us...> - 2018-08-20 17:58:02
|
Revision: 15533 http://sourceforge.net/p/htmlunit/code/15533 Author: rbri Date: 2018-08-20 17:57:58 +0000 (Mon, 20 Aug 2018) Log Message: ----------- next step in event refactoring (wip) Modified Paths: -------------- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/event/Event.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/Window3Test.java 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-20 17:36:20 UTC (rev 15532) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/event/Event.java 2018-08-20 17:57:58 UTC (rev 15533) @@ -676,5 +676,6 @@ @JsxSetter(CHROME) public void setReturnValue(final Object newValue) { returnValue_ = ScriptRuntime.toBoolean(newValue); + preventDefault_ = !returnValue_; } } Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/Window3Test.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/Window3Test.java 2018-08-20 17:36:20 UTC (rev 15532) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/Window3Test.java 2018-08-20 17:57:58 UTC (rev 15533) @@ -2191,11 +2191,28 @@ * @throws Exception if the test fails */ @Test - @Alerts({"listener: stop propagation & return false", + @Alerts(DEFAULT = {"listener: stop propagation & return false", "FIRED a1", "listener: return true", "property: return false", - "listener: return true"}) + "listener: return true", + "listener: prevented=false returnValue: undefined -> false (false)", + "listener: prevented=false returnValue: false -> true (true)", + "listener: prevented=false returnValue: true -> preventDefault() (true)", + "property: prevented=true returnValue: true -> return true", + "listener: prevented=true returnValue: true -> x (x)", + "listener: prevented=true returnValue: x -> null (null)"}, + CHROME = {"listener: stop propagation & return false", + "FIRED a1", + "listener: return true", + "property: return false", + "listener: return true", + "listener: prevented=false returnValue: true -> false (false)", + "listener: prevented=true returnValue: false -> true (true)", + "listener: prevented=false returnValue: true -> preventDefault() (false)", + "property: prevented=true returnValue: false -> return true", + "listener: prevented=true returnValue: false -> x (true)", + "listener: prevented=false returnValue: true -> null (false)"}) public void stopPropagation() throws Exception { final String html = HtmlPageTest.STANDARDS_MODE_PREFIX_ + "<html><head>\n" @@ -2208,6 +2225,7 @@ + "<body>\n" + " <div><a id='a1' href='javascript:log(\"FIRED a1\")'>test: listener return false</a></div>\n" + " <div><a id='a2' href='javascript:log(\"FIRED a2\")'>test: property return false</a></div>\n" + + " <div><a id='a3' href='javascript:log(\"FIRED a3\")'>test: listener returnValue = false</a></div>\n" + " <textarea id='log' rows=40 cols=80></textarea>\n" @@ -2218,20 +2236,58 @@ + "log('listener: stop propagation & return false');" + "event.stopPropagation(); return false })\n" - // The only return value that matters is the value from the 'onclick' property. The 'return false' below - // prevents "href' being processed. - + " a2.addEventListener('click'," - + " function (event) { log('listener: return true'); event.stopPropagation(); return true })\n" - + " a2.onclick = function () { log('property: return false'); return false }\n" - + " a2.addEventListener('click', function (event) { log('listener: return true'); return true })\n" + // The only return value that matters is the value from the 'onclick' property. The 'return false' below + // prevents "href' being processed. + + " a2.addEventListener('click'," + + " function (event) { log('listener: return true'); event.stopPropagation(); return true })\n" + + " a2.onclick = function () { log('property: return false'); return false }\n" + + " a2.addEventListener('click', function (event) { log('listener: return true'); return true })\n" - // Uncommenting this causes a2 to fire because propagation is - // stopped before 'onclick' property is processed. - // Again, the 'return false' here is ineffective. - // The return values of non-property handlers are probably ignored. (tested in Chrome/FF) - //window.addEventListener("click", function (event) { - // log('window: stop propagation & return false'); - // event.stopPropagation(); return false }, true) + // Uncommenting this causes a2 to fire because propagation is + // stopped before 'onclick' property is processed. + // Again, the 'return false' here is ineffective. + // The return values of non-property handlers are probably ignored. (tested in Chrome/FF) + //window.addEventListener("click", function (event) { + // log('window: stop propagation & return false'); + // event.stopPropagation(); return false }, true) + + // In Chrome/Edge, this sets event.returnValue to 'false' + // which is synonymous with setting 'event.defaultPrevented' + // In FF/IE11, event.returnValue is settable but does not appear to be used for anything + + " a3.addEventListener('click', function (event) {" + + " var a = event.returnValue, p = event.defaultPrevented, b = false; event.returnValue = b;" + + " log('listener: prevented=' + p + ' returnValue: ' + a " + + "+ ' -> ' + b + ' (' + event.returnValue + ')') })\n" + // This shows it's possible to set event.returnValue back to 'true' from 'false' + + " a3.addEventListener('click', function (event) {" + + " var a = event.returnValue, p = event.defaultPrevented, b = true; event.returnValue = b;" + + " log('listener: prevented=' + p + ' returnValue: ' + a " + + "+ ' -> ' + b + ' (' + event.returnValue + ')') })\n" + // The value of event.returnValue is consistent across multiple listener calls of the same event + + " a3.addEventListener('click', function (event) {" + + " var a = event.returnValue, p = event.defaultPrevented, " + + "b = 'preventDefault()'; event.preventDefault();" + + " log('listener: prevented=' + p + ' returnValue: ' + a " + + "+ ' -> ' + b + ' (' + event.returnValue + ')') })\n" + // This shows a property handler returning 'true' will not change event.returnValue if it's already 'false' + + " a3.onclick = function (event) {" + + " var a = event.returnValue, p = event.defaultPrevented; b = true;" + + " log('property: prevented=' + p + ' returnValue: ' + a + ' -> return ' + b); return b }\n" + // Instead of returning 'true', the property handler can directly set + // event.returnValue to set it to 'true' from 'false' + //+ " a3.onclick = function (event) {" + //+ " var a = event.returnValue, p = event.defaultPrevented; b = true;" + //+ " log('property: prevented=' + p + ' returnValue: ' + a + ' -> true'); event.returnValue = b }\n" + // These shows setting event.returnValue cannot be set to a non-boolean + // value in Chrome/Edge but can in (FF/IE11) + + " a3.addEventListener('click', function (event) {" + + " var a = event.returnValue, p = event.defaultPrevented, b = 'x'; event.returnValue = b;" + + " log('listener: prevented=' + p + ' returnValue: ' + a " + + "+ ' -> ' + b + ' (' + event.returnValue + ')') })\n" + + " a3.addEventListener('click', function (event) {" + + " var a = event.returnValue, p = event.defaultPrevented, b = null; event.returnValue = b;" + + " log('listener: prevented=' + p + ' returnValue: ' + a " + + "+ ' -> ' + b + ' (' + event.returnValue + ')') })\n" + "</script>\n" + "</body></html>"; @@ -2238,6 +2294,7 @@ final WebDriver driver = loadPage2(html); driver.findElement(By.id("a1")).click(); driver.findElement(By.id("a2")).click(); + driver.findElement(By.id("a3")).click(); final String text = driver.getTitle().trim().replaceAll(";", "\n").trim(); assertEquals(String.join("\n", getExpectedAlerts()), text); |
From: <rb...@us...> - 2018-08-20 17:36:24
|
Revision: 15532 http://sourceforge.net/p/htmlunit/code/15532 Author: rbri Date: 2018-08-20 17:36:20 +0000 (Mon, 20 Aug 2018) Log Message: ----------- preventDefault is available in Chrome also Modified Paths: -------------- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/event/Event.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/event/EventTest.java 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-20 17:30:03 UTC (rev 15531) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/event/Event.java 2018-08-20 17:36:20 UTC (rev 15532) @@ -529,7 +529,7 @@ * called for this event. Otherwise this attribute must return {@code false}. * @return {@code true} if this event has been cancelled or not */ - @JsxGetter({FF, IE, EDGE}) + @JsxGetter public boolean isDefaultPrevented() { return cancelable_ && preventDefault_; } Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/event/EventTest.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/event/EventTest.java 2018-08-20 17:30:03 UTC (rev 15531) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/event/EventTest.java 2018-08-20 17:36:20 UTC (rev 15532) @@ -974,6 +974,27 @@ * @throws Exception if the test fails */ @Test + @Alerts({"false", "boolean"}) + public void defaultPrevented() throws Exception { + final String html = HtmlPageTest.STANDARDS_MODE_PREFIX_ + + "<html><head><title>foo</title><script>\n" + + " function test() {\n" + + " try {\n" + + " var event = document.createEvent('Event');\n" + + " alert(event.defaultPrevented);\n" + + " alert(typeof event.defaultPrevented);\n" + + " } catch (e) { alert('exception') }\n" + + " }\n" + + "</script></head><body onload='test()'>\n" + + "</body></html>"; + + loadPageWithAlerts2(html); + } + + /** + * @throws Exception if the test fails + */ + @Test @Alerts(DEFAULT = {"undefined", "undefined"}, CHROME = {"true", "boolean"}) public void returnValue() throws Exception { |
From: <rb...@us...> - 2018-08-20 17:30:09
|
Revision: 15531 http://sourceforge.net/p/htmlunit/code/15531 Author: rbri Date: 2018-08-20 17:30:03 +0000 (Mon, 20 Aug 2018) Log Message: ----------- next step in event refactoring (wip) Modified Paths: -------------- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/event/Event.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/Window3Test.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/event/EventTest.java 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-20 06:39:52 UTC (rev 15530) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/event/Event.java 2018-08-20 17:30:03 UTC (rev 15531) @@ -14,7 +14,6 @@ */ package com.gargoylesoftware.htmlunit.javascript.host.event; -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.javascript.configuration.SupportedBrowser.CHROME; import static com.gargoylesoftware.htmlunit.javascript.configuration.SupportedBrowser.EDGE; @@ -21,7 +20,6 @@ import static com.gargoylesoftware.htmlunit.javascript.configuration.SupportedBrowser.FF; import static com.gargoylesoftware.htmlunit.javascript.configuration.SupportedBrowser.IE; -import java.lang.reflect.Method; import java.util.LinkedList; import com.gargoylesoftware.htmlunit.ScriptResult; @@ -35,6 +33,7 @@ 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; @@ -181,6 +180,7 @@ private boolean stopPropagation_; private boolean stopImmediatePropagation_; private boolean preventDefault_; + private boolean returnValue_; /** * The current event phase. This is a W3C standard attribute. One of {@link #NONE}, @@ -229,6 +229,8 @@ target_ = target; currentTarget_ = target; type_ = type; + returnValue_ = true; + setParentScope(target); setPrototype(getPrototype(getClass())); @@ -268,6 +270,7 @@ public void eventCreated() { setBubbles(false); setCancelable(false); + returnValue_ = true; } /** @@ -609,17 +612,7 @@ type_ = type; bubbles_ = bubbles; cancelable_ = cancelable; - if (TYPE_BEFORE_UNLOAD.equals(type) && getBrowserVersion().hasFeature(EVENT_FOCUS_FOCUS_IN_BLUR_OUT)) { - try { - final Class<?> klass = getClass(); - final Method readMethod = klass.getMethod("getReturnValue"); - final Method writeMethod = klass.getMethod("setReturnValue", Object.class); - defineProperty("returnValue", null, readMethod, writeMethod, ScriptableObject.EMPTY); - } - catch (final Exception e) { - throw Context.throwAsScriptRuntimeEx(e); - } - } + returnValue_ = true; } /** @@ -668,4 +661,20 @@ public boolean processLabelAfterBubbling() { return false; } + + /** + * @return the return value property + */ + @JsxGetter(CHROME) + public Object getReturnValue() { + return returnValue_; + } + + /** + * @param newValue the new return value + */ + @JsxSetter(CHROME) + public void setReturnValue(final Object newValue) { + returnValue_ = ScriptRuntime.toBoolean(newValue); + } } Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/Window3Test.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/Window3Test.java 2018-08-20 06:39:52 UTC (rev 15530) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/Window3Test.java 2018-08-20 17:30:03 UTC (rev 15531) @@ -2164,7 +2164,7 @@ + " d1.addEventListener('click', function () { log('d1 at click 2 capture') }, true)\n" + " d2.addEventListener('click', function () { log('d2 at click 1') })\n" - + " d2.onclick = function () { log('d2 onclick'); d2.parentNode.removeChild(d2) }\n" + + " d2.onclick = function () { log('d2 onclick'); if (d2.parentNode) d2.parentNode.removeChild(d2) }\n" + " d2.addEventListener('click', function () { log('d2 at click 1 capture') }, true)\n" + " d2.addEventListener('click', function () { log('d2 at click 2') })\n" + " d2.addEventListener('click', function () { log('d2 at click 2 capture') }, true)\n" Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/event/EventTest.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/event/EventTest.java 2018-08-20 06:39:52 UTC (rev 15530) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/event/EventTest.java 2018-08-20 17:30:03 UTC (rev 15531) @@ -969,4 +969,72 @@ verifyAlerts(driver, getExpectedAlerts()); } + + /** + * @throws Exception if the test fails + */ + @Test + @Alerts(DEFAULT = {"undefined", "undefined"}, + CHROME = {"true", "boolean"}) + public void returnValue() throws Exception { + final String html = HtmlPageTest.STANDARDS_MODE_PREFIX_ + + "<html><head><title>foo</title><script>\n" + + " function test() {\n" + + " try {\n" + + " var event = document.createEvent('Event');\n" + + " alert(event.returnValue);\n" + + " alert(typeof event.returnValue);\n" + + " } catch (e) { alert('exception') }\n" + + " }\n" + + "</script></head><body onload='test()'>\n" + + "</body></html>"; + + loadPageWithAlerts2(html); + } + + /** + * @throws Exception if the test fails + */ + @Test + @Alerts(DEFAULT = {"undefined", "undefined", + "false", "boolean", + "undefined", "undefined", + "test", "string", + "0", "number"}, + CHROME = {"true", "boolean", + "false", "boolean", + "false", "boolean", + "true", "boolean", + "false", "boolean"}) + public void returnValueSetter() throws Exception { + final String html = HtmlPageTest.STANDARDS_MODE_PREFIX_ + + "<html><head><title>foo</title><script>\n" + + " function test() {\n" + + " try {\n" + + " var event = document.createEvent('Event');\n" + + " alert(event.returnValue);\n" + + " alert(typeof event.returnValue);\n" + + + " event.returnValue = false;\n" + + " alert(event.returnValue);\n" + + " alert(typeof event.returnValue);\n" + + + " event.returnValue = undefined;\n" + + " alert(event.returnValue);\n" + + " alert(typeof event.returnValue);\n" + + + " event.returnValue = 'test';\n" + + " alert(event.returnValue);\n" + + " alert(typeof event.returnValue);\n" + + + " event.returnValue = 0;\n" + + " alert(event.returnValue);\n" + + " alert(typeof event.returnValue);\n" + + " } catch (e) { alert('exception') }\n" + + " }\n" + + "</script></head><body onload='test()'>\n" + + "</body></html>"; + + loadPageWithAlerts2(html); + } } |
From: <rb...@us...> - 2018-08-20 06:41:51
|
Revision: 15530 http://sourceforge.net/p/htmlunit/code/15530 Author: rbri Date: 2018-08-20 06:39:52 +0000 (Mon, 20 Aug 2018) Log Message: ----------- next step in event refactoring (wip) Modified Paths: -------------- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/event/BeforeUnloadEvent.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/event/EventTarget.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/dom/Node2Test.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/dom/NodeTest.java 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:48:56 UTC (rev 15529) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/event/BeforeUnloadEvent.java 2018-08-20 06:39:52 UTC (rev 15530) @@ -117,7 +117,7 @@ if (!Undefined.isUndefined(returnValue) && (returnValue != null || browserVersion.isIE())) { if (!browserVersion.hasFeature(EVENT_BEFORE_UNLOAD_USES_HANDLER_RETURN_ONLY_IF_FIRST) - || !getReturnValueDefault(browserVersion).equals(getReturnValue())) { + || getReturnValueDefault(browserVersion).equals(getReturnValue())) { setReturnValue(returnValue); } } 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-17 19:48:56 UTC (rev 15529) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/event/EventTarget.java 2018-08-20 06:39:52 UTC (rev 15530) @@ -112,6 +112,16 @@ * @return the result */ public ScriptResult fireEvent(final Event event) { + fireEventImpl(event); + // This is deprecated but there're still a few places using ScriptResult.getNewPage() + return new ScriptResult(null, getWindow().getWebWindow().getWebClient().getCurrentWindow().getEnclosedPage()); + } + + /** + * Fires the event on the node with capturing and bubbling phase. + * @param event the event + */ + private void fireEventImpl(final Event event) { final Window window = getWindow(); final Object[] args = new Object[] {event}; @@ -161,7 +171,7 @@ final ScriptResult r = elc.executeCapturingListeners(event, args); result = ScriptResult.combine(r, result); if (event.isPropagationStopped()) { - return result; + return; } } } @@ -178,7 +188,7 @@ final ScriptResult r = elc.executeAtTargetListeners(event, args); result = ScriptResult.combine(r, result); if (event.isPropagationStopped()) { - return result; + return; } } } @@ -207,7 +217,7 @@ final ScriptResult r = elc.executeBubblingListeners(event, args); result = ScriptResult.combine(r, result); if (event.isPropagationStopped()) { - return result; + return; } } } @@ -230,8 +240,6 @@ event.endFire(); window.setCurrentEvent(previousEvent); // reset event } - - return result; } /** Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/dom/Node2Test.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/dom/Node2Test.java 2018-08-17 19:48:56 UTC (rev 15529) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/dom/Node2Test.java 2018-08-20 06:39:52 UTC (rev 15530) @@ -14,17 +14,10 @@ */ package com.gargoylesoftware.htmlunit.javascript.host.dom; -import java.net.URL; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -import org.apache.commons.lang3.ArrayUtils; import org.junit.Test; import org.junit.runner.RunWith; import com.gargoylesoftware.htmlunit.BrowserRunner; -import com.gargoylesoftware.htmlunit.BrowserRunner.Alerts; import com.gargoylesoftware.htmlunit.SimpleWebTestCase; import com.gargoylesoftware.htmlunit.html.HtmlPage; @@ -53,122 +46,9 @@ + " var b = document.getElementById('b');\n" + " a.replaceChild(b, b);\n" + "}\n" - + "</script></head><body onload='doTest()'><div id='a'><div id='b'/></div></html>"; + + "</script></head>\n" + + "<body onload='doTest()'><div id='a'><div id='b'/></div></html>"; final HtmlPage page = loadPageWithAlerts(html); assertNotNull(page.getHtmlElementById("b").getParentNode()); } - - /** - * @throws Exception if the test fails - */ - @Test - @Alerts({"1", "2"}) - public void eventListener() throws Exception { - final String html - = "<html><head>\n" - + "<script>\n" - + " function clicking1() {\n" - + " alert(1);\n" - + " }\n" - + " function clicking2() {\n" - + " alert(2);\n" - + " }\n" - + " function test() {\n" - + " var e = document.getElementById('myAnchor');\n" - + " e.addEventListener('click', clicking1, false);\n" - + " e.addEventListener('click', clicking2, false);\n" - + " }\n" - + "</script></head><body onload='test()'>\n" - + " <a href='" + URL_SECOND + "' id='myAnchor'>Click me</a>\n" - + "</body></html>"; - - final List<String> collectedAlerts = new ArrayList<>(); - final HtmlPage page = loadPage(html, collectedAlerts); - final HtmlPage page2 = page.getHtmlElementById("myAnchor").click(); - //IE doesn't have specific order - Collections.sort(collectedAlerts); - assertEquals(getExpectedAlerts(), collectedAlerts); - assertEquals(URL_SECOND.toExternalForm(), page2.getUrl().toExternalForm()); - } - - /** - * @throws Exception if the test fails - */ - @Test - @Alerts({"1", "2"}) - public void eventListener_return_false() throws Exception { - final String html - = "<html><head>\n" - + "<script>\n" - + " function clicking1() {\n" - + " alert(1);\n" - + " }\n" - + " function clicking2() {\n" - + " alert(2);\n" - + " return false;\n" - + " }\n" - + " function test() {\n" - + " var e = document.getElementById('myAnchor');\n" - + " e.addEventListener('click', clicking1, false);\n" - + " e.addEventListener('click', clicking2, false);\n" - + " }\n" - + "</script></head><body onload='test()'>\n" - + " <a href='" + URL_SECOND + "' id='myAnchor'>Click me</a>\n" - + "</body></html>"; - - final List<String> collectedAlerts = new ArrayList<>(); - final HtmlPage page = loadPage(html, collectedAlerts); - final HtmlPage page2 = page.getHtmlElementById("myAnchor").click(); - //IE doesn't have specific order - Collections.sort(collectedAlerts); - assertEquals(getExpectedAlerts(), collectedAlerts); - - final URL expectedURL; - if (getBrowserVersion().isIE()) { - expectedURL = URL_FIRST; - } - else { - expectedURL = URL_SECOND; - } - assertEquals(expectedURL.toExternalForm(), page2.getUrl().toExternalForm()); - } - - /** - * @throws Exception if the test fails - */ - @Test - @Alerts({"1", "2", "§§URL§§second/"}) - public void eventListener_returnValue_false() throws Exception { - final String html - = "<html><head>\n" - + "<script>\n" - + " function clicking1() {\n" - + " alert(1);\n" - + " }\n" - + " function clicking2() {\n" - + " alert(2);\n" - + " if (window.event)\n" - + " window.event.returnValue = false;\n" - + " }\n" - + " function test() {\n" - + " var e = document.getElementById('myAnchor');\n" - + " e.addEventListener('click', clicking1, false);\n" - + " e.addEventListener('click', clicking2, false);\n" - + " }\n" - + "</script></head><body onload='test()'>\n" - + " <a href='" + URL_SECOND + "' id='myAnchor'>Click me</a>\n" - + "</body></html>"; - - expandExpectedAlertsVariables(URL_FIRST); - - final List<String> collectedAlerts = new ArrayList<>(); - final HtmlPage page = loadPage(html, collectedAlerts); - final HtmlPage page2 = page.getHtmlElementById("myAnchor").click(); - //IE doesn't have specific order - Collections.sort(collectedAlerts); - assertEquals(ArrayUtils.subarray(getExpectedAlerts(), 0, 2), collectedAlerts); - - assertEquals(getExpectedAlerts()[2], page2.getUrl().toExternalForm()); - } - } Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/dom/NodeTest.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/dom/NodeTest.java 2018-08-17 19:48:56 UTC (rev 15529) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/dom/NodeTest.java 2018-08-20 06:39:52 UTC (rev 15530) @@ -19,6 +19,7 @@ import static com.gargoylesoftware.htmlunit.javascript.host.xml.XMLDocumentTest.callLoadXMLDocumentFromString; import static com.gargoylesoftware.htmlunit.javascript.host.xml.XMLDocumentTest.callSerializeXMLDocumentToString; +import org.apache.commons.lang3.ArrayUtils; import org.junit.Test; import org.junit.runner.RunWith; import org.openqa.selenium.By; @@ -1279,4 +1280,110 @@ loadPageWithAlerts2(html); } + + /** + * @throws Exception if the test fails + */ + @Test + @Alerts({"1", "2", "§§URL§§second"}) + public void eventListener() throws Exception { + final String html + = "<html><head>\n" + + "<script>\n" + + " function clicking1() {\n" + + " alert(1);\n" + + " }\n" + + " function clicking2() {\n" + + " alert(2);\n" + + " }\n" + + " function test() {\n" + + " var e = document.getElementById('myAnchor');\n" + + " e.addEventListener('click', clicking1, false);\n" + + " e.addEventListener('click', clicking2, false);\n" + + " }\n" + + "</script></head><body onload='test()'>\n" + + " <a href='second' id='myAnchor'>Click me</a>\n" + + "</body></html>"; + + getMockWebConnection().setDefaultResponse("<html><body>Test</body></html>"); + expandExpectedAlertsVariables(URL_FIRST); + + final WebDriver driver = loadPage2(html); + driver.findElement(By.id("myAnchor")).click(); + verifyAlerts(driver, ArrayUtils.subarray(getExpectedAlerts(), 0, 2)); + Thread.sleep(200); // FF60 WebDriver + assertEquals(getExpectedAlerts()[2], driver.getCurrentUrl()); + } + + /** + * @throws Exception if the test fails + */ + @Test + @Alerts({"1", "2", "§§URL§§second"}) + public void eventListener_return_false() throws Exception { + final String html + = "<html><head>\n" + + "<script>\n" + + " function clicking1() {\n" + + " alert(1);\n" + + " }\n" + + " function clicking2() {\n" + + " alert(2);\n" + + " return false;\n" + + " }\n" + + " function test() {\n" + + " var e = document.getElementById('myAnchor');\n" + + " e.addEventListener('click', clicking1, false);\n" + + " e.addEventListener('click', clicking2, false);\n" + + " }\n" + + "</script></head><body onload='test()'>\n" + + " <a href='second' id='myAnchor'>Click me</a>\n" + + "</body></html>"; + + getMockWebConnection().setDefaultResponse("<html><body>Test</body></html>"); + expandExpectedAlertsVariables(URL_FIRST); + + final WebDriver driver = loadPage2(html); + driver.findElement(By.id("myAnchor")).click(); + verifyAlerts(driver, ArrayUtils.subarray(getExpectedAlerts(), 0, 2)); + Thread.sleep(200); // FF60 WebDriver + assertEquals(getExpectedAlerts()[2], driver.getCurrentUrl()); + } + + /** + * @throws Exception if the test fails + */ + @Test + @Alerts(DEFAULT = {"1", "2", "§§URL§§second"}, + CHROME = {"1", "2", "§§URL§§"}) + public void eventListener_returnValue_false() throws Exception { + final String html + = "<html><head>\n" + + "<script>\n" + + " function clicking1() {\n" + + " alert(1);\n" + + " }\n" + + " function clicking2() {\n" + + " alert(2);\n" + + " if (window.event)\n" + + " window.event.returnValue = false;\n" + + " }\n" + + " function test() {\n" + + " var e = document.getElementById('myAnchor');\n" + + " e.addEventListener('click', clicking1, false);\n" + + " e.addEventListener('click', clicking2, false);\n" + + " }\n" + + "</script></head><body onload='test()'>\n" + + " <a href='second' id='myAnchor'>Click me</a>\n" + + "</body></html>"; + + getMockWebConnection().setDefaultResponse("<html><body>Test</body></html>"); + expandExpectedAlertsVariables(URL_FIRST); + + final WebDriver driver = loadPage2(html); + driver.findElement(By.id("myAnchor")).click(); + verifyAlerts(driver, ArrayUtils.subarray(getExpectedAlerts(), 0, 2)); + Thread.sleep(200); // FF60 WebDriver + assertEquals(getExpectedAlerts()[2], driver.getCurrentUrl()); + } } |
From: RBRi <rb...@us...> - 2018-08-20 06:40:51
|
Have to work on this later... Btw. working on the migration of HtmlUnit code to github, hope this will make it simpler for you and all the other to provide patches. But this requires time. --- ** [bugs:#1984] Reworking the JS Event listeners implementation** **Status:** accepted **Group:** Latest SVN **Created:** Tue Aug 14, 2018 01:38 PM UTC by Atsushi Nakagawa **Last Updated:** Mon Aug 20, 2018 05:15 AM UTC **Owner:** RBRi **Attachments:** - [EventListenersContainer.java](https://sourceforge.net/p/htmlunit/bugs/1984/attachment/EventListenersContainer.java) (16.9 kB; application/octet-stream) - [EventListenersContainer.java-2.32.txt](https://sourceforge.net/p/htmlunit/bugs/1984/attachment/EventListenersContainer.java-2.32.txt) (15.5 kB; text/plain) - [EventTarget.java](https://sourceforge.net/p/htmlunit/bugs/1984/attachment/EventTarget.java) (14.7 kB; application/octet-stream) - [EventTarget.java-2.32.txt](https://sourceforge.net/p/htmlunit/bugs/1984/attachment/EventTarget.java-2.32.txt) (13.4 kB; text/plain) ### Problem in brief Thorough testing has revealed event listeners in HtmlUnit are implemented quite liberally in a few places with regards to how they should work. It's somewhat surprising they're working so well in practice. This bug report attempts to address the problems and tackle at fixing them. Scope includes `xyz.addListenerEvent('foo', function () { ... })` listeners and `xyz.onfoo = function () { ... }` property handlers. ##### Problems noticed * Ordering of listeners called during the *at target* phase should honour the order in which the listeners were added, but does not. * Ordering of property handlers such as `window.onload` should honour the timing at which the property was set, with respect to other event listeners, but does not. * Events where `event.bubbles` is `false` should not have a *bubbling* phase, but does. * The load event for `Window`should only traverse `Window` but traverses `Window, Document` instead. * The load event for everything else should traverse from `Document` to all levels down to the element in question, but traverses the element in question only. (Every place using `EventTarget.executeEventLocally()` potentially applies to this and should probably be using the standard `EventTarget.fireEvent()` instead.) * The load event for the `<frame>` element should be treated like "everything else" above, but is not. (On the other hand, the `onload` property for `<body>` and `<frameset>` is correctly tied to `Window`.) * The propagation path of events should not be affected by changes to the DOM tree by intermediate listeners, and therefore the *bubbling* phase should always traverse the same nodes as the *capturing* phase only in reverse, but is and does not. * The return value of event listeners should be ignored (really? it looks that way.. maybe it was different in older IE) and only that of the property handler should be used, but is not. ### Test cases There are five tests which I'm putting in the comments because it's quite long. * `test_onload.html` * `test_frame.html` * `test_click.html` * `test_nested_click.html` * `test_event_return_value.html` These extra two I'm including but haven't fixed yet. They're limited to the load/error behaviour of `<script>` and `<img>` and require fixing up some implementation in `HtmlScript` and `HtmlImage`. * `test_script_onload.html` * `test_img_onload.html` ### Possible fix The fix spans three files: * `html/HtmlPage.java` * `javascript/host/event/EventListenersContainer.java` * `javascript/host/event/EventTarget.java` Changes to `HtmlPage` is the diff below. The changes for `EventListenersContainer.java` and `EventTarget.java` are rather extensive so I'm attaching the modified files along with their respective base versions suffixed with `-2.32.txt`. ```diff --- a/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlPage.java +++ b/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlPage.java @@ -86,15 +86,16 @@ import com.gargoylesoftware.htmlunit.javascript.PostponedAction; import com.gargoylesoftware.htmlunit.javascript.SimpleScriptable; import com.gargoylesoftware.htmlunit.javascript.host.Window; -import com.gargoylesoftware.htmlunit.javascript.host.dom.Node; import com.gargoylesoftware.htmlunit.javascript.host.event.BeforeUnloadEvent; import com.gargoylesoftware.htmlunit.javascript.host.event.Event; +import com.gargoylesoftware.htmlunit.javascript.host.event.EventTarget; import com.gargoylesoftware.htmlunit.javascript.host.html.HTMLDocument; import com.gargoylesoftware.htmlunit.protocol.javascript.JavaScriptURLConnection; import com.gargoylesoftware.htmlunit.util.EncodingSniffer; import com.gargoylesoftware.htmlunit.util.UrlUtils; import net.sourceforge.htmlunit.corejs.javascript.Context; +import net.sourceforge.htmlunit.corejs.javascript.ContextFactory; import net.sourceforge.htmlunit.corejs.javascript.Function; import net.sourceforge.htmlunit.corejs.javascript.Script; import net.sourceforge.htmlunit.corejs.javascript.Scriptable; @@ -1214,18 +1215,28 @@ private boolean executeEventHandlersIfNeeded(final String eventType) { // Execute the specified event on the document element. final WebWindow window = getEnclosingWindow(); if (window.getScriptableObject() instanceof Window) { - final DomElement element = getDocumentElement(); - if (element == null) { // happens for instance if document.documentElement has been removed from parent - return true; - } + // We need the 'Document' node for these load events but getDocumentElement() returns + // <html> (HtmlHtml) which is one below that. The 'Document' node is incidentally just + // us (HtmlPage). (Some tidbits at https://www.w3.org/TR/DOM-Level-3-Events/#event-flow) + final DomNode node = this; final Event event; if (eventType.equals(Event.TYPE_BEFORE_UNLOAD)) { - event = new BeforeUnloadEvent(element, eventType); + event = new BeforeUnloadEvent(node, eventType); } else { - event = new Event(element, eventType); + event = new Event(node, eventType); + } + + // This is the same as DomElement.fireEvent() and was copied + // here so it could be used with HtmlPage. + if (LOG.isDebugEnabled()) { + LOG.debug("Firing " + event); } - final ScriptResult result = element.fireEvent(event); + + final EventTarget jsNode = node.getScriptableObject(); + final ContextFactory cf = ((JavaScriptEngine) getWebClient().getJavaScriptEngine()).getContextFactory(); + final ScriptResult result = cf.call(cx -> jsNode.fireEvent(event)); + if (!isOnbeforeunloadAccepted(this, event, result)) { return false; } @@ -1253,7 +1264,12 @@ private boolean executeEventHandlersIfNeeded(final String eventType) { else { event = new Event(frame, eventType); } - final ScriptResult result = ((Node) frame.getScriptableObject()).executeEventLocally(event); + + // This fires the "load" event for the <frame> element which, like all non-window + // load events, propagates up to Document but not Window. The "load" event for + // <frameset> on the other hand, like that of <body>, is handled above where it is + // fired against Document and directed to Window. + final ScriptResult result = frame.fireEvent(event); if (!isOnbeforeunloadAccepted((HtmlPage) frame.getPage(), event, result)) { return false; } ``` --- Sent from sourceforge.net because htm...@li... is subscribed to https://sourceforge.net/p/htmlunit/bugs/ To unsubscribe from further messages, a project admin can change settings at https://sourceforge.net/p/htmlunit/admin/bugs/options. Or, if this is a mailing list, you can unsubscribe from the mailing list. |
From: rbri <rb...@rb...> - 2018-08-18 07:38:53
|
Branch: refs/heads/master Home: https://github.com/HtmlUnit/htmlunit-rhino-fork Commit: 731bf1814adbd1b87b1f7ba92e255d31d6762052 https://github.com/HtmlUnit/htmlunit-rhino-fork/commit/731bf1814adbd1b87b1f7ba92e255d31d6762052 Author: Ravi Kishore <rav...@us...> Date: 2018-08-10 (Fri, 10 Aug 2018) Changed paths: M src/org/mozilla/javascript/Parser.java M src/org/mozilla/javascript/ScriptRuntime.java M src/org/mozilla/javascript/TokenStream.java M src/org/mozilla/javascript/ast/AstNode.java M src/org/mozilla/javascript/ast/AstRoot.java M src/org/mozilla/javascript/ast/Block.java M src/org/mozilla/javascript/ast/Comment.java M src/org/mozilla/javascript/ast/DoLoop.java M src/org/mozilla/javascript/ast/ExpressionStatement.java M src/org/mozilla/javascript/ast/ForLoop.java M src/org/mozilla/javascript/ast/FunctionCall.java M src/org/mozilla/javascript/ast/IfStatement.java M src/org/mozilla/javascript/ast/Scope.java M src/org/mozilla/javascript/ast/SwitchCase.java M src/org/mozilla/javascript/ast/TryStatement.java M src/org/mozilla/javascript/ast/VariableDeclaration.java M src/org/mozilla/javascript/ast/WhileLoop.java M src/org/mozilla/javascript/ast/WithStatement.java M testsrc/org/mozilla/javascript/tests/ParserTest.java A testsrc/org/mozilla/javascript/tests/commentspr465/CommentsTestUtils.java A testsrc/org/mozilla/javascript/tests/commentspr465/IfCommentsTest.java A testsrc/org/mozilla/javascript/tests/commentspr465/LoopCommentsTest.java A testsrc/org/mozilla/javascript/tests/commentspr465/MiscCommentsTest.java A testsrc/org/mozilla/javascript/tests/commentspr465/SwitchCommentsTest.java Log Message: ----------- Retain of comments and their position in the actual code after parsing. (#465) * Ignoring inline comments which come within an expression or statement like c = a + b //test + d Added pom.xml for WM to generate jar and push to repository. Added minimum Java version requirement for compilation - Handling of inline comments for "do" satement in a do-while - Modified toSource methods of do and while AstNodes for handling of inline comments. Handling of String literals if they are enclosed within backtick (`) - Handling of inline comments if used after try, with, case - adding messages resources to rhino.jar itself. - Inline comments at the case level are handled properly - Inline comments within object literal are ignored. - Fix below scenario if(a == 3) { b = 3; } //inlinecomment 1 else { b = 5; } - Fix for a bug in function with no argument after last comma f1(a,b,); - Added a setter method for updating the comment text. - Modified minor version to avoid manual copy of new jar. - Modified minor version to avoid manual copy of new jar. because in previous build, resource files are not copied. - ignoring comments if they are placed after an incomplete statement like var a = 3 /* */ var t=3; * Ignoring inline comments which come within an expression or statement like c = a + b //test + d Added pom.xml for WM to generate jar and push to repository. Added minimum Java version requirement for compilation - Handling of inline comments for "do" satement in a do-while - Modified toSource methods of do and while AstNodes for handling of inline comments. Handling of String literals if they are enclosed within backtick (`) - Handling of inline comments if used after try, with, case - adding messages resources to rhino.jar itself. - Inline comments at the case level are handled properly - Inline comments within object literal are ignored. - Fix below scenario if(a == 3) { b = 3; } //inlinecomment 1 else { b = 5; } - Fix for a bug in function with no argument after last comma f1(a,b,); - Added a setter method for updating the comment text. - Modified minor version to avoid manual copy of new jar. - Modified minor version to avoid manual copy of new jar. because in previous build, resource files are not copied. - ignoring comments if they are placed after an incomplete statement like var a = 3 /* */ var t=3; - Ignoring inline comments which come within an expression or statement like c = a + b //test + d - Handling of inline comments for "do" satement in a do-while - Modified toSource methods of do and while AstNodes for handling of inline comments. - Handling of String literals if they are enclosed within backtick (`) - Handling of inline comments if used after try, with, case - adding messages resources to rhino.jar itself. - Inline comments at the case level are handled properly - Inline comments within object literal are ignored. - Fix below scenario if(a == 3) { b = 3; } //inlinecomment 1 else { b = 5; } - Fix for a bug in function with no argument after last comma. f1(a,b,); - Added a setter method for updating the comment text. - Modified try block parsing to capture inline comments. - Added test cases testing inline comments of if, for, loops Commit: 57b8abc16a3d157da51e98244b590796bf9080e0 https://github.com/HtmlUnit/htmlunit-rhino-fork/commit/57b8abc16a3d157da51e98244b590796bf9080e0 Author: rbri <rb...@rb...> Date: 2018-08-13 (Mon, 13 Aug 2018) Changed paths: M src/org/mozilla/classfile/ClassFileWriter.java M src/org/mozilla/javascript/Arguments.java M src/org/mozilla/javascript/BaseFunction.java M src/org/mozilla/javascript/ConsString.java M src/org/mozilla/javascript/Context.java M src/org/mozilla/javascript/ContextFactory.java M src/org/mozilla/javascript/DToA.java M src/org/mozilla/javascript/DefaultErrorReporter.java M src/org/mozilla/javascript/DefiningClassLoader.java M src/org/mozilla/javascript/Delegator.java M src/org/mozilla/javascript/Function.java M src/org/mozilla/javascript/IRFactory.java M src/org/mozilla/javascript/IdScriptableObject.java M src/org/mozilla/javascript/InterfaceAdapter.java M src/org/mozilla/javascript/InterpretedFunction.java M src/org/mozilla/javascript/Interpreter.java M src/org/mozilla/javascript/InterpreterData.java M src/org/mozilla/javascript/JavaAdapter.java M src/org/mozilla/javascript/JavaMembers.java M src/org/mozilla/javascript/JavaScriptException.java M src/org/mozilla/javascript/LazilyLoadedCtor.java M src/org/mozilla/javascript/MemberBox.java M src/org/mozilla/javascript/NativeArray.java M src/org/mozilla/javascript/NativeContinuation.java M src/org/mozilla/javascript/NativeDate.java M src/org/mozilla/javascript/NativeError.java M src/org/mozilla/javascript/NativeFunction.java M src/org/mozilla/javascript/NativeGlobal.java M src/org/mozilla/javascript/NativeJSON.java M src/org/mozilla/javascript/NativeJavaClass.java M src/org/mozilla/javascript/NativeJavaMethod.java M src/org/mozilla/javascript/NativeJavaObject.java M src/org/mozilla/javascript/NativeJavaPackage.java M src/org/mozilla/javascript/NativeJavaTopPackage.java M src/org/mozilla/javascript/NativeNumber.java M src/org/mozilla/javascript/NativeObject.java M src/org/mozilla/javascript/NativeString.java M src/org/mozilla/javascript/NativeSymbol.java M src/org/mozilla/javascript/NativeWith.java M src/org/mozilla/javascript/Node.java M src/org/mozilla/javascript/NodeTransformer.java M src/org/mozilla/javascript/ObjToIntMap.java M src/org/mozilla/javascript/Parser.java M src/org/mozilla/javascript/PolicySecurityController.java M src/org/mozilla/javascript/ScriptRuntime.java M src/org/mozilla/javascript/ScriptableObject.java M src/org/mozilla/javascript/SecureCaller.java M src/org/mozilla/javascript/SecurityController.java M src/org/mozilla/javascript/SecurityUtilities.java M src/org/mozilla/javascript/ThreadSafeSlotMapContainer.java M src/org/mozilla/javascript/TokenStream.java M src/org/mozilla/javascript/UintMap.java M src/org/mozilla/javascript/ast/ArrayLiteral.java M src/org/mozilla/javascript/ast/AstNode.java M src/org/mozilla/javascript/ast/AstRoot.java M src/org/mozilla/javascript/ast/ErrorCollector.java M src/org/mozilla/javascript/ast/ObjectLiteral.java M src/org/mozilla/javascript/commonjs/module/Require.java M src/org/mozilla/javascript/commonjs/module/provider/CachingModuleScriptProviderBase.java M src/org/mozilla/javascript/commonjs/module/provider/DefaultUrlConnectionExpiryCalculator.java M src/org/mozilla/javascript/commonjs/module/provider/ModuleSourceProviderBase.java M src/org/mozilla/javascript/commonjs/module/provider/MultiModuleScriptProvider.java M src/org/mozilla/javascript/commonjs/module/provider/UrlModuleSourceProvider.java M src/org/mozilla/javascript/jdk15/VMBridge_jdk15.java M src/org/mozilla/javascript/json/JsonParser.java M src/org/mozilla/javascript/optimizer/Codegen.java M src/org/mozilla/javascript/optimizer/Optimizer.java M src/org/mozilla/javascript/regexp/NativeRegExp.java M src/org/mozilla/javascript/regexp/RegExpImpl.java M src/org/mozilla/javascript/typedarrays/Conversions.java M src/org/mozilla/javascript/typedarrays/NativeDataView.java M src/org/mozilla/javascript/typedarrays/NativeFloat32Array.java M src/org/mozilla/javascript/typedarrays/NativeFloat64Array.java M src/org/mozilla/javascript/typedarrays/NativeInt16Array.java M src/org/mozilla/javascript/typedarrays/NativeInt32Array.java M src/org/mozilla/javascript/typedarrays/NativeInt8Array.java M src/org/mozilla/javascript/typedarrays/NativeTypedArrayIterator.java M src/org/mozilla/javascript/typedarrays/NativeTypedArrayView.java M src/org/mozilla/javascript/typedarrays/NativeUint16Array.java M src/org/mozilla/javascript/typedarrays/NativeUint32Array.java M src/org/mozilla/javascript/typedarrays/NativeUint8Array.java M src/org/mozilla/javascript/typedarrays/NativeUint8ClampedArray.java M src/org/mozilla/javascript/v8dtoa/DoubleConversion.java M src/org/mozilla/javascript/v8dtoa/DoubleHelper.java M toolsrc/org/mozilla/javascript/tools/debugger/SwingGui.java Log Message: ----------- add @Override and some more cleanup Commit: 72d55e2fea36cc656623d16032e888aa84b5228c https://github.com/HtmlUnit/htmlunit-rhino-fork/commit/72d55e2fea36cc656623d16032e888aa84b5228c Author: rbri <rb...@rb...> Date: 2018-08-14 (Tue, 14 Aug 2018) Changed paths: M src/org/mozilla/javascript/NativeDate.java Log Message: ----------- fix ctor called with date arg Commit: 959852a1b555eb9b257df9e68336b79e7e1e036e https://github.com/HtmlUnit/htmlunit-rhino-fork/commit/959852a1b555eb9b257df9e68336b79e7e1e036e Author: rbri <rb...@rb...> Date: 2018-08-14 (Tue, 14 Aug 2018) Changed paths: M src/org/mozilla/javascript/ScriptableObject.java M testsrc/test262.properties Log Message: ----------- valueOf has to be called without any args Commit: ba4acd54d8ffc03444edefcacfbb445f88754817 https://github.com/HtmlUnit/htmlunit-rhino-fork/commit/ba4acd54d8ffc03444edefcacfbb445f88754817 Author: rbri <rb...@rb...> Date: 2018-08-14 (Tue, 14 Aug 2018) Changed paths: M src/org/mozilla/javascript/NativeDate.java M testsrc/test262.properties Log Message: ----------- fix remaining utc constructor case Commit: f14dda1361c2abe524aba71355ba91410ecf2ff5 https://github.com/HtmlUnit/htmlunit-rhino-fork/commit/f14dda1361c2abe524aba71355ba91410ecf2ff5 Author: rbri <rb...@rb...> Date: 2018-08-14 (Tue, 14 Aug 2018) Changed paths: M src/org/mozilla/javascript/ScriptableObject.java Log Message: ----------- minor cleanup Commit: 560b6b2e47f4dd3b5d661a44fd664b4893abfb6f https://github.com/HtmlUnit/htmlunit-rhino-fork/commit/560b6b2e47f4dd3b5d661a44fd664b4893abfb6f Author: Gregory Brail <gre...@go...> Date: 2018-08-16 (Thu, 16 Aug 2018) Changed paths: M src/org/mozilla/javascript/NativeObject.java A testsrc/jstests/extensions/getset-null.js A testsrc/org/mozilla/javascript/tests/es5/GetSetNullTest.java Log Message: ----------- Fix NullPointerException in __defineGetter__ __defineGetter__ and __defineSetter__ throw an NPE when called with "null" as "this." This was causing tests from the Kangax "compat-table" project to crash. Commit: b3d450810da3e1969f97fea1ad7af26e35349396 https://github.com/HtmlUnit/htmlunit-rhino-fork/commit/b3d450810da3e1969f97fea1ad7af26e35349396 Author: rbri <rb...@rb...> Date: 2018-08-17 (Fri, 17 Aug 2018) Changed paths: M src/org/mozilla/classfile/ClassFileWriter.java M src/org/mozilla/javascript/Arguments.java M src/org/mozilla/javascript/BaseFunction.java M src/org/mozilla/javascript/ConsString.java M src/org/mozilla/javascript/Context.java M src/org/mozilla/javascript/ContextFactory.java M src/org/mozilla/javascript/DToA.java M src/org/mozilla/javascript/DefaultErrorReporter.java M src/org/mozilla/javascript/DefiningClassLoader.java M src/org/mozilla/javascript/Delegator.java M src/org/mozilla/javascript/Function.java M src/org/mozilla/javascript/IRFactory.java M src/org/mozilla/javascript/IdScriptableObject.java M src/org/mozilla/javascript/InterfaceAdapter.java M src/org/mozilla/javascript/InterpretedFunction.java M src/org/mozilla/javascript/Interpreter.java M src/org/mozilla/javascript/InterpreterData.java M src/org/mozilla/javascript/JavaAdapter.java M src/org/mozilla/javascript/JavaMembers.java M src/org/mozilla/javascript/JavaScriptException.java M src/org/mozilla/javascript/LazilyLoadedCtor.java M src/org/mozilla/javascript/MemberBox.java M src/org/mozilla/javascript/NativeArray.java M src/org/mozilla/javascript/NativeContinuation.java M src/org/mozilla/javascript/NativeDate.java M src/org/mozilla/javascript/NativeError.java M src/org/mozilla/javascript/NativeFunction.java M src/org/mozilla/javascript/NativeGlobal.java M src/org/mozilla/javascript/NativeJSON.java M src/org/mozilla/javascript/NativeJavaClass.java M src/org/mozilla/javascript/NativeJavaMethod.java M src/org/mozilla/javascript/NativeJavaObject.java M src/org/mozilla/javascript/NativeJavaPackage.java M src/org/mozilla/javascript/NativeJavaTopPackage.java M src/org/mozilla/javascript/NativeNumber.java M src/org/mozilla/javascript/NativeObject.java M src/org/mozilla/javascript/NativeString.java M src/org/mozilla/javascript/NativeSymbol.java M src/org/mozilla/javascript/NativeWith.java M src/org/mozilla/javascript/Node.java M src/org/mozilla/javascript/NodeTransformer.java M src/org/mozilla/javascript/ObjToIntMap.java M src/org/mozilla/javascript/Parser.java M src/org/mozilla/javascript/PolicySecurityController.java M src/org/mozilla/javascript/ScriptRuntime.java M src/org/mozilla/javascript/ScriptableObject.java M src/org/mozilla/javascript/SecureCaller.java M src/org/mozilla/javascript/SecurityController.java M src/org/mozilla/javascript/SecurityUtilities.java M src/org/mozilla/javascript/ThreadSafeSlotMapContainer.java M src/org/mozilla/javascript/TokenStream.java M src/org/mozilla/javascript/UintMap.java M src/org/mozilla/javascript/ast/ArrayLiteral.java M src/org/mozilla/javascript/ast/AstNode.java M src/org/mozilla/javascript/ast/AstRoot.java M src/org/mozilla/javascript/ast/Block.java M src/org/mozilla/javascript/ast/Comment.java M src/org/mozilla/javascript/ast/DoLoop.java M src/org/mozilla/javascript/ast/ErrorCollector.java M src/org/mozilla/javascript/ast/ExpressionStatement.java M src/org/mozilla/javascript/ast/ForLoop.java M src/org/mozilla/javascript/ast/FunctionCall.java M src/org/mozilla/javascript/ast/IfStatement.java M src/org/mozilla/javascript/ast/ObjectLiteral.java M src/org/mozilla/javascript/ast/Scope.java M src/org/mozilla/javascript/ast/SwitchCase.java M src/org/mozilla/javascript/ast/TryStatement.java M src/org/mozilla/javascript/ast/VariableDeclaration.java M src/org/mozilla/javascript/ast/WhileLoop.java M src/org/mozilla/javascript/ast/WithStatement.java M src/org/mozilla/javascript/commonjs/module/Require.java M src/org/mozilla/javascript/commonjs/module/provider/CachingModuleScriptProviderBase.java M src/org/mozilla/javascript/commonjs/module/provider/DefaultUrlConnectionExpiryCalculator.java M src/org/mozilla/javascript/commonjs/module/provider/ModuleSourceProviderBase.java M src/org/mozilla/javascript/commonjs/module/provider/MultiModuleScriptProvider.java M src/org/mozilla/javascript/commonjs/module/provider/UrlModuleSourceProvider.java M src/org/mozilla/javascript/jdk15/VMBridge_jdk15.java M src/org/mozilla/javascript/json/JsonParser.java M src/org/mozilla/javascript/optimizer/Codegen.java M src/org/mozilla/javascript/optimizer/Optimizer.java M src/org/mozilla/javascript/regexp/NativeRegExp.java M src/org/mozilla/javascript/regexp/RegExpImpl.java M src/org/mozilla/javascript/typedarrays/Conversions.java M src/org/mozilla/javascript/typedarrays/NativeDataView.java M src/org/mozilla/javascript/typedarrays/NativeFloat32Array.java M src/org/mozilla/javascript/typedarrays/NativeFloat64Array.java M src/org/mozilla/javascript/typedarrays/NativeInt16Array.java M src/org/mozilla/javascript/typedarrays/NativeInt32Array.java M src/org/mozilla/javascript/typedarrays/NativeInt8Array.java M src/org/mozilla/javascript/typedarrays/NativeTypedArrayIterator.java M src/org/mozilla/javascript/typedarrays/NativeTypedArrayView.java M src/org/mozilla/javascript/typedarrays/NativeUint16Array.java M src/org/mozilla/javascript/typedarrays/NativeUint32Array.java M src/org/mozilla/javascript/typedarrays/NativeUint8Array.java M src/org/mozilla/javascript/typedarrays/NativeUint8ClampedArray.java M src/org/mozilla/javascript/v8dtoa/DoubleConversion.java M src/org/mozilla/javascript/v8dtoa/DoubleHelper.java A testsrc/jstests/extensions/getset-null.js M testsrc/org/mozilla/javascript/tests/ParserTest.java A testsrc/org/mozilla/javascript/tests/commentspr465/CommentsTestUtils.java A testsrc/org/mozilla/javascript/tests/commentspr465/IfCommentsTest.java A testsrc/org/mozilla/javascript/tests/commentspr465/LoopCommentsTest.java A testsrc/org/mozilla/javascript/tests/commentspr465/MiscCommentsTest.java A testsrc/org/mozilla/javascript/tests/commentspr465/SwitchCommentsTest.java A testsrc/org/mozilla/javascript/tests/es5/GetSetNullTest.java M testsrc/test262.properties M toolsrc/org/mozilla/javascript/tools/debugger/SwingGui.java Log Message: ----------- Merge remote-tracking branch 'rhino/master' # Conflicts: # src/org/mozilla/javascript/InterpreterData.java Compare: https://github.com/HtmlUnit/htmlunit-rhino-fork/compare/a47c25b9c4a4...b3d450810da3 **NOTE:** This service has been marked for deprecation: https://developer.github.com/changes/2018-04-25-github-services-deprecation/ Functionality will be removed from GitHub.com on January 31st, 2019. |