From 3e5817542cec3e4b538bb0ab73f8be2cb2ddb35d Mon Sep 17 00:00:00 2001 From: alwu Date: Mon, 7 Jan 2019 18:38:26 +0000 Subject: [PATCH] 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 --- .../base/content/test/permissions/browser.ini | 4 - .../browser_autoplay_doorhanger.js | 33 -------- browser/components/nsBrowserGlue.js | 3 - .../en-US/chrome/browser/browser.properties | 9 -- browser/modules/PermissionUI.jsm | 84 ------------------- browser/modules/SitePermissions.jsm | 4 +- .../browser/browser_PermissionUI_prompts.js | 9 +- 7 files changed, 3 insertions(+), 143 deletions(-) delete mode 100644 browser/base/content/test/permissions/browser_autoplay_doorhanger.js diff --git a/browser/base/content/test/permissions/browser.ini b/browser/base/content/test/permissions/browser.ini index 42406db7ff8f..a6e7b58d92ff 100644 --- a/browser/base/content/test/permissions/browser.ini +++ b/browser/base/content/test/permissions/browser.ini @@ -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] diff --git a/browser/base/content/test/permissions/browser_autoplay_doorhanger.js b/browser/base/content/test/permissions/browser_autoplay_doorhanger.js deleted file mode 100644 index f78fff1eaa98..000000000000 --- a/browser/base/content/test/permissions/browser_autoplay_doorhanger.js +++ /dev/null @@ -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"); -}); diff --git a/browser/components/nsBrowserGlue.js b/browser/components/nsBrowserGlue.js index dcffe1eeb554..cfaa3505314f 100644 --- a/browser/components/nsBrowserGlue.js +++ b/browser/components/nsBrowserGlue.js @@ -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); } diff --git a/browser/locales/en-US/chrome/browser/browser.properties b/browser/locales/en-US/chrome/browser/browser.properties index 1a2af6174ead..01957a754f06 100644 --- a/browser/locales/en-US/chrome/browser/browser.properties +++ b/browser/locales/en-US/chrome/browser/browser.properties @@ -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. diff --git a/browser/modules/PermissionUI.jsm b/browser/modules/PermissionUI.jsm index ff77f82a1ba3..dbf2aefa6654 100644 --- a/browser/modules/PermissionUI.jsm +++ b/browser/modules/PermissionUI.jsm @@ -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; diff --git a/browser/modules/SitePermissions.jsm b/browser/modules/SitePermissions.jsm index a223f0c0a8d2..6063c4015e1b 100644 --- a/browser/modules/SitePermissions.jsm +++ b/browser/modules/SitePermissions.jsm @@ -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; diff --git a/browser/modules/test/browser/browser_PermissionUI_prompts.js b/browser/modules/test/browser/browser_PermissionUI_prompts.js index 9d92f2d9ec1b..4ad839645634 100644 --- a/browser/modules/test/browser/browser_PermissionUI_prompts.js +++ b/browser/modules/test/browser/browser_PermissionUI_prompts.js @@ -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);