Skip to content

Commit 44fe510

Browse files
wanghongjuanrogerwang
authored andcommitted
[test] Add test for isse6136
- Add test for issue nwjs#6136 - This case is failed on failed version 0.24.4, pass on fixed version 0.28.0-beta1
1 parent d0aa0f3 commit 44fe510

File tree

6 files changed

+115
-0
lines changed

6 files changed

+115
-0
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<!doctype html>
2+
<html>
3+
<head>
4+
<meta charset="utf-8">
5+
<title>nwjs-history-escapes-iframe</title>
6+
</head>
7+
<body>
8+
<h1>Iframe index</h1>
9+
<a href="iframe-second-page.html">Next</a>
10+
</body>
11+
</html>
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<!doctype html>
2+
<html>
3+
<head>
4+
<meta charset="utf-8">
5+
<title>nwjs-history-escapes-iframe</title>
6+
</head>
7+
<body>
8+
<h1>Iframe Second Page</h1>
9+
<p>In 3 seconds it will go back to the "Index" page escaping iframe, but it should not!</p>
10+
<script>
11+
setTimeout(function () {
12+
history.back();
13+
history.back();
14+
history.back();
15+
history.back();
16+
history.back();
17+
history.back();
18+
}, 3000);
19+
</script>
20+
</body>
21+
</html>
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<!doctype html>
2+
<html>
3+
<head>
4+
<meta charset="utf-8">
5+
<title>nwjs-history-escapes-iframe</title>
6+
</head>
7+
<body>
8+
<h1>Index</h1>
9+
<a href="second-page.html">Next</a>
10+
</body>
11+
</html>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"name": "nwjs-history-escapes-iframe",
3+
"main": "index.html"
4+
}
5+
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<!doctype html>
2+
<html>
3+
<head>
4+
<meta charset="utf-8">
5+
<title>nwjs-history-escapes-iframe</title>
6+
</head>
7+
<body>
8+
<h1>Second Page</h1>
9+
<p>nwdisable="true" nwfaketop="true"</p>
10+
<iframe nwdisable="true" nwfaketop="true" nwUserAgent="test" src="iframe-index.html"></iframe>
11+
</body>
12+
</html>
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
import time
2+
import os
3+
import platform
4+
import sys
5+
6+
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
7+
from nw_util import *
8+
9+
from selenium import webdriver
10+
from selenium.webdriver.chrome.options import Options
11+
12+
chrome_options = Options()
13+
testdir = os.path.dirname(os.path.abspath(__file__))
14+
chrome_options.add_argument('nwapp=' + testdir)
15+
16+
driver = webdriver.Chrome(executable_path=os.environ['CHROMEDRIVER'], chrome_options=chrome_options)
17+
driver.implicitly_wait(2)
18+
try:
19+
print driver.current_url
20+
21+
print 'Click Next button'
22+
driver.find_element_by_tag_name('a').click()
23+
output = wait_for_element_tag(driver, 'h1')
24+
assert('Second Page' in output)
25+
assert(driver.find_element_by_tag_name('iframe') is not None)
26+
27+
print 'Switch to iframe'
28+
driver.switch_to_frame(driver.find_element_by_tag_name('iframe'))
29+
result1 = wait_for_element_tag(driver, 'h1')
30+
assert('Iframe index' in result1)
31+
32+
print 'Click Next button in Iframe index page'
33+
driver.find_element_by_tag_name('a').click()
34+
35+
print 'Switch to second iframe'
36+
result2 = wait_for_element_tag(driver, 'h1')
37+
assert('Iframe Second Page' in result2)
38+
39+
print 'waiting for back to iframe page'
40+
timeout = 4
41+
while timeout > 0:
42+
try:
43+
output = driver.find_element_by_tag_name('h1').get_attribute('innerHTML')
44+
assert('Iframe Second Page' in output)
45+
break
46+
except selenium.common.exceptions.WebDriverException:
47+
pass
48+
time.sleep(1)
49+
timeout = timeout - 1
50+
if timeout <= 0:
51+
raise Exception('Timeout when waiting for element')
52+
print 'Return to inframe page'
53+
54+
finally:
55+
driver.quit()

0 commit comments

Comments
 (0)