forked from nwjs/nw.js
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Add test for issue nwjs#5622 - This test is failed on v0.19.5, passed on v0.30.0
- Loading branch information
1 parent
c25a5a0
commit 3793e7c
Showing
4 changed files
with
78 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<webview id="sandbox" allownw src="about:blank"></webview> | ||
<script> | ||
const sandbox = document.getElementById('sandbox'); | ||
setTimeout(function() { | ||
sandbox.showDevTools(true); | ||
sandbox.setAttribute('src', 'http://localhost:{port}/sandbox.html'); | ||
}, 100); | ||
</script> |
4 changes: 4 additions & 0 deletions
4
test/sanity/issue5622-setTimeout-webview-node-vm/package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"name": "5622", | ||
"main": "index.html" | ||
} |
19 changes: 19 additions & 0 deletions
19
test/sanity/issue5622-setTimeout-webview-node-vm/sandbox.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<!doctype html> | ||
<html> | ||
<head> | ||
<title>5622</title> | ||
<meta charset="UTF-8"> | ||
<script> window.name = 'webview0' </script> | ||
</head> | ||
<body> | ||
<h1 id="result"></h1> | ||
<script> | ||
const vm = require('vm'); | ||
vm.runInNewContext('setTimeout(function(){document.getElementById("result").innerHTML="in sandbox"}, 10)', { | ||
console: console, | ||
document: document, | ||
setTimeout: setTimeout | ||
}); | ||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import time | ||
import os | ||
import sys | ||
import subprocess | ||
|
||
sys.path.append(os.path.join(os.path.dirname(__file__), '..')) | ||
from nw_util import * | ||
|
||
from selenium import webdriver | ||
from selenium.webdriver.chrome.options import Options | ||
from selenium.webdriver.common import utils | ||
|
||
chrome_options = Options() | ||
testdir = os.path.dirname(os.path.abspath(__file__)) | ||
chrome_options.add_argument("nwapp=" + testdir) | ||
chrome_options.add_experimental_option("windowTypes", ["webview"]) | ||
|
||
capabilities = {"pageLoadStrategy": "none"} | ||
|
||
port = str(utils.free_port()) | ||
server_file = os.path.join(testdir, "../", "http-server.py") | ||
server = subprocess.Popen(['python', server_file, port]) | ||
|
||
tpl = open('index.tpl', 'r') | ||
content = tpl.read().replace('{port}', port) | ||
tpl.close() | ||
|
||
html = open('index.html', 'w') | ||
html.write(content) | ||
html.close() | ||
|
||
driver = webdriver.Chrome(executable_path=os.environ["CHROMEDRIVER"], chrome_options=chrome_options, desired_capabilities = capabilities, service_log_path="log", service_args=["--verbose"]) | ||
driver.implicitly_wait(5) | ||
time.sleep(1) | ||
try: | ||
print driver.current_url | ||
print 'wait for window open' | ||
print driver.window_handles | ||
wait_window_handles(driver, 3) | ||
print 'switch to webview window' | ||
wait_switch_window_name(driver, 'webview0') | ||
res = wait_for_element_id(driver, "result") | ||
print res | ||
assert("in sandbox" in res) | ||
finally: | ||
server.terminate() | ||
driver.quit() |