View Javadoc
1   /*
2    * Copyright (c) 2002-2025 Gargoyle Software Inc.
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    * https://www.apache.org/licenses/LICENSE-2.0
8    *
9    * Unless required by applicable law or agreed to in writing, software
10   * distributed under the License is distributed on an "AS IS" BASIS,
11   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12   * See the License for the specific language governing permissions and
13   * limitations under the License.
14   */
15  package org.htmlunit.libraries;
16  
17  import java.util.List;
18  
19  import org.htmlunit.WebServerTestCase;
20  import org.junit.jupiter.api.BeforeAll;
21  import org.junit.jupiter.api.Test;
22  import org.openqa.selenium.By;
23  import org.openqa.selenium.WebDriver;
24  import org.openqa.selenium.WebElement;
25  
26  /**
27   * Tests for compatibility with version 1.6.0 of
28   * <a href="http://www.prototypejs.org/">Prototype JavaScript library</a>.
29   *
30   * @author Ahmed Ashour
31   * @author Marc Guillemot
32   * @author Ronald Brill
33   */
34  public class Prototype160Test extends PrototypeTestBase {
35  
36      /**
37       * @throws Exception if an error occurs
38       */
39      @BeforeAll
40      public static void aaa_startSesrver() throws Exception {
41          SERVER_ = WebServerTestCase.createWebServer("src/test/resources/libraries/prototype/1.6.0/", null);
42      }
43  
44      /**
45       * {@inheritDoc}
46       */
47      @Override
48      protected String getVersion() {
49          return "1.6.0";
50      }
51  
52      /**
53       * @return the resource base url
54       */
55      @Override
56      protected String getBaseUrl() {
57          return URL_FIRST + "test/unit/";
58      }
59  
60      @Override
61      protected boolean testFinished(final WebDriver driver) {
62          final List<WebElement> status = driver.findElements(By.cssSelector("div#logsummary"));
63          for (final WebElement webElement : status) {
64              if (!webElement.getText().contains("errors")) {
65                  return false;
66              }
67          }
68          return true;
69      }
70  
71      /**
72       * @throws Exception if test fails
73       */
74      @Test
75      public void ajax() throws Exception {
76          test("ajax.html");
77      }
78  
79      /**
80       * @throws Exception if test fails
81       */
82      @Test
83      public void array() throws Exception {
84          test("array.html");
85      }
86  
87      /**
88       * @throws Exception if test fails
89       */
90      @Test
91      public void base() throws Exception {
92          test("base.html");
93      }
94  
95      /**
96       * Note: <tt>testElementGetDimensions:</tt>, <tt>testElementGetStyle</tt>, <tt>testElementGetHeight</tt>,
97       *       <tt>testElementScrollTo:</tt>, <tt>testPositionedOffset</tt>, <tt>testViewportOffset</tt>,
98       *       <tt>testViewportDimensions</tt>, <tt>testViewportScrollOffsets</tt>
99       *       and <tt>testElementGetWidth</tt> are expected to fail with HtmlUnit,
100      *       as they need calculating width and height of all elements.
101      *
102      * Other tests succeed.
103      *
104      * @throws Exception if test fails
105      */
106     @Test
107     public void dom() throws Exception {
108         test("dom.html");
109     }
110 
111     /**
112      * Depends on {@link org.htmlunit.javascript.HtmlUnitScriptable2Test#parentProtoFeature()}.
113      *
114      * @throws Exception if test fails
115      */
116     @Test
117     public void elementMixins() throws Exception {
118         test("element_mixins.html");
119     }
120 
121     /**
122      * @throws Exception if test fails
123      */
124     @Test
125     public void enumerable() throws Exception {
126         test("enumerable.html");
127     }
128 
129     /**
130      * @throws Exception if test fails
131      */
132     @Test
133     public void event() throws Exception {
134         test("event.html");
135     }
136 
137     /**
138      * @throws Exception if test fails
139      */
140     @Test
141     public void form() throws Exception {
142         test("form.html");
143     }
144 
145     /**
146      * @throws Exception if test fails
147      */
148     @Test
149     public void hash() throws Exception {
150         test("hash.html");
151     }
152 
153     /**
154      * @throws Exception if test fails
155      */
156     @Test
157     public void number() throws Exception {
158         test("number.html");
159     }
160 
161     /**
162      * @throws Exception if test fails
163      */
164     @Test
165     public void position() throws Exception {
166         test("position.html");
167     }
168 
169     /**
170      * @throws Exception if test fails
171      */
172     @Test
173     public void range() throws Exception {
174         test("range.html");
175     }
176 
177     /**
178      * @throws Exception if test fails
179      */
180     @Test
181     public void selector() throws Exception {
182         test("selector.html");
183     }
184 
185     /**
186      * @throws Exception if test fails
187      */
188     @Test
189     public void string() throws Exception {
190         test("string.html");
191     }
192 
193     /**
194      * 1 expected failure is because the server port is other than 4711.
195      * @throws Exception if test fails
196      */
197     @Test
198     public void unitTests() throws Exception {
199         test("unit_tests.html");
200     }
201 }