Skip to content

Commit

Permalink
[skip ci] Merge branch main into v6
Browse files Browse the repository at this point in the history
  • Loading branch information
dd-devflow[bot] authored Nov 25, 2024
2 parents 746252d + c60a856 commit bdec463
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,9 @@ export function createScrollValuesObservable(

const observerTarget = document.scrollingElement || document.documentElement
const resizeObserver = new ResizeObserver(monitor(throttledNotify.throttled))
resizeObserver.observe(observerTarget)
if (observerTarget) {
resizeObserver.observe(observerTarget)
}
const eventListener = addEventListener(configuration, window, DOM_EVENT.SCROLL, throttledNotify.throttled, {
passive: true,
})
Expand Down
1 change: 1 addition & 0 deletions test/e2e/lib/framework/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ export { getTestServers, waitForServersIdle } from './httpServers'
export { flushEvents } from './flushEvents'
export { waitForRequests } from './waitForRequests'
export { LARGE_RESPONSE_MIN_BYTE_SIZE } from './serverApps/mock'
export { RUM_BUNDLE } from './sdkBuilds'
41 changes: 41 additions & 0 deletions test/e2e/scenario/rum/s8sInject.scenario.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import * as fs from 'fs'
import { RUM_BUNDLE } from '../../lib/framework'
import { APPLICATION_ID, CLIENT_TOKEN } from '../../lib/helpers/configuration'

describe('Inject RUM with Puppeteer', () => {
// S8s tests inject RUM with puppeteer evaluateOnNewDocument
it('should not throw error in chrome', async () => {
const isInjected = await injectRumWithPuppeteer()
expect(isInjected).toBe(true)
})
})

async function injectRumWithPuppeteer() {
const ddRUM = fs.readFileSync(RUM_BUNDLE, 'utf8')
const puppeteerBrowser = await browser.getPuppeteer()
let injected = true

await browser.call(async () => {
const page = await puppeteerBrowser.newPage()
await page.evaluateOnNewDocument(
`
if (location.href !== 'about:blank') {
${ddRUM}
window.DD_RUM._setDebug(true)
window.DD_RUM.init({
applicationId: ${APPLICATION_ID},
clientToken: ${CLIENT_TOKEN},
})
window.DD_RUM.startView()
}
`
)
page.on('console', (msg) => {
if (msg.type() === 'error') {
injected = false
}
})
await page.goto('https://webdriver.io')
})
return injected
}
2 changes: 1 addition & 1 deletion test/e2e/wdio.bs.conf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export const config: Options.Testrunner = {
...baseConfig,

specFileRetries: 1,

exclude: [...baseConfig.exclude!, './scenario/rum/s8sInject.scenario.ts'],
capabilities: browserConfigurations.map((configuration) =>
// See https://www.browserstack.com/automate/capabilities?tag=selenium-4
// Make sure to look at the "W3C Protocol" tab
Expand Down

0 comments on commit bdec463

Please sign in to comment.