| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 fail() { | 5 function fail() { |
| 6 window.domAutomationController.send(false); | 6 window.domAutomationController.send(false); |
| 7 throw "Failed!"; | 7 throw "Failed!"; |
| 8 } | 8 } |
| 9 | 9 |
| 10 function succeed() { | 10 function succeed() { |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 for (var j = 0; j < win.tabs.length; j++) { | 29 for (var j = 0; j < win.tabs.length; j++) { |
| 30 var tab = win.tabs[j]; | 30 var tab = win.tabs[j]; |
| 31 if (tab.id > maxTabId) | 31 if (tab.id > maxTabId) |
| 32 maxTabId = tab.id; | 32 maxTabId = tab.id; |
| 33 } | 33 } |
| 34 } | 34 } |
| 35 | 35 |
| 36 // Now ask for the next highest tabId. | 36 // Now ask for the next highest tabId. |
| 37 chrome.tabs.get(maxTabId + 1, function(tab) { | 37 chrome.tabs.get(maxTabId + 1, function(tab) { |
| 38 // Make sure lastError *is* set and tab is not. | 38 // Make sure lastError *is* set and tab is not. |
| 39 if (!chrome.extension.lastError || | 39 if (!chrome.runtime.lastError || |
| 40 !chrome.extension.lastError.message || | 40 !chrome.runtime.lastError.message || |
| 41 tab) | 41 tab) |
| 42 fail(); | 42 fail(); |
| 43 | 43 |
| 44 window.setTimeout(finish, 10); | 44 window.setTimeout(finish, 10); |
| 45 }); | 45 }); |
| 46 }); | 46 }); |
| 47 } | 47 } |
| 48 | 48 |
| 49 function finish() { | 49 function finish() { |
| 50 // Now make sure lastError is unset outside the callback context. | 50 // Now make sure lastError is unset outside the callback context. |
| 51 if (chrome.tabs.lastError) | 51 if (chrome.tabs.lastError) |
| 52 fail(); | 52 fail(); |
| 53 | 53 |
| 54 succeed(); | 54 succeed(); |
| 55 } | 55 } |
| 56 | 56 |
| 57 document.documentElement.addEventListener("click", function() { | 57 document.documentElement.addEventListener("click", function() { |
| 58 testLastError(); | 58 testLastError(); |
| 59 }, true); | 59 }, true); |
| OLD | NEW |