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

Unified Diff: chrome/browser/extensions/native_bindings_apitest.cc

Issue 2819683002: [Extenisons Bindings] Don't throw unchecked errors; add console errors (Closed)
Patch Set: . Created 3 years, 8 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
« no previous file with comments | « no previous file | extensions/renderer/api_binding_unittest.cc » ('j') | extensions/renderer/api_last_error.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « no previous file | extensions/renderer/api_binding_unittest.cc » ('j') | extensions/renderer/api_last_error.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698