Bug 1696978 - Require user input for slow extension warning r=smaug,extension-reviewers,kmag

Per conversations with Bas, we want the behavior for slow extensions to match
that of slow content scripts WRT requiring user input. The test change is less
than great, but I don't think we have the ability to simulate input in
mochitests without running JS in the content process? But correct me if I'm
wrong.

Differential Revision: https://phabricator.services.mozilla.com/D107521
This commit is contained in:
Doug Thayer 2021-03-09 01:35:03 +00:00
Родитель 0a34cbc059
Коммит d9e6ea9ffe
2 изменённых файлов: 8 добавлений и 5 удалений

Просмотреть файл

@ -22,6 +22,7 @@ add_task(async function test_slow_content_script() {
["dom.ipc.processCount", DEFAULT_PROCESS_COUNT * 2],
["dom.ipc.processPrelaunch.enabled", false],
["dom.ipc.reportProcessHangs", true],
["dom.max_script_run_time.require_critical_input", false],
],
});

Просмотреть файл

@ -619,7 +619,6 @@ bool XPCJSContext::InterruptCallback(JSContext* cx) {
nsString addonId;
const char* prefName;
bool runningContentJS = false;
auto principal = BasePrincipal::Cast(nsContentUtils::SubjectPrincipal(cx));
bool chrome = principal->Is<SystemPrincipal>();
if (chrome) {
@ -633,7 +632,6 @@ bool XPCJSContext::InterruptCallback(JSContext* cx) {
} else {
prefName = PREF_MAX_SCRIPT_RUN_TIME_CONTENT;
limit = StaticPrefs::dom_max_script_run_time();
runningContentJS = true;
}
// When the parent process slow script dialog is disabled, we still want
@ -660,9 +658,13 @@ bool XPCJSContext::InterruptCallback(JSContext* cx) {
return true;
}
// For content scripts, we only want to show the slow script dialogue if the
// user is actually trying to perform an important interaction.
if (runningContentJS && XRE_IsContentProcess() &&
// For scripts in content processes, we only want to show the slow script
// dialogue if the user is actually trying to perform an important
// interaction. In theory this could be a chrome script running in the
// content process, which we probably don't want to give the user the ability
// to terminate. However, if this is the case we won't be able to map the
// script global to a window and we'll bail out below.
if (XRE_IsContentProcess() &&
StaticPrefs::dom_max_script_run_time_require_critical_input()) {
// Call possibly slow PeekMessages after the other common early returns in
// this method.