Chromium Code Reviews| 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..b953c142f9a7f3d8eed87e8bdb0915314faefadd 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) { |
|
Finnur
2014/08/18 11:50:14
nit: Capitalize n in new?
robwu
2014/08/18 15:37:32
The casing is intentional, this function does noth
Finnur
2014/08/18 16:07:43
I don't see why it matters in this case *what* the
not at google - send to devlin
2014/08/18 16:09:44
Nevertheless, I would prefer throwNewError.
robwu
2014/08/18 20:59:46
Done.
|
| + 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'); |
| }); |
| } |
| ]); |