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

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

Issue 11369039: Add setBounds method and browsertest for get/set bounds to app window API (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 1 month 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
(Empty)
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
3 // found in the LICENSE file.
4
5 function closeEnough(actual, expected, maxAllowedDifference) {
6 return Math.abs(actual - expected) < maxAllowedDifference;
7 }
8
9 function waitForBounds(expectedBounds, callback) {
10 function checkBounds() {
11 var bounds = chrome.app.window.current().getBounds();
12 if (closeEnough(bounds.left, expectedBounds.left, slop) &&
13 closeEnough(bounds.top, expectedBounds.top, slop) &&
14 closeEnough(bounds.width, expectedBounds.width, slop) &&
15 closeEnough(bounds.height, expectedBounds.height, slop)) {
16 callback();
17 } else {
18 setTimeout(checkBounds, 50);
jeremya 2012/11/02 05:06:41 Can you add a TODO here to rewrite when bounds cha
asargent_no_longer_on_chrome 2012/11/09 20:25:35 Done.
19 }
20 }
21 checkBounds();
22 }
23
24 var slop = 0;
25
26 chrome.test.sendMessage("ready", function(response) {
27 slop = parseInt(response);
28 waitForBounds({left:100, top:200, width:300, height:400}, function() {
29 var newBounds = {left:50, top:100, width:150, height:200};
30 chrome.app.window.current().setBounds(newBounds);
31 waitForBounds(newBounds, function(){
32 chrome.test.sendMessage("success");
33 });
34 });
35 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698