{
braveryDefaults = makeImmutable(braveryDefaults)
return Immutable.fromJS({
+ autoplay: [{
+ setting: braveryDefaults.get('autoplay') ? 'allow' : 'block',
+ primaryPattern: '*'
+ }],
cookies: getDefault3rdPartyStorageSettings(braveryDefaults, appSettings, appConfig),
referer: [{
setting: braveryDefaults.get('cookieControl') !== 'allowAllCookies' ? 'block' : 'allow',
@@ -277,6 +281,9 @@ 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')
+ }
})
// On the second pass we consider only shieldsUp === false settings since we want those to take precedence.
currentSiteSettings.forEach((siteSetting, hostPattern) => {
@@ -289,6 +296,7 @@ const siteSettingsToContentSettings = (currentSiteSettings, defaultContentSettin
contentSettings = addContentSettings(contentSettings, 'javascript', primaryPattern, '*', 'allow')
contentSettings = addContentSettings(contentSettings, 'referer', primaryPattern, '*', 'allow')
contentSettings = addContentSettings(contentSettings, 'plugins', primaryPattern, '*', 'allow')
+ contentSettings = addContentSettings(contentSettings, 'autoplay', primaryPattern, '*', 'allow')
}
})
return contentSettings
diff --git a/test/bravery-components/braveryPanelTest.js b/test/bravery-components/braveryPanelTest.js
index 05cb4ec952..690d975b2a 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, fpStat, noScriptNavButton, customFiltersInput} = require('../lib/selectors')
+const {cookieControl, allowAllCookiesOption, blockAllCookiesOption, urlInput, braveMenu, braveMenuDisabled, adsBlockedStat, adsBlockedControl, showAdsOption, blockAdsOption, braveryPanel, httpsEverywhereStat, noScriptStat, noScriptSwitch, fpSwitch, autoplaySwitch, fpStat, noScriptNavButton, customFiltersInput} = require('../lib/selectors')
const {getTargetAboutUrl} = require('../../js/lib/appUrlUtil')
describe('Bravery Panel', function () {
@@ -500,4 +500,70 @@ describe('Bravery Panel', function () {
.waitForTextValue(fpStat, '0')
})
})
+
+ describe('Autoplay test', function () {
+ Brave.beforeEach(this)
+ beforeEach(function * () {
+ yield setup(this.app.client)
+ })
+
+ it('default block', 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 === ''
+ })
+ })
+ })
+
+ it('allow autoplay in regular tab', 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 === ''
+ })
+ })
+ .openBraveMenu(braveMenu, braveryPanel)
+ .click(autoplaySwitch)
+ .keys(Brave.keys.ESCAPE)
+ .tabByUrl(url)
+ .waitUntil(function () {
+ return this.getText('div[id="status"]')
+ .then((status) => {
+ return status === 'Autoplay playing'
+ })
+ })
+ })
+
+ it('allow autoplay in private tab', function * () {
+ const url = Brave.server.url('autoplay.html')
+ yield this.app.client
+ .newTab({ url, isPrivate: true })
+ .waitForUrl(url)
+ .waitUntil(function () {
+ return this.getText('div[id="status"]')
+ .then((status) => {
+ return status === ''
+ })
+ })
+ .openBraveMenu(braveMenu, braveryPanel)
+ .click(autoplaySwitch)
+ .keys(Brave.keys.ESCAPE)
+ .tabByUrl(url)
+ .waitUntil(function () {
+ return this.getText('div[id="status"]')
+ .then((status) => {
+ return status === 'Autoplay playing'
+ })
+ })
+ })
+ })
})
diff --git a/test/fixtures/autoplay.html b/test/fixtures/autoplay.html
new file mode 100644
index 0000000000..8ca04a62dc
--- /dev/null
+++ b/test/fixtures/autoplay.html
@@ -0,0 +1,23 @@
+
+
+
+
+
Autoplay
+
+
+
+
+
+
+
+
+
+
+
diff --git a/test/fixtures/video/autoplay.mp4 b/test/fixtures/video/autoplay.mp4
new file mode 100644
index 0000000000..3b46840196
Binary files /dev/null and b/test/fixtures/video/autoplay.mp4 differ
diff --git a/test/lib/selectors.js b/test/lib/selectors.js
index 22637de26c..ec8d775685 100644
--- a/test/lib/selectors.js
+++ b/test/lib/selectors.js
@@ -58,6 +58,7 @@ module.exports = {
noScriptAllowOnceButton: '[data-l10n-id="allowScriptsOnce"]',
noScriptAllowButton: '[data-l10n-id="allowScripts"]',
safeBrowsingSwitch: '.safeBrowsingSwitch .switchMiddle',
+ autoplaySwitch: '.allowAutoplay .switchMiddle',
backButton: '.backforward .backButton',
forwardButton: '.backforward .forwardButton',
reloadButton: '.reloadButton',