Skip to content

Commit

Permalink
[test] test case for #5163
Browse files Browse the repository at this point in the history
  • Loading branch information
Cong Liu authored and rogerwang committed Aug 24, 2016
1 parent ca8692b commit becb87c
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 0 deletions.
11 changes: 11 additions & 0 deletions test/sanity/issue5163-new-instance/child.html
@@ -0,0 +1,11 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>child.html</title>
</head>
<body>
<script>document.write('<h1 id="result">process.pid=' + process.pid + '</h1>')</script>
</body>
</html>
16 changes: 16 additions & 0 deletions test/sanity/issue5163-new-instance/index.html
@@ -0,0 +1,16 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>issue5163</title>
</head>
<body>
<button id="spawnRender" type="button" onclick="spawnRender()">Create New Instance Window</button>
<script>
function spawnRender() {
nw.Window.open('child.html', {new_instance: true});
}
</script>
</body>
</html>
4 changes: 4 additions & 0 deletions test/sanity/issue5163-new-instance/package.json
@@ -0,0 +1,4 @@
{
"name": "issue5163-new-instance",
"main": "index.html"
}
31 changes: 31 additions & 0 deletions test/sanity/issue5163-new-instance/test.py
@@ -0,0 +1,31 @@
import time
import os
import sys
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from nw_util import *

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
driver.find_element_by_id('spawnRender').click()
driver.find_element_by_id('spawnRender').click()
print 'wait for window open'
wait_window_handles(driver, 3)
print driver.window_handles
print 'switch to 1st window'
driver.switch_to_window(driver.window_handles[-2])
result1 = driver.find_element_by_id('result').get_attribute('innerHTML')
print result1
print 'switch to 2nd window'
driver.switch_to_window(driver.window_handles[-1])
result2 = driver.find_element_by_id('result').get_attribute('innerHTML')
print result2
assert result1 != result2, "renders should not share same pid"
finally:
driver.quit()

0 comments on commit becb87c

Please sign in to comment.