mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-19 00:05:36 +00:00
Bug 1560229 - [Fission] Make Autoplay work with JSWindowActor. r=NeilDeakin
Differential Revision: https://phabricator.services.mozilla.com/D35395 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
632715284a
commit
90236200b9
@ -6,10 +6,8 @@
|
||||
|
||||
var EXPORTED_SYMBOLS = ["AutoplayChild"];
|
||||
|
||||
const {ActorChild} = ChromeUtils.import("resource://gre/modules/ActorChild.jsm");
|
||||
|
||||
class AutoplayChild extends ActorChild {
|
||||
class AutoplayChild extends JSWindowActorChild {
|
||||
handleEvent(event) {
|
||||
this.mm.sendAsyncMessage("GloballyAutoplayBlocked");
|
||||
this.sendAsyncMessage("GloballyAutoplayBlocked", {});
|
||||
}
|
||||
}
|
||||
|
20
toolkit/actors/AutoplayParent.jsm
Normal file
20
toolkit/actors/AutoplayParent.jsm
Normal file
@ -0,0 +1,20 @@
|
||||
/* vim: set ts=2 sw=2 sts=2 et tw=80: */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
"use strict";
|
||||
|
||||
var EXPORTED_SYMBOLS = ["AutoplayParent"];
|
||||
|
||||
class AutoplayParent extends JSWindowActorParent {
|
||||
receiveMessage(aMessage) {
|
||||
let topBrowsingContext = this.manager.browsingContext.top;
|
||||
let browser = topBrowsingContext.embedderElement;
|
||||
let document = browser.ownerDocument;
|
||||
let event = document.createEvent("CustomEvent");
|
||||
event.initCustomEvent("GloballyAutoplayBlocked", true, false, {
|
||||
url: this.documentURI,
|
||||
});
|
||||
browser.dispatchEvent(event);
|
||||
}
|
||||
}
|
@ -21,6 +21,7 @@ TESTING_JS_MODULES += [
|
||||
FINAL_TARGET_FILES.actors += [
|
||||
'AudioPlaybackChild.jsm',
|
||||
'AutoplayChild.jsm',
|
||||
'AutoplayParent.jsm',
|
||||
'BrowserElementChild.jsm',
|
||||
'BrowserElementParent.jsm',
|
||||
'ControllersChild.jsm',
|
||||
|
@ -982,14 +982,6 @@ class MozBrowser extends MozElements.MozElementMixin(XULFrameElement) {
|
||||
this.dispatchEvent(event);
|
||||
}
|
||||
|
||||
notifyGloballyAutoplayBlocked() {
|
||||
let event = document.createEvent("CustomEvent");
|
||||
event.initCustomEvent("GloballyAutoplayBlocked", true, false, {
|
||||
url: this.documentURI,
|
||||
});
|
||||
this.dispatchEvent(event);
|
||||
}
|
||||
|
||||
/**
|
||||
* When the pref "media.block-autoplay-until-in-foreground" is on,
|
||||
* Gecko delays starting playback of media resources in tabs until the
|
||||
@ -1181,7 +1173,6 @@ class MozBrowser extends MozElements.MozElementMixin(XULFrameElement) {
|
||||
this.messageManager.addMessageListener("AudioPlayback:ActiveMediaBlockStart", this);
|
||||
this.messageManager.addMessageListener("AudioPlayback:ActiveMediaBlockStop", this);
|
||||
this.messageManager.addMessageListener("UnselectedTabHover:Toggle", this);
|
||||
this.messageManager.addMessageListener("GloballyAutoplayBlocked", this);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1295,9 +1286,6 @@ class MozBrowser extends MozElements.MozElementMixin(XULFrameElement) {
|
||||
++this._unselectedTabHoverMessageListenerCount > 0 :
|
||||
--this._unselectedTabHoverMessageListenerCount == 0;
|
||||
break;
|
||||
case "GloballyAutoplayBlocked":
|
||||
this.notifyGloballyAutoplayBlocked();
|
||||
break;
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
@ -101,6 +101,21 @@ const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||
const {DefaultMap} = ExtensionUtils;
|
||||
|
||||
let ACTORS = {
|
||||
Autoplay: {
|
||||
parent: {
|
||||
moduleURI: "resource://gre/actors/AutoplayParent.jsm",
|
||||
},
|
||||
|
||||
child: {
|
||||
moduleURI: "resource://gre/actors/AutoplayChild.jsm",
|
||||
events: {
|
||||
"GloballyAutoplayBlocked": {},
|
||||
},
|
||||
},
|
||||
|
||||
allFrames: true,
|
||||
},
|
||||
|
||||
BrowserElement: {
|
||||
parent: {
|
||||
moduleURI: "resource://gre/actors/BrowserElementParent.jsm",
|
||||
@ -159,15 +174,6 @@ let LEGACY_ACTORS = {
|
||||
},
|
||||
},
|
||||
|
||||
Autoplay: {
|
||||
child: {
|
||||
module: "resource://gre/actors/AutoplayChild.jsm",
|
||||
events: {
|
||||
"GloballyAutoplayBlocked": {},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
Controllers: {
|
||||
child: {
|
||||
module: "resource://gre/actors/ControllersChild.jsm",
|
||||
|
Loading…
Reference in New Issue
Block a user