Skip to content

Commit 146fae3

Browse files
wanghongjuanrogerwang
authored andcommitted
[test] Add test for issue6001
- Add test for issue nwjs#6001 - This case is failed on failed version 0.23.5, pass on fixed version 0.27.4
1 parent 5972edb commit 146fae3

File tree

4 files changed

+64
-0
lines changed

4 files changed

+64
-0
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<meta charset="utf-8">
5+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
6+
<title>issue6001-devtools-open-crash</title>
7+
</head>
8+
<body>
9+
<script>
10+
nw.Window.get().evalNWBin(null, 'index.bin');
11+
nw.Window.get().showDevTools();
12+
</script>
13+
</body>
14+
</html>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
function test(){};
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"name": "issue6001-devtools-open-crash",
3+
"main": "index.html"
4+
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import time
2+
import os
3+
import shutil
4+
import subprocess
5+
import sys
6+
7+
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
8+
from nw_util import *
9+
10+
from selenium import webdriver
11+
from selenium.webdriver.chrome.options import Options
12+
13+
chrome_options = Options()
14+
testdir = os.path.dirname(os.path.abspath(__file__))
15+
chrome_options.add_argument("nwapp=" + testdir)
16+
binfile = os.path.join(testdir, "index.bin")
17+
nwjc = os.path.join(os.path.dirname(os.environ['CHROMEDRIVER']),
18+
"nwjc.exe" if os.name == "nt" else "nwjc")
19+
os.chdir(testdir)
20+
21+
try:
22+
os.remove(binfile)
23+
except:
24+
pass
25+
26+
assert(False == os.path.isfile(binfile))
27+
subprocess.call([nwjc, "--future", "index.js", "index.bin"])
28+
assert(os.path.isfile(binfile))
29+
30+
driver = webdriver.Chrome(executable_path=os.environ['CHROMEDRIVER'], chrome_options=chrome_options)
31+
driver.implicitly_wait(2)
32+
try:
33+
switch_to_app(driver)
34+
print driver.current_url
35+
print 'waiting for devtools open'
36+
wait_window_handles(driver, 2)
37+
print 'switch to devtools'
38+
switch_to_devtools(driver, None, True)
39+
print 'waiting for crash'
40+
time.sleep(5)
41+
handles = driver.window_handles
42+
assert(len(handles) is 2)
43+
print 'There is no crash'
44+
finally:
45+
driver.quit()

0 commit comments

Comments
 (0)