Skip to content

Commit e186411

Browse files
committed
[test] add case for nwjs#6251: node crypto crash
1 parent 1e30b4f commit e186411

File tree

3 files changed

+56
-0
lines changed

3 files changed

+56
-0
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<title>Hello World!</title>
5+
<script>
6+
var dataString = "Test short string";
7+
var nodeCrypto = require('crypto');
8+
9+
setTimeout(function(){
10+
var password = "Example123456789";
11+
var salt = nodeCrypto.randomBytes(32);
12+
var iv = nodeCrypto.randomBytes(16);
13+
var AESKey = nodeCrypto.pbkdf2Sync(Buffer.from(password), salt, 4096, 32, 'sha256');
14+
var AESCipher = nodeCrypto.createCipheriv('aes256', AESKey, iv);
15+
var encoded = AESCipher.update(dataString, 'utf8', 'base64');
16+
encoded += AESCipher.final('base64');
17+
console.log(encoded);
18+
document.getElementById('result').innerHTML = encoded;
19+
}, 500);
20+
</script>
21+
</head>
22+
<body>
23+
<h1 id='result'>waiting for result</h1>
24+
</body>
25+
</html>
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"name": "nw-demo",
3+
"main": "index.html"
4+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import time
2+
import os
3+
import shutil
4+
import subprocess
5+
import platform
6+
import sys
7+
from subprocess import Popen, PIPE
8+
9+
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
10+
from nw_util import *
11+
12+
from selenium import webdriver
13+
from selenium.webdriver.chrome.options import Options
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(2)
20+
try:
21+
print driver.current_url
22+
time.sleep(1)
23+
ret = driver.find_element_by_id('result').get_attribute('innerHTML')
24+
print 'result: ', ret
25+
assert('waiting' not in ret)
26+
finally:
27+
driver.quit()

0 commit comments

Comments
 (0)