Created
April 25, 2016 19:52
-
-
Save linclark/4171e8483b035c425ed4103a97df4347 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/app/ui/browser/index.jsx b/app/ui/browser/index.jsx | |
index 4ab9a68..e2a5972 100644 | |
--- a/app/ui/browser/index.jsx | |
+++ b/app/ui/browser/index.jsx | |
@@ -20,6 +20,10 @@ import configureStore from './store/store'; | |
import rootReducer from './reducers'; | |
import Immutable from 'immutable'; | |
+import * as actions from './actions/main-actions'; | |
+ | |
+import Perf from 'react-addons-perf'; | |
+ | |
const initialProfileState = ipcRenderer.sendSync('window-loaded'); | |
const initialState = rootReducer(undefined, { type: null }); | |
@@ -38,3 +42,41 @@ const container = document.getElementById('browser-container'); | |
const onRender = () => ipcRenderer.send('window-ready'); | |
ReactDOM.render(chrome, container, onRender); | |
+ | |
+let then = 0; | |
+ | |
+const urls = [ | |
+ "http://google.com", | |
+ "http://twitter.com", | |
+ "http://facebook.com", | |
+] | |
+ | |
+function perfTest(statusText) { | |
+ Perf.start(); | |
+ store.dispatch(actions.setPageDetails(null, { statusText })); | |
+ process.nextTick(() => { | |
+ Perf.stop(); | |
+ Perf.printWasted(); | |
+ scheduleTest(); | |
+ }); | |
+} | |
+const scheduleTest = () => { | |
+ if (urls.length > 0) { | |
+ // Give a little time between this test and the next | |
+ window.setTimeout(perfTest, 2000, urls.pop()); | |
+ } | |
+}; | |
+ | |
+// Give the browser some time to load | |
+window.setTimeout(() => { | |
+ // Create a bunch of tabs to mimic real life use | |
+ store.dispatch(actions.createTab()); | |
+ store.dispatch(actions.createTab()); | |
+ store.dispatch(actions.createTab()); | |
+ store.dispatch(actions.createTab()); | |
+ store.dispatch(actions.createTab()); | |
+ store.dispatch(actions.createTab()); | |
+ store.dispatch(actions.setCurrentTab()); | |
+ | |
+ scheduleTest(); | |
+}, 3000); | |
diff --git a/app/ui/browser/reducers/main-reducers.js b/app/ui/browser/reducers/main-reducers.js | |
index 5f7fc63..8ddadd1 100644 | |
--- a/app/ui/browser/reducers/main-reducers.js | |
+++ b/app/ui/browser/reducers/main-reducers.js | |
@@ -196,8 +196,9 @@ function navigatePageTo(state, pageId, location) { | |
} | |
function setPageDetails(state, pageId, payload) { | |
- assert(isUUID(pageId), 'SET_PAGE_DETAILS requires a page id.'); | |
- const pageIndex = getPageIndexById(state, pageId); | |
+ //assert(isUUID(pageId), 'SET_PAGE_DETAILS requires a page id.'); | |
+ // TESTING: if pageId is null, then set it to 0 for the first tab | |
+ const pageIndex = pageId ? getPageIndexById(state, pageId) : 0; | |
assert(pageIndex >= 0, `Page ${pageId} not found in current state`); | |
return state.withMutations(mut => { | |
@@ -213,16 +214,17 @@ function setPageDetails(state, pageId, payload) { | |
} | |
function setUserTypedLocation(state, pageId, { text }) { | |
- assert(isUUID(pageId), 'SET_USER_TYPED_LOCATION requires a page id.'); | |
- const pageIndex = getPageIndexById(state, pageId); | |
+ //assert(isUUID(pageId), 'SET_USER_TYPED_LOCATION requires a page id.'); | |
+ const pageIndex = 0; | |
assert(pageIndex >= 0, `Page ${pageId} not found in current state`); | |
return state.setIn(['pages', pageIndex, 'userTyped'], text); | |
} | |
function setCurrentTab(state, pageId) { | |
- assert(isUUID(pageId), 'SET_CURRENT_TAB requires a page id.'); | |
- const pageIndex = getPageIndexById(state, pageId); | |
+ //assert(isUUID(pageId), 'SET_CURRENT_TAB requires a page id.'); | |
+ // TESTING: make this always tab 0 | |
+ const pageIndex = 0; | |
assert(pageIndex >= 0, `Page ${pageId} not found in current state`); | |
return state.set('currentPageIndex', pageIndex); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment