Skip to content

Commit 33b18bc

Browse files
wanghongjuanrogerwang
authored andcommitted
[test] Add test for issue5730
- Add test for issue nwjs#5730 - This case is failed on failed version 0.20.3, passed on fixed version 0.27.5
1 parent 115eaf2 commit 33b18bc

File tree

8 files changed

+113
-0
lines changed

8 files changed

+113
-0
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
chrome.app.runtime.onLaunched.addListener(function(launchData) {
2+
chrome.app.window.create(
3+
'index.html',
4+
{
5+
id: 'mainWindow',
6+
bounds: {width: 800, height: 500}
7+
}
8+
);
9+
});
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<meta charset="utf-8" />
5+
<link rel="stylesheet" type="text/css" href="style.css"/>
6+
<script src="jquery.min.js"></script>
7+
8+
</head>
9+
10+
<body>
11+
<div><b>Request normal: </b><span id="request1"></span>
12+
<div><b>Webview delayed: </b><span id="request2"></span>
13+
</div>
14+
15+
<webview src="https://nwjs.io/"></webview>
16+
<script src="main.js"></script>
17+
</body>
18+
</html>

test/sanity/issue5730-add-node-in-permissions/jquery.min.js

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
2+
$(function() {
3+
4+
var wv = document.querySelector('webview');
5+
document.getElementById("request1").innerHTML = JSON.stringify(wv.request);
6+
7+
setTimeout(function(){
8+
document.getElementById("request2").innerHTML = JSON.stringify(wv.request);
9+
}, 500);
10+
11+
12+
})
13+
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"manifest_version": 2,
3+
"name": "issue5730-add-node-in-permissions",
4+
"short_name": "Webview Test",
5+
"description": "",
6+
"version": "1.0",
7+
8+
"app": {
9+
"background": {
10+
"scripts": ["background.js"]
11+
}
12+
},
13+
"permissions": [
14+
"node",
15+
"webview"
16+
]
17+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
body {
2+
font-family: sans-serif;
3+
}
4+
5+
webview {
6+
width: 100%;
7+
height: 90vh;
8+
display: flex;
9+
margin: 10px 10px 0 0;
10+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/* CSS file placeholder. */
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import time
2+
import os
3+
4+
from selenium import webdriver
5+
from selenium.webdriver.chrome.options import Options
6+
7+
chrome_options = Options()
8+
testdir = os.path.dirname(os.path.abspath(__file__))
9+
chrome_options.add_argument('nwapp=' + testdir)
10+
11+
driver = webdriver.Chrome(executable_path=os.environ['CHROMEDRIVER'], chrome_options=chrome_options)
12+
driver.implicitly_wait(3)
13+
try:
14+
print driver.current_url
15+
ret1 = ''
16+
ret2 = ''
17+
timeout = 10
18+
while timeout > 0:
19+
try:
20+
ret2 = driver.find_element_by_id('request2').get_attribute('innerHTML')
21+
ret1 = driver.find_element_by_id('request1').get_attribute('innerHTML')
22+
if (ret2 != ''):
23+
print 'show webview delayed value'
24+
print ret2
25+
print 'show request normatl value'
26+
print ret1
27+
break
28+
except selenium.common.exceptions.NoSuchElementException:
29+
pass
30+
31+
time.sleep(1)
32+
timeout = timeout - 1
33+
if timeout <= 0:
34+
raise Exception('Timeout when waiting for element' + elem_id)
35+
36+
assert('onRequest' in ret2)
37+
assert('onRequest' in ret1)
38+
39+
finally:
40+
driver.quit()

0 commit comments

Comments
 (0)