Skip to content
This repository has been archived by the owner on Dec 11, 2019. It is now read-only.

Commit

Permalink
1. Make name more consistent
Browse files Browse the repository at this point in the history
2. Remove twitch out of site hack
3. Add test

Auditors: @bridiver
  • Loading branch information
darkdh committed Aug 31, 2016
1 parent 23fcbbd commit ea401ab
Show file tree
Hide file tree
Showing 8 changed files with 73 additions and 25 deletions.
2 changes: 1 addition & 1 deletion app/extensions/brave/locales/en-US/app.properties
Original file line number Diff line number Diff line change
Expand Up @@ -190,4 +190,4 @@ phone=Phone
email=Email
editAddress=Edit Address
editCreditCard=Edit Credit Card
allowMixedContent=Allow Mixed Content
allowRunInsecureContent=Allow Run Insecure Content
4 changes: 2 additions & 2 deletions docs/state.md
Original file line number Diff line number Diff line change
Expand Up @@ -267,8 +267,8 @@ WindowStore
realm: string
},
isExtendedValidation: boolean, // is using https ev
isRunInsecureConent: boolean, // has active mixed content
blockedRunInsecureConent: string, // source of blocked active mixed content
runInsecureContent: boolean, // has active mixed content
blockedRunInsecureContent: string, // first domain of blocked active mixed content
},
parentFrameKey: number, // the key of the frame this frame was opened from
modalPromptDetail: {...},
Expand Down
7 changes: 2 additions & 5 deletions js/components/frame.js
Original file line number Diff line number Diff line change
Expand Up @@ -749,10 +749,10 @@ class Frame extends ImmutableComponent {
windowActions.onWebviewLoadStart(this.frame, e.url)
windowActions.setBlockedRunInsecureContent(this.frame)
const isSecure = parsedUrl.protocol === 'https:' && !this.runInsecureContent()
const isRunInsecureContent = parsedUrl.protocol === 'https:' && this.runInsecureContent()
const runInsecureContent = parsedUrl.protocol === 'https:' && this.runInsecureContent()
windowActions.setSecurityState(this.frame, {
secure: isSecure,
runInsecureContent: isRunInsecureContent
runInsecureContent: runInsecureContent
})
if (isSecure) {
// Check that there isn't a cert error.
Expand All @@ -770,9 +770,6 @@ class Frame extends ImmutableComponent {
if (this.doNotTrack) {
this.webview.executeJavaScript('Navigator.prototype.__defineGetter__("doNotTrack", () => {return 1});')
}
if (hack && hack.allowRunningInsecureContent) {
appActions.changeSiteSetting(this.origin, 'runInsecureContent', true)
}
}
const loadEnd = (savePage) => {
windowActions.onWebviewLoadEnd(
Expand Down
20 changes: 10 additions & 10 deletions js/components/siteInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ const siteUtil = require('../state/siteUtil')
class SiteInfo extends ImmutableComponent {
constructor () {
super()
this.onAllowMixedContent = this.onAllowMixedContent.bind(this)
this.OnAllowRunInsecureContent = this.OnAllowRunInsecureContent.bind(this)
}
onAllowMixedContent () {
OnAllowRunInsecureContent () {
appActions.changeSiteSetting(siteUtil.getOrigin(this.isBlockedRunInsecureContent), 'runInsecureContent', true)
ipc.emit(messages.SHORTCUT_ACTIVE_FRAME_LOAD_URL, {}, this.isBlockedRunInsecureContent)
this.props.onHide()
Expand All @@ -28,8 +28,8 @@ class SiteInfo extends ImmutableComponent {
get isSecure () {
return this.props.frameProps.getIn(['security', 'isSecure'])
}
get isRunInsecureContent () {
return this.props.frameProps.getIn(['security', 'isRunInsecureContent'])
get runInsecureContent () {
return this.props.frameProps.getIn(['security', 'runInsecureContent'])
}
get isBlockedRunInsecureContent () {
return this.props.frameProps.getIn(['security', 'blockedRunInsecureContent'])
Expand All @@ -39,14 +39,14 @@ class SiteInfo extends ImmutableComponent {
}
render () {
let secureIcon
if (this.isSecure && !this.isRunInsecureContent) {
if (this.isSecure && !this.runInsecureContent) {
secureIcon = <li><span
className={cx({
fa: true,
'fa-lock': true,
extendedValidation: this.isExtendedValidation
})} /><span data-l10n-id='secureConnection' /></li>
} else if (this.isRunInsecureContent) {
} else if (this.runInsecureContent) {
secureIcon = <li><span className='fa fa-unlock' /><span data-l10n-id='mixedConnection' /></li>
} else {
secureIcon = <li><span className='fa fa-unlock' /><span data-l10n-id='insecureConnection' data-l10n-args={JSON.stringify(l10nArgs)} /></li>
Expand All @@ -63,10 +63,10 @@ class SiteInfo extends ImmutableComponent {
<span data-l10n-args={JSON.stringify(l10nArgs)} data-l10n-id='sessionInfo' /></li>
}

let allowMixedContentButton
let allowRunInsecureContentButton
if (this.isBlockedRunInsecureContent) {
allowMixedContentButton =
<Button l10nId='allowMixedContent' className='primaryButton' onClick={this.onAllowMixedContent} />
allowRunInsecureContentButton =
<Button l10nId='allowRunInsecureContent' className='primaryButton allowRunInsecureContentButton' onClick={this.OnAllowRunInsecureContent} />
}

return <Dialog onHide={this.props.onHide} className='siteInfo' isClickDismiss>
Expand All @@ -78,7 +78,7 @@ class SiteInfo extends ImmutableComponent {
partitionInfo
}
{
allowMixedContentButton
allowRunInsecureContentButton
}
</ul>
</Dialog>
Expand Down
4 changes: 0 additions & 4 deletions js/data/siteHacks.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ module.exports = {
},
// For links like: https://player.twitch.tv/?channel=iwilldominate
'player.twitch.tv': {
allowRunningInsecureContent: true,
enableForAll: true
},
'www.wired.com': {
Expand All @@ -61,9 +60,6 @@ module.exports = {
};
})();`
},
'www.twitch.tv': {
allowRunningInsecureContent: true
},
'imasdk.googleapis.com': {
enableForAdblock: true,
onBeforeRequest: function (details) {
Expand Down
2 changes: 1 addition & 1 deletion js/stores/windowStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -743,7 +743,7 @@ const doAction = (action) => {
action.securityState.secure)
}
if (action.securityState.runInsecureContent !== undefined) {
windowState = windowState.setIn(path.concat(['security', 'isRunInsecureContent']),
windowState = windowState.setIn(path.concat(['security', 'runInsecureContent']),
action.securityState.runInsecureContent)
}
if (action.securityState.certDetails) {
Expand Down
56 changes: 55 additions & 1 deletion test/components/navigationBarTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

const Brave = require('../lib/brave')
const config = require('../../js/constants/config')
const {urlBarSuggestions, urlInput, activeWebview, activeTabFavicon, activeTab, navigatorLoadTime, navigator, titleBar, urlbarIcon, bookmarksToolbar, navigatorNotBookmarked, navigatorBookmarked, saveButton} = require('../lib/selectors')
const {urlBarSuggestions, urlInput, activeWebview, activeTabFavicon, activeTab, navigatorLoadTime, navigator, titleBar, urlbarIcon, bookmarksToolbar, navigatorNotBookmarked, navigatorBookmarked, saveButton, allowRunInsecureContentButton} = require('../lib/selectors')
const urlParse = require('url').parse
const assert = require('assert')
const settings = require('../../js/constants/settings')
Expand Down Expand Up @@ -247,6 +247,10 @@ describe('navigationBar', function () {
.getAttribute(urlbarIcon, 'class').then((classes) =>
classes.includes('fa-unlock')
))
.windowByUrl(Brave.browserWindowUrl)
.click(urlbarIcon)
.waitForVisible('[data-l10n-id="insecureConnection"]')
.keys('\uE00C')
})
it('Shows secure URL icon', function * () {
const page1Url = 'https://badssl.com/'
Expand All @@ -258,6 +262,10 @@ describe('navigationBar', function () {
this.app.client.getAttribute(urlbarIcon, 'class').then((classes) =>
classes.includes('fa-lock')
))
.windowByUrl(Brave.browserWindowUrl)
.click(urlbarIcon)
.waitForVisible('[data-l10n-id="secureConnection"]')
.keys('\uE00C')
})
it('Blocks active mixed content', function * () {
const page1Url = 'https://mixed-script.badssl.com/'
Expand All @@ -272,6 +280,52 @@ describe('navigationBar', function () {
color.value === 'rgba(128,128,128,1)'
)
})
.windowByUrl(Brave.browserWindowUrl)
.waitForExist(urlbarIcon)
.waitUntil(() =>
this.app.client.getAttribute(urlbarIcon, 'class').then((classes) =>
classes.includes('fa-lock')
))
.windowByUrl(Brave.browserWindowUrl)
.click(urlbarIcon)
.waitForVisible('[data-l10n-id="secureConnection"]')
.keys('\uE00C')
})
it('Temporarily allow active mixed content', function * () {
const page1Url = 'https://mixed-script.badssl.com/'
yield this.app.client.tabByUrl(Brave.newTabUrl)
.url(page1Url)
.waitUntil(() => {
return this.app.client.execute(() => document.readyState).then((ret) =>
ret.value === 'complete'
)
}).waitUntil(() => {
return this.app.client.getCssProperty('body', 'background-color').then((color) =>
color.value === 'rgba(128,128,128,1)'
)
})
.windowByUrl(Brave.browserWindowUrl)
.click(urlbarIcon)
.windowByUrl(Brave.browserWindowUrl)
.waitForVisible(allowRunInsecureContentButton)
.click(allowRunInsecureContentButton)
.tabByUrl(this.page1Url)
.waitUntil(() => {
return this.app.client.execute(() => document.readyState).then((ret) =>
ret.value === 'complete'
)
}).waitUntil(() => {
return this.app.client.getCssProperty('body', 'background-color').then((color) =>
color.value === 'rgba(255,0,0,1)'
)
})
.windowByUrl(Brave.browserWindowUrl)
.click(urlbarIcon)
.getAttribute(urlbarIcon, 'class').then((classes) =>
classes.includes('fa-unlock')
)
.waitForVisible('[data-l10n-id="mixedConnection"]')
.keys('\uE00C')
})
})

Expand Down
3 changes: 2 additions & 1 deletion test/lib/selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,6 @@ module.exports = {
saveButton: '[data-l10n-id="save"]',
deleteButton: '[data-l10n-id="delete"]',
autofillAddressPanel: '.autofillAddressPanel',
autofillCreditCardPanel: '.autofillCreditCardPanel'
autofillCreditCardPanel: '.autofillCreditCardPanel',
allowRunInsecureContentButton: '.allowRunInsecureContentButton'
}

0 comments on commit ea401ab

Please sign in to comment.