Chromium Code Reviews| Index: chrome/browser/extensions/native_bindings_apitest.cc |
| diff --git a/chrome/browser/extensions/native_bindings_apitest.cc b/chrome/browser/extensions/native_bindings_apitest.cc |
| index 08869d46922bf48d67312773bd0b5fc0be148905..28fc698504862009f22db111f5da27a6d2a74d3b 100644 |
| --- a/chrome/browser/extensions/native_bindings_apitest.cc |
| +++ b/chrome/browser/extensions/native_bindings_apitest.cc |
| @@ -193,4 +193,51 @@ IN_PROC_BROWSER_TEST_F(NativeBindingsApiTest, ContextMenusTest) { |
| EXPECT_TRUE(listener.WaitUntilSatisfied()); |
| } |
| +// Tests that unchecked errors don't impede future calls. |
| +IN_PROC_BROWSER_TEST_F(NativeBindingsApiTest, ErrorsInCallbackTest) { |
| + host_resolver()->AddRule("*", "127.0.0.1"); |
| + embedded_test_server()->ServeFilesFromDirectory(test_data_dir_); |
| + ASSERT_TRUE(StartEmbeddedTestServer()); |
| + |
| + TestExtensionDir test_dir; |
| + test_dir.WriteManifest( |
| + R"({ |
| + "name": "Errors In Callback", |
| + "manifest_version": 2, |
| + "version": "0.1", |
| + "permissions": ["contextMenus"], |
| + "background": { |
| + "scripts": ["background.js"] |
| + } |
| + })"); |
| + test_dir.WriteFile( |
| + FILE_PATH_LITERAL("background.js"), |
| + R"(chrome.tabs.query({}, function(tabs) { |
| + chrome.tabs.executeScript(tabs[0].id, {code: 'x'}, function() { |
| + // There's an error here (we don't have permission to access the |
| + // host), but we don't check it so that it gets surfaced as an |
| + // unchecked runtime.lastError. |
| + // We should still be able to invoke other APIs and get correct |
| + // callbacks. |
| + chrome.tabs.query({}, function(tabs) { |
| + chrome.tabs.query({}, function(tabs) { |
|
Devlin
2017/04/14 00:43:17
Interestingly, this level of nesting is necessary
|
| + chrome.test.sendMessage('callback'); |
| + }); |
| + }); |
| + }); |
| + });)"); |
| + |
| + ui_test_utils::NavigateToURL( |
| + browser(), embedded_test_server()->GetURL( |
| + "example.com", "/native_bindings/simple.html")); |
| + |
| + const Extension* extension = nullptr; |
|
jbroman
2017/04/19 17:45:04
nit: Since there's nothing below the below block,
Devlin
2017/04/19 19:45:33
Whoops, copy-paste leftovers. Cleaned.
|
| + { |
| + ExtensionTestMessageListener listener("callback", false); |
| + extension = LoadExtension(test_dir.UnpackedPath()); |
| + ASSERT_TRUE(extension); |
| + EXPECT_TRUE(listener.WaitUntilSatisfied()); |
| + } |
| +} |
| + |
| } // namespace extensions |