Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / chrome / test / data / extensions / api_test / window_open / opener / test.js
blob73db0f8cfac57a4ddbd0fcbb58f69c884e061171
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 chrome.test.runTests([
6 // Tests that even though window.opener is not set when using
7 // chrome.windows.create directly, the same effect can be achieved by creating
8 // a window, giving it a name, and then targetting that window via
9 // window.open().
10 function checkOpener() {
11 // Make sure that we wait for the load callbacks to fire.
12 var testCompleted = chrome.test.callbackAdded();
13 var testWindowId;
15 window.onSetNameLoaded = function(testWindow) {
16 // It's not technically required for window.opener to be null when using
17 // chrome.windows.create, but that is the current expected behavior (and
18 // the reason why the window.name/open() workaround is necessary).
19 chrome.test.assertTrue(testWindow.opener == null);
20 window.open('check-opener.html', 'target-window');
23 window.onCheckOpenerLoaded = function(testWindow) {
24 // The opener should now be set...
25 chrome.test.assertTrue(testWindow.opener != null);
26 // ...and the test window should only have one tab (because it was
27 // targetted via the "target-window" name).
28 chrome.tabs.getAllInWindow(
29 testWindowId,
30 chrome.test.callbackPass(function(tabs) {
31 chrome.test.assertEq(1, tabs.length);
32 chrome.test.assertEq(
33 chrome.extension.getURL('check-opener.html'), tabs[0].url);
34 testCompleted();
35 }));
38 chrome.windows.create(
39 {'url': 'set-name.html'},
40 chrome.test.callbackPass(function(win) {
41 testWindowId = win.id;
42 }));
44 ]);