Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 function createTestFunction(expected_message) { | |
| 2 return function(tab) { | |
| 3 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.
| |
| 4 if (debuggee.tabId == tab.id && method == 'Console.messageAdded') { | |
| 5 if (params.message.text.indexOf(expected_message) > -1) | |
| 6 chrome.test.succeed(); | |
| 7 } | |
| 8 }); | |
| 9 chrome.debugger.attach({ tabId: tab.id }, "1.1", function() { | |
| 10 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.
| |
| 11 // Enabling console provides both stored and new messages via the | |
| 12 // Console.messageAdded event. | |
| 13 chrome.debugger.sendCommand({ tabId: tab.id }, "Console.enable"); | |
| 14 }); | |
| 15 } | |
| 16 } | |
| 17 | |
| 18 chrome.test.runTests([ | |
| 19 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.
| |
| 20 chrome.tabs.create( | |
| 21 {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.
| |
| 22 createTestFunction('Exception thrown in extension page.')); | |
| 23 }, | |
| 24 | |
| 25 function ExceptionInInjectedScript() { | |
| 26 function injectScriptAndSendMessage(tab) { | |
| 27 chrome.tabs.executeScript( | |
| 28 tab.id, | |
| 29 { file: "content_script.js" }, | |
| 30 function() { | |
| 31 (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.
| |
| 32 }); | |
| 33 } | |
| 34 | |
| 35 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.
| |
| 36 chrome.test.getConfig(function(config) { | |
| 37 var test_url = | |
| 38 "http://localhost:PORT/extensions/test_file.html" | |
| 39 .replace(/PORT/, config.testServer.port); | |
| 40 | |
| 41 chrome.tabs.create({ url: test_url }, injectScriptAndSendMessage); | |
| 42 }); | |
| 43 } | |
| 44 ]); | |
| OLD | NEW |