Skip to content

Commit b13e068

Browse files
wanghongjuanrogerwang
authored andcommitted
[test] add test for issue5906
- Add test for issue nwjs#5906 - This case is pass on v0.22.2 and v0.27.4
1 parent 146fae3 commit b13e068

File tree

3 files changed

+54
-0
lines changed

3 files changed

+54
-0
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<style type="text/css">
2+
#demo{
3+
display: inline-block;
4+
height: 200px;
5+
width: 320px;
6+
}
7+
</style>
8+
<webview id="demo" partition="trusted" src="about:blank"></webview>
9+
<script>
10+
var win = nw.Window.get();
11+
function out(id, msg) {
12+
var h2 = document.createElement("h2");
13+
h2.setAttribute("id", id);
14+
h2.innerHTML = msg;
15+
document.body.appendChild(h2);
16+
}
17+
var webview = document.getElementById("demo");
18+
document.addEventListener("DOMContentLoaded", function (event) {
19+
setTimeout(() => {
20+
storeId = webview.getCookieStoreId()
21+
out('result', storeId)
22+
}, 1000)
23+
})
24+
</script>
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"name": "issue5906-webview-getCookieStoreId",
3+
"main": "index.html"
4+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import time
2+
import os
3+
import sys
4+
5+
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
6+
from nw_util import *
7+
8+
from selenium import webdriver
9+
from selenium.webdriver.chrome.options import Options
10+
11+
chrome_options = Options()
12+
testdir = os.path.dirname(os.path.abspath(__file__))
13+
chrome_options.add_argument("nwapp=" + testdir)
14+
15+
driver = webdriver.Chrome(executable_path=os.environ['CHROMEDRIVER'], chrome_options=chrome_options)
16+
driver.implicitly_wait(5)
17+
time.sleep(1)
18+
try:
19+
print driver.current_url
20+
print 'waiting to load storeId in cookie'
21+
result = wait_for_element_tag(driver, "h2")
22+
print result
23+
assert(len(result) > 0)
24+
print 'storeId is loaded'
25+
finally:
26+
driver.quit()

0 commit comments

Comments
 (0)