| <!DOCTYPE html> |
| <html> |
| <head> |
| <meta charset="utf-8"> |
| <title>window_scroll_test</title> |
| <link rel="stylesheet" href="/filez/_main/third_party/js/qunit/qunit.css"> |
| <script src="/filez/_main/third_party/js/qunit/qunit.js"></script> |
| <script src="/filez/_main/third_party/js/qunit/qunit_test_runner.js"></script> |
| <script src="test_bootstrap.js" type="text/javascript"></script> |
| <script type="text/javascript"> |
| goog.require('bot.userAgent'); |
| goog.require('bot.window'); |
| goog.require('goog.Promise'); |
| goog.require('goog.math.Coordinate'); |
| </script> |
| <script type="text/javascript"> |
| function verifyScroll(assert, expectedScroll) { |
| var actualScroll = bot.window.getScroll(); |
| assert.strictEqual(actualScroll.x, expectedScroll.x); |
| assert.strictEqual(actualScroll.y, expectedScroll.y); |
| } |
| |
| QUnit.test('scrolling', function(assert) { |
| var done = assert.async(); |
| // Initial page scroll should be (0, 0). |
| var pos = bot.window.getScroll(); |
| verifyScroll(assert, new goog.math.Coordinate(0, 0)); |
| |
| pos = new goog.math.Coordinate(25, 50); |
| bot.window.setScroll(pos); |
| |
| // Yield to ensure all browsers apply the scrolling change. |
| // Relying on the implicit tick in a promise resolution is enough. |
| goog.Promise.resolve().then(function() { |
| // For some reason Android stock browser and webview do not apply |
| // the full scroll. |
| if (goog.userAgent.product.ANDROID) { |
| pos = new goog.math.Coordinate(24, 48); |
| } |
| verifyScroll(assert, pos); |
| done(); |
| }); |
| }); |
| |
| QUnit.test('setScrollUsingGetScroll', function(assert) { |
| var pos = bot.window.getScroll(); |
| bot.window.setScroll(pos); |
| verifyScroll(assert, pos); |
| }); |
| </script> |
| </head> |
| <body style="width: 8000px; height: 8000px; padding: 0px;margin: 0px;"> |
| <div id="qunit"></div> |
| <div id="qunit-fixture"></div> |
| Hello |
| </body> |
| </html> |