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

Detect JS Engine when reporting errors #7708

Merged
merged 6 commits into from Feb 22, 2017

Conversation

jridgewell
Copy link
Contributor

This should save us some time trying to determine what the real browser
is, not what the UserAgent is masquerading as.

This should save us some time trying to determine what the real browser
is, not what the UserAgent is masquerading as.
Also add comments
// SauceLabs, which runs does not masquerade with UserAgent.
describe.configure().ifIos().run('on iOS', () => {
it.configure().ifSafari().run('detects safari as safari', () => {
expect(detectJsEngineFromStack()).to.equal('Safari');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indent if off in this file.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

src/error.js Outdated
throw new Error('message');
}
});
try {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why don't we run this on the server side?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Firefox and IE return different results based on how the prototype is constructed.

function Klass() {}
Klass.prototype.t

// Different than
proto = { t };
obj = Object.create(proto);

It'd have to do much more complicated testing if I don't know for certain how the chain is constructed.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

K. Please update errortracker.go to append this to the UA string (maybe wrapped in [] or something like that).

@@ -409,3 +410,40 @@ describes.sandboxed('reportError', {}, () => {
}).to.throw(/_reported_ Error reported incorrectly/);
});
});

describe.only('detectJsEngineFromStack', () => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you update the integration test glob to include this (so the tests actually run on SC)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@jridgewell jridgewell merged commit 0f1ac07 into ampproject:master Feb 22, 2017
@jridgewell jridgewell deleted the determine-browser-from-stack branch February 22, 2017 20:35
@zhouyx zhouyx mentioned this pull request Feb 23, 2017
@jridgewell jridgewell self-assigned this Feb 27, 2017
@jridgewell jridgewell added this to the Sprint H2 Feb milestone Feb 27, 2017
mrjoro pushed a commit to mrjoro/amphtml that referenced this pull request Apr 28, 2017
* Detect JS Engine when reporting errors

This should save us some time trying to determine what the real browser
is, not what the UserAgent is masquerading as.

* Fix IE detection

Also add comments

* linting

* JSDoc

* Add error tests to integrations suite

* Fix closure type check
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants