@cloudcare/browser-rum 3.0.26 → 3.0.29
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bundle/dataflux-rum.js +1 -1
- package/cjs/boot/buildEnv.js +1 -1
- package/cjs/boot/rumPublicApi.js +37 -38
- package/cjs/domain/assembly.js +4 -6
- package/cjs/domain/domMutationCollection.js +2 -2
- package/cjs/domain/performanceCollection.js +2 -3
- package/cjs/domain/replay/record/mutationBatch.js +22 -17
- package/cjs/domain/replay/record/mutationObserver.js +1 -1
- package/cjs/domain/replay/record/observers.js +1 -1
- package/cjs/domain/replay/record/privacy.js +15 -0
- package/cjs/domain/replay/record/serializationUtils.js +74 -1
- package/cjs/domain/replay/record/serialize.js +5 -72
- package/cjs/domain/rumEventsCollection/actions/getSelectorsFromElement.js +4 -4
- package/cjs/domain/rumEventsCollection/resource/resourceUtils.js +2 -1
- package/esm/boot/buildEnv.js +1 -1
- package/esm/boot/rumPublicApi.js +38 -39
- package/esm/domain/assembly.js +4 -6
- package/esm/domain/domMutationCollection.js +3 -3
- package/esm/domain/performanceCollection.js +3 -4
- package/esm/domain/replay/record/mutationBatch.js +22 -17
- package/esm/domain/replay/record/mutationObserver.js +2 -2
- package/esm/domain/replay/record/observers.js +2 -2
- package/esm/domain/replay/record/privacy.js +14 -0
- package/esm/domain/replay/record/serializationUtils.js +62 -1
- package/esm/domain/replay/record/serialize.js +2 -69
- package/esm/domain/rumEventsCollection/actions/getSelectorsFromElement.js +4 -4
- package/esm/domain/rumEventsCollection/resource/resourceUtils.js +2 -1
- package/package.json +4 -4
- package/src/boot/rumPublicApi.js +41 -38
- package/src/domain/assembly.js +4 -6
- package/src/domain/domMutationCollection.js +20 -17
- package/src/domain/performanceCollection.js +4 -3
- package/src/domain/replay/record/mutationBatch.js +21 -3
- package/src/domain/replay/record/mutationObserver.js +3 -2
- package/src/domain/replay/record/observers.js +5 -2
- package/src/domain/replay/record/privacy.js +22 -0
- package/src/domain/replay/record/serializationUtils.js +64 -2
- package/src/domain/replay/record/serialize.js +5 -68
- package/src/domain/rumEventsCollection/actions/getSelectorsFromElement.js +4 -4
- package/src/domain/rumEventsCollection/resource/resourceUtils.js +4 -1
package/src/boot/rumPublicApi.js
CHANGED
|
@@ -15,7 +15,8 @@ import {
|
|
|
15
15
|
checkUser,
|
|
16
16
|
noop,
|
|
17
17
|
assign,
|
|
18
|
-
canUseEventBridge
|
|
18
|
+
canUseEventBridge,
|
|
19
|
+
monitor
|
|
19
20
|
} from '@cloudcare/browser-core'
|
|
20
21
|
import { validateAndBuildRumConfiguration } from '../domain/configuration'
|
|
21
22
|
import { buildCommonContext } from '../domain/contexts/commonContext'
|
|
@@ -138,49 +139,51 @@ export function makeRumPublicApi(startRumImpl, recorderApi) {
|
|
|
138
139
|
startRumResults.viewContexts
|
|
139
140
|
)
|
|
140
141
|
}
|
|
141
|
-
var startView = function (options) {
|
|
142
|
+
var startView = monitor(function (options) {
|
|
142
143
|
var sanitizedOptions =
|
|
143
144
|
typeof options === 'object' ? options : { name: options }
|
|
144
145
|
startViewStrategy(sanitizedOptions)
|
|
145
|
-
}
|
|
146
|
+
})
|
|
146
147
|
var rumPublicApi = makePublicApi({
|
|
147
|
-
init: initRum,
|
|
148
|
+
init: monitor(initRum),
|
|
148
149
|
/** @deprecated: use setGlobalContextProperty instead */
|
|
149
|
-
addRumGlobalContext: globalContextManager.add,
|
|
150
|
-
setGlobalContextProperty: globalContextManager.setContextProperty,
|
|
150
|
+
addRumGlobalContext: monitor(globalContextManager.add),
|
|
151
|
+
setGlobalContextProperty: monitor(globalContextManager.setContextProperty),
|
|
151
152
|
|
|
152
153
|
/** @deprecated: use removeGlobalContextProperty instead */
|
|
153
|
-
removeRumGlobalContext: globalContextManager.remove,
|
|
154
|
-
removeGlobalContextProperty:
|
|
154
|
+
removeRumGlobalContext: monitor(globalContextManager.remove),
|
|
155
|
+
removeGlobalContextProperty: monitor(
|
|
156
|
+
globalContextManager.removeContextProperty
|
|
157
|
+
),
|
|
155
158
|
|
|
156
159
|
/** @deprecated: use getGlobalContext instead */
|
|
157
|
-
getRumGlobalContext: globalContextManager.get,
|
|
158
|
-
getGlobalContext: globalContextManager.getContext,
|
|
160
|
+
getRumGlobalContext: monitor(globalContextManager.get),
|
|
161
|
+
getGlobalContext: monitor(globalContextManager.getContext),
|
|
159
162
|
|
|
160
163
|
/** @deprecated: use setGlobalContext instead */
|
|
161
|
-
setRumGlobalContext: globalContextManager.set,
|
|
162
|
-
setGlobalContext: globalContextManager.setContext,
|
|
164
|
+
setRumGlobalContext: monitor(globalContextManager.set),
|
|
165
|
+
setGlobalContext: monitor(globalContextManager.setContext),
|
|
163
166
|
|
|
164
|
-
clearGlobalContext: globalContextManager.clearContext,
|
|
167
|
+
clearGlobalContext: monitor(globalContextManager.clearContext),
|
|
165
168
|
|
|
166
|
-
getInitConfiguration: function () {
|
|
169
|
+
getInitConfiguration: monitor(function () {
|
|
167
170
|
return getInitConfigurationStrategy()
|
|
168
|
-
},
|
|
169
|
-
getInternalContext: function (startTime) {
|
|
171
|
+
}),
|
|
172
|
+
getInternalContext: monitor(function (startTime) {
|
|
170
173
|
return getInternalContextStrategy(startTime)
|
|
171
|
-
},
|
|
172
|
-
addDebugSession: function (id) {},
|
|
173
|
-
clearDebugSession: function () {},
|
|
174
|
-
getDebugSession: function () {},
|
|
175
|
-
addAction: function (name, context) {
|
|
174
|
+
}),
|
|
175
|
+
addDebugSession: monitor(function (id) {}),
|
|
176
|
+
clearDebugSession: monitor(function () {}),
|
|
177
|
+
getDebugSession: monitor(function () {}),
|
|
178
|
+
addAction: monitor(function (name, context) {
|
|
176
179
|
addActionStrategy({
|
|
177
180
|
name: name,
|
|
178
181
|
context: deepClone(context),
|
|
179
182
|
startClocks: clocksNow(),
|
|
180
183
|
type: ActionType.CUSTOM
|
|
181
184
|
})
|
|
182
|
-
},
|
|
183
|
-
addError: function (error, context) {
|
|
185
|
+
}),
|
|
186
|
+
addError: monitor(function (error, context) {
|
|
184
187
|
var handlingStack = createHandlingStack()
|
|
185
188
|
addErrorStrategy({
|
|
186
189
|
error: error,
|
|
@@ -188,33 +191,33 @@ export function makeRumPublicApi(startRumImpl, recorderApi) {
|
|
|
188
191
|
context: deepClone(context),
|
|
189
192
|
startClocks: clocksNow()
|
|
190
193
|
})
|
|
191
|
-
},
|
|
192
|
-
addTiming: function (name, time) {
|
|
194
|
+
}),
|
|
195
|
+
addTiming: monitor(function (name, time) {
|
|
193
196
|
addTimingStrategy(name, time)
|
|
194
|
-
},
|
|
195
|
-
setUser: function (newUser) {
|
|
197
|
+
}),
|
|
198
|
+
setUser: monitor(function (newUser) {
|
|
196
199
|
if (checkUser(newUser)) {
|
|
197
200
|
userContextManager.setContext(sanitizeUser(newUser))
|
|
198
201
|
}
|
|
199
|
-
},
|
|
200
|
-
getUser: userContextManager.getContext,
|
|
201
|
-
setUserProperty: function (key, property) {
|
|
202
|
+
}),
|
|
203
|
+
getUser: monitor(userContextManager.getContext),
|
|
204
|
+
setUserProperty: monitor(function (key, property) {
|
|
202
205
|
var newUser = {}
|
|
203
206
|
newUser[key] = property
|
|
204
207
|
var sanitizedProperty = sanitizeUser(newUser)[key]
|
|
205
208
|
userContextManager.setContextProperty(key, sanitizedProperty)
|
|
206
|
-
},
|
|
207
|
-
removeUserProperty: userContextManager.removeContextProperty,
|
|
209
|
+
}),
|
|
210
|
+
removeUserProperty: monitor(userContextManager.removeContextProperty),
|
|
208
211
|
|
|
209
212
|
/** @deprecated: renamed to clearUser */
|
|
210
|
-
removeUser: userContextManager.clearContext,
|
|
211
|
-
clearUser: userContextManager.clearContext,
|
|
213
|
+
removeUser: monitor(userContextManager.clearContext),
|
|
214
|
+
clearUser: monitor(userContextManager.clearContext),
|
|
212
215
|
startView: startView,
|
|
213
|
-
stopSession: function () {
|
|
216
|
+
stopSession: monitor(function () {
|
|
214
217
|
stopSessionStrategy()
|
|
215
|
-
},
|
|
216
|
-
startSessionReplayRecording: recorderApi.start,
|
|
217
|
-
stopSessionReplayRecording: recorderApi.stop
|
|
218
|
+
}),
|
|
219
|
+
startSessionReplayRecording: monitor(recorderApi.start),
|
|
220
|
+
stopSessionReplayRecording: monitor(recorderApi.stop)
|
|
218
221
|
})
|
|
219
222
|
return rumPublicApi
|
|
220
223
|
function canHandleSession(initConfiguration) {
|
package/src/domain/assembly.js
CHANGED
|
@@ -23,9 +23,7 @@ var VIEW_MODIFIABLE_FIELD_PATHS = {
|
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
var USER_CUSTOMIZABLE_FIELD_PATHS = {
|
|
26
|
-
|
|
27
|
-
'_gc.trace_id': 'string',
|
|
28
|
-
'_gc.span_id': 'string'
|
|
26
|
+
context: 'object'
|
|
29
27
|
}
|
|
30
28
|
|
|
31
29
|
var modifiableFieldPathsByEvent = {}
|
|
@@ -145,7 +143,7 @@ export function startRumAssembly(
|
|
|
145
143
|
var serverRumEvent = withSnakeCaseKeys(rumEvent)
|
|
146
144
|
var context = extend2Lev({}, commonContext.context, customerContext)
|
|
147
145
|
if (!isEmptyObject(context)) {
|
|
148
|
-
serverRumEvent.
|
|
146
|
+
serverRumEvent.context = context
|
|
149
147
|
}
|
|
150
148
|
if (!('has_replay' in serverRumEvent.session)) {
|
|
151
149
|
serverRumEvent.session.has_replay = commonContext.hasReplay
|
|
@@ -169,8 +167,8 @@ export function startRumAssembly(
|
|
|
169
167
|
eventRateLimiters
|
|
170
168
|
)
|
|
171
169
|
) {
|
|
172
|
-
if (isEmptyObject(serverRumEvent.
|
|
173
|
-
delete serverRumEvent.
|
|
170
|
+
if (isEmptyObject(serverRumEvent.context)) {
|
|
171
|
+
delete serverRumEvent.context
|
|
174
172
|
}
|
|
175
173
|
lifeCycle.notify(
|
|
176
174
|
LifeCycleEventType.RUM_EVENT_COLLECTED,
|
|
@@ -1,29 +1,32 @@
|
|
|
1
1
|
import {
|
|
2
2
|
noop,
|
|
3
3
|
Observable,
|
|
4
|
-
getZoneJsOriginalValue
|
|
4
|
+
getZoneJsOriginalValue,
|
|
5
|
+
monitor
|
|
5
6
|
} from '@cloudcare/browser-core'
|
|
6
7
|
|
|
7
8
|
export function createDOMMutationObservable() {
|
|
8
9
|
var MutationObserver = getMutationObserverConstructor()
|
|
9
10
|
|
|
10
|
-
var observable = new Observable(
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
11
|
+
var observable = new Observable(
|
|
12
|
+
monitor(function () {
|
|
13
|
+
if (!MutationObserver) {
|
|
14
|
+
return
|
|
15
|
+
}
|
|
16
|
+
var observer = new MutationObserver(function () {
|
|
17
|
+
return observable.notify()
|
|
18
|
+
})
|
|
19
|
+
observer.observe(document, {
|
|
20
|
+
attributes: true,
|
|
21
|
+
characterData: true,
|
|
22
|
+
childList: true,
|
|
23
|
+
subtree: true
|
|
24
|
+
})
|
|
25
|
+
return function () {
|
|
26
|
+
return observer.disconnect()
|
|
27
|
+
}
|
|
22
28
|
})
|
|
23
|
-
|
|
24
|
-
return observer.disconnect()
|
|
25
|
-
}
|
|
26
|
-
})
|
|
29
|
+
)
|
|
27
30
|
return observable
|
|
28
31
|
}
|
|
29
32
|
|
|
@@ -12,7 +12,8 @@ import {
|
|
|
12
12
|
LifeCycleEventType,
|
|
13
13
|
runOnReadyState,
|
|
14
14
|
setTimeout,
|
|
15
|
-
addEventListener
|
|
15
|
+
addEventListener,
|
|
16
|
+
monitor
|
|
16
17
|
} from '@cloudcare/browser-core'
|
|
17
18
|
import {
|
|
18
19
|
FAKE_INITIAL_DOCUMENT,
|
|
@@ -43,13 +44,13 @@ export function startPerformanceCollection(lifeCycle, configuration) {
|
|
|
43
44
|
})
|
|
44
45
|
}
|
|
45
46
|
if (window.PerformanceObserver) {
|
|
46
|
-
var handlePerformanceEntryList = function (entries) {
|
|
47
|
+
var handlePerformanceEntryList = monitor(function (entries) {
|
|
47
48
|
handleRumPerformanceEntries(
|
|
48
49
|
lifeCycle,
|
|
49
50
|
configuration,
|
|
50
51
|
entries.getEntries()
|
|
51
52
|
)
|
|
52
|
-
}
|
|
53
|
+
})
|
|
53
54
|
var mainEntries = ['resource', 'navigation', 'longtask', 'paint']
|
|
54
55
|
var experimentalEntries = [
|
|
55
56
|
'largest-contentful-paint',
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { noop,
|
|
1
|
+
import { noop, monitor } from '@cloudcare/browser-core'
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Maximum duration to wait before processing mutations. If the browser is idle, mutations will be
|
|
@@ -25,8 +25,8 @@ export function createMutationBatch(processMutationBatch) {
|
|
|
25
25
|
timeout: MUTATION_PROCESS_MAX_DELAY
|
|
26
26
|
})
|
|
27
27
|
}
|
|
28
|
-
pendingMutations.push(...mutations)
|
|
29
|
-
|
|
28
|
+
// pendingMutations.push(...mutations)
|
|
29
|
+
Array.prototype.push.apply(pendingMutations, mutations)
|
|
30
30
|
},
|
|
31
31
|
|
|
32
32
|
flush: flush,
|
|
@@ -36,3 +36,21 @@ export function createMutationBatch(processMutationBatch) {
|
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
|
+
|
|
40
|
+
function requestIdleCallback(callback, opts) {
|
|
41
|
+
// Use 'requestIdleCallback' when available: it will throttle the mutation processing if the
|
|
42
|
+
// browser is busy rendering frames (ex: when frames are below 60fps). When not available, the
|
|
43
|
+
// fallback on 'requestAnimationFrame' will still ensure the mutations are processed after any
|
|
44
|
+
// browser rendering process (Layout, Recalculate Style, etc.), so we can serialize DOM nodes
|
|
45
|
+
// efficiently.
|
|
46
|
+
if (window.requestIdleCallback) {
|
|
47
|
+
var id = window.requestIdleCallback(monitor(callback), opts)
|
|
48
|
+
return function () {
|
|
49
|
+
return window.cancelIdleCallback(id)
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
var id = window.requestAnimationFrame(monitor(callback))
|
|
53
|
+
return function () {
|
|
54
|
+
return window.cancelAnimationFrame(id)
|
|
55
|
+
}
|
|
56
|
+
}
|
|
@@ -3,7 +3,8 @@ import {
|
|
|
3
3
|
getChildNodes,
|
|
4
4
|
isNodeShadowHost,
|
|
5
5
|
getParentNode,
|
|
6
|
-
isNullUndefinedDefaultValue
|
|
6
|
+
isNullUndefinedDefaultValue,
|
|
7
|
+
monitor
|
|
7
8
|
} from '@cloudcare/browser-core'
|
|
8
9
|
import { getMutationObserverConstructor } from '../../domMutationCollection'
|
|
9
10
|
import { NodePrivacyLevel } from '../../../constants'
|
|
@@ -45,7 +46,7 @@ export function startMutationObserver(
|
|
|
45
46
|
)
|
|
46
47
|
})
|
|
47
48
|
|
|
48
|
-
var observer = new MutationObserver(mutationBatch.addMutations)
|
|
49
|
+
var observer = new MutationObserver(monitor(mutationBatch.addMutations))
|
|
49
50
|
|
|
50
51
|
observer.observe(target, {
|
|
51
52
|
attributeOldValue: true,
|
|
@@ -10,7 +10,8 @@ import {
|
|
|
10
10
|
LifeCycleEventType,
|
|
11
11
|
RumEventType,
|
|
12
12
|
ActionType,
|
|
13
|
-
isNodeShadowHost
|
|
13
|
+
isNodeShadowHost,
|
|
14
|
+
cssEscape
|
|
14
15
|
} from '@cloudcare/browser-core'
|
|
15
16
|
import { initViewportObservable } from '../../initViewportObservable'
|
|
16
17
|
import { NodePrivacyLevel } from '../../../constants'
|
|
@@ -368,7 +369,9 @@ export function initInputObserver(cb, defaultPrivacyLevel, target) {
|
|
|
368
369
|
var name = target.name
|
|
369
370
|
if (type === 'radio' && name && target.checked) {
|
|
370
371
|
forEach(
|
|
371
|
-
document.querySelectorAll(
|
|
372
|
+
document.querySelectorAll(
|
|
373
|
+
'input[type="radio"][name="' + cssEscape(name) + '"]'
|
|
374
|
+
),
|
|
372
375
|
function (el) {
|
|
373
376
|
if (el !== target) {
|
|
374
377
|
// TODO: Consider the privacy implications for various differing input privacy levels
|
|
@@ -3,6 +3,11 @@ import {
|
|
|
3
3
|
getParentNode,
|
|
4
4
|
isTextNode
|
|
5
5
|
} from '@cloudcare/browser-core'
|
|
6
|
+
import {
|
|
7
|
+
switchToAbsoluteUrl,
|
|
8
|
+
getCssRulesString,
|
|
9
|
+
getHref
|
|
10
|
+
} from './serializationUtils'
|
|
6
11
|
import {
|
|
7
12
|
NodePrivacyLevel,
|
|
8
13
|
PRIVACY_ATTR_NAME,
|
|
@@ -225,6 +230,23 @@ export function getTextContent(
|
|
|
225
230
|
} else {
|
|
226
231
|
textContent = censorText(textContent)
|
|
227
232
|
}
|
|
233
|
+
} else if (isStyle && textContent) {
|
|
234
|
+
try {
|
|
235
|
+
// try to read style sheet
|
|
236
|
+
if (textNode.nextSibling || textNode.previousSibling) {
|
|
237
|
+
// This is not the only child of the stylesheet.
|
|
238
|
+
// We can't read all of the sheet's .cssRules and expect them
|
|
239
|
+
// to _only_ include the current rule(s) added by the text node.
|
|
240
|
+
// So we'll be conservative and keep textContent as-is.
|
|
241
|
+
} else if (
|
|
242
|
+
textNode.parentNode &&
|
|
243
|
+
textNode.parentNode.sheet &&
|
|
244
|
+
textNode.parentNode.sheet.cssRules
|
|
245
|
+
) {
|
|
246
|
+
textContent = getCssRulesString(textNode.parentNode.sheet)
|
|
247
|
+
}
|
|
248
|
+
} catch (err) {}
|
|
249
|
+
textContent = switchToAbsoluteUrl(textContent, getHref())
|
|
228
250
|
}
|
|
229
251
|
return textContent
|
|
230
252
|
}
|
|
@@ -85,7 +85,34 @@ function extractOrigin(url) {
|
|
|
85
85
|
export var URL_IN_CSS_REF = /url\((?:(')([^']*)'|(")([^"]*)"|([^)]*))\)/gm
|
|
86
86
|
export var ABSOLUTE_URL = /^[A-Za-z]+:|^\/\//
|
|
87
87
|
export var DATA_URI = /^data:.*,/i
|
|
88
|
-
|
|
88
|
+
/**
|
|
89
|
+
* Browsers sometimes destructively modify the css rules they receive.
|
|
90
|
+
* This function tries to rectify the modifications the browser made to make it more cross platform compatible.
|
|
91
|
+
* @param cssText - output of `CSSStyleRule.cssText`
|
|
92
|
+
* @returns `cssText` with browser inconsistencies fixed.
|
|
93
|
+
*/
|
|
94
|
+
export function fixBrowserCompatibilityIssuesInCSS(cssText) {
|
|
95
|
+
/**
|
|
96
|
+
* Chrome outputs `-webkit-background-clip` as `background-clip` in `CSSStyleRule.cssText`.
|
|
97
|
+
* But then Chrome ignores `background-clip` as css input.
|
|
98
|
+
* Re-introduce `-webkit-background-clip` to fix this issue.
|
|
99
|
+
*/
|
|
100
|
+
if (
|
|
101
|
+
cssText.includes(' background-clip: text;') &&
|
|
102
|
+
!cssText.includes(' -webkit-background-clip: text;')
|
|
103
|
+
) {
|
|
104
|
+
cssText = cssText.replace(
|
|
105
|
+
' background-clip: text;',
|
|
106
|
+
' -webkit-background-clip: text; background-clip: text;'
|
|
107
|
+
)
|
|
108
|
+
}
|
|
109
|
+
return cssText
|
|
110
|
+
}
|
|
111
|
+
export function getHref() {
|
|
112
|
+
var a = document.createElement('a')
|
|
113
|
+
a.href = ''
|
|
114
|
+
return a.href
|
|
115
|
+
}
|
|
89
116
|
export function switchToAbsoluteUrl(cssText, cssHref) {
|
|
90
117
|
return cssText.replace(
|
|
91
118
|
URL_IN_CSS_REF,
|
|
@@ -116,7 +143,42 @@ export function switchToAbsoluteUrl(cssText, cssHref) {
|
|
|
116
143
|
}
|
|
117
144
|
)
|
|
118
145
|
}
|
|
146
|
+
export function getCssRulesString(cssStyleSheet) {
|
|
147
|
+
if (!cssStyleSheet) {
|
|
148
|
+
return null
|
|
149
|
+
}
|
|
150
|
+
var rules
|
|
151
|
+
try {
|
|
152
|
+
rules = cssStyleSheet.rules || cssStyleSheet.cssRules
|
|
153
|
+
} catch {
|
|
154
|
+
// if css is protected by CORS we cannot access cssRules see: https://www.w3.org/TR/cssom-1/#the-cssstylesheet-interface
|
|
155
|
+
}
|
|
156
|
+
if (!rules) {
|
|
157
|
+
return null
|
|
158
|
+
}
|
|
159
|
+
var styleSheetCssText = fixBrowserCompatibilityIssuesInCSS(
|
|
160
|
+
Array.from(rules, getCssRuleString).join('')
|
|
161
|
+
)
|
|
162
|
+
return switchToAbsoluteUrl(styleSheetCssText, cssStyleSheet.href)
|
|
163
|
+
}
|
|
164
|
+
export function isCSSImportRule(rule) {
|
|
165
|
+
return 'styleSheet' in rule
|
|
166
|
+
}
|
|
119
167
|
|
|
168
|
+
export function isSVGElement(el) {
|
|
169
|
+
return el.tagName === 'svg' || el instanceof SVGElement
|
|
170
|
+
}
|
|
171
|
+
export function getCssRuleString(rule) {
|
|
172
|
+
var cssStringified = rule.cssText
|
|
173
|
+
if (isCSSImportRule(rule)) {
|
|
174
|
+
try {
|
|
175
|
+
cssStringified = getCssRulesString(rule.styleSheet) || cssStringified
|
|
176
|
+
} catch {
|
|
177
|
+
// ignore
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
return validateStringifiedCssRule(cssStringified)
|
|
181
|
+
}
|
|
120
182
|
export function makeUrlAbsolute(url, baseUrl) {
|
|
121
183
|
try {
|
|
122
184
|
return buildUrl(url, baseUrl).href
|
|
@@ -141,7 +203,7 @@ export function serializeStyleSheets(cssStyleSheets) {
|
|
|
141
203
|
return cssStyleSheets.map(function (cssStyleSheet) {
|
|
142
204
|
var rules = cssStyleSheet.cssRules || cssStyleSheet.rules
|
|
143
205
|
var cssRules = Array.from(rules, function (cssRule) {
|
|
144
|
-
return cssRule.cssText ? validateStringifiedCssRule(
|
|
206
|
+
return cssRule.cssText ? validateStringifiedCssRule(cssRule.cssText) : ''
|
|
145
207
|
})
|
|
146
208
|
|
|
147
209
|
var styleSheet = {
|
|
@@ -29,7 +29,9 @@ import {
|
|
|
29
29
|
serializeStyleSheets,
|
|
30
30
|
absoluteToDoc,
|
|
31
31
|
getAbsoluteSrcsetString,
|
|
32
|
-
|
|
32
|
+
isSVGElement,
|
|
33
|
+
getHref,
|
|
34
|
+
getCssRulesString
|
|
33
35
|
} from './serializationUtils'
|
|
34
36
|
|
|
35
37
|
// Those values are the only one that can be used when inheriting privacy levels from parent to
|
|
@@ -327,7 +329,7 @@ function generateNextId() {
|
|
|
327
329
|
|
|
328
330
|
var TAG_NAME_REGEX = /[^a-z1-6-_]/
|
|
329
331
|
function getValidTagName(tagName) {
|
|
330
|
-
var processedTagName = tagName.toLowerCase().trim()
|
|
332
|
+
var processedTagName = (tagName + '').toLowerCase().trim()
|
|
331
333
|
|
|
332
334
|
if (TAG_NAME_REGEX.test(processedTagName)) {
|
|
333
335
|
// if the tag name is odd and we cannot extract
|
|
@@ -338,68 +340,7 @@ function getValidTagName(tagName) {
|
|
|
338
340
|
|
|
339
341
|
return processedTagName
|
|
340
342
|
}
|
|
341
|
-
/**
|
|
342
|
-
* Browsers sometimes destructively modify the css rules they receive.
|
|
343
|
-
* This function tries to rectify the modifications the browser made to make it more cross platform compatible.
|
|
344
|
-
* @param cssText - output of `CSSStyleRule.cssText`
|
|
345
|
-
* @returns `cssText` with browser inconsistencies fixed.
|
|
346
|
-
*/
|
|
347
|
-
function fixBrowserCompatibilityIssuesInCSS(cssText) {
|
|
348
|
-
/**
|
|
349
|
-
* Chrome outputs `-webkit-background-clip` as `background-clip` in `CSSStyleRule.cssText`.
|
|
350
|
-
* But then Chrome ignores `background-clip` as css input.
|
|
351
|
-
* Re-introduce `-webkit-background-clip` to fix this issue.
|
|
352
|
-
*/
|
|
353
|
-
if (
|
|
354
|
-
cssText.includes(' background-clip: text;') &&
|
|
355
|
-
!cssText.includes(' -webkit-background-clip: text;')
|
|
356
|
-
) {
|
|
357
|
-
cssText = cssText.replace(
|
|
358
|
-
' background-clip: text;',
|
|
359
|
-
' -webkit-background-clip: text; background-clip: text;'
|
|
360
|
-
)
|
|
361
|
-
}
|
|
362
|
-
return cssText
|
|
363
|
-
}
|
|
364
|
-
|
|
365
|
-
function getCssRulesString(cssStyleSheet) {
|
|
366
|
-
if (!cssStyleSheet) {
|
|
367
|
-
return null
|
|
368
|
-
}
|
|
369
|
-
var rules
|
|
370
|
-
try {
|
|
371
|
-
rules = cssStyleSheet.rules || cssStyleSheet.cssRules
|
|
372
|
-
} catch {
|
|
373
|
-
// if css is protected by CORS we cannot access cssRules see: https://www.w3.org/TR/cssom-1/#the-cssstylesheet-interface
|
|
374
|
-
}
|
|
375
|
-
if (!rules) {
|
|
376
|
-
return null
|
|
377
|
-
}
|
|
378
|
-
var styleSheetCssText = fixBrowserCompatibilityIssuesInCSS(
|
|
379
|
-
Array.from(rules, getCssRuleString).join('')
|
|
380
|
-
)
|
|
381
|
-
return switchToAbsoluteUrl(styleSheetCssText, cssStyleSheet.href)
|
|
382
|
-
}
|
|
383
343
|
|
|
384
|
-
function getCssRuleString(rule) {
|
|
385
|
-
var cssStringified = rule.cssText
|
|
386
|
-
if (isCSSImportRule(rule)) {
|
|
387
|
-
try {
|
|
388
|
-
cssStringified = getCssRulesString(rule.styleSheet) || cssStringified
|
|
389
|
-
} catch {
|
|
390
|
-
// ignore
|
|
391
|
-
}
|
|
392
|
-
}
|
|
393
|
-
return validateStringifiedCssRule(cssStringified)
|
|
394
|
-
}
|
|
395
|
-
|
|
396
|
-
function isCSSImportRule(rule) {
|
|
397
|
-
return 'styleSheet' in rule
|
|
398
|
-
}
|
|
399
|
-
|
|
400
|
-
function isSVGElement(el) {
|
|
401
|
-
return el.tagName === 'svg' || el instanceof SVGElement
|
|
402
|
-
}
|
|
403
344
|
function transformAttribute(doc, tagName, name, value) {
|
|
404
345
|
if (!value) return value
|
|
405
346
|
if (
|
|
@@ -425,11 +366,7 @@ function transformAttribute(doc, tagName, name, value) {
|
|
|
425
366
|
return value
|
|
426
367
|
}
|
|
427
368
|
}
|
|
428
|
-
|
|
429
|
-
var a = document.createElement('a')
|
|
430
|
-
a.href = ''
|
|
431
|
-
return a.href
|
|
432
|
-
}
|
|
369
|
+
|
|
433
370
|
function getAttributesForPrivacyLevel(element, nodePrivacyLevel, options) {
|
|
434
371
|
if (nodePrivacyLevel === NodePrivacyLevel.HIDDEN) {
|
|
435
372
|
return {}
|
|
@@ -97,12 +97,12 @@ function getClassSelector(element) {
|
|
|
97
97
|
continue
|
|
98
98
|
}
|
|
99
99
|
|
|
100
|
-
return element.tagName + '.' + cssEscape(className)
|
|
100
|
+
return cssEscape(element.tagName) + '.' + cssEscape(className)
|
|
101
101
|
}
|
|
102
102
|
}
|
|
103
103
|
}
|
|
104
104
|
function getTagNameSelector(element) {
|
|
105
|
-
return element.tagName
|
|
105
|
+
return cssEscape(element.tagName)
|
|
106
106
|
}
|
|
107
107
|
function getStableAttributeSelector(element, actionNameAttribute) {
|
|
108
108
|
if (actionNameAttribute) {
|
|
@@ -123,7 +123,7 @@ function getStableAttributeSelector(element, actionNameAttribute) {
|
|
|
123
123
|
function getAttributeSelector(attributeName) {
|
|
124
124
|
if (element.hasAttribute(attributeName)) {
|
|
125
125
|
return (
|
|
126
|
-
element.tagName +
|
|
126
|
+
cssEscape(element.tagName) +
|
|
127
127
|
'[' +
|
|
128
128
|
attributeName +
|
|
129
129
|
'="' +
|
|
@@ -144,7 +144,7 @@ function getPositionSelector(element) {
|
|
|
144
144
|
}
|
|
145
145
|
sibling = sibling.nextElementSibling
|
|
146
146
|
}
|
|
147
|
-
var tagName = element.tagName
|
|
147
|
+
var tagName = cssEscape(element.tagName)
|
|
148
148
|
// 伪元素需要做特殊处理,没有nth-of-type选择器
|
|
149
149
|
if (/^::/.test(tagName)) {
|
|
150
150
|
return tagName
|
|
@@ -367,7 +367,10 @@ export function computeSize(entry) {
|
|
|
367
367
|
if (entry.startTime < entry.responseStart) {
|
|
368
368
|
return {
|
|
369
369
|
size: entry.decodedBodySize,
|
|
370
|
-
encodeSize:
|
|
370
|
+
encodeSize:
|
|
371
|
+
Number.MAX_SAFE_INTEGER < entry.encodedBodySize
|
|
372
|
+
? 0
|
|
373
|
+
: entry.encodedBodySize // max safe interger
|
|
371
374
|
}
|
|
372
375
|
}
|
|
373
376
|
return undefined
|