Skip to content

Commit a10179e

Browse files
committed
[test] add case vm-crash for nwjs#4018
1 parent f93a7b4 commit a10179e

File tree

4 files changed

+38
-0
lines changed

4 files changed

+38
-0
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<script src='bug.js'></script>

test/sanity/issue4018-vm-crash/bug.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
window.onload = function() {
2+
var vm = require('vm');
3+
var c = new vm.createContext({e: document.body});
4+
var script = new vm.Script('e.innerHTML += "<p id=\'ret\'>success</p>"');
5+
script.runInContext(c);
6+
};
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"name": "crash test",
3+
"main": "bug.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 subprocess
4+
import sys
5+
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
6+
from nw_util import *
7+
8+
from selenium import webdriver
9+
from selenium.webdriver.chrome.options import Options
10+
from selenium.webdriver.common import utils
11+
12+
chrome_options = Options()
13+
chrome_options.add_argument("nwapp=" + os.path.dirname(os.path.abspath(__file__)))
14+
15+
capabilities = {"pageLoadStrategy": "none"}
16+
17+
testdir = os.path.dirname(os.path.abspath(__file__))
18+
os.chdir(testdir)
19+
20+
driver = webdriver.Chrome(executable_path=os.environ['CHROMEDRIVER'], chrome_options=chrome_options, desired_capabilities = capabilities)
21+
try:
22+
result = wait_for_element_id(driver, 'ret')
23+
print 'result=' + result
24+
assert("success" in result)
25+
finally:
26+
driver.quit()
27+

0 commit comments

Comments
 (0)