1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 package org.htmlunit.javascript.host;
16
17 import org.htmlunit.WebDriverTestCase;
18 import org.htmlunit.junit.BrowserRunner;
19 import org.htmlunit.junit.annotation.Alerts;
20 import org.junit.Test;
21 import org.junit.runner.RunWith;
22 import org.openqa.selenium.By;
23 import org.openqa.selenium.WebDriver;
24
25
26
27
28
29
30 @RunWith(BrowserRunner.class)
31 public class WindowConcurrency2Test extends WebDriverTestCase {
32
33
34
35
36
37
38
39 @Test
40 @Alerts("xxx")
41 public void setIntervalZeroDelay() throws Exception {
42 final String html = DOCTYPE_HTML
43 + "<html><body><div id='d'></div>\n"
44 + "<script>\n"
45 + " var count = 0;\n"
46
47 + " function doTimeout() {\n"
48 + " document.getElementById('d').innerHTML += 'x';\n"
49 + " count++;\n"
50 + " if (count > 2) {\n"
51 + " clearInterval(id);\n"
52 + " }\n"
53 + " }\n"
54
55 + " var id = setInterval(doTimeout, 0);\n"
56 + "</script>\n"
57 + "</body></html>";
58
59 final WebDriver driver = loadPage2(html);
60
61 verify(() -> driver.findElement(By.id("d")).getText(), getExpectedAlerts()[0]);
62 }
63 }