chrome headless handles popups
Reported by
dm.wh...@gmail.com,
Sep 5 2017
|
|||||
Issue descriptionUserAgent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.113 Safari/537.36 Steps to reproduce the problem: start chrome in command line: chrome --headless --disable-gpu --remote-debugging-port=9222 --disable-xssauditor --disable-client-side-phishing-detection --disable-sync --disable-web-resources server the html code below on the local server. <div style="display:none"><form action="http://www.qq.com" method="post" name="popup" target="_blank"><input type="submit" style="display:none"/></form></div> <script type="text/javascript"> document.getElementsByName("popup")[0].submit(); </script> run python code below. from websocket import create_connection import requests tab = requests.get("http://127.0.0.1:9222/json/new").json() tab_ws_url = tab['webSocketDebuggerUrl'] ws = create_connection(tab_ws_url) ws.settimeout(5) ws.send(json.dumps({ "method": "Page.navigate", "id": 2, "params": {"url": "http://127.0.0.1:8000/untitled.html"} })) while True: try: data = ws.recv() print(json.loads(data)) except WebSocketTimeoutException: break requests.get("http://127.0.0.1:9222/json/close/{}".format(tab['id'])) 3. see opened tabs with curl. curl http://127.0.0.1/json I see it will auto open a tab when meets popups in headless mode. but starts without headless mode, it will auto block popups. like below. so I want to auto block popups in headless mode, that means not open a new tab in headless mode or let me know what tab is opened. I tried enable Target.setDiscoverTargets and monitor the Target.targetCreated but it will recv all opened tabs before. What is the expected behavior? don't open popup window in headless mode or let me known what new window is opened. What went wrong? ad window popups when in headless mode. Did this work before? No Chrome version: 60.0.3112.113 Channel: stable OS Version: OS X 10.12.6 Flash Version: Shockwave Flash 26.0 r0 thanks.
,
Sep 6 2017
,
Sep 7 2017
Adding appropriate labels for further triaging. Thanks!
,
Sep 7 2017
,
Sep 11 2017
Thanks for the bug report! I'll mark this as WAI for now, since this is how it should work for headless. The best to handle this is through the Target.targetCreated event, as you suggest. You should be able to capture those events and call Target.closeTarget to close popup. Would that work for you? |
|||||
►
Sign in to add a comment |
|||||
Comment 1 by dm.wh...@gmail.com
, Sep 5 2017