Skip to content

Commit 115eaf2

Browse files
wanghongjuanrogerwang
authored andcommitted
[test] Add test case for issue nwjs#5882
- This case is failed on failed version 0.21.2, pass on fixed version 0.27.4
1 parent 4752dd1 commit 115eaf2

File tree

3 files changed

+87
-0
lines changed

3 files changed

+87
-0
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<title>issue5882-debugging-tools-crash</title>
5+
</head>
6+
<body>
7+
<h1>Hello World!</h1>
8+
We are using node.js <script>document.write(process.version)</script>.
9+
<script type="text/javascript">
10+
var request = require('request');
11+
setInterval(function() {
12+
request({
13+
url: 'http://www.bing.com',
14+
method: 'get'
15+
}, function(err, response, body) {
16+
debugger;
17+
if (err) return console.error(err.stack); // line 16
18+
console.log(response, body);
19+
});
20+
}, 3 * 1000);
21+
nw.Window.get().showDevTools()
22+
</script>
23+
</body>
24+
</html>
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"name": "issue5882-nw-crash-with-debugging-tools",
3+
"main": "index.html",
4+
"dependencies": {
5+
"request": "^2.83.0"
6+
}
7+
}
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
import time
2+
import os
3+
import platform
4+
import sys
5+
6+
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
7+
from nw_util import *
8+
9+
from selenium import webdriver
10+
from selenium.webdriver.chrome.options import Options
11+
12+
from selenium.webdriver.common.action_chains import ActionChains
13+
from selenium.webdriver.common.keys import Keys
14+
from selenium.webdriver.support.select import Select
15+
16+
chrome_options = Options()
17+
testdir = os.path.dirname(os.path.abspath(__file__))
18+
chrome_options.add_argument("nwapp=" + testdir)
19+
os.chdir(testdir)
20+
21+
install_native_modules()
22+
23+
def clickResume():
24+
if platform.system() != "Darwin":
25+
ActionChains(driver).key_down(Keys.CONTROL).send_keys("\\").key_up(Keys.CONTROL).perform()
26+
else:
27+
ActionChains(driver).key_down(Keys.COMMAND).send_keys("\\").key_up(Keys.COMMAND).perform()
28+
29+
driver = webdriver.Chrome(executable_path=os.environ['CHROMEDRIVER'], chrome_options=chrome_options, service_log_path="log", service_args=["--verbose"])
30+
driver.implicitly_wait(2)
31+
try:
32+
switch_to_app(driver)
33+
print driver.current_url
34+
print 'wait for devtools open'
35+
wait_window_handles(driver, 2)
36+
print 'switch to devtools'
37+
switch_to_devtools(driver)
38+
print "click Sources panel"
39+
devtools_click_tab(driver, 'sources')
40+
print 'start to debug line 16 via breakpoint'
41+
for i in range(10):
42+
print "click Resume script execution button: %s" % i
43+
while i < 10:
44+
try:
45+
clickResume()
46+
break
47+
except selenium.common.exceptions.WebDriverException:
48+
pass
49+
time.sleep(1)
50+
i = i + 1
51+
if i >= 10:
52+
raise Exception('Timeout when waiting for clicking resume button')
53+
assert(len(driver.window_handles) is 2)
54+
print 'There is no crash'
55+
finally:
56+
driver.quit()

0 commit comments

Comments
 (0)