| OLD | NEW |
| 1 // Copyright (c) 2012 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.getViews. | 5 // API test for chrome.extension.getViews. |
| 6 // browser_tests.exe --gtest_filter=ExtensionApiTest.GetViews | 6 // browser_tests.exe --gtest_filter=ExtensionApiTest.GetViews |
| 7 | 7 |
| 8 const assertEq = chrome.test.assertEq; | 8 const assertEq = chrome.test.assertEq; |
| 9 const assertTrue = chrome.test.assertTrue; | 9 const assertTrue = chrome.test.assertTrue; |
| 10 | 10 |
| 11 // This function is called by the infobar during the test run. | 11 // This function is called by the infobar during the test run. |
| (...skipping 19 matching lines...) Expand all Loading... |
| 31 chrome.test.notifyPass(); | 31 chrome.test.notifyPass(); |
| 32 } | 32 } |
| 33 | 33 |
| 34 var tests = [ | 34 var tests = [ |
| 35 function getViews() { | 35 function getViews() { |
| 36 assertTrue(typeof(chrome.extension.getBackgroundPage()) != "undefined"); | 36 assertTrue(typeof(chrome.extension.getBackgroundPage()) != "undefined"); |
| 37 assertEq(1, chrome.extension.getViews().length); | 37 assertEq(1, chrome.extension.getViews().length); |
| 38 assertEq(0, chrome.extension.getViews({"type": "tab"}).length); | 38 assertEq(0, chrome.extension.getViews({"type": "tab"}).length); |
| 39 assertEq(0, chrome.extension.getViews({"type": "infobar"}).length); | 39 assertEq(0, chrome.extension.getViews({"type": "infobar"}).length); |
| 40 assertEq(0, chrome.extension.getViews({"type": "notification"}).length); | 40 assertEq(0, chrome.extension.getViews({"type": "notification"}).length); |
| 41 | 41 |
| 42 chrome.windows.getAll({populate: true}, function(windows) { | 42 chrome.windows.getAll({populate: true}, function(windows) { |
| 43 assertEq(1, windows.length); | 43 assertEq(1, windows.length); |
| 44 | 44 |
| 45 // Show an infobar. | 45 // Show an infobar. |
| 46 chrome.experimental.infobars.show({tabId: windows[0].tabs[0].id, | 46 chrome.experimental.infobars.show({tabId: windows[0].tabs[0].id, |
| 47 "path": "infobar.html"}, | 47 "path": "infobar.html"}, |
| 48 function(window) { | 48 function(window) { |
| 49 assertTrue(window.id > 0); | 49 assertTrue(window.id > 0); |
| 50 // The infobar will call back to us through infobarCallback (above). | 50 // The infobar will call back to us through infobarCallback (above). |
| 51 }); | 51 }); |
| 52 | 52 |
| 53 }); | 53 }); |
| 54 } | 54 } |
| 55 ]; | 55 ]; |
| 56 | 56 |
| 57 chrome.test.runTests(tests); | 57 chrome.test.runTests(tests); |
| OLD | NEW |