-
Notifications
You must be signed in to change notification settings - Fork 303
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
Feat: support window onerror and global error event #601
Conversation
const ex = new Error('CustomErrorTest'); | ||
window.onerror = function(event, sourceURL, line, column, error) { | ||
expect(window.onerror).toBe(arguments.callee); | ||
const ex = new Error('CustomErrorTest'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
需要把相关测试代码组织在 describe 里
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
测试 window.onerror 的代码需要独立在 jasmine 之外,因为 jasmine 也会监听 window.onerror,存在冲突
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
移到外部就不冲突了? 会特征判断?那是否只需要 window.onerror 就可以了,而且最好加注释说明下
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
嗯,因为 onerror 的测试是需要直接给 JS 抛个异常,jasmine 直接就当作是测试失败了。
JSValueRef errorObjectValue = getObjectPropertyValue(ctx, eventType, eventInstance->object, &exception); | ||
JSObjectRef errorObject = JSValueToObject(ctx, errorObjectValue, &exception); | ||
JSValueRef messageValue = getObjectPropertyValue(ctx, "message", errorObject, &exception); | ||
JSValueRef sourceURLValue = getObjectPropertyValue(ctx, "sourceURL", errorObject, &exception); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
为什么不考虑命名上与 w3c 标准对齐
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里的代码是操作 Error 对象,而不是 ErrorEvent
94d1ab8
to
8493d33
Compare
Fixed #600