Skip to content

Commit

Permalink
[test] Add test case for issue #5882
Browse files Browse the repository at this point in the history
- This case is failed on failed version 0.21.2, pass on fixed version 0.27.4
  • Loading branch information
wanghongjuan committed Feb 6, 2018
1 parent 65cc2f4 commit 2308d35
Show file tree
Hide file tree
Showing 3 changed files with 88 additions and 0 deletions.
24 changes: 24 additions & 0 deletions test/sanity/issue5882-debugging-tools-crash/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<!DOCTYPE html>
<html>
<head>
<title>issue5882-debugging-tools-crash</title>
</head>
<body>
<h1>Hello World!</h1>
We are using node.js <script>document.write(process.version)</script>.
<script type="text/javascript">
var request = require('request');
setInterval(function() {
request({
url: 'http://www.bing.com',
method: 'get'
}, function(err, response, body) {
debugger;
if (err) return console.error(err.stack); // line 16
console.log(response, body);
});
}, 3 * 1000);
nw.Window.get().showDevTools()
</script>
</body>
</html>
7 changes: 7 additions & 0 deletions test/sanity/issue5882-debugging-tools-crash/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"name": "issue5882-nw-crash-with-debugging-tools",
"main": "index.html",
"dependencies": {
"request": "^2.83.0"
}
}
57 changes: 57 additions & 0 deletions test/sanity/issue5882-debugging-tools-crash/test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import time
import os
import platform
import sys

sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from nw_util import *

from selenium import webdriver
from selenium.webdriver.chrome.options import Options

from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.select import Select

chrome_options = Options()
testdir = os.path.dirname(os.path.abspath(__file__))
chrome_options.add_argument("nwapp=" + testdir)
node_module = os.path.join(testdir, "node_modules")
os.chdir(testdir)

install_native_modules()

def clickResume():
if platform.system() != "Darwin":
ActionChains(driver).key_down(Keys.CONTROL).send_keys("\\").key_up(Keys.CONTROL).perform()
else:
ActionChains(driver).key_down(Keys.COMMAND).send_keys("\\").key_up(Keys.COMMAND).perform()

driver = webdriver.Chrome(executable_path=os.environ['CHROMEDRIVER'], chrome_options=chrome_options, service_log_path="log", service_args=["--verbose"])
driver.implicitly_wait(2)
try:
switch_to_app(driver)
print driver.current_url
print 'wait for devtools open'
wait_window_handles(driver, 2)
print 'switch to devtools'
switch_to_devtools(driver)
print "click Sources panel"
devtools_click_tab(driver, 'sources')
print 'start to debug line 16 via breakpoint'
for i in range(10):
print "click Resume script execution button: %s" % i
while i < 10:
try:
clickResume()
break
except selenium.common.exceptions.WebDriverException:
pass
time.sleep(1)
i = i + 1
if i >= 10:
raise Exception('Timeout when waiting for clicking resume button')
assert(len(driver.window_handles) is 2)
print 'There is no crash'
finally:
driver.quit()

0 comments on commit 2308d35

Please sign in to comment.