- add sources.
[platform/framework/web/crosswalk.git] / src / chrome / test / data / extensions / api_test / window_update / sizing / test.js
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.
4
5 var pass = chrome.test.callbackPass;
6
7 var finalTop = 400;
8 var finalLeft = 10;
9 var finalWidth = 476
10 var finalHeight = 301;
11
12 var chromeWindow = null;
13
14 function checkTop(currentWindow) {
15   chrome.test.assertEq(finalTop, currentWindow.top);
16 }
17
18 function checkHeightAndContinue(currentWindow) {
19   chrome.test.assertEq(finalHeight, currentWindow.height);
20   chrome.windows.update(
21     currentWindow.id, { 'top': finalTop },
22     pass(checkTop)
23   );
24 }
25
26 function checkWidthAndContinue(currentWindow) {
27   chrome.test.assertEq(finalWidth, currentWindow.width);
28   chrome.windows.update(
29     currentWindow.id, { 'height': finalHeight },
30     pass(checkHeightAndContinue)
31   );
32 }
33
34 function checkLeftAndContinue(currentWindow) {
35   chrome.test.assertEq(finalLeft, currentWindow.left);
36   chrome.windows.update(
37     currentWindow.id, { 'width': finalWidth },
38     pass(checkWidthAndContinue)
39   );
40 }
41
42 function updateLeftAndContinue(tab) {
43   chrome.windows.update(
44     chromeWindow.id, { 'left': finalLeft},
45     pass(checkLeftAndContinue)
46   );
47 }
48
49 chrome.test.runTests([
50   function setResizeWindow() {
51     chrome.windows.getCurrent(
52       pass(function(currentWindow) {
53         chromeWindow = currentWindow;
54         chrome.tabs.create(
55           { 'windowId': currentWindow.id, 'url': 'blank.html' },
56           pass(updateLeftAndContinue)
57         );
58     }));
59   },
60 ]);