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

Unified Diff: chrome/test/data/extensions/api_test/uncaught_exception_logging/test.js

Issue 678393002: Send extension console messages to the right WebFrame. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add the missing copyright notice. Created 6 years, 1 month 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/uncaught_exception_logging/test.js
diff --git a/chrome/test/data/extensions/api_test/uncaught_exception_logging/test.js b/chrome/test/data/extensions/api_test/uncaught_exception_logging/test.js
new file mode 100644
index 0000000000000000000000000000000000000000..cc68ec1b29d709f1a13f78748bb702f70a8fc52e
--- /dev/null
+++ b/chrome/test/data/extensions/api_test/uncaught_exception_logging/test.js
@@ -0,0 +1,49 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+function createTestFunction(expected_message) {
+ return function(tab) {
+ function onDebuggerEvent(debuggee, method, params) {
+ if (debuggee.tabId == tab.id && method == 'Console.messageAdded') {
+ if (params.message.text.indexOf(expected_message) > -1) {
+ chrome.debugger.onEvent.removeListener(onDebuggerEvent);
+ chrome.test.succeed();
+ }
+ }
+ };
+ chrome.debugger.onEvent.addListener(onDebuggerEvent);
+ chrome.debugger.attach({ tabId: tab.id }, "1.1", function() {
+ // Enabling console provides both stored and new messages via the
+ // Console.messageAdded event.
+ chrome.debugger.sendCommand({ tabId: tab.id }, "Console.enable");
+ });
+ }
+}
+
+chrome.test.runTests([
+ function testExceptionInExtensionPage() {
+ chrome.tabs.create(
+ {url: chrome.runtime.getURL('extension_page.html')},
+ createTestFunction('Exception thrown in extension page.'));
+ },
+
+ function testExceptionInInjectedScript() {
+ function injectScriptAndSendMessage(tab) {
+ chrome.tabs.executeScript(
+ tab.id,
+ { file: 'content_script.js' },
+ function() {
+ createTestFunction('Exception thrown in injected script.')(tab);
+ });
+ }
+
+ chrome.test.getConfig(function(config) {
+ var test_url =
+ 'http://localhost:PORT/extensions/test_file.html'
+ .replace(/PORT/, config.testServer.port);
+
+ chrome.tabs.create({ url: test_url }, injectScriptAndSendMessage);
+ });
+ }
+]);
« no previous file with comments | « chrome/test/data/extensions/api_test/uncaught_exception_logging/manifest.json ('k') | extensions/renderer/console.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698