Roll src/third_party/WebKit d9c6159:8139f33 (svn 201974:201975)
[chromium-blink-merge.git] / chrome / test / data / extensions / api_test / window_open / spanning / background.js
blobf851f6334094b3bc8f28444abd429bc8b9c1a322
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
3 // found in the LICENSE file.
5 var nextTest = null;
6 openFromNormalShouldOpenInNormal();
8 function openFromNormalShouldOpenInNormal() {
9 nextTest = openFromExtensionHostInIncognitoBrowserShouldOpenInNormalBrowser;
10 chrome.windows.getAll({populate: true}, function(windows) {
11 chrome.test.assertEq(1, windows.length);
12 chrome.test.assertFalse(windows[0].incognito);
13 chrome.test.assertEq(1, windows[0].tabs.length);
14 chrome.test.assertFalse(windows[0].tabs[0].incognito);
16 chrome.windows.update(windows[0].id, {
17 focused: true
18 }, function() {
19 chrome.browserAction.openPopup(function(popupWindow) {
20 chrome.test.assertTrue(!!popupWindow);
21 // The rest of the test continues in popup.html.
22 });
23 });
24 });
27 function openFromExtensionHostInIncognitoBrowserShouldOpenInNormalBrowser() {
28 nextTest = null;
29 chrome.windows.getCurrent(function(normalWin) {
30 chrome.test.assertFalse(normalWin.incognito);
31 // Create an incognito window.
32 chrome.windows.create({
33 incognito: true,
34 focused: true
35 }, function(incognitoWin) {
36 // Remove the normal window. We keep running because of the incognito
37 // window.
38 chrome.windows.remove(normalWin.id, function() {
39 chrome.tabs.getAllInWindow(incognitoWin.id, function(tabs) {
40 chrome.test.assertEq(1, tabs.length);
41 chrome.browserAction.openPopup(function(popupWindow) {
42 chrome.test.assertTrue(!!popupWindow);
43 // The rest of the test continues in popup.html.
44 });
45 });
46 });
47 });
48 });
51 function verifyCreatedTab(tab) {
52 // The new tab should be a normal tab, and it should be in a normal
53 // window.
54 chrome.test.assertFalse(tab.incognito);
55 chrome.windows.get(tab.windowId, function(win) {
56 chrome.test.assertFalse(win.incognito);
57 if (nextTest) {
58 nextTest();
59 } else {
60 chrome.test.notifyPass();
62 });