Bug 1371664 P5 Fix browser_timeout_throttling_with_audio_playback.js not to expect clamping in background windows using audio. r=ehsan

This commit is contained in:
Ben Kelly 2017-06-13 18:08:28 -07:00
Родитель a3c8156b38
Коммит 4eb739057c
1 изменённых файлов: 15 добавлений и 13 удалений

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

@ -9,13 +9,19 @@ var testURLs = [
// We want to ensure that while audio is being played back, a background tab is
// treated the same as a foreground tab as far as timeout throttling is concerned.
// So we use a 10ms minimum timeout value for foreground tabs and a 100,000 second
// minimum timeout value for background tabs. This means that in case the test
// fails, it will time out in practice, but just for sanity the test condition
// ensures that the observed timeout delay falls in this range.
const kMinTimeoutForeground = 10;
// So we use a 100,000 second minimum timeout value for background tabs. This
// means that in case the test fails, it will time out in practice, but just for
// sanity the test condition ensures that the observed timeout delay falls in
// this range.
const kMinTimeoutBackground = 100 * 1000 * 1000;
const kDelay = 10;
// Allow a very generous error range due to debug automation tests running
// very slowly. This is still far below the configured background throttle
// amount.
const kAllowedError = 1000;
Services.scriptloader.loadSubScript(kPluginJS, this);
function* runTest(url) {
@ -31,19 +37,16 @@ function* runTest(url) {
// Put the tab in the background.
yield BrowserTestUtils.switchTab(gBrowser, currentTab);
let timeout = yield ContentTask.spawn(newBrowser, {}, function() {
let timeout = yield ContentTask.spawn(newBrowser, kDelay, function(delay) {
return new Promise(resolve => {
let before = new Date();
content.window.setTimeout(function() {
let after = new Date();
// Sometimes due to rounding errors, we may get a result of 9ms here, so
// let's round up by 1 to protect against such intermittent failures.
resolve(after - before + 1);
}, 0);
resolve(after - before);
}, delay);
});
});
ok(timeout >= kMinTimeoutForeground &&
timeout < kMinTimeoutBackground, `Got the correct timeout (${timeout})`);
ok(timeout <= kDelay + kAllowedError, `Got the correct timeout (${timeout}`);
// All done.
yield BrowserTestUtils.removeTab(newTab);
@ -51,7 +54,6 @@ function* runTest(url) {
add_task(function* setup() {
yield SpecialPowers.pushPrefEnv({"set": [
["dom.min_timeout_value", kMinTimeoutForeground],
["dom.min_background_timeout_value", kMinTimeoutBackground],
]});
});