How to toggle Device Mode on a popup window in Chrome?

Deadly 提交于 2019-12-02 04:20:37

问题


I have a web app with a chat that opens in a new popup window. Normally, in Chrome I can hit F12 and click the icon of a smart phone to toggle it. But in the popup window this icon does not appear. This is important for me since I need to throttle the connection of the popup in order to simulate a user disconnecting from the chat.

Thanks!


回答1:


It doesn't seem to be currently possible. I've opened a ticket for you. Meanwhile you have couple of options:

  • open popup in a regular window (copy paste the url, or modify window.open call to open a new tab instead of a separate window),
  • create a Chrome extension that uses debugger API to send emulateNetworkConditions message to your popup window
  • or try hacking DevTools like so:
    • open DevTools (A) for your popup
    • focus on DevTools window and open another DevTools (B) for that window using a keyboard shortcut (F12/alt+cmd+J)
    • in the console of the DevTools B call WebInspector.overridesSupport.setEmulationEnabled(true) (to enable emulation) and then WebInspector.overridesSupport.settings.networkConditions.set({throughput: 1.5 * 1024, latency: 40}); (to enable network throttling)


来源:https://stackoverflow.com/questions/30786150/how-to-toggle-device-mode-on-a-popup-window-in-chrome

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!