OLD | NEW |
| 1 <!-- |
| 2 * Copyright (c) 2011 The Chromium Authors. All rights reserved. Use of this |
| 3 * source code is governed by a BSD-style license that can be found in the |
| 4 * LICENSE file. |
| 5 --> |
1 <html> | 6 <html> |
2 <head> | 7 <head> |
3 <script> | 8 <script src="bg.js"></script> |
4 function fail() { | |
5 window.domAutomationController.send(false); | |
6 throw "Failed!"; | |
7 } | |
8 | |
9 function succeed() { | |
10 window.domAutomationController.send(true); | |
11 } | |
12 | |
13 function testLastError() { | |
14 // Make sure lastError is not yet set | |
15 if (chrome.tabs.lastError) | |
16 fail(); | |
17 | |
18 var maxTabId = 0; | |
19 | |
20 // Find the highest tab id | |
21 chrome.windows.getAll({populate:true}, function(windows) { | |
22 // Make sure lastError is still not set. (this call have should succeeded). | |
23 if (chrome.tabs.lastError) | |
24 fail(); | |
25 | |
26 for (var i = 0; i < windows.length; i++) { | |
27 var win = windows[i]; | |
28 for (var j = 0; j < win.tabs.length; j++) { | |
29 var tab = win.tabs[j]; | |
30 if (tab.id > maxTabId) | |
31 maxTabId = tab.id; | |
32 } | |
33 } | |
34 | |
35 // Now ask for the next highest tabId. | |
36 chrome.tabs.get(maxTabId + 1, function(tab) { | |
37 // Make sure lastError *is* set and tab is not. | |
38 if (!chrome.extension.lastError || | |
39 !chrome.extension.lastError.message || | |
40 tab) | |
41 fail(); | |
42 | |
43 window.setTimeout(finish, 10); | |
44 }); | |
45 }); | |
46 } | |
47 | |
48 function finish() { | |
49 // Now make sure lastError is unset outside the callback context. | |
50 if (chrome.tabs.lastError) | |
51 fail(); | |
52 | |
53 succeed(); | |
54 } | |
55 </script> | |
56 </head> | 9 </head> |
57 <body> | 10 <body> |
58 <div onclick="testLastError();"> Last Error Test </div> | 11 <div> Last Error Test </div> |
59 </body> | 12 </body> |
60 </html> | 13 </html> |
61 | 14 |
OLD | NEW |