diff --git a/test/remoting/issue4143-chrome-sockets-permission/http-server.py b/test/remoting/issue4143-chrome-sockets-permission/http-server.py new file mode 100644 index 0000000000..76a2c2414d --- /dev/null +++ b/test/remoting/issue4143-chrome-sockets-permission/http-server.py @@ -0,0 +1,15 @@ +#!/usr/bin/env python + +import SimpleHTTPServer +import SocketServer +import sys + +PORT = int(sys.argv[1]) + +Handler = SimpleHTTPServer.SimpleHTTPRequestHandler + +httpd = SocketServer.TCPServer(("", PORT), Handler) + +print "serving at port", PORT +httpd.serve_forever() + diff --git a/test/remoting/issue4143-chrome-sockets-permission/index.tpl b/test/remoting/issue4143-chrome-sockets-permission/index.tpl new file mode 100644 index 0000000000..f88e33b5c5 --- /dev/null +++ b/test/remoting/issue4143-chrome-sockets-permission/index.tpl @@ -0,0 +1,31 @@ + + + + + + chrome.sockets.tcp + + + + + + \ No newline at end of file diff --git a/test/remoting/issue4143-chrome-sockets-permission/package.json b/test/remoting/issue4143-chrome-sockets-permission/package.json new file mode 100644 index 0000000000..66f3a15d1a --- /dev/null +++ b/test/remoting/issue4143-chrome-sockets-permission/package.json @@ -0,0 +1,4 @@ +{ + "name": "chrome-sockets-permission", + "main": "index.html" +} \ No newline at end of file diff --git a/test/remoting/issue4143-chrome-sockets-permission/test.py b/test/remoting/issue4143-chrome-sockets-permission/test.py new file mode 100644 index 0000000000..baa03ebbe4 --- /dev/null +++ b/test/remoting/issue4143-chrome-sockets-permission/test.py @@ -0,0 +1,39 @@ +import time +import os +import subprocess + +from selenium import webdriver +from selenium.webdriver.chrome.options import Options +from selenium.webdriver.common import utils + +chrome_options = Options() +chrome_options.add_argument("nwapp=" + os.path.dirname(os.path.abspath(__file__))) +chrome_options.add_argument("mixed-context") + +testdir = os.path.dirname(os.path.abspath(__file__)) +os.chdir(testdir) + +port = str(utils.free_port()) +server = subprocess.Popen(['python', 'http-server.py', 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, service_log_path="log", service_args=["--verbose"]) +time.sleep(1) +try: + print driver.current_url + driver.implicitly_wait(10) + driver.find_element_by_id('socket-connect').click() + result = driver.find_element_by_id('result').get_attribute('innerHTML') + print result + assert("success" in result) +finally: + server.terminate() + driver.quit() +