diff options
author | mlamouri@chromium.org <mlamouri@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-12-04 11:48:17 +0000 |
---|---|---|
committer | mlamouri@chromium.org <mlamouri@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-12-04 11:48:17 +0000 |
commit | ff2a025a862f684c424cd7ed7b129e0a581f9cce (patch) | |
tree | 6647cf842a5c41d4723ce26b5bd030267270b8bc | |
parent | 8c59735fcc0830e0e60eddb5e76d3b10e67cec0e (diff) | |
download | chromium_src-ff2a025a862f684c424cd7ed7b129e0a581f9cce.zip chromium_src-ff2a025a862f684c424cd7ed7b129e0a581f9cce.tar.gz chromium_src-ff2a025a862f684c424cd7ed7b129e0a581f9cce.tar.bz2 |
Wait for the load event in TestRestoreAfterGeometrycacheChange.
BUG=324915
Review URL: https://codereview.chromium.org/100393008
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@238675 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/test/data/extensions/platform_apps/window_api/test.js | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/chrome/test/data/extensions/platform_apps/window_api/test.js b/chrome/test/data/extensions/platform_apps/window_api/test.js index 3000841..bae9e49 100644 --- a/chrome/test/data/extensions/platform_apps/window_api/test.js +++ b/chrome/test/data/extensions/platform_apps/window_api/test.js @@ -32,6 +32,22 @@ function eventLoopCheck(check, callback) { } } +// This help function will call the callback when the window passed to it will +// be loaded. The callback will have the AppWindow passed as a parameter. +function waitForLoad(win, callback) { + var window = win.contentWindow; + + if (window.document.readyState == 'complete') { + callback(win); + return; + } + + window.addEventListener('load', callbackPass(function() { + window.removeEventListener('load', arguments.callee); + callback(win); + })); +} + function testCreate() { chrome.test.runTests([ function basic() { @@ -328,7 +344,7 @@ function testRestoreAfterGeometryCacheChange() { function restorePositionAndSize() { chrome.app.window.create('test.html', { bounds: { left: 200, top: 200, width: 200, height: 200 }, id: 'test-ps', - }, callbackPass(function(win) { + }, callbackPass(function(win) { waitForLoad(win, function(win) { var w = win.contentWindow; // The fuzzy factor here is related to the fact that depending on the // platform, the bounds initialization will set the inner bounds or the @@ -346,18 +362,18 @@ function testRestoreAfterGeometryCacheChange() { win.onClosed.addListener(callbackPass(function() { chrome.app.window.create('test.html', { id: 'test-ps' - }, callbackPass(function(win) { + }, callbackPass(function(win) { waitForLoad(win, function(win) { var w = win.contentWindow; chrome.test.assertEq(100, w.screenX); chrome.test.assertEq(100, w.screenY); chrome.test.assertEq(300, w.outerWidth); chrome.test.assertEq(300, w.outerHeight); - })); + })})); })); win.close(); }); - })); + })})); }, ]); } |