Backed out 2 changesets (bug 1656414) for bc failure on browser_TabUnloader.js

Backed out changeset 210ab3a4f6d3 (bug 1656414)
Backed out changeset 576f1ac1fd81 (bug 1656414)
This commit is contained in:
Narcis Beleuzu 2020-09-25 23:38:38 +03:00
Родитель 61e09da070
Коммит 7cf9da23d5
9 изменённых файлов: 7 добавлений и 163 удалений

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

@ -1,8 +0,0 @@
"use strict";
module.exports = {
extends: ["plugin:mozilla/browser-test"],
rules: {
"no-shadow": "off",
},
};

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

@ -1,8 +0,0 @@
[DEFAULT]
support-files =
file_autoplay_media.html
file_empty.html
gizmo.mp4
head.js
[browser_destroy_iframe.js]

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

@ -1,49 +0,0 @@
const EMPTY_PAGE_URL = GetTestWebBasedURL("file_empty.html");
const AUTPLAY_PAGE_URL = GetTestWebBasedURL("file_autoplay_media.html");
const CORS_AUTPLAY_PAGE_URL = GetTestWebBasedURL(
"file_autoplay_media.html",
true
);
/**
* When an iframe that has audible media gets destroyed, if there is no other
* audible playing media existing in the page, then the sound indicator should
* disappear.
*/
add_task(async function testDestroyAudibleIframe() {
const iframesURL = [AUTPLAY_PAGE_URL, CORS_AUTPLAY_PAGE_URL];
for (let iframeURL of iframesURL) {
info(`open a tab, create an iframe and load an autoplay media page inside`);
const tab = await BrowserTestUtils.openNewForegroundTab(
gBrowser,
EMPTY_PAGE_URL
);
await createIframeAndLoadURL(tab, iframeURL);
info(`sound indicator should appear because of audible playing media`);
await waitForTabSoundIndicatorAppears(tab);
info(`sound indicator should disappear after destroying iframe`);
await removeIframe(tab);
await waitForTabSoundIndicatorDisappears(tab);
info("remove tab");
BrowserTestUtils.removeTab(tab);
}
});
function createIframeAndLoadURL(tab, url) {
return SpecialPowers.spawn(tab.linkedBrowser, [url], async url => {
const iframe = content.document.createElement("iframe");
content.document.body.appendChild(iframe);
iframe.src = url;
info(`load ${url} for iframe`);
await new Promise(r => (iframe.onload = r));
});
}
function removeIframe(tab) {
return SpecialPowers.spawn(tab.linkedBrowser, [], _ => {
content.document.getElementsByTagName("iframe")[0].remove();
});
}

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

@ -1,9 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<title>autoplay media page</title>
</head>
<body>
<video id="video" src="gizmo.mp4" loop autoplay></video>
</body>
</html>

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

@ -1,8 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<title>empty page</title>
</head>
<body>
</body>
</html>

Двоичный файл не отображается.

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

@ -1,54 +0,0 @@
/**
* Return a web-based URL for a given file based on the testing directory.
* @param {String} fileName
* file that caller wants its web-based url
* @param {Boolean} cors [optional]
* if set, then return a url with different origin
*/
function GetTestWebBasedURL(fileName, cors = false) {
const origin = cors ? "http://example.org" : "http://example.com";
return (
getRootDirectory(gTestPath).replace("chrome://mochitests/content", origin) +
fileName
);
}
/**
* Wait until tab sound indicator appears on the given tab.
* @param {tabbrowser} tab
* given tab where tab sound indicator should appear
*/
async function waitForTabSoundIndicatorAppears(tab) {
if (!tab.soundPlaying) {
info("Tab sound indicator doesn't appear yet");
await BrowserTestUtils.waitForEvent(
tab,
"TabAttrModified",
false,
event => {
return event.detail.changed.includes("soundplaying");
}
);
}
ok(tab.soundPlaying, "Tab sound indicator appears");
}
/**
* Wait until tab sound indicator disappears on the given tab.
* @param {tabbrowser} tab
* given tab where tab sound indicator should disappear
*/
async function waitForTabSoundIndicatorDisappears(tab) {
if (tab.soundPlaying) {
info("Tab sound indicator doesn't disappear yet");
await BrowserTestUtils.waitForEvent(
tab,
"TabAttrModified",
false,
event => {
return event.detail.changed.includes("soundplaying");
}
);
}
ok(!tab.soundPlaying, "Tab sound indicator disappears");
}

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

@ -53,7 +53,6 @@ BROWSER_CHROME_MANIFESTS += [
'content/test/sync/browser.ini',
'content/test/tabcrashed/browser.ini',
'content/test/tabdialogs/browser.ini',
'content/test/tabMediaIndicator/browser.ini',
'content/test/tabPrompts/browser.ini',
'content/test/tabs/browser.ini',
'content/test/touch/browser.ini',

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

@ -7,42 +7,23 @@
var EXPORTED_SYMBOLS = ["AudioPlaybackParent"];
class AudioPlaybackParent extends JSWindowActorParent {
constructor() {
super();
this._hasAudioPlayback = false;
this._hasBlockMedia = false;
this._topLevelBrowser = null;
}
receiveMessage(aMessage) {
// To ensure we can still access browser element in `didDestroy()` because
// we might not be able to access that from browsing context at that time.
this._topLevelBrowser = this.browsingContext.top.embedderElement;
let topBrowsingContext = this.browsingContext.top;
let browser = topBrowsingContext.embedderElement;
switch (aMessage.name) {
case "AudioPlayback:Start":
this._hasAudioPlayback = true;
this._topLevelBrowser.audioPlaybackStarted();
browser.audioPlaybackStarted();
break;
case "AudioPlayback:Stop":
this._hasAudioPlayback = false;
this._topLevelBrowser.audioPlaybackStopped();
browser.audioPlaybackStopped();
break;
case "AudioPlayback:ActiveMediaBlockStart":
this._hasBlockMedia = true;
this._topLevelBrowser.activeMediaBlockStarted();
browser.activeMediaBlockStarted();
break;
case "AudioPlayback:ActiveMediaBlockStop":
this._hasBlockMedia = false;
this._topLevelBrowser.activeMediaBlockStopped();
browser.activeMediaBlockStopped();
break;
}
}
didDestroy() {
if (this._hasAudioPlayback) {
this._topLevelBrowser.audioPlaybackStopped();
}
if (this._hasBlockMedia) {
this._topLevelBrowser.activeMediaBlockStopped();
}
this._topLevelBrowser = null;
}
}