【问题标题】:How to make Firefox restore its state properly when launched from vscode debug?从 vscode 调试启动时,如何使 Firefox 正确恢复其状态?
【发布时间】:2020-07-10 07:30:09
【问题描述】:

对于我的 React webapp,我有一个启动配置来启动 Chrome 或 Firefox 进行调试。两者都工作得很好,除了 Firefox 在调试启动后没有恢复它以前的设置(或者它甚至没有保存它们)。

当我启动 Chrome 时,它​​会记住浏览器的大小和位置,以及我接受了本地主机的自签名证书。

Firefox 不会做任何事情。启动后,我总是必须重新定位窗口并再次接受自签名证书,随着时间的推移,这真的很烦人。

这是我的启动设置:

{
    "version": "0.2.0",
    "configurations": [
        {
            "type": "firefox",
            "request": "launch",
            "reAttach": true,
            "name": "Launch MSG on FF",
            "url": "https://localhost:3001",
            "webRoot": "${workspaceFolder}/src",
            "clearConsoleOnReload": true,
            "preLaunchTask": "tsc: watch"
        },
        {
            "type": "chrome",
            "request": "launch",
            "name": "Launch MSG on Chrome",
            "url": "https://localhost:3001",
            "webRoot": "${workspaceFolder}/src",
            "userDataDir": "${workspaceRoot}/.vscode/chrome",
            "sourceMaps": true,
            "preLaunchTask": "tsc: watch",
            "sourceMapPathOverrides": {
                "webpack:///build/*": "${webRoot}/*"
            }
        },
        {
            "type": "node",
            "name": "Run Tests",
            "request": "launch",
            "program": "${workspaceFolder}/node_modules/jest/bin/jest",
            "args": [
                "--config ${workspaceFolder}/jest.config.js"
            ],
            "cwd": "${workspaceFolder}",
            "console": "integratedTerminal",
            "internalConsoleOptions": "neverOpen",
            "disableOptimisticBPs": true
        }
    ]
}

在从 vscode 调试时,需要更改什么以使 FF 也保持最后的状态?

以防万一:我在 macOS 上,调试实例的 FF 配置文件文件夹位于 /var/folders/03/... 中(并且该文件夹存在并且是可写的)。

【问题讨论】:

    标签: reactjs firefox visual-studio-code


    【解决方案1】:

    您正在寻找以下标志:

    keepProfileChanges : true
    

    此外,您可以使用以下方式指定配置文件:

    profile : "dev"
    

    还有一点,您可以使用以下命令自动打开开发工具:

    firefoxArgs : [
       -devtools
    ]
    

    为简洁起见:

    "configurations": [
      {
        "type": "firefox",
        "request": "launch",
        "reAttach": true,
        "name": "Launch Name",
        "clearConsoleOnReload": true,
        "keepProfileChanges": true,
        "profile": "dev",
        "firefoxArgs": [
            "-devtools",
        ]
    ]
    

    如果您需要创建配置文件的资源:@​​987654321@

    Firefox CLI ref

    【讨论】:

    • 这是朝着正确方向迈出的一步!但是,浏览器窗口位置仍未保存(但至少证书警告不再显示)。另请注意:在 macOS 上,您必须删除 reAttach 设置(即使错误说明相反)。否则 vscode 不会启动 FF。
    • 嗯,我没有这个问题,可能是因为我使用的是 Windows。找到了一个可以帮助@MikeLischke support.mozilla.org/en-US/kb/… 的链接
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-07-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多