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

Commit

Permalink
Record firstRunTimestamp in sessionStore
Browse files Browse the repository at this point in the history
Auditors: @bsclifton

Test Plan:

Upgrading existing userData
1. Be on `master` and close Brave
2. Open session-store-1 with less (e.g. ~/Library/Application\ Support/brave-development/session-store-1)
3. See firstRunTimestamp is not there
4. Check out this branch
5. Open Brave, then close it
6. View again session-store-1 and see firstRunTimestamp is there
8. Restart Brave again, then close it
9. See firstRunTimestamp is see firstRunTimestamp is unchanged

New profile
1. Delete userData dir (e.g. ~/Library/Application\ Support/brave-development)
2. Open Brave
3. Close Brave
4. View session-store-1 and see firstRunTimestamp
  • Loading branch information
ayumi committed Sep 21, 2016
1 parent d4d561b commit 2850702
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 0 deletions.
3 changes: 3 additions & 0 deletions app/sessionStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,9 @@ module.exports.loadAppState = () => {
module.exports.cleanAppData(data, false)
}
data = Object.assign(module.exports.defaultAppState(), data)
if (!data.firstRunTimestamp) {
data.firstRunTimestamp = new Date().getTime()
}
data.cleanedOnShutdown = false
// Always recalculate the update status
if (data.updates) {
Expand Down
1 change: 1 addition & 0 deletions docs/state.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ AppStore

```javascript
{
firstRunTimestamp: integer,
extensions: {
[id]: { // the unique id of the extension
id: string,
Expand Down
41 changes: 41 additions & 0 deletions test/app/sessionStoreTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,45 @@ describe('sessionStore', function () {
yield Brave.app.client.waitForExist(navigatorBookmarked)
})
})

describe('firstRunTimestamp', function () {
Brave.beforeAllServerSetup(this)
before(function * () {
// AY: Why do I need to start, stop and start for this to work properly?
yield Brave.startApp()
yield setup(Brave.app.client)
yield Brave.stopApp(false)
yield Brave.startApp()
yield setup(Brave.app.client)
})

after(function * () {
yield Brave.stopApp()
})

it('sets it once', function * () {
const timestamp = new Date().getTime()
let firstRunTimestamp
yield Brave.app.client
.waitUntil(function () {
return this.getAppState().then((val) => {
firstRunTimestamp = val.value.firstRunTimestamp
return (
firstRunTimestamp > (timestamp - 30 * 1000) &&
firstRunTimestamp <= timestamp
)
})
})

yield Brave.stopApp(false)
yield Brave.startApp()
yield setup(Brave.app.client)
yield Brave.app.client
.waitUntil(function () {
return this.getAppState().then((val) => {
return (val.value.firstRunTimestamp === firstRunTimestamp)
})
})
})
})
})

0 comments on commit 2850702

Please sign in to comment.