Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Cong Liu
committed
Jan 15, 2016
1 parent
328d8f0
commit b2c04b8
Showing
3 changed files
with
57 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"name":"issue4007-reload-lost-app-window", | ||
"main":"index.html" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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() |