Skip to content

Commit

Permalink
test case for issue #4007
Browse files Browse the repository at this point in the history
  • Loading branch information
Cong Liu committed Jan 15, 2016
1 parent 328d8f0 commit b2c04b8
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 0 deletions.
25 changes: 25 additions & 0 deletions test/remoting/issue4007-reload-lost-app-window/index.html
@@ -0,0 +1,25 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Reload Lost appWindow</title>
<link rel="stylesheet" href="">
</head>
<body>
<h1>Reload the app</h1>
<button id="reloadapp" onclick="reloadApp()">Reload</button>
<script>
function reloadApp() {
chrome.runtime.reload();
}

try {
nw.Window.get()
document.write('<h1 id="result">success</h1>');
} catch (e) {
document.write('<h1 id="result">failed</h1>');
}
</script>
</body>
</html>
4 changes: 4 additions & 0 deletions test/remoting/issue4007-reload-lost-app-window/package.json
@@ -0,0 +1,4 @@
{
"name":"issue4007-reload-lost-app-window",
"main":"index.html"
}
28 changes: 28 additions & 0 deletions test/remoting/issue4007-reload-lost-app-window/test.py
@@ -0,0 +1,28 @@
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)
time.sleep(1)
try:
print driver.current_url
result = driver.find_element_by_id('result').get_attribute('innerHTML')
print result
assert("success" in result)
driver.find_element_by_id('reloadapp').click()
# wait 10s for reload complete
# on Linux, the reload is quite slow
time.sleep(10)
print driver.window_handles
# devtools will be opened as the first window handle
# real window is the last one
driver.switch_to_window(driver.window_handles[-1])
result = driver.find_element_by_id('result').get_attribute('innerHTML')
print result
assert("success" in result)
finally:
driver.quit()

0 comments on commit b2c04b8

Please sign in to comment.