Skip to content

Commit

Permalink
test case for issue nwjs#4187
Browse files Browse the repository at this point in the history
  • Loading branch information
Cong Liu committed Jan 19, 2016
1 parent 6e616ed commit 8d8de5d
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 0 deletions.
31 changes: 31 additions & 0 deletions test/remoting/issue4187-close-hidden/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>hidden crash</title>
</head>

<body>
<h1 id="result">success</h1>
<script>
nw.Window.open('splash.html', {}, function(ssWin) {

ssWin.on('loaded', function() {
console.log('on ssWin loaded');

setTimeout(function() {
ssWin.close();
ssWin = null;

console.log('close window');
nw.Window.get().show();
}, 3000);
});

});

</script>
</body>

</html>
7 changes: 7 additions & 0 deletions test/remoting/issue4187-close-hidden/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"name": "issue4187-close-hidden",
"main": "index.html",
"window": {
"show": false
}
}
14 changes: 14 additions & 0 deletions test/remoting/issue4187-close-hidden/splash.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<!DOCTYPE html>
<html>

<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>splash</title>
</head>

<body>
<h1>This is a splash</h1>
</body>

</html>
25 changes: 25 additions & 0 deletions test/remoting/issue4187-close-hidden/test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import time
import os

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

chrome_options = Options()
chrome_options.add_argument("nwapp=" + os.path.dirname(os.path.abspath(__file__)))

driver = webdriver.Chrome(executable_path=os.environ['CHROMEDRIVER'], chrome_options=chrome_options)
driver.implicitly_wait(2)
time.sleep(1)
try:
print driver.current_url
time.sleep(1) # wait for window open
print 'Wait for splash window close'
while len(driver.window_handles) != 1:
time.sleep(1)
print driver.window_handles
driver.switch_to_window(driver.window_handles[0])
result = driver.find_element_by_id('result').get_attribute('innerHTML')
print result
assert('success' in result)
finally:
driver.quit()

0 comments on commit 8d8de5d

Please sign in to comment.