Skip to content

Commit a08215c

Browse files
wanghongjuanrogerwang
authored andcommitted
[test] Add test for issue4993
- Add test for issue nwjs#4993 - This test is failed on v0.15.4, passed on v0.30.4
1 parent 225296f commit a08215c

File tree

3 files changed

+57
-0
lines changed

3 files changed

+57
-0
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<meta charset="utf-8">
5+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
6+
<title>4993</title>
7+
</head>
8+
<body>
9+
<button id="resize-window" onclick="resizeWindow()">Resize to 777x555</button>
10+
<script>
11+
function out(id, msg) {
12+
var h1 = document.createElement('h1');
13+
h1.setAttribute('id', id);
14+
h1.innerHTML = msg;
15+
document.body.appendChild(h1);
16+
}
17+
function resizeWindow() {
18+
nw.Window.get().resizeTo(777,555);
19+
}
20+
21+
var res;
22+
nw.Window.get().on('resize', (width, height) => {
23+
if (res){clearTimeout(res)};
24+
res = setTimeout(function(){
25+
out('resize', 'width:' + width + ', height: ' + height);
26+
},100);
27+
});
28+
</script>
29+
</body>
30+
</html>
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"name": "4993",
3+
"main": "index.html"
4+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import os
2+
import sys
3+
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
4+
from nw_util import *
5+
6+
from selenium import webdriver
7+
from selenium.webdriver.chrome.options import Options
8+
from selenium.webdriver.common.action_chains import ActionChains
9+
10+
chrome_options = Options()
11+
chrome_options.add_argument("nwapp=" + os.path.dirname(os.path.abspath(__file__)))
12+
13+
driver = webdriver.Chrome(executable_path=os.environ['CHROMEDRIVER'], chrome_options=chrome_options)
14+
driver.implicitly_wait(2)
15+
try:
16+
print driver.current_url
17+
element = driver.find_element_by_id('resize-window')
18+
ActionChains(driver).click(element).perform()
19+
res = wait_for_element_id(driver, "resize")
20+
print res
21+
assert("width: 777, height: 555" in res)
22+
finally:
23+
driver.quit()

0 commit comments

Comments
 (0)