{
if (this.frame.isEmpty()) {
diff --git a/js/constants/appConfig.js b/js/constants/appConfig.js
index f49f30e3795..7dd3c1f07a5 100644
--- a/js/constants/appConfig.js
+++ b/js/constants/appConfig.js
@@ -19,7 +19,7 @@ module.exports = {
quitTimeout: 10 * 1000,
resourceNames: {
ADBLOCK: 'adblock',
- AUTOPLAY: 'autoplay',
+ NOAUTOPLAY: 'noAutoplay',
SAFE_BROWSING: 'safeBrowsing',
HTTPS_EVERYWHERE: 'httpsEverywhere',
TRACKING_PROTECTION: 'trackingProtection',
@@ -36,8 +36,8 @@ module.exports = {
cookieblock: {
enabled: true
},
- autoplay: {
- enabled: false
+ noAutoplay: {
+ enabled: true
},
cookieblockAll: {
enabled: false
diff --git a/js/constants/appConstants.js b/js/constants/appConstants.js
index 0c5206ae4fa..f7ea8959105 100644
--- a/js/constants/appConstants.js
+++ b/js/constants/appConstants.js
@@ -123,7 +123,8 @@ const appConstants = {
APP_ON_GO_FORWARD: _,
APP_ON_GO_TO_INDEX: _,
APP_ON_GO_BACK_LONG: _,
- APP_ON_GO_FORWARD_LONG: _
+ APP_ON_GO_FORWARD_LONG: _,
+ APP_AUTOPLAY_BLOCKED: _
}
module.exports = mapValuesByKeys(appConstants)
diff --git a/js/state/contentSettings.js b/js/state/contentSettings.js
index b9c2d6539d8..f6a2c46c179 100644
--- a/js/state/contentSettings.js
+++ b/js/state/contentSettings.js
@@ -64,7 +64,7 @@ const getDefaultUserPrefContentSettings = (braveryDefaults, appSettings, appConf
braveryDefaults = makeImmutable(braveryDefaults)
return Immutable.fromJS({
autoplay: [{
- setting: braveryDefaults.get('autoplay') ? 'allow' : 'block',
+ setting: braveryDefaults.get('noAutoplay') ? 'block' : 'allow',
primaryPattern: '*'
}],
cookies: getDefault3rdPartyStorageSettings(braveryDefaults, appSettings, appConfig),
@@ -281,8 +281,8 @@ const siteSettingsToContentSettings = (currentSiteSettings, defaultContentSettin
if (typeof siteSetting.get('widevine') === 'number' && braveryDefaults.get('widevine')) {
contentSettings = addContentSettings(contentSettings, 'plugins', primaryPattern, '*', 'allow', appConfig.widevine.resourceId)
}
- if (typeof siteSetting.get('autoplay') === 'boolean') {
- contentSettings = addContentSettings(contentSettings, 'autoplay', primaryPattern, '*', siteSetting.get('autoplay') ? 'allow' : 'block')
+ if (typeof siteSetting.get('noAutoplay') === 'boolean') {
+ contentSettings = addContentSettings(contentSettings, 'autoplay', primaryPattern, '*', siteSetting.get('noAutoplay') ? 'block' : 'allow')
}
})
// On the second pass we consider only shieldsUp === false settings since we want those to take precedence.
diff --git a/js/stores/appStore.js b/js/stores/appStore.js
index 75cf7e09945..74658672a3a 100644
--- a/js/stores/appStore.js
+++ b/js/stores/appStore.js
@@ -375,6 +375,7 @@ const handleAppAction = (action) => {
reducers = [
require('../../app/browser/reducers/downloadsReducer'),
require('../../app/browser/reducers/flashReducer'),
+ require('../../app/browser/reducers/autoplayReducer'),
// tabs, sites and windows reducers need to stay in that order
// until we have a better way to manage dependencies.
// tabsReducer must be above dragDropReducer.
diff --git a/test/bravery-components/braveryPanelTest.js b/test/bravery-components/braveryPanelTest.js
index 690d975b2ad..af8a8cc4eae 100644
--- a/test/bravery-components/braveryPanelTest.js
+++ b/test/bravery-components/braveryPanelTest.js
@@ -1,7 +1,7 @@
/* global describe, it, beforeEach */
const Brave = require('../lib/brave')
-const {cookieControl, allowAllCookiesOption, blockAllCookiesOption, urlInput, braveMenu, braveMenuDisabled, adsBlockedStat, adsBlockedControl, showAdsOption, blockAdsOption, braveryPanel, httpsEverywhereStat, noScriptStat, noScriptSwitch, fpSwitch, autoplaySwitch, fpStat, noScriptNavButton, customFiltersInput} = require('../lib/selectors')
+const {cookieControl, allowAllCookiesOption, blockAllCookiesOption, urlInput, braveMenu, braveMenuDisabled, adsBlockedStat, adsBlockedControl, showAdsOption, blockAdsOption, braveryPanel, httpsEverywhereStat, noScriptStat, noScriptSwitch, fpSwitch, noAutoplaySwitch, fpStat, noScriptNavButton, customFiltersInput, notificationBar, reloadButton} = require('../lib/selectors')
const {getTargetAboutUrl} = require('../../js/lib/appUrlUtil')
describe('Bravery Panel', function () {
@@ -518,6 +518,11 @@ describe('Bravery Panel', function () {
return status === ''
})
})
+ .windowByUrl(Brave.browserWindowUrl)
+ .waitForExist(notificationBar)
+ .waitUntil(function () {
+ return this.getText(notificationBar).then((val) => val.includes('autoplay media'))
+ })
})
it('allow autoplay in regular tab', function * () {
@@ -531,8 +536,13 @@ describe('Bravery Panel', function () {
return status === ''
})
})
+ .windowByUrl(Brave.browserWindowUrl)
+ .waitForExist(notificationBar)
+ .waitUntil(function () {
+ return this.getText(notificationBar).then((val) => val.includes('autoplay media'))
+ })
.openBraveMenu(braveMenu, braveryPanel)
- .click(autoplaySwitch)
+ .click(noAutoplaySwitch)
.keys(Brave.keys.ESCAPE)
.tabByUrl(url)
.waitUntil(function () {
@@ -554,8 +564,13 @@ describe('Bravery Panel', function () {
return status === ''
})
})
+ .windowByUrl(Brave.browserWindowUrl)
+ .waitForExist(notificationBar)
+ .waitUntil(function () {
+ return this.getText(notificationBar).then((val) => val.includes('autoplay media'))
+ })
.openBraveMenu(braveMenu, braveryPanel)
- .click(autoplaySwitch)
+ .click(noAutoplaySwitch)
.keys(Brave.keys.ESCAPE)
.tabByUrl(url)
.waitUntil(function () {
@@ -565,5 +580,62 @@ describe('Bravery Panel', function () {
})
})
})
+
+ it('allow autoplay in notification bar', function * () {
+ const url = Brave.server.url('autoplay.html')
+ yield this.app.client
+ .tabByIndex(0)
+ .loadUrl(url)
+ .waitUntil(function () {
+ return this.getText('div[id="status"]')
+ .then((status) => {
+ return status === ''
+ })
+ })
+ .windowByUrl(Brave.browserWindowUrl)
+ .waitForExist(notificationBar)
+ .waitUntil(function () {
+ return this.getText(notificationBar).then((val) => val.includes('autoplay media'))
+ })
+ .click('button=Yes')
+ .tabByUrl(url)
+ .waitUntil(function () {
+ return this.getText('div[id="status"]')
+ .then((status) => {
+ return status === 'Autoplay playing'
+ })
+ })
+ })
+
+ it('Remember block autoplay in notification bar', function * () {
+ const url = Brave.server.url('autoplay.html')
+ yield this.app.client
+ .tabByIndex(0)
+ .loadUrl(url)
+ .waitUntil(function () {
+ return this.getText('div[id="status"]')
+ .then((status) => {
+ return status === ''
+ })
+ })
+ .windowByUrl(Brave.browserWindowUrl)
+ .waitForExist(notificationBar)
+ .waitUntil(function () {
+ return this.getText(notificationBar).then((val) => val.includes('autoplay media'))
+ })
+ .click('[data-l10n-id=rememberDecision]')
+ .click('button=No')
+ .windowByUrl(Brave.browserWindowUrl)
+ .click(reloadButton)
+ .tabByUrl(url)
+ .waitUntil(function () {
+ return this.getText('div[id="status"]')
+ .then((status) => {
+ return status === ''
+ })
+ })
+ .windowByUrl(Brave.browserWindowUrl)
+ .waitForElementCount('.notificationItem', 0)
+ })
})
})
diff --git a/test/lib/selectors.js b/test/lib/selectors.js
index ec8d775685e..a212d55e1a1 100644
--- a/test/lib/selectors.js
+++ b/test/lib/selectors.js
@@ -58,7 +58,7 @@ module.exports = {
noScriptAllowOnceButton: '[data-l10n-id="allowScriptsOnce"]',
noScriptAllowButton: '[data-l10n-id="allowScripts"]',
safeBrowsingSwitch: '.safeBrowsingSwitch .switchMiddle',
- autoplaySwitch: '.allowAutoplay .switchMiddle',
+ noAutoplaySwitch: '.noAutoplaySwitch .switchMiddle',
backButton: '.backforward .backButton',
forwardButton: '.backforward .forwardButton',
reloadButton: '.reloadButton',