Backed out 3 changesets (bug 1519430) for mda failures at test_autoplay_policy_web_audio_notResumePageInvokedSuspendedAudioContext.html

Backed out changeset b7bc38b0f9c5 (bug 1519430)
Backed out changeset 987aa2594ba6 (bug 1519430)
Backed out changeset 521176ad7ae8 (bug 1519430)
This commit is contained in:
Coroiu Cristina 2019-01-17 09:45:15 +02:00
Родитель 49e3dc22ba
Коммит 576b2b1b23
5 изменённых файлов: 5 добавлений и 136 удалений

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

@ -5401,7 +5401,8 @@ void nsGlobalWindowInner::Suspend() {
// Suspend all of the AudioContexts for this window
for (uint32_t i = 0; i < mAudioContexts.Length(); ++i) {
mAudioContexts[i]->SuspendFromChrome();
ErrorResult dummy;
RefPtr<Promise> d = mAudioContexts[i]->Suspend(dummy);
}
}
@ -5442,7 +5443,8 @@ void nsGlobalWindowInner::Resume() {
// Resume all of the AudioContexts for this window
for (uint32_t i = 0; i < mAudioContexts.Length(); ++i) {
mAudioContexts[i]->ResumeFromChrome();
ErrorResult dummy;
RefPtr<Promise> d = mAudioContexts[i]->Resume(dummy);
}
mTimeoutManager->Resume();

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

@ -724,8 +724,6 @@ skip-if = android_version >= '23' # bug 1424903
skip-if = android_version >= '23' # bug 1424903
[test_autoplay_policy_permission.html]
skip-if = android_version >= '23' # bug 1424903
[test_autoplay_policy_web_audio_notResumePageInvokedSuspendedAudioContext.html]
skip-if = android_version >= '23' # bug 1424903
[test_autoplay_policy_web_audio_mediaElementAudioSourceNode.html]
skip-if = android_version >= '23' # bug 1424903
[test_buffered.html]

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

@ -1,95 +0,0 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Autoplay policy test : do not resume AudioContext which is suspended by page</title>
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
<script type="text/javascript" src="manifest.js"></script>
</head>
<body>
<script>
/**
* This test is used to ensure we won't resume AudioContext which is suspended
* by page (it means calling suspend() explicitly) when calling
* `AudioScheduledSourceNode.start()`.
*/
SimpleTest.waitForExplicitFinish();
(async function testNotResumeUserInvokedSuspendedAudioContext() {
await setupTestPreferences();
const nodeTypes = ["AudioBufferSourceNode", "ConstantSourceNode", "OscillatorNode"];
for (let nodeType of nodeTypes) {
info(`- create an audio context which should not be allowed to start, it's allowed to be created, but it's forbidden to start -`);
await createAudioContext();
info(`- explicitly suspend the AudioContext in the page -`);
suspendAudioContext();
info(`- start an 'AudioScheduledSourceNode', and check that the AudioContext does not start, because it has been explicitly suspended -`);
await createAndStartAudioScheduledSourceNode(nodeType);
}
SimpleTest.finish();
})();
/**
* Test utility functions
*/
function setupTestPreferences() {
return SpecialPowers.pushPrefEnv({"set": [
["media.autoplay.default", SpecialPowers.Ci.nsIAutoplay.BLOCKED],
["media.autoplay.enabled.user-gestures-needed", true],
["media.autoplay.block-webaudio", true],
["media.autoplay.block-event.enabled", true],
]});
}
async function createAudioContext() {
window.ac = new AudioContext();
await once(ac, "blocked");
is(ac.state, "suspended", `AudioContext is blocked.`);
}
function suspendAudioContext() {
try {
ac.suspend();
} catch(e) {
ok(false, `AudioContext suspend failed!`);
}
}
async function createAndStartAudioScheduledSourceNode(nodeType) {
let node;
info(`- create ${nodeType} -`);
switch (nodeType) {
case "AudioBufferSourceNode":
node = ac.createBufferSource();
break;
case "ConstantSourceNode":
node = ac.createConstantSource();
break;
case "OscillatorNode":
node = ac.createOscillator();
break;
default:
ok(false, "undefined AudioScheduledSourceNode type");
return;
}
node.connect(ac.destination);
// activate the document in order to allow autoplay.
SpecialPowers.wrap(document).notifyUserGestureActivation();
node.start();
await once(ac, "blocked");
is(ac.state, "suspended", `AudioContext should not be resumed.`);
// reset the activation flag of the document in order not to interfere next test.
SpecialPowers.wrap(document).clearUserGestureActivation();
}
</script>

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

@ -153,7 +153,6 @@ AudioContext::AudioContext(nsPIDOMWindowInner* aWindow, bool aIsOffline,
mSuspendCalled(false),
mIsDisconnecting(false),
mWasAllowedToStart(true),
mSuspendedByContent(false),
mWasEverAllowedToStart(false),
mWasEverBlockedToStart(false),
mWouldBeAllowedToStart(true) {
@ -194,11 +193,7 @@ void AudioContext::StartBlockedAudioContextIfAllowed() {
const bool isAllowedToPlay = AutoplayPolicy::IsAllowedToPlay(*this);
AUTOPLAY_LOG("Trying to start AudioContext %p, IsAllowedToPlay=%d", this,
isAllowedToPlay);
// Only start the AudioContext if this resume() call was initiated by content,
// not if it was a result of the AudioContext starting after having been
// blocked because of the auto-play policy.
if (isAllowedToPlay && !mSuspendedByContent) {
if (isAllowedToPlay) {
ResumeInternal();
} else {
ReportBlocked();
@ -907,22 +902,11 @@ already_AddRefed<Promise> AudioContext::Suspend(ErrorResult& aRv) {
return promise.forget();
}
mSuspendedByContent = true;
mPromiseGripArray.AppendElement(promise);
SuspendInternal(promise);
return promise.forget();
}
void AudioContext::SuspendFromChrome() {
// Not support suspend call for these situations.
if (mAudioContextState == AudioContextState::Suspended ||
mIsOffline ||
(mAudioContextState == AudioContextState::Closed || mCloseCalled)) {
return;
}
SuspendInternal(nullptr);
}
void AudioContext::SuspendInternal(void* aPromise) {
Destination()->Suspend();
@ -940,16 +924,6 @@ void AudioContext::SuspendInternal(void* aPromise) {
mSuspendCalled = true;
}
void AudioContext::ResumeFromChrome() {
// Not support resume call for these situations.
if (mAudioContextState == AudioContextState::Running ||
mIsOffline ||
(mAudioContextState == AudioContextState::Closed || mCloseCalled)) {
return;
}
ResumeInternal();
}
already_AddRefed<Promise> AudioContext::Resume(ErrorResult& aRv) {
nsCOMPtr<nsIGlobalObject> parentObject = do_QueryInterface(GetParentObject());
RefPtr<Promise> promise;
@ -968,7 +942,6 @@ already_AddRefed<Promise> AudioContext::Resume(ErrorResult& aRv) {
return promise.forget();
}
mSuspendedByContent = false;
mPendingResumePromises.AppendElement(promise);
const bool isAllowedToPlay = AutoplayPolicy::IsAllowedToPlay(*this);

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

@ -201,12 +201,6 @@ class AudioContext final : public DOMEventTargetHelper,
already_AddRefed<Promise> Close(ErrorResult& aRv);
IMPL_EVENT_HANDLER(statechange)
// These two functions are similar with Suspend() and Resume(), the difference
// is they are designed for calling from chrome side, not content side. eg.
// calling from inner window, so we won't need to return promise for caller.
void SuspendFromChrome();
void ResumeFromChrome();
already_AddRefed<AudioBufferSourceNode> CreateBufferSource(ErrorResult& aRv);
already_AddRefed<ConstantSourceNode> CreateConstantSource(ErrorResult& aRv);
@ -386,9 +380,6 @@ class AudioContext final : public DOMEventTargetHelper,
// This flag stores the value of previous status of `allowed-to-start`.
bool mWasAllowedToStart;
// True if this AudioContext has been suspended by the page.
bool mSuspendedByContent;
// These variables are used for telemetry, they're not reflect the actual
// status of AudioContext, they are based on the "assumption" of enabling
// blocking web audio. Because we want to record Telemetry no matter user