Skip to content

Commit 7b45496

Browse files
committed
[test] guard nwjc with checking source code and strings
1 parent 09d5c2f commit 7b45496

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

test/sanity/nwjc/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,6 @@
77
</script>
88
<script>
99
mytest(2);
10+
document.write('<p id="result2">' + mytest.toString() + '</p>');
1011
</script>
1112
</body></html>

test/sanity/nwjc/test.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
import os
33
import shutil
44
import subprocess
5+
import platform
6+
from subprocess import Popen, PIPE
57

68
from selenium import webdriver
79
from selenium.webdriver.chrome.options import Options
@@ -19,12 +21,21 @@
1921
subprocess.call([nwjc, "mytest.js", "mytest.bin"])
2022
assert(os.path.isfile(binfile))
2123

24+
if platform.system() == 'Linux':
25+
proc = Popen(['strings', 'mytest.bin'], stdout=PIPE, stderr=PIPE)
26+
out, err = proc.communicate()
27+
print out
28+
assert("42" not in out)
29+
2230
driver = webdriver.Chrome(executable_path=os.environ['CHROMEDRIVER'], chrome_options=chrome_options)
2331
try:
2432
print driver.current_url
2533
time.sleep(1)
2634
result = driver.find_element_by_id('result')
2735
print result.get_attribute('innerHTML')
2836
assert("44" == result.get_attribute('innerHTML'))
37+
result2 = driver.find_element_by_id('result2')
38+
print result2.get_attribute('innerHTML')
39+
assert("native code" in result2)
2940
finally:
3041
driver.quit()

0 commit comments

Comments
 (0)