Backed out 5 changesets (bug 1513681) for browser_autoplay_blocked.js failures CLOSED TREE

Backed out changeset d24ddb803761 (bug 1513681)
Backed out changeset 6f52b229d953 (bug 1513681)
Backed out changeset 79a78732c3ac (bug 1513681)
Backed out changeset d0a9422928ae (bug 1513681)
Backed out changeset 23b5a58e3bcc (bug 1513681)

--HG--
rename : toolkit/actors/AutoplayChild.jsm => toolkit/actors/AudibleAutoplayChild.jsm
This commit is contained in:
Bogdan Tara 2018-12-29 04:00:53 +02:00
Родитель 80d4fb46b9
Коммит 6defca7262
12 изменённых файлов: 88 добавлений и 48 удалений

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

@ -4763,17 +4763,14 @@ window._gBrowser = {
}
});
this.addEventListener("GloballyAutoplayBlocked", (event) => {
this.addEventListener("AudibleAutoplayMediaOccurred", (event) => {
let browser = event.originalTarget;
let tab = this.getTabForBrowser(browser);
if (!tab) {
return;
}
SitePermissions.set(event.detail.url, "autoplay-media",
SitePermissions.BLOCK,
SitePermissions.SCOPE_GLOBAL,
browser);
Services.obs.notifyObservers(tab, "AudibleAutoplayMediaOccurred");
});
},

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

@ -306,6 +306,19 @@ var PermissionPromptPrototype = {
this.browser);
if (state == SitePermissions.BLOCK) {
// If the request is blocked by a global setting then we record
// a flag that lasts for the duration of the current page load
// to notify the user that the permission has been blocked.
// Currently only applies to autoplay-media
if (state == SitePermissions.getDefault(this.permissionKey) &&
SitePermissions.showGloballyBlocked(this.permissionKey)) {
SitePermissions.set(this.principal.URI,
this.permissionKey,
state,
SitePermissions.SCOPE_GLOBAL,
this.browser);
}
this.cancel();
return;
}
@ -327,6 +340,8 @@ var PermissionPromptPrototype = {
this.browser);
if (state == SitePermissions.BLOCK) {
// TODO: Add support for showGloballyBlocked
this.cancel();
return;
}

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

@ -434,6 +434,23 @@ var SitePermissions = {
return this._defaultPrefBranch.getIntPref(permissionID, this.UNKNOWN);
},
/**
* Return whether the browser should notify the user if a permission was
* globally blocked due to a preference.
*
* @param {string} permissionID
* The ID to get the state for.
*
* @return boolean Whether to show notification for globally blocked permissions.
*/
showGloballyBlocked(permissionID) {
if (permissionID in gPermissionObject &&
gPermissionObject[permissionID].showGloballyBlocked)
return gPermissionObject[permissionID].showGloballyBlocked;
return false;
},
/*
* Return whether SitePermissions is permitted to store a TEMPORARY ALLOW
* state for a particular permission.
@ -746,6 +763,7 @@ var gPermissionObject = {
"autoplay-media": {
exactHostMatch: true,
showGloballyBlocked: true,
permitTemporaryAllow: true,
notifyWhenTemporaryPermissionChanged: true,
getDefault() {

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

@ -11750,28 +11750,18 @@ void nsIDocument::NotifyUserGestureActivation() {
}
}
void nsIDocument::MaybeNotifyAutoplayBlocked() {
nsIDocument* topLevelDoc = GetTopLevelContentDocument();
if (!topLevelDoc ||
!nsContentUtils::IsExactSitePermDeny(topLevelDoc->NodePrincipal(),
"autoplay-media")) {
return;
}
// This event is used to notify front-end side that we've blocked autoplay
// permanantly, so front-end side should show blocking icon as well.
RefPtr<AsyncEventDispatcher> asyncDispatcher = new AsyncEventDispatcher(
topLevelDoc, NS_LITERAL_STRING("GloballyAutoplayBlocked"),
CanBubble::eYes, ChromeOnlyDispatch::eYes);
asyncDispatcher->PostDOMEvent();
}
void nsIDocument::SetDocTreeHadAudibleMedia() {
nsIDocument* topLevelDoc = GetTopLevelContentDocument();
if (!topLevelDoc) {
return;
}
if (!topLevelDoc->mDocTreeHadAudibleMedia) {
RefPtr<AsyncEventDispatcher> asyncDispatcher = new AsyncEventDispatcher(
topLevelDoc, NS_LITERAL_STRING("AudibleAutoplayMediaOccurred"),
CanBubble::eYes, ChromeOnlyDispatch::eYes);
asyncDispatcher->PostDOMEvent();
}
topLevelDoc->mDocTreeHadAudibleMedia = true;
}

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

@ -3390,10 +3390,6 @@ class nsIDocument : public nsINode,
void ReportShadowDOMUsage();
// When the doc is blocked permanantly, we would dispatch event to notify
// front-end side to show blocking icon.
void MaybeNotifyAutoplayBlocked();
// Sets flags for media autoplay telemetry.
void SetDocTreeHadAudibleMedia();
void SetDocTreeHadPlayRevoked();

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

@ -3697,7 +3697,6 @@ void HTMLMediaElement::DispatchEventsWhenPlayWasNotAllowed() {
ChromeOnlyDispatch::eYes);
asyncDispatcher->PostDOMEvent();
#endif
OwnerDoc()->MaybeNotifyAutoplayBlocked();
}
void HTMLMediaElement::PlayInternal(bool aHandlingUserInput) {

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

@ -4,12 +4,12 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";
var EXPORTED_SYMBOLS = ["AutoplayChild"];
var EXPORTED_SYMBOLS = ["AudibleAutoplayChild"];
ChromeUtils.import("resource://gre/modules/ActorChild.jsm");
class AutoplayChild extends ActorChild {
class AudibleAutoplayChild extends ActorChild {
handleEvent(event) {
this.mm.sendAsyncMessage("GloballyAutoplayBlocked");
this.mm.sendAsyncMessage("AudibleAutoplayMediaOccurred");
}
}

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

@ -11,8 +11,8 @@ with Files('Finder*.jsm'):
BUG_COMPONENT = ('Toolkit', 'Find Toolbar')
FINAL_TARGET_FILES.actors += [
'AudibleAutoplayChild.jsm',
'AudioPlaybackChild.jsm',
'AutoplayChild.jsm',
'BrowserChild.jsm',
'ControllersChild.jsm',
'DateTimePickerChild.jsm',

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

@ -30,6 +30,7 @@ support-files =
tags = audiochannel
[browser_audioCompeting_onlyForActiveAgent.js]
tags = audiochannel
[browser_autoplay_audibleMediaOccurred.js]
[browser_autoplay_policy_iframe_hierarchy.js]
support-files =
file_autoplay_three_layers_frame1.html

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

@ -0,0 +1,27 @@
/**
* This test is used to test whether the topic 'AudibleAutoplayMediaOccurred'
* is sent correctly when the autoplay audible media tries to start.
*/
"use strict";
const PAGE = "https://example.com/browser/toolkit/content/tests/browser/file_mediaPlayback.html";
add_task(async function testAudibleAutoplayMedia() {
info("- open new tab -");
let tab = await BrowserTestUtils.openNewForegroundTab(window.gBrowser,
"about:blank");
let browser = tab.linkedBrowser;
// start observing the topic before loading the page to ensure we can get it.
let audibleAutoplayOccurred = TestUtils.topicObserved("AudibleAutoplayMediaOccurred");
browser.loadURI(PAGE, {
triggeringPrincipal: Services.scriptSecurityManager.getSystemPrincipal(),
});
await BrowserTestUtils.browserLoaded(browser);
await audibleAutoplayOccurred;
ok(true, "Got the topic 'AudibleAutoplayMediaOccurred'.");
info("- remove tab -");
BrowserTestUtils.removeTab(tab);
});

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

@ -762,14 +762,11 @@
</body>
</method>
<method name="notifyGloballyAutoplayBlocked">
<method name="notifyAudibleAutoplayMediaOccurred">
<body>
<![CDATA[
let event = document.createEvent("CustomEvent");
event.initCustomEvent("GloballyAutoplayBlocked", true, false,
{
url: this.documentURI,
});
let event = document.createEvent("Events");
event.initEvent("AudibleAutoplayMediaOccurred", true, false);
this.dispatchEvent(event);
]]>
</body>
@ -1111,7 +1108,7 @@
this.messageManager.addMessageListener("AudioPlayback:ActiveMediaBlockStart", this);
this.messageManager.addMessageListener("AudioPlayback:ActiveMediaBlockStop", this);
this.messageManager.addMessageListener("UnselectedTabHover:Toggle", this);
this.messageManager.addMessageListener("GloballyAutoplayBlocked", this);
this.messageManager.addMessageListener("AudibleAutoplayMediaOccurred", this);
if (this.hasAttribute("selectmenulist")) {
this.messageManager.addMessageListener("Forms:ShowDropDown", this);
@ -1253,8 +1250,8 @@
++this._unselectedTabHoverMessageListenerCount > 0 :
--this._unselectedTabHoverMessageListenerCount == 0;
break;
case "GloballyAutoplayBlocked":
this.notifyGloballyAutoplayBlocked();
case "AudibleAutoplayMediaOccurred":
this.notifyAudibleAutoplayMediaOccurred();
break;
case "Forms:ShowDropDown": {
if (!this._selectParentHelper) {

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

@ -101,6 +101,15 @@ ChromeUtils.import("resource://gre/modules/Services.jsm");
const {DefaultMap} = ExtensionUtils;
let ACTORS = {
AudibleAutoplay: {
child: {
module: "resource://gre/actors/AudibleAutoplayChild.jsm",
events: {
"AudibleAutoplayMediaOccurred": {},
},
},
},
AudioPlayback: {
child: {
module: "resource://gre/actors/AudioPlaybackChild.jsm",
@ -114,15 +123,6 @@ let ACTORS = {
},
},
Autoplay: {
child: {
module: "resource://gre/actors/AutoplayChild.jsm",
events: {
"GloballyAutoplayBlocked": {},
},
},
},
Browser: {
child: {
module: "resource://gre/actors/BrowserChild.jsm",