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..8c13b3e22bae20937d026a137397555ea232274d |
--- /dev/null |
+++ b/chrome/test/data/extensions/api_test/uncaught_exception_logging/test.js |
@@ -0,0 +1,44 @@ |
+function createTestFunction(expected_message) { |
+ return function(tab) { |
+ chrome.debugger.onEvent.addListener(function(debuggee, method, params) { |
not at google - send to devlin
2014/11/11 00:50:25
Also nice to remove the event listener when the te
msimonides
2014/11/12 07:41:01
Done.
|
+ if (debuggee.tabId == tab.id && method == 'Console.messageAdded') { |
+ if (params.message.text.indexOf(expected_message) > -1) |
+ chrome.test.succeed(); |
+ } |
+ }); |
+ chrome.debugger.attach({ tabId: tab.id }, "1.1", function() { |
+ chrome.tabs.sendMessage(tab.id, { "action": "start_test" }); |
not at google - send to devlin
2014/11/11 00:50:25
Should this sendMessage only happen if the chrome.
msimonides
2014/11/12 07:41:01
There is no race between sendMessage and debugger.
|
+ // 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 ExceptionInExtensionPage() { |
not at google - send to devlin
2014/11/11 00:50:25
More consistent if these are testExceptionInExtens
msimonides
2014/11/12 07:41:01
Done.
|
+ chrome.tabs.create( |
+ {url: chrome.runtime.getURL("extension_page.html")}, |
not at google - send to devlin
2014/11/11 00:50:25
Be consistent with " vs ' (I prefer ').
msimonides
2014/11/12 07:41:01
Done.
|
+ createTestFunction('Exception thrown in extension page.')); |
+ }, |
+ |
+ function ExceptionInInjectedScript() { |
+ function injectScriptAndSendMessage(tab) { |
+ chrome.tabs.executeScript( |
+ tab.id, |
+ { file: "content_script.js" }, |
+ function() { |
+ (createTestFunction('Exception thrown in injected script.'))(tab); |
not at google - send to devlin
2014/11/11 00:50:25
I don't think you need the outer parens here.
msimonides
2014/11/12 07:41:01
Done.
|
+ }); |
+ } |
+ |
+ chrome.test.log('getConfig'); |
not at google - send to devlin
2014/11/11 00:50:25
No logging.
msimonides
2014/11/12 07:41:01
Done.
|
+ 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); |
+ }); |
+ } |
+]); |