Skip to content

Fix pushState exception when run inside Chrome Apps (fixes #601) #621

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

Merged
merged 2 commits into from
Jun 23, 2016
Merged
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
8 changes: 7 additions & 1 deletion src/raven.js
Original file line number Diff line number Diff line change
Expand Up @@ -889,7 +889,13 @@ Raven.prototype = {
}

// record navigation (URL) changes
if ('history' in window && history.pushState) {
// NOTE: in Chrome App environment, touching history.pushState, *even inside
// a try/catch block*, will cause Chrome to output an error to console.error
// borrowed from: https://github.com/angular/angular.js/pull/13945/files
var chrome = window.chrome;
var isChromePackagedApp = chrome && chrome.app && chrome.app.runtime;
var hasPushState = !isChromePackagedApp && window.history && history.pushState;
if (hasPushState) {
// TODO: remove onpopstate handler on uninstall()
var oldOnPopState = window.onpopstate;
window.onpopstate = function () {
Expand Down