-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[test] Add test case for issue #5882
- This case is failed on failed version 0.21.2, pass on fixed version 0.27.4
- Loading branch information
1 parent
65cc2f4
commit 2308d35
Showing
3 changed files
with
88 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |