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

Side by Side Diff: chrome/test/data/extensions/platform_apps/windows_api/test.js

Issue 10910304: Cache the object given to the chrome.app.window.create callback (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: rebase to r157512 (conflicts) Created 8 years, 3 months 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 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 var callbackPass = chrome.test.callbackPass; 5 var callbackPass = chrome.test.callbackPass;
6 6
7 chrome.app.runtime.onLaunched.addListener(function() { 7 chrome.app.runtime.onLaunched.addListener(function() {
8 chrome.test.runTests([ 8 chrome.test.runTests([
9 function testCreateWindow() { 9 function testCreateWindow() {
10 chrome.app.window.create('test.html', {}, callbackPass(function (win) { 10 chrome.app.window.create('test.html',
11 {id: 'testId'},
12 callbackPass(function (win) {
11 chrome.test.assertTrue(typeof win.contentWindow.window === 'object'); 13 chrome.test.assertTrue(typeof win.contentWindow.window === 'object');
12 chrome.test.assertEq('about:blank', win.contentWindow.location.href); 14 chrome.test.assertEq('about:blank', win.contentWindow.location.href);
13 chrome.test.assertEq('<html><head></head><body></body></html>', 15 chrome.test.assertEq('<html><head></head><body></body></html>',
14 win.contentWindow.document.documentElement.outerHTML); 16 win.contentWindow.document.documentElement.outerHTML);
15 })) 17 var cw = win.contentWindow.chrome.app.window.current();
18 chrome.test.assertEq(cw, win);
19 chrome.test.assertEq('testId', cw.id);
20 }));
21 },
22
23 function testCreateMultiWindow() {
24 chrome.test.assertTrue(null === chrome.app.window.current());
25 chrome.app.window.create('test.html',
26 {id: 'testId1'},
27 callbackPass(function (win1) {
28 chrome.app.window.create('test.html',
29 {id: 'testId2'},
30 callbackPass(function (win2) {
31 var cw1 = win1.contentWindow.chrome.app.window.current();
32 var cw2 = win2.contentWindow.chrome.app.window.current();
33 chrome.test.assertEq('testId1', cw1.id);
34 chrome.test.assertEq('testId2', cw2.id);
35 chrome.test.assertTrue(cw1 === win1);
36 chrome.test.assertTrue(cw2 === win2);
37 chrome.test.assertFalse(cw1 === cw2);
38 }));
39 }));
16 }, 40 },
17 41
18 function testUpdateWindowWidth() { 42 function testUpdateWindowWidth() {
19 chrome.app.window.create('test.html', 43 chrome.app.window.create('test.html',
20 {width:512, height:384, frame:'custom'}, 44 {width:512, height:384, frame:'custom'},
21 callbackPass(function(win) { 45 callbackPass(function(win) {
22 chrome.test.assertEq(512, win.contentWindow.innerWidth); 46 chrome.test.assertEq(512, win.contentWindow.innerWidth);
23 chrome.test.assertEq(384, win.contentWindow.innerHeight); 47 chrome.test.assertEq(384, win.contentWindow.innerHeight);
24 var oldWidth = win.contentWindow.outerWidth; 48 var oldWidth = win.contentWindow.outerWidth;
25 var oldHeight = win.contentWindow.outerHeight; 49 var oldHeight = win.contentWindow.outerHeight;
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 chrome.test.assertEq(oldHeight, win.innerHeight); 85 chrome.test.assertEq(oldHeight, win.innerHeight);
62 }); 86 });
63 }) 87 })
64 win.chrome.app.window.restore(); 88 win.chrome.app.window.restore();
65 }); 89 });
66 win.chrome.app.window.maximize(); 90 win.chrome.app.window.maximize();
67 })); 91 }));
68 },*/ 92 },*/
69 ]); 93 ]);
70 }); 94 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698