OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 function createTestFunction(expected_message) { | 5 function createTestFunction(expected_message) { |
6 return function(tab) { | 6 return function(tab) { |
7 function onDebuggerEvent(debuggee, method, params) { | 7 function onDebuggerEvent(debuggee, method, params) { |
8 if (debuggee.tabId == tab.id && method == 'Runtime.exceptionThrown') { | 8 if (debuggee.tabId == tab.id && method == 'Runtime.exceptionThrown') { |
9 if (params.exception.value.indexOf(expected_message) > -1) { | 9 var exception = params.exceptionDetails.exception; |
| 10 if (exception.value.indexOf(expected_message) > -1) { |
10 chrome.debugger.onEvent.removeListener(onDebuggerEvent); | 11 chrome.debugger.onEvent.removeListener(onDebuggerEvent); |
11 chrome.test.succeed(); | 12 chrome.test.succeed(); |
12 } | 13 } |
13 } | 14 } |
14 }; | 15 }; |
15 chrome.debugger.onEvent.addListener(onDebuggerEvent); | 16 chrome.debugger.onEvent.addListener(onDebuggerEvent); |
16 chrome.debugger.attach({ tabId: tab.id }, "1.1", function() { | 17 chrome.debugger.attach({ tabId: tab.id }, "1.1", function() { |
17 // Enabling console provides both stored and new messages via the | 18 // Enabling console provides both stored and new messages via the |
18 // Console.messageAdded event. | 19 // Console.messageAdded event. |
19 chrome.debugger.sendCommand({ tabId: tab.id }, "Runtime.enable"); | 20 chrome.debugger.sendCommand({ tabId: tab.id }, "Runtime.enable"); |
(...skipping 20 matching lines...) Expand all Loading... |
40 | 41 |
41 chrome.test.getConfig(function(config) { | 42 chrome.test.getConfig(function(config) { |
42 var test_url = | 43 var test_url = |
43 'http://localhost:PORT/extensions/test_file.html' | 44 'http://localhost:PORT/extensions/test_file.html' |
44 .replace(/PORT/, config.testServer.port); | 45 .replace(/PORT/, config.testServer.port); |
45 | 46 |
46 chrome.tabs.create({ url: test_url }, injectScriptAndSendMessage); | 47 chrome.tabs.create({ url: test_url }, injectScriptAndSendMessage); |
47 }); | 48 }); |
48 } | 49 } |
49 ]); | 50 ]); |
OLD | NEW |