OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 // API test for chrome.extension.infobars. | 5 // API test for chrome.extension.infobars. |
6 // browser_tests.exe --gtest_filter=ExtensionApiTest.Infobars | 6 // browser_tests.exe --gtest_filter=ExtensionApiTest.Infobars |
7 | 7 |
8 const assertEq = chrome.test.assertEq; | 8 const assertEq = chrome.test.assertEq; |
9 | 9 |
10 var windowA = 0; | 10 var windowA = 0; |
(...skipping 12 matching lines...) Expand all Loading... |
23 tabA = tab.id; | 23 tabA = tab.id; |
24 windowA = tab.windowId; | 24 windowA = tab.windowId; |
25 console.log('tabid: ' + tabA + ' windowA: ' + windowA); | 25 console.log('tabid: ' + tabA + ' windowA: ' + windowA); |
26 | 26 |
27 chrome.windows.create({"url": "about:blank"}, function(window) { | 27 chrome.windows.create({"url": "about:blank"}, function(window) { |
28 windowB = window.id; | 28 windowB = window.id; |
29 console.log('windowB: ' + windowB); | 29 console.log('windowB: ' + windowB); |
30 | 30 |
31 // Show infobarA in window A (tab A) (and specify no callback). | 31 // Show infobarA in window A (tab A) (and specify no callback). |
32 chrome.experimental.infobars.show({"path": "infobarA.html", | 32 chrome.experimental.infobars.show({"path": "infobarA.html", |
33 "tabId": tabA}); | 33 "tabId": tabA, |
| 34 "height": 36}); |
34 // Flow continues in infobarCallbackA. | 35 // Flow continues in infobarCallbackA. |
35 }); | 36 }); |
36 }); | 37 }); |
37 } | 38 } |
38 ]; | 39 ]; |
39 | 40 |
40 function infobarCallbackA() { | 41 function infobarCallbackA() { |
41 // We have now added an infobar so the total count goes up one. | 42 // We have now added an infobar so the total count goes up one. |
42 assertEq(2, chrome.extension.getViews().length); | 43 assertEq(2, chrome.extension.getViews().length); |
43 assertEq(1, chrome.extension.getViews({"type": "infobar"}).length); | 44 assertEq(1, chrome.extension.getViews({"type": "infobar"}).length); |
44 // Window A should have 1 infobar. | 45 // Window A should have 1 infobar. |
45 assertEq(1, chrome.extension.getViews({"type": "infobar", | 46 assertEq(1, chrome.extension.getViews({"type": "infobar", |
46 "windowId": windowA}).length); | 47 "windowId": windowA}).length); |
47 // Window B should have no infobars. | 48 // Window B should have no infobars. |
48 assertEq(0, chrome.extension.getViews({"type": "infobar", | 49 assertEq(0, chrome.extension.getViews({"type": "infobar", |
49 "windowId": windowB}).length); | 50 "windowId": windowB}).length); |
50 | 51 |
51 chrome.tabs.getAllInWindow(windowB, function(tabs) { | 52 chrome.tabs.getAllInWindow(windowB, function(tabs) { |
52 assertEq(1, tabs.length); | 53 assertEq(1, tabs.length); |
53 tabB = tabs[0].id; | 54 tabB = tabs[0].id; |
54 | 55 |
55 // Show infobarB in (current) window B (with callback). | 56 // Show infobarB in (current) window B (with callback). |
56 chrome.experimental.infobars.show({"path": "infobarB.html", | 57 chrome.experimental.infobars.show({"path": "infobarB.html", |
57 "tabId": tabB}, | 58 "tabId": tabB, |
| 59 "height": 36}, |
58 function(window) { | 60 function(window) { |
59 assertEq(window.id, windowB); | 61 assertEq(window.id, windowB); |
60 // This infobar will call back to us through infobarCallbackB (below). | 62 // This infobar will call back to us through infobarCallbackB (below). |
61 }); | 63 }); |
62 }); | 64 }); |
63 } | 65 } |
64 | 66 |
65 function infobarCallbackB() { | 67 function infobarCallbackB() { |
66 // We have now added an infobar so the total count goes up one. | 68 // We have now added an infobar so the total count goes up one. |
67 assertEq(3, chrome.extension.getViews().length); | 69 assertEq(3, chrome.extension.getViews().length); |
68 assertEq(2, chrome.extension.getViews({"type": "infobar"}).length); | 70 assertEq(2, chrome.extension.getViews({"type": "infobar"}).length); |
69 | 71 |
70 // Window A should have 1 infobar. | 72 // Window A should have 1 infobar. |
71 assertEq(1, chrome.extension.getViews({"type": "infobar", | 73 assertEq(1, chrome.extension.getViews({"type": "infobar", |
72 "windowId": windowA}).length); | 74 "windowId": windowA}).length); |
73 // Window B should have 1 infobar. | 75 // Window B should have 1 infobar. |
74 assertEq(1, chrome.extension.getViews({"type": "infobar", | 76 assertEq(1, chrome.extension.getViews({"type": "infobar", |
75 "windowId": windowB}).length); | 77 "windowId": windowB}).length); |
76 | 78 |
77 chrome.test.notifyPass(); | 79 chrome.test.notifyPass(); |
78 } | 80 } |
79 | 81 |
80 chrome.test.runTests(tests); | 82 chrome.test.runTests(tests); |
OLD | NEW |