()
| 397 | }); |
| 398 | |
| 399 | const captureNestedStylesheetRulesTest = async () => { |
| 400 | await ctx.page.evaluate(() => { |
| 401 | const { record } = (window as unknown as IWindow).rrweb; |
| 402 | |
| 403 | record({ |
| 404 | emit: (window as unknown as IWindow).emit, |
| 405 | }); |
| 406 | |
| 407 | const styleElement = document.createElement('style'); |
| 408 | document.head.appendChild(styleElement); |
| 409 | |
| 410 | const styleSheet = <CSSStyleSheet>styleElement.sheet; |
| 411 | styleSheet.insertRule('@media {}'); |
| 412 | const atMediaRule = styleSheet.cssRules[0] as CSSMediaRule; |
| 413 | |
| 414 | const ruleIdx0 = atMediaRule.insertRule('body { background: #000; }', 0); |
| 415 | const ruleIdx1 = atMediaRule.insertRule('body { background: #111; }', 0); |
| 416 | atMediaRule.deleteRule(ruleIdx1); |
| 417 | setTimeout(() => { |
| 418 | atMediaRule.insertRule('body { color: #fff; }', 0); |
| 419 | }, 0); |
| 420 | setTimeout(() => { |
| 421 | atMediaRule.deleteRule(ruleIdx0); |
| 422 | }, 5); |
| 423 | setTimeout(() => { |
| 424 | atMediaRule.insertRule('body { color: #ccc; }', 0); |
| 425 | }, 10); |
| 426 | }); |
| 427 | await ctx.page.waitForTimeout(50); |
| 428 | const styleSheetRuleEvents = ctx.events.filter( |
| 429 | (e) => |
| 430 | e.type === EventType.IncrementalSnapshot && |
| 431 | e.data.source === IncrementalSource.StyleSheetRule, |
| 432 | ); |
| 433 | const addRuleCount = styleSheetRuleEvents.filter((e) => |
| 434 | Boolean((e.data as styleSheetRuleData).adds), |
| 435 | ).length; |
| 436 | const removeRuleCount = styleSheetRuleEvents.filter((e) => |
| 437 | Boolean((e.data as styleSheetRuleData).removes), |
| 438 | ).length; |
| 439 | // sync insert/delete should be ignored |
| 440 | expect(addRuleCount).toEqual(2); |
| 441 | expect(removeRuleCount).toEqual(1); |
| 442 | await assertSnapshot(ctx.events); |
| 443 | }; |
| 444 | it('captures nested stylesheet rules', captureNestedStylesheetRulesTest); |
| 445 | |
| 446 | describe('without CSSGroupingRule support', () => { |
nothing calls this directly
no test coverage detected
searching dependent graphs…