Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3968)

Unified Diff: chrome/test/data/extensions/api_test/bindings/exception_in_handler_should_not_crash/page.js

Issue 482603002: Unify logic of stack trace generation for extension errors (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Processed reviewers' comments Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/test/data/extensions/api_test/bindings/exception_in_handler_should_not_crash/page.js
diff --git a/chrome/test/data/extensions/api_test/bindings/exception_in_handler_should_not_crash/page.js b/chrome/test/data/extensions/api_test/bindings/exception_in_handler_should_not_crash/page.js
index d69f04c609b03d6119d1df0242a71ea3dd84d0f6..035eac01e982e724a4cfae3fa28a0ddcdcb908de 100644
--- a/chrome/test/data/extensions/api_test/bindings/exception_in_handler_should_not_crash/page.js
+++ b/chrome/test/data/extensions/api_test/bindings/exception_in_handler_should_not_crash/page.js
@@ -2,23 +2,30 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+// A named function that throws the error, used to verify that the error message
+// has a stack trace that contains the relevant stack frames.
+function throwNewError(message) {
+ throw new Error(message)
+}
+
chrome.test.runTests([
function tabsCreateThrowsError() {
- chrome.test.setExceptionHandler(function(_, exception) {
+ chrome.test.setExceptionHandler(function(message, exception) {
+ chrome.test.assertTrue(message.indexOf('throwNewError') >= 0);
chrome.test.assertEq('tata', exception.message);
chrome.test.succeed();
});
chrome.tabs.create({}, function() {
- throw new Error('tata');
+ throwNewError('tata');
});
},
function tabsOnCreatedThrowsError() {
var listener = function() {
- throw new Error('hi');
+ throwNewError('hi');
};
- chrome.test.setExceptionHandler(function(_, exception) {
- chrome.test.assertEq('hi', exception.message);
+ chrome.test.setExceptionHandler(function(message, exception) {
+ chrome.test.assertTrue(message.indexOf('throwNewError') >= 0);
chrome.tabs.onCreated.removeListener(listener);
chrome.test.succeed();
});
@@ -29,12 +36,13 @@ chrome.test.runTests([
function permissionsGetAllThrowsError() {
// permissions.getAll has a custom callback, as do many other methods, but
// this is easy to call.
- chrome.test.setExceptionHandler(function(_, exception) {
+ chrome.test.setExceptionHandler(function(message, exception) {
+ chrome.test.assertTrue(message.indexOf('throwNewError') >= 0);
chrome.test.assertEq('boom', exception.message);
chrome.test.succeed();
});
chrome.permissions.getAll(function() {
- throw new Error('boom');
+ throwNewError('boom');
});
}
]);

Powered by Google App Engine
This is Rietveld 408576698