Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✅[e2e cbt] add edge and firefox #196

Merged
merged 5 commits into from
Dec 10, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions packages/rum/src/performanceCollection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@ declare global {
}

function supportPerformanceObject() {
return window.performance !== undefined && 'getEntries' in performance && 'addEventListener' in performance
return window.performance !== undefined && 'getEntries' in performance
}

function supportPerformanceNavigationTimingEvent() {
return (
window.PerformanceObserver &&
PerformanceObserver.supportedEntryTypes !== undefined &&
PerformanceObserver.supportedEntryTypes.includes('navigation')
)
Expand All @@ -30,19 +31,18 @@ export function startPerformanceCollection(lifeCycle: LifeCycle, session: RumSes
)
observer.observe({ entryTypes: ['resource', 'navigation', 'paint', 'longtask'] })

if (supportPerformanceObject()) {
if (supportPerformanceObject() && 'addEventListener' in performance) {
// https://bugzilla.mozilla.org/show_bug.cgi?id=1559377
performance.addEventListener('resourcetimingbufferfull', () => {
performance.clearResourceTimings()
})

if (!supportPerformanceNavigationTimingEvent()) {
retrieveNavigationTimingWhenLoaded((timing) => {
handlePerformanceEntries(session, lifeCycle, [timing])
})
}
}
}
if (!supportPerformanceNavigationTimingEvent()) {
retrieveNavigationTimingWhenLoaded((timing) => {
handlePerformanceEntries(session, lifeCycle, [timing])
})
}
}

interface FakePerformanceNavigationTiming {
Expand Down
10 changes: 10 additions & 0 deletions test/e2e/browsers.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,14 @@ module.exports = [
browserName: 'Safari',
browser_api_name: 'Safari12',
},
{
os_api_name: 'Win10',
browserName: 'Microsoft Edge 18',
browser_api_name: 'Edge18',
},
{
os_api_name: 'Win10',
browserName: 'Firefox 70',
browser_api_name: 'FF70',
},
]
25 changes: 22 additions & 3 deletions test/e2e/scenario/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,28 @@ export function findLastEvent(events: RumEvent[], predicate: (event: RumEvent) =
}

export async function renewSession() {
// Expire sessionId cookie
await browser.deleteCookies(['_dd'])
await deleteAllCookies()
expect(await findSessionCookie()).not.toBeDefined()
// Cookies are cached for 1s, wait until the cache expires
await browser.pause(1100)
await browser.keys(['f'])
const button = await $('button')
await button.click()
expect(await findSessionCookie()).toBeDefined()
}

// wdio method does not work for some browsers
async function deleteAllCookies() {
return browserExecute(() => {
const cookies = document.cookie.split(';')
for (const cookie of cookies) {
const eqPos = cookie.indexOf('=')
const name = eqPos > -1 ? cookie.substr(0, eqPos) : cookie
document.cookie = `${name}=;expires=Thu, 01 Jan 1970 00:00:00 GMT`
}
})
}

async function findSessionCookie() {
// tslint:disable-next-line: no-unsafe-any
return ((await browser.getCookies()) as any[]).find((cookie: any) => cookie.name === '_dd')
}
4 changes: 3 additions & 1 deletion test/static/bundle-e2e-page.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,7 @@
})
</script>
</head>
<body></body>
<body>
<button>click me</button>
</body>
</html>
4 changes: 3 additions & 1 deletion test/static/npm-e2e-page.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,7 @@
<title>npm tests page</title>
<script type="text/javascript" src="./app.js"></script>
</head>
<body></body>
<body>
<button>click me</button>
</body>
</html>