Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(93)

Side by Side Diff: chrome/test/data/extensions/api_test/window_open/opener/test.html

Issue 8775046: Convert another batch of extension tests to manifest_version 2 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 <script> 1 <!--
2 chrome.test.runTests([ 2 * Copyright (c) 2011 The Chromium Authors. All rights reserved. Use of this
3 // Tests that even though window.opener is not set when using 3 * source code is governed by a BSD-style license that can be found in the
4 // chrome.windows.create directly, the same effect can be achieved by creating 4 * LICENSE file.
5 // a window, giving it a name, and then targetting that window via 5 -->
6 // window.open(). 6 <script src="test.js"></script>
7 function checkOpener() {
8 // Make sure that we wait for the load callbacks to fire.
9 var testCompleted = chrome.test.callbackAdded();
10 var testWindowId;
11
12 window.onSetNameLoaded = function(testWindow) {
13 // It's not technically required for window.opener to be null when using
14 // chrome.windows.create, but that is the current expected behavior (and
15 // the reason why the window.name/open() workaround is necessary).
16 chrome.test.assertTrue(testWindow.opener == null);
17 window.open('check-opener.html', 'target-window');
18 };
19
20 window.onCheckOpenerLoaded = function(testWindow) {
21 // The opener should now be set...
22 chrome.test.assertTrue(testWindow.opener != null);
23 // ...and the test window should only have one tab (because it was
24 // targetted via the "target-window" name).
25 chrome.tabs.getAllInWindow(
26 testWindowId,
27 chrome.test.callbackPass(function(tabs) {
28 chrome.test.assertEq(1, tabs.length);
29 chrome.test.assertEq(
30 chrome.extension.getURL('check-opener.html'), tabs[0].url);
31 testCompleted();
32 }));
33 };
34
35 chrome.windows.create(
36 {'url': 'set-name.html'},
37 chrome.test.callbackPass(function(win) {
38 testWindowId = win.id;
39 }));
40 }
41 ]);
42 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698