{"id":15552238,"url":"https://github.com/bahmutov/onbeforeunload-example","last_synced_at":"2025-09-29T00:33:12.658Z","repository":{"id":38849768,"uuid":"338639574","full_name":"bahmutov/onbeforeunload-example","owner":"bahmutov","description":"Cypress test for a site that uses onbeforeunload and a confirmation prompt","archived":false,"fork":false,"pushed_at":"2025-09-20T05:30:39.000Z","size":105,"stargazers_count":3,"open_issues_count":5,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-09-20T07:15:55.781Z","etag":null,"topics":["cypress-example"],"latest_commit_sha":null,"homepage":"https://glebbahmutov.com/blog/onbeforeunload/","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bahmutov.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2021-02-13T18:20:29.000Z","updated_at":"2024-06-05T08:00:45.000Z","dependencies_parsed_at":"2024-01-17T06:50:59.488Z","dependency_job_id":"af20c426-d5bc-4f12-9c2e-ef05513a775d","html_url":"https://github.com/bahmutov/onbeforeunload-example","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/bahmutov/onbeforeunload-example","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bahmutov%2Fonbeforeunload-example","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bahmutov%2Fonbeforeunload-example/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bahmutov%2Fonbeforeunload-example/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bahmutov%2Fonbeforeunload-example/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bahmutov","download_url":"https://codeload.github.com/bahmutov/onbeforeunload-example/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bahmutov%2Fonbeforeunload-example/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":277450940,"owners_count":25819971,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-28T02:00:08.834Z","response_time":79,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cypress-example"],"created_at":"2024-10-02T14:13:15.543Z","updated_at":"2025-09-29T00:33:12.404Z","avatar_url":"https://github.com/bahmutov.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# onbeforeunload-example\n![cypress version](https://img.shields.io/badge/cypress-9.7.0-brightgreen) [![ci status][ci image]][ci url] [![badges status][badges image]][badges url] [![renovate-app badge][renovate-badge]][renovate-app]\n\u003e Cypress test for a site that uses onbeforeunload and a confirmation prompt\n\nRead [window.onbeforeunload and Cypress](https://glebbahmutov.com/blog/onbeforeunload/)\n\n## Links\n\nOriginal Cypress issue [#2118](https://github.com/cypress-io/cypress/issues/2118)\n\n## Install and use\n\n- `npm install`\n- `npm run dev`\n- click on the spec, play with the [cypress/integration tests](cypress/integration) and [the application code](./public).\n\n## Debugger protocol\n\nIn DevTools console you can execute the following code, but I did not see it cleanly remove _all_ event listeners\n\n```js\ngetEventListeners(window).beforeunload\n  .forEach(({ type, listener, useCapture }) =\u003e {\n    console.log('removing', type, listener, useCapture)\n    window.removeEventListener(type, listener, useCapture)\n  })\n```\n\n[Source](https://twitter.com/AndyDavies/status/1359167670873190405)\n\n[ci image]: https://github.com/bahmutov/onbeforeunload-example/workflows/ci/badge.svg?branch=main\n[ci url]: https://github.com/bahmutov/onbeforeunload-example/actions\n[badges image]: https://github.com/bahmutov/onbeforeunload-example/workflows/badges/badge.svg?branch=main\n[badges url]: https://github.com/bahmutov/onbeforeunload-example/actions\n[renovate-badge]: https://img.shields.io/badge/renovate-app-blue.svg\n[renovate-app]: https://renovateapp.com/\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbahmutov%2Fonbeforeunload-example","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbahmutov%2Fonbeforeunload-example","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbahmutov%2Fonbeforeunload-example/lists"}