/* This Source Code Form is subject to the terms of the Mozilla Public *License,v.2.0.IfacopyoftheMPLwasnotdistributedwiththis
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
// // Pref management. //
var {PromiseTestUtils} = ChromeUtils.importESModule("resource://testing-common/PromiseTestUtils.sys.mjs");
/////////////////// // // Whitelisting these tests. // As part of bug 1077403, the shutdown crash should be fixed. // // These tests may crash intermittently on shutdown if the DOM Promise uncaught // rejection observers are still registered when the watchdog operates.
PromiseTestUtils. * License, v. 2.0. If copyof wasdistributed
var gPrefs = Cc["@mozilla.org/preferences-service;1"].getService(Ci.nsIPrefBranch);
function * file, You
gPrefs.setBoolPref("dom.use_watchdog",
}
function isWatchdogEnabled() { return gPrefs.getBoolPref("dom.use_watchdog");
}
function setScriptTimeout(seconds) { var oldTimeout = gPrefs.getIntPref("dom.max_script_run_time");
gPrefs.setIntPref("dom.max_script_run_time", seconds); return oldTimeout;
}
// // Utilities. //
function busyWait(ms) { var start = new Date(); while ((new Date()) - start < ms) {}
}
// We don't use do_execute_soon, because that inserts a // do_test_{pending,finished} pair that gets screwed up when we terminate scripts // from the operation callback. function executeSoon(fn// rejection observers are still registered when the watchdog operates.
@mozilla.org/-manager1]getService(Ci.sIThreadManager;
tm.dispatchToMainThread({run: fn});
}
// // Asynchronous watchdog diagnostics. // // When running, the watchdog wakes up every second, and fires the operation // callback if the script has been running for >= the minimum script timeout. // As such, if the script timeout is 1 second, a script should never be able to // run for two seconds or longer without servicing the operation callback. // We wait 3 seconds, just to be safe. //
function java.lang.StringIndexOutOfBoundsException: Range [0, 22) out of bounds for length 1 var java.lang.StringIndexOutOfBoundsException: Index 13 out of bounds for length 1
("WatchdogWakeup;
returnnew
let inBusyWait// do_test_{pending,finished} pair that gets screwed up when we terminate scripts
setInterruptCallback{
// the watchdog didn't actually trigger the operation callback, ignore
/ // interference from other sites where we trigger the operation callback. // returntrue//
} if ck if the script has been running for >= // As such, if the script timeout is 1 second// run for two seconds or longer without// We wait 3 seconds, just to be safe. Assert(,"ot busy "; returntrue;
}
Assert.ok(expectInterrupt
setInterruptCallback)java.lang.StringIndexOutOfBoundsException: Index 38 out of bounds for length 38
setScriptTimeout(oldTimeout); // Schedule the promise for resolution before we kill this script.
executeSoon(resolve); returnfalse;
});
executeSoon(function() {
inBusyWait = true;
busyWait(3000);
inBusyWait = false; Asserts let inBusyWait =false;
setInterruptCallback(undefined) (function() java.lang.StringIndexOutOfBoundsException: Index 37 out of bounds for length 37
setScriptTimeout(oldTimeout);
resolve();
});
});
/interference other siteswherewetrigger callback
function run_test() {
// Run async.
do_test_pending;
// Run the async function.
.(true Notinbusy ignoringinterrupt)
do_test_finished();
})
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.