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

Saving a document doesn't show correct origin #8786

Merged
merged 1 commit into from
May 10, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/extensions/brave/locales/en-US/downloads.properties
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ downloadInProgress=Downloading: {{downloadPercent}}
downloadInProgressUnknownTotal=Downloading…
downloadPaused=Paused: {{downloadPercent}}
downloadDeleteConfirmation=Delete?
downloadLocalFile=Local file

downloadPause.title=Pause Download
downloadResume.title=Resume Download
Expand Down
4 changes: 3 additions & 1 deletion app/renderer/components/downloadItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ class DownloadItem extends ImmutableComponent {
}
render () {
const origin = getOrigin(this.props.download.get('url'))
const localFileOrigins = ['file:', 'blob:', 'data:', 'chrome-extension:', 'chrome:']
const localFile = origin && localFileOrigins.some((localFileOrigin) => origin.startsWith(localFileOrigin))
const progressStyle = {
width: downloadUtil.getPercentageComplete(this.props.download)
}
Expand Down Expand Up @@ -160,7 +162,7 @@ class DownloadItem extends ImmutableComponent {
? <span className='fa fa-unlock isInsecure' />
: null
}
<span title={origin}>{origin}</span>
<span data-l10n-id={localFile ? 'downloadLocalFile' : null} title={origin}>{localFile ? null : origin}</span>
</div>
: null
}
Expand Down
32 changes: 32 additions & 0 deletions test/unit/app/renderer/downloadItemTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ require('../../braveUnit')

const savePath = path.join(require('os').tmpdir(), 'mostHatedPrimes.txt')
const downloadUrl = 'http://www.bradrichter.com/mostHatedPrimes.txt'
const localFileDownloadUrl = 'file:///Users/foobar/Library/abc.txt'
const newDownload = (state) => Immutable.fromJS({
startTime: new Date().getTime(),
filename: 'mostHatedPrimes.txt',
Expand All @@ -28,6 +29,16 @@ const newDownload = (state) => Immutable.fromJS({
deleteConfirmationVisible: false,
state
})
const newDownloadLocalFile = (state) => Immutable.fromJS({
startTime: new Date().getTime(),
filename: 'abc.txt',
savePath,
url: localFileDownloadUrl,
totalBytes: 104729,
receivedBytes: 96931,
deleteConfirmationVisible: false,
state
})

describe('downloadItem component', function () {
before(function () {
Expand All @@ -46,6 +57,27 @@ describe('downloadItem component', function () {
})

Object.values(downloadStates).forEach(function (state) {
describe(`${state} download local item`, function () {
before(function () {
this.downloadId = uuid.v4()
this.download = newDownloadLocalFile(state)
this.result = mount(
<DownloadItem
downloadId={this.downloadId}
download={this.download}
deleteConfirmationVisible={this.download.get('deleteConfirmationVisible')} />
)
})

it('filename exists and matches download filename', function () {
assert.equal(this.result.find('.downloadFilename').text(), this.download.get('filename'))
})

it('has local origin i.e file: and matches to "Local file" origin', function () {
assert.equal(this.result.find('.downloadOrigin').text(), '')
})
})

describe(`${state} download item`, function () {
before(function () {
this.downloadId = uuid.v4()
Expand Down