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

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

Issue 2819683002: [Extenisons Bindings] Don't throw unchecked errors; add console errors (Closed)
Patch Set: jbroman's 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') | no next file with comments »
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 a2891dc7ab008d930462dca431e66ff805e7c153..c19ec638f0d378eb0eeb2325c8276c0cdaf80f4e 100644
--- a/chrome/browser/extensions/native_bindings_apitest.cc
+++ b/chrome/browser/extensions/native_bindings_apitest.cc
@@ -202,4 +202,47 @@ 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) {
+ chrome.test.sendMessage('callback');
+ });
+ });
+ });
+ });)");
+
+ ui_test_utils::NavigateToURL(
+ browser(), embedded_test_server()->GetURL(
+ "example.com", "/native_bindings/simple.html"));
+
+ ExtensionTestMessageListener listener("callback", false);
+ ASSERT_TRUE(LoadExtension(test_dir.UnpackedPath()));
+ EXPECT_TRUE(listener.WaitUntilSatisfied());
+}
+
} // namespace extensions
« no previous file with comments | « no previous file | extensions/renderer/api_binding_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698