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

Commit 4c6a625

Browse files
committed
Remove unused clone frame code
Auditors: @bridiver
1 parent f2cf0d4 commit 4c6a625

File tree

6 files changed

+0
-155
lines changed

6 files changed

+0
-155
lines changed

docs/windowActions.md

-12
Original file line numberDiff line numberDiff line change
@@ -221,18 +221,6 @@ Dispatches a message to the store to create a new frame
221221

222222

223223

224-
### cloneFrame(frameProps, guestInstanceId)
225-
226-
Dispatches a message to the store to clone an existing frame
227-
228-
**Parameters**
229-
230-
**frameProps**: `Object`, The properties of the frame to clone
231-
232-
**guestInstanceId**: `number`, The guestInstanceId of the cloned webcontents
233-
234-
235-
236224
### closeFrame(frames, frameProps)
237225

238226
Dispatches a message to close a frame

js/actions/windowActions.js

-15
Original file line numberDiff line numberDiff line change
@@ -292,21 +292,6 @@ const windowActions = {
292292
})
293293
},
294294

295-
/**
296-
* Dispatches a message to the store to clone an existing frame
297-
*
298-
* @param {Object} frameProps - The properties of the frame to clone
299-
* @param {number} guestInstanceId - The guestInstanceId of the cloned webcontents
300-
*/
301-
cloneFrame: function (frameProps, guestInstanceId, openInForeground) {
302-
dispatch({
303-
actionType: windowConstants.WINDOW_CLONE_FRAME,
304-
frameOpts: frameProps.toJS ? frameProps.toJS() : frameProps,
305-
guestInstanceId,
306-
openInForeground
307-
})
308-
},
309-
310295
/**
311296
* Dispatches a message to close a frame
312297
*

js/constants/windowConstants.js

-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ const windowConstants = {
1010
WINDOW_SET_NAVBAR_INPUT: _,
1111
WINDOW_NEW_FRAME: _,
1212
WINDOW_VIEW_KEY: _,
13-
WINDOW_CLONE_FRAME: _,
1413
WINDOW_CLOSE_FRAME: _,
1514
WINDOW_SET_ACTIVE_FRAME: _,
1615
WINDOW_SET_FOCUSED_FRAME: _,

js/state/frameStateUtil.js

-33
Original file line numberDiff line numberDiff line change
@@ -242,38 +242,6 @@ function getPartition (frameOpts) {
242242
return partition
243243
}
244244

245-
function cloneFrame (frameOpts, guestInstanceId, key) {
246-
const cloneableAttributes = [
247-
'audioMuted',
248-
'canGoBack',
249-
'canGoForward',
250-
'icon',
251-
'title',
252-
'isPrivate',
253-
'partitionNumber',
254-
'themeColor',
255-
'computedThemeColor'
256-
]
257-
let clone = {}
258-
cloneableAttributes.forEach((attr) => {
259-
clone[attr] = frameOpts[attr]
260-
})
261-
262-
clone.guestInstanceId = guestInstanceId
263-
// copy the history
264-
clone.history = frameOpts.history.slice(0)
265-
// location is loaded by the webcontents
266-
clone.delayedLoadUrl = frameOpts.location
267-
clone.location = 'about:blank'
268-
clone.src = 'about:blank'
269-
clone.parentFrameKey = frameOpts.key
270-
if (frameOpts.aboutDetails !== undefined) {
271-
clone.aboutDetails = frameOpts.aboutDetails
272-
clone.aboutDetails.frameKey = key
273-
}
274-
return clone
275-
}
276-
277245
/**
278246
* Returns an object in the same format that was passed to it (ImmutableJS/POD)
279247
* for the subset of frame data that is used for tabs.
@@ -556,7 +524,6 @@ module.exports = {
556524
getFramePropsIndex,
557525
getFrameKeysByDisplayIndex,
558526
getPartition,
559-
cloneFrame,
560527
addFrame,
561528
undoCloseFrame,
562529
removeFrame,

js/stores/windowStore.js

-8
Original file line numberDiff line numberDiff line change
@@ -467,14 +467,6 @@ const doAction = (action) => {
467467
case windowConstants.WINDOW_VIEW_KEY:
468468
newFrame(action.frameOpts, action.openInForeground)
469469
break
470-
case windowConstants.WINDOW_CLONE_FRAME:
471-
{
472-
let insertionIndex = frameStateUtil.findIndexForFrameKey(windowState.get('frames'), action.frameOpts.key) + 1
473-
const nextKey = incrementNextKey()
474-
newFrame(frameStateUtil.cloneFrame(action.frameOpts, action.guestInstanceId, nextKey),
475-
action.openInForeground, insertionIndex, nextKey)
476-
break
477-
}
478470
case windowConstants.WINDOW_CLOSE_FRAME:
479471
// Use the frameProps we passed in, or default to the active frame
480472
const frameProps = action.frameProps || frameStateUtil.getActiveFrame(windowState)

test/unit/state/frameStateUtilTest.js

-86
Original file line numberDiff line numberDiff line change
@@ -17,92 +17,6 @@ describe('frameStateUtil', function () {
1717
this.windowState = Immutable.fromJS(Object.assign({}, defaultWindowStore.toJS()))
1818
})
1919

20-
describe('cloneFrame', function () {
21-
before(function () {
22-
this.frameOpts = {
23-
key: 1,
24-
tabId: 2,
25-
parentFrameKey: 3,
26-
audioMuted: true,
27-
canGoBack: true,
28-
canGoForward: true,
29-
icon: 'icon',
30-
title: 'title',
31-
isPrivate: true,
32-
partitionNumber: 4,
33-
themeColor: 'ffffff',
34-
computedThemeColor: 'aaaaaa',
35-
history: ['http://brave.com'],
36-
location: 'http://brave.com/about'
37-
}
38-
this.aboutFrameOpts = {}
39-
Object.assign(this.aboutFrameOpts, this.frameOpts)
40-
this.aboutFrameOpts['aboutDetails'] =
41-
{
42-
errorCode: -1,
43-
frameKey: 1
44-
}
45-
this.clonedFrame = frameStateUtil.cloneFrame(this.frameOpts, 4)
46-
this.key = 6
47-
this.aboutClonedFrame = frameStateUtil.cloneFrame(this.aboutFrameOpts, 5, this.key)
48-
})
49-
50-
it('does not copy the key', function () {
51-
assert.equal(this.frameOpts.key, 1)
52-
assert.equal(this.clonedFrame.key, undefined)
53-
})
54-
55-
it('does not copy the tabId', function () {
56-
assert.equal(this.frameOpts.tabId, 2)
57-
assert.equal(this.clonedFrame.tabId, undefined)
58-
})
59-
60-
it('sets the parentFrameKey to frameOpts.key', function () {
61-
assert.equal(this.frameOpts.parentFrameKey, 3)
62-
assert.equal(this.clonedFrame.parentFrameKey, 1)
63-
})
64-
65-
it('sets the delayedLoadUrl to frameOpts.location', function () {
66-
assert.equal(this.clonedFrame.delayedLoadUrl, 'http://brave.com/about')
67-
})
68-
69-
it('sets the location to about:blank', function () {
70-
assert.equal(this.clonedFrame.location, 'about:blank')
71-
})
72-
73-
it('sets the src to about:blank', function () {
74-
assert.equal(this.clonedFrame.src, 'about:blank')
75-
})
76-
77-
it('sets the guestInstanceId', function () {
78-
assert.equal(this.clonedFrame.guestInstanceId, 4)
79-
})
80-
81-
it('copies audioMuted, canGoBack, canGoForward, icon, title, isPrivate, partitionNumber, themeColor, computere and history', function () {
82-
// attributes that should be copied
83-
assert.equal(this.clonedFrame.audioMuted, true)
84-
assert.equal(this.clonedFrame.canGoBack, true)
85-
assert.equal(this.clonedFrame.canGoForward, true)
86-
assert.equal(this.clonedFrame.icon, 'icon')
87-
assert.equal(this.clonedFrame.title, 'title')
88-
assert.equal(this.clonedFrame.isPrivate, true)
89-
assert.equal(this.clonedFrame.partitionNumber, 4)
90-
assert.equal(this.clonedFrame.themeColor, 'ffffff')
91-
assert.equal(this.clonedFrame.computedThemeColor, 'aaaaaa')
92-
assert.deepEqual(this.clonedFrame.history, ['http://brave.com'])
93-
assert(this.clonedFrame.history !== this.frameOpts.history)
94-
})
95-
96-
it('clone without aboutDetails', function () {
97-
assert.equal(this.clonedFrame.aboutDetails, undefined)
98-
})
99-
100-
it('copies aboutDetails with key', function () {
101-
assert.equal(this.aboutClonedFrame.aboutDetails.errorCode, this.aboutFrameOpts.aboutDetails.errorCode)
102-
assert.equal(this.aboutClonedFrame.aboutDetails.frameKey, this.key)
103-
})
104-
})
105-
10620
describe('query', function () {
10721
before(function () {
10822
this.frames = Immutable.fromJS([

0 commit comments

Comments
 (0)