Skip to content

Commit abfe854

Browse files
wanghongjuanrogerwang
authored andcommitted
[test] Add test for issue#6231
- Add test for issue nwjs#6231 - This case is failed on failed version 0.26.0, pass on v0.27.4
1 parent 33b18bc commit abfe854

File tree

3 files changed

+120
-0
lines changed

3 files changed

+120
-0
lines changed
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<meta charset="utf-8">
5+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
6+
<title>issue6231-linux-websocket-more-than-2-connections</title>
7+
</head>
8+
<body>
9+
<script>
10+
let socket1 = new WebSocket('wss://echo.websocket.org');
11+
let socket2 = new WebSocket('wss://echo.websocket.org');
12+
let socket3 = new WebSocket('wss://echo.websocket.org');
13+
let socket4 = new WebSocket('wss://echo.websocket.org');
14+
15+
socket1.onopen = ()=>{
16+
console.log('Socket 1 open');
17+
var p1 = document.createElement('p');
18+
p1.id = "socket1";
19+
p1.innerText = 'Socket 1 open';
20+
document.body.appendChild(p1);
21+
}
22+
23+
socket1.onclose = () =>{
24+
console.log('Socket 1 close');
25+
var p1 = document.createElement('p');
26+
p1.id = "socket1";
27+
p1.innerText = 'Socket 1 close';
28+
document.body.appendChild(p1);
29+
}
30+
31+
socket2.onopen = ()=>{
32+
console.log('Socket 2 open');
33+
var p2 = document.createElement('p');
34+
p2.id = "socket2";
35+
p2.innerText = 'Socket 2 open';
36+
document.body.appendChild(p2);
37+
}
38+
39+
socket2.onclose = () =>{
40+
console.log('Socket 2 close');
41+
var p2 = document.createElement('p');
42+
p2.id = "socket2";
43+
p2.innerText = 'Socket 2 close';
44+
document.body.appendChild(p2);
45+
}
46+
47+
socket3.onopen = ()=>{
48+
console.log('Socket 3 open');
49+
var p3 = document.createElement('p');
50+
p3.id = "socket3";
51+
p3.innerText = 'Socket 3 open';
52+
document.body.appendChild(p3);
53+
}
54+
55+
socket3.onclose = () =>{
56+
console.log('Socket 3 close');
57+
var p3 = document.createElement('p');
58+
p3.id = "socket3";
59+
p3.innerText = 'Socket 3 close';
60+
document.body.appendChild(p3);
61+
}
62+
63+
socket4.onopen = ()=>{
64+
console.log('Socket 4 open');
65+
var p4 = document.createElement('p');
66+
p4.id = "socket4";
67+
p4.innerText = 'Socket 4 open';
68+
document.body.appendChild(p4);
69+
}
70+
71+
socket4.onclose = () =>{
72+
console.log('Socket 4 close');
73+
var p4 = document.createElement('p');
74+
p4.id = "socket4";
75+
p4.innerText = 'Socket 4 close';
76+
document.body.appendChild(p4);
77+
}
78+
nw.Window.get().showDevTools();
79+
</script>
80+
</body>
81+
</html>
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"name": "issue6231-linux-websocket-more-than-2-connections",
3+
"main": "index.html"
4+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import time
2+
import os
3+
import shutil
4+
import platform
5+
import sys
6+
7+
if platform.system() != 'Linux':
8+
print 'Skipped for non Linux platform'
9+
sys.exit(0)
10+
11+
from selenium import webdriver
12+
from selenium.webdriver.chrome.options import Options
13+
14+
chrome_options = Options()
15+
testdir = os.path.dirname(os.path.abspath(__file__))
16+
chrome_options.add_argument('nwapp=' + testdir)
17+
18+
driver = webdriver.Chrome(executable_path=os.environ['CHROMEDRIVER'], chrome_options=chrome_options)
19+
driver.implicitly_wait(5)
20+
try:
21+
print driver.current_url
22+
23+
result1 = driver.find_element_by_id('socket1').get_attribute('innerText')
24+
assert('Socket 1 open' in result1)
25+
26+
result2 = driver.find_element_by_id('socket2').get_attribute('innerText')
27+
assert('Socket 2 open' in result2)
28+
29+
result3 = driver.find_element_by_id('socket3').get_attribute('innerText')
30+
assert('Socket 3 open' in result3)
31+
32+
result4 = driver.find_element_by_id('socket4').get_attribute('innerText')
33+
assert('Socket 4 open' in result4)
34+
finally:
35+
driver.quit()

0 commit comments

Comments
 (0)