Bug 1270729 - When stopping slow scripts totally halt script execution; r=bholley
authorMorgan Phillips <winter2718@gmail.com>
Mon, 16 May 2016 01:20:06 -0700
changeset 299032 e40a0a79995f436d45560da4865df67d20df12af
parent 299031 22c42d243a5cb24bd97efa201ecaa4d3c5965502
child 299033 1663fc3667704a407270f3395c20719b197763e7
push id77405
push usermphillips@mozilla.com
push dateWed, 25 May 2016 20:40:39 +0000
treeherdermozilla-inbound@e40a0a79995f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbholley
bugs1270729
milestone49.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1270729 - When stopping slow scripts totally halt script execution; r=bholley
js/xpconnect/src/XPCJSRuntime.cpp
modules/libpref/init/all.js
--- 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);