使用严格模式时无法检查范围变量

Tim*_*imm 14 javascript safari web-inspector

在Safari中运行以下脚本时(打开Inspector)

window.onload = function() { 
    "use strict";
    var x = 1;
    debugger; // debugger will auto-break on this line
}
Run Code Online (Sandbox Code Playgroud)

x在断点上时,在控制台中询问时出现以下错误:

Error
message: "'with' statements are not valid in strict mode"
Run Code Online (Sandbox Code Playgroud)

删除该"use strict";行允许我x在该断点处从控制台访问.

两次都x显示Scope Variables在侧栏中.

Rig*_*red 24

这似乎是Safari的一个已知问题:https://bugs.webkit.org/show_bug.cgi? id = 65829

要重现错误,您只需在控制台中键入任何代码,同时在断点处和严格模式下停止.

这是bug报告中的代码:

(function(){
    "use strict";
    debugger;
})();
Run Code Online (Sandbox Code Playgroud)

因此,当您在断点处时,转到控制台并键入2+3(或任何表达式),您将获得错误.

在此输入图像描述