Bug 1270729 - When stopping slow scripts totally halt script execution; r=bholley
--- a/js/xpconnect/src/XPCJSRuntime.cpp
+++ b/js/xpconnect/src/XPCJSRuntime.cpp
@@ -1439,18 +1439,21 @@ XPCJSRuntime::InterruptCallback(JSContex
if (!chrome && !self->mTimeoutAccumulated) {
uint32_t delay = uint32_t(self->mSlowScriptActualWait.ToMilliseconds() - (limit * 1000.0));
Telemetry::Accumulate(Telemetry::SLOW_SCRIPT_NOTIFY_DELAY, delay);
self->mTimeoutAccumulated = true;
}
// Show the prompt to the user, and kill if requested.
nsGlobalWindow::SlowScriptResponse response = win->ShowSlowScriptDialog();
- if (response == nsGlobalWindow::KillSlowScript)
+ if (response == nsGlobalWindow::KillSlowScript) {
+ if (Preferences::GetBool("dom.global_stop_script", true))
+ xpc::Scriptability::Get(global).Block();
return false;
+ }
// The user chose to continue the script. Reset the timer, and disable this
// machinery with a pref of the user opted out of future slow-script dialogs.
if (response != nsGlobalWindow::ContinueSlowScriptAndKeepNotifying)
self->mSlowScriptCheckpoint = TimeStamp::NowLoRes();
if (response == nsGlobalWindow::AlwaysContinueSlowScript)
Preferences::SetInt(prefName, 0);
--- a/modules/libpref/init/all.js
+++ b/modules/libpref/init/all.js
@@ -2644,16 +2644,19 @@ pref("gestures.enable_single_finger_inpu
pref("editor.resizing.preserve_ratio", true);
pref("editor.positioning.offset", 0);
pref("dom.use_watchdog", true);
pref("dom.max_chrome_script_run_time", 20);
pref("dom.max_script_run_time", 10);
+// Stop all scripts in a compartment when the "stop script" dialog is used.
+pref("dom.global_stop_script", true);
+
// If true, ArchiveReader will be enabled
pref("dom.archivereader.enabled", false);
// Hang monitor timeout after which we kill the browser, in seconds
// (0 is disabled)
// Disabled on all platforms per bug 705748 until the found issues are
// resolved.
pref("hangmonitor.timeout", 0);