Backed out changeset 4de429b6ad64 (bug 1572798) for causing browser chrome failures CLOSED TREE

This commit is contained in:
Noemi Erli 2021-01-06 07:05:57 +02:00
Родитель eb8875ae13
Коммит ebe9167de8
5 изменённых файлов: 13 добавлений и 60 удалений

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

@ -7270,7 +7270,8 @@ void Document::SetScriptGlobalObject(
// still test false at this point and no state change will happen) or we're
// doing the initial document load and don't want to fire the event for this
// change.
//
dom::VisibilityState oldState = mVisibilityState;
mVisibilityState = ComputeVisibilityState();
// When the visibility is changed, notify it to observers.
// Some observers need the notification, for example HTMLMediaElement uses
// it to update internal media resource allocation.
@ -7283,7 +7284,9 @@ void Document::SetScriptGlobalObject(
// not yet necessary. But soon after Document::SetScriptGlobalObject()
// call, the document becomes not hidden. At the time, MediaDecoder needs
// to know it and needs to start updating decoding.
UpdateVisibilityState(DispatchVisibilityChange::No);
if (oldState != mVisibilityState) {
EnumerateActivityObservers(NotifyActivityChanged);
}
// The global in the template contents owner document should be the same.
if (mTemplateContentsOwner && mTemplateContentsOwner != this) {
@ -14852,15 +14855,13 @@ void Document::UnlockPointer(Document* aDoc) {
asyncDispatcher->RunDOMEventWhenSafe();
}
void Document::UpdateVisibilityState(DispatchVisibilityChange aDispatchEvent) {
void Document::UpdateVisibilityState() {
dom::VisibilityState oldState = mVisibilityState;
mVisibilityState = ComputeVisibilityState();
if (oldState != mVisibilityState) {
if (aDispatchEvent == DispatchVisibilityChange::Yes) {
nsContentUtils::DispatchTrustedEvent(this, ToSupports(this),
u"visibilitychange"_ns,
CanBubble::eYes, Cancelable::eNo);
}
EnumerateActivityObservers(NotifyActivityChanged);
}
@ -14886,9 +14887,9 @@ VisibilityState Document::ComputeVisibilityState() const {
}
void Document::PostVisibilityUpdateEvent() {
nsCOMPtr<nsIRunnable> event = NewRunnableMethod<DispatchVisibilityChange>(
"Document::UpdateVisibilityState", this, &Document::UpdateVisibilityState,
DispatchVisibilityChange::Yes);
nsCOMPtr<nsIRunnable> event =
NewRunnableMethod("Document::UpdateVisibilityState", this,
&Document::UpdateVisibilityState);
Dispatch(TaskCategory::Other, event.forget());
}

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

@ -3207,11 +3207,7 @@ class Document : public nsINode,
// This method may fire a DOM event; if it does so it will happen
// synchronously.
//
// Whether the event fires is controlled by the argument.
enum class DispatchVisibilityChange { No, Yes };
void UpdateVisibilityState(
DispatchVisibilityChange = DispatchVisibilityChange::Yes);
void UpdateVisibilityState();
// Posts an event to call UpdateVisibilityState.
void PostVisibilityUpdateEvent();

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

@ -47,10 +47,6 @@ skip-if = (os == "win" && processor == "aarch64") || (os == "mac") || (os == "li
[browser_delay_autoplay_webAudio.js]
tags = audiochannel
skip-if = (os == "win" && processor == "aarch64") # aarch64 due to 1536573
[browser_bug1572798.js]
tags = audiochannel
skip-if = (os == "win" && processor == "aarch64") # aarch64 due to 1536573
support-files = file_document_open_audio.html
[browser_bug1170531.js]
skip-if =
os == "linux" && !debug && !ccov # Bug 1647973

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

@ -1,29 +0,0 @@
add_task(async function test_bug_1572798() {
let tab = BrowserTestUtils.addTab(window.gBrowser, "about:blank");
BrowserTestUtils.loadURI(
tab.linkedBrowser,
"https://example.com/browser/toolkit/content/tests/browser/file_document_open_audio.html"
);
await BrowserTestUtils.browserLoaded(tab.linkedBrowser);
let windowLoaded = BrowserTestUtils.waitForNewWindow();
info("- clicking button to spawn a new window -");
await ContentTask.spawn(tab.linkedBrowser, null, function() {
content.document.querySelector("button").click();
});
info("- waiting for the new window -");
let newWin = await windowLoaded;
info("- checking that the new window plays the audio -");
let documentOpenedBrowser = newWin.gBrowser.selectedBrowser;
await ContentTask.spawn(documentOpenedBrowser, null, async function() {
try {
await content.document.querySelector("audio").play();
ok(true, "Could play the audio");
} catch (e) {
ok(false, "Rejected audio promise" + e);
}
});
info("- Cleaning up -");
await BrowserTestUtils.closeWindow(newWin);
await BrowserTestUtils.removeTab(tab);
});

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

@ -1,11 +0,0 @@
<!doctype html>
<title>Test for bug 1572798</title>
<script>
function openVideo() {
var w = window.open('', '', 'width = 640, height = 480, scrollbars=yes, menubar=no, toolbar=no, resizable=yes');
w.document.open();
w.document.write('<!DOCTYPE html><title>test popup</title><audio controls src="audio.ogg"></audio>');
w.document.close();
}
</script>
<button onclick="openVideo()">Open video</button>