Skip to content

Commit a889442

Browse files
committed
[test] add issue7609-mixed-context for nwjs#7609
1 parent 20b5033 commit a889442

File tree

4 files changed

+56
-0
lines changed

4 files changed

+56
-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+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
6+
<title>child.html</title>
7+
</head>
8+
<body>
9+
<script>document.write('<h1 id="result">typeof module = ' + typeof module + '</h1>')</script>
10+
</body>
11+
</html>
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<meta charset="utf-8">
5+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
6+
<title>issue5163</title>
7+
</head>
8+
<body>
9+
<button id="spawnRender" type="button" onclick="spawnRender()">Create New Instance Window</button>
10+
<script>
11+
function spawnRender() {
12+
nw.Window.open('child.html', {new_instance: true, mixed_context: true});
13+
}
14+
</script>
15+
</body>
16+
</html>
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"name": "issue5163-new-instance",
3+
"main": "index.html"
4+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import time
2+
import os
3+
import sys
4+
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
5+
from nw_util import *
6+
7+
from selenium import webdriver
8+
from selenium.webdriver.chrome.options import Options
9+
chrome_options = Options()
10+
chrome_options.add_argument("nwapp=" + os.path.dirname(os.path.abspath(__file__)))
11+
12+
driver = webdriver.Chrome(executable_path=os.environ['CHROMEDRIVER'], chrome_options=chrome_options)
13+
try:
14+
print driver.current_url
15+
driver.find_element_by_id('spawnRender').click()
16+
print 'wait for window open'
17+
wait_window_handles(driver, 2)
18+
print driver.window_handles
19+
print 'switch to 1st window'
20+
driver.switch_to_window(driver.window_handles[-1])
21+
result1 = driver.find_element_by_id('result').get_attribute('innerHTML')
22+
print result1
23+
assert('object' in result1)
24+
finally:
25+
driver.quit()

0 commit comments

Comments
 (0)