зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1513039 - part8 : remove autoplay prompt front-end codes. r=florian,daleharvey,flod
Remove autoplay prompt related js codes. Differential Revision: https://phabricator.services.mozilla.com/D14333 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
1f7a52686c
Коммит
3e5817542c
|
@ -15,10 +15,6 @@ support-files =
|
|||
browser_autoplay_blocked.html
|
||||
../general/audio.ogg
|
||||
skip-if = verify && os == 'linux' && debug # Bug 1483648
|
||||
[browser_autoplay_doorhanger.js]
|
||||
support-files =
|
||||
browser_autoplay_blocked.html
|
||||
../general/audio.ogg
|
||||
[browser_temporary_permissions_expiry.js]
|
||||
[browser_temporary_permissions_navigation.js]
|
||||
[browser_temporary_permissions_tabs.js]
|
||||
|
|
|
@ -1,33 +0,0 @@
|
|||
/*
|
||||
* Test that autoplay doorhanger is hidden when user clicks back to new tab page
|
||||
*/
|
||||
|
||||
const AUTOPLAY_PAGE = getRootDirectory(gTestPath).replace("chrome://mochitests/content", "https://example.com") + "browser_autoplay_blocked.html";
|
||||
|
||||
add_task(async function testHiddenAfterBack() {
|
||||
|
||||
Services.prefs.setIntPref("media.autoplay.default", Ci.nsIAutoplay.PROMPT);
|
||||
|
||||
await BrowserTestUtils.withNewTab("about:home", async function(browser) {
|
||||
|
||||
is(PopupNotifications.panel.state, "closed", "Doorhanger is hidden");
|
||||
|
||||
let shown = BrowserTestUtils.waitForEvent(PopupNotifications.panel, "popupshown");
|
||||
let loaded = BrowserTestUtils.browserLoaded(browser);
|
||||
BrowserTestUtils.loadURI(browser, AUTOPLAY_PAGE);
|
||||
await loaded;
|
||||
await shown;
|
||||
|
||||
is(PopupNotifications.panel.state, "open", "Doorhanger is shown");
|
||||
|
||||
let hidden = BrowserTestUtils.waitForEvent(PopupNotifications.panel, "popuphidden");
|
||||
let backPromise = BrowserTestUtils.browserStopped(browser);
|
||||
EventUtils.synthesizeMouseAtCenter(document.getElementById("back-button"), {});
|
||||
await backPromise;
|
||||
await hidden;
|
||||
|
||||
is(PopupNotifications.panel.state, "closed", "Doorhanger is hidden");
|
||||
});
|
||||
|
||||
Services.prefs.clearUserPref("media.autoplay.default");
|
||||
});
|
|
@ -3171,9 +3171,6 @@ const ContentPermissionIntegration = {
|
|||
case "midi": {
|
||||
return new PermissionUI.MIDIPermissionPrompt(request);
|
||||
}
|
||||
case "autoplay-media": {
|
||||
return new PermissionUI.AutoplayPermissionPrompt(request);
|
||||
}
|
||||
case "storage-access": {
|
||||
return new PermissionUI.StorageAccessPermissionPrompt(request);
|
||||
}
|
||||
|
|
|
@ -1000,15 +1000,6 @@ midi.shareSysexWithFile.message = Will you allow this local file to access your
|
|||
# LOCALIZATION NOTE (midi.shareSysexWithSite.message): %S is the name of the site URL (https://...) requesting MIDI access
|
||||
midi.shareSysexWithSite.message = Will you allow %S to access your MIDI devices and send/receive SysEx messages?
|
||||
|
||||
autoplay.Allow2.label = Allow
|
||||
autoplay.Allow2.accesskey = A
|
||||
autoplay.DontAllow.label = Don’t Allow
|
||||
autoplay.DontAllow.accesskey = n
|
||||
autoplay.remember = Remember this decision
|
||||
autoplay.remember-private = Remember for this session
|
||||
# LOCALIZATION NOTE (autoplay.message): %S is the name of the site URL (https://...) trying to autoplay media
|
||||
autoplay.message = Will you allow %S to autoplay media with sound?
|
||||
autoplay.messageWithFile = Will you allow this file to autoplay media with sound?
|
||||
# LOCALIZATION NOTE (panel.back):
|
||||
# This is used by screen readers to label the "back" button in various browser
|
||||
# popup panels, including the sliding subviews of the main menu.
|
||||
|
|
|
@ -826,90 +826,6 @@ MIDIPermissionPrompt.prototype = {
|
|||
|
||||
PermissionUI.MIDIPermissionPrompt = MIDIPermissionPrompt;
|
||||
|
||||
function AutoplayPermissionPrompt(request) {
|
||||
this.request = request;
|
||||
}
|
||||
|
||||
AutoplayPermissionPrompt.prototype = {
|
||||
__proto__: PermissionPromptForRequestPrototype,
|
||||
|
||||
get permissionKey() {
|
||||
return "autoplay-media";
|
||||
},
|
||||
|
||||
get popupOptions() {
|
||||
let learnMoreURL =
|
||||
Services.urlFormatter.formatURLPref("app.support.baseURL") + "block-autoplay";
|
||||
let checkbox = {show: !this.principal.URI.schemeIs("file")};
|
||||
if (checkbox.show) {
|
||||
checkbox.checked = true;
|
||||
checkbox.label = PrivateBrowsingUtils.isWindowPrivate(this.browser.ownerGlobal) ?
|
||||
gBrowserBundle.GetStringFromName("autoplay.remember-private") :
|
||||
gBrowserBundle.GetStringFromName("autoplay.remember");
|
||||
}
|
||||
return {
|
||||
checkbox,
|
||||
learnMoreURL,
|
||||
displayURI: false,
|
||||
name: this.principal.URI.hostPort,
|
||||
};
|
||||
},
|
||||
|
||||
get notificationID() {
|
||||
return "autoplay-media";
|
||||
},
|
||||
|
||||
get anchorID() {
|
||||
return "autoplay-media-notification-icon";
|
||||
},
|
||||
|
||||
get message() {
|
||||
if (this.principal.URI.schemeIs("file")) {
|
||||
return gBrowserBundle.GetStringFromName("autoplay.messageWithFile");
|
||||
}
|
||||
return gBrowserBundle.formatStringFromName("autoplay.message", ["<>"], 1);
|
||||
},
|
||||
|
||||
get promptActions() {
|
||||
return [{
|
||||
label: gBrowserBundle.GetStringFromName("autoplay.Allow2.label"),
|
||||
accessKey: gBrowserBundle.GetStringFromName("autoplay.Allow2.accesskey"),
|
||||
action: Ci.nsIPermissionManager.ALLOW_ACTION,
|
||||
},
|
||||
{
|
||||
label: gBrowserBundle.GetStringFromName("autoplay.DontAllow.label"),
|
||||
accessKey: gBrowserBundle.GetStringFromName("autoplay.DontAllow.accesskey"),
|
||||
action: Ci.nsIPermissionManager.DENY_ACTION,
|
||||
}];
|
||||
},
|
||||
|
||||
onAfterShow() {
|
||||
// Remove the event listener to prevent any leaks.
|
||||
this.browser.removeEventListener(
|
||||
"DOMAudioPlaybackStarted", this.handlePlaybackStart);
|
||||
},
|
||||
|
||||
onBeforeShow() {
|
||||
// Hide the prompt if the tab starts playing media.
|
||||
this.handlePlaybackStart = () => {
|
||||
let chromeWin = this.browser.ownerGlobal;
|
||||
if (!chromeWin.PopupNotifications) {
|
||||
return;
|
||||
}
|
||||
let notification = chromeWin.PopupNotifications.getNotification(
|
||||
this.notificationID, this.browser);
|
||||
if (notification) {
|
||||
chromeWin.PopupNotifications.remove(notification);
|
||||
}
|
||||
};
|
||||
this.browser.addEventListener(
|
||||
"DOMAudioPlaybackStarted", this.handlePlaybackStart);
|
||||
return true;
|
||||
},
|
||||
};
|
||||
|
||||
PermissionUI.AutoplayPermissionPrompt = AutoplayPermissionPrompt;
|
||||
|
||||
function StorageAccessPermissionPrompt(request) {
|
||||
this.request = request;
|
||||
|
||||
|
|
|
@ -715,10 +715,10 @@ var gPermissionObject = {
|
|||
permitTemporaryAllow: true,
|
||||
getDefault() {
|
||||
let state = Services.prefs.getIntPref("media.autoplay.default",
|
||||
Ci.nsIAutoplay.PROMPT);
|
||||
Ci.nsIAutoplay.BLOCKED);
|
||||
if (state == Ci.nsIAutoplay.ALLOWED) {
|
||||
return SitePermissions.ALLOW;
|
||||
} if (state == Ci.nsIAutoplay.BLOCKED) {
|
||||
} else if (state == Ci.nsIAutoplay.BLOCKED) {
|
||||
return SitePermissions.BLOCK;
|
||||
}
|
||||
return SitePermissions.UNKNOWN;
|
||||
|
|
|
@ -30,14 +30,7 @@ add_task(async function test_midi_permission_prompt() {
|
|||
await testPrompt(PermissionUI.MIDIPermissionPrompt);
|
||||
});
|
||||
|
||||
// Tests that AutoplayPermissionPrompt works as expected
|
||||
add_task(async function test_autoplay_permission_prompt() {
|
||||
Services.prefs.setIntPref("media.autoplay.default", Ci.nsIAutoplay.PROMPT);
|
||||
await testPrompt(PermissionUI.AutoplayPermissionPrompt);
|
||||
Services.prefs.clearUserPref("media.autoplay.default");
|
||||
});
|
||||
|
||||
// Tests that AutoplayPermissionPrompt works as expected
|
||||
// Tests that StoragePermissionPrompt works as expected
|
||||
add_task(async function test_storage_access_permission_prompt() {
|
||||
Services.prefs.setBoolPref("dom.storage_access.auto_grants", false);
|
||||
await testPrompt(PermissionUI.StorageAccessPermissionPrompt);
|
||||
|
|
Загрузка…
Ссылка в новой задаче