-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix that timer.addAction reverses order when splicing multiple events…
… at same timestamp (#611) * Add test for event ordering utilizing final html testing method added by Justin (with thanks) * Found an error where two mutation events had the same timestamp, but one removed a node added in the other. The `actions.splice` method was reversing their order and triggering a 'Node with id [...] not found' error
- Loading branch information
1 parent
188f31e
commit 009d73a
Showing
4 changed files
with
218 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
import { EventType, eventWithTime, IncrementalSource } from '../../src/types'; | ||
|
||
const now = Date.now(); | ||
const events: eventWithTime[] = [ | ||
{ | ||
type: EventType.DomContentLoaded, | ||
data: {}, | ||
timestamp: now, | ||
}, | ||
{ | ||
type: EventType.Load, | ||
data: {}, | ||
timestamp: now + 10, | ||
}, | ||
{ | ||
type: EventType.Meta, | ||
data: { | ||
href: 'http://localhost', | ||
width: 1000, | ||
height: 800, | ||
}, | ||
timestamp: now + 10, | ||
}, | ||
// full snapshot: | ||
{ | ||
data: { | ||
node: { | ||
id: 1, | ||
type: 0, | ||
childNodes: [ | ||
{ id: 2, name: 'html', type: 1, publicId: '', systemId: '' }, | ||
{ | ||
id: 3, | ||
type: 2, | ||
tagName: 'html', | ||
attributes: { lang: 'en' }, | ||
childNodes: [ | ||
{ | ||
id: 4, | ||
type: 2, | ||
tagName: 'head', | ||
attributes: {}, | ||
childNodes: [], | ||
}, | ||
{ | ||
id: 100, | ||
type: 2, | ||
tagName: 'body', | ||
attributes: {}, | ||
childNodes: [ | ||
{ | ||
id: 101, | ||
type: 2, | ||
tagName: 'span', | ||
attributes: {}, | ||
childNodes: [ | ||
{ | ||
id: 102, | ||
type: 3, | ||
textContent: 'Initial', | ||
}, | ||
], | ||
}, | ||
], | ||
}, | ||
], | ||
}, | ||
], | ||
}, | ||
initialOffset: { top: 0, left: 0 }, | ||
}, | ||
type: EventType.FullSnapshot, | ||
timestamp: now + 20, | ||
}, | ||
// 1st mutation that modifies text content | ||
{ | ||
data: { | ||
adds: [], | ||
texts: [ | ||
{ | ||
id: 102, | ||
value: 'Intermediate - incorrect', | ||
} | ||
], | ||
source: IncrementalSource.Mutation, | ||
removes: [], | ||
attributes: [], | ||
}, | ||
type: EventType.IncrementalSnapshot, | ||
timestamp: now + 30, | ||
}, | ||
// 2nd mutation (with same timestamp) that modifies text content | ||
{ | ||
data: { | ||
adds: [], | ||
texts: [ | ||
{ | ||
id: 102, | ||
value: 'Final - correct', | ||
} | ||
], | ||
source: IncrementalSource.Mutation, | ||
removes: [], | ||
attributes: [], | ||
}, | ||
type: EventType.IncrementalSnapshot, | ||
timestamp: now + 30, | ||
}, | ||
// dummy - presence triggers a bug | ||
{ | ||
data: { | ||
adds: [], | ||
texts: [], | ||
source: IncrementalSource.Mutation, | ||
removes: [], | ||
attributes: [], | ||
}, | ||
type: EventType.IncrementalSnapshot, | ||
timestamp: now + 35, | ||
}, | ||
]; | ||
|
||
export default events; |
This file contains 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