| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 var panelWindowId = 0; | |
| 6 var panelLoaded = false; | |
| 7 | |
| 8 // This function is called by the panel during the test run. | |
| 9 function panelCallback() { | |
| 10 panelLoaded = true; | |
| 11 maybeReadyForTest(); | |
| 12 } | |
| 13 | |
| 14 function maybeReadyForTest() { | |
| 15 // The order of the two callbacks is not guaranteed. | |
| 16 if( panelWindowId === 0 || !panelLoaded) | |
| 17 return; | |
| 18 | |
| 19 // We have now added a panel so the total counts is 2 (browser + panel). | |
| 20 chrome.test.assertEq(2, chrome.extension.getViews().length); | |
| 21 // Verify that we're able to get the view of the panel by its window id. | |
| 22 chrome.test.assertEq(1, | |
| 23 chrome.extension.getViews({"windowId": panelWindowId}).length); | |
| 24 chrome.test.notifyPass(); | |
| 25 } | |
| 26 | |
| 27 chrome.test.runTests([ | |
| 28 function openPanel() { | |
| 29 chrome.test.listenOnce(chrome.windows.onCreated, function(window) { | |
| 30 chrome.test.assertTrue(window.width > 0); | |
| 31 chrome.test.assertTrue(window.height > 0); | |
| 32 chrome.test.assertEq("panel", window.type); | |
| 33 chrome.test.assertTrue(!window.incognito); | |
| 34 }); | |
| 35 chrome.windows.create( | |
| 36 { 'url': chrome.extension.getURL('panel.html'), 'type': 'panel' }, | |
| 37 function(win) { | |
| 38 chrome.test.assertEq('panel', win.type); | |
| 39 chrome.test.assertEq(true, win.alwaysOnTop); | |
| 40 panelWindowId = win.id; | |
| 41 // The panel will call back to us through panelCallback (above). | |
| 42 maybeReadyForTest(); | |
| 43 }); | |
| 44 } | |
| 45 ]); | |
| OLD | NEW |