"Fossies" - the Fresh Open Source Software Archive

Member "selenium-selenium-4.8.1/javascript/atoms/test/window_scroll_test.html" (17 Feb 2023, 1566 Bytes) of package /linux/www/selenium-selenium-4.8.1.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) HTML source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file.

    1 <!DOCTYPE html>
    2 <html>
    3 <head>
    4   <title>window_scroll_test</title>
    5   <script src="test_bootstrap.js" type="text/javascript"></script>
    6   <script type="text/javascript">
    7     goog.require('bot.userAgent');
    8     goog.require('bot.window');
    9     goog.require('goog.Promise');
   10     goog.require('goog.math.Coordinate');
   11     goog.require('goog.testing.jsunit');
   12   </script>
   13   <script type="text/javascript">
   14     function verifyScroll(expectedScroll) {
   15       var actualScroll = bot.window.getScroll();
   16       assertEquals(expectedScroll.x, actualScroll.x);
   17       assertEquals(expectedScroll.y, actualScroll.y);
   18     }
   19 
   20     function testScrolling() {
   21       // Initial page scroll should be (0, 0).
   22       var pos = bot.window.getScroll();
   23       verifyScroll(new goog.math.Coordinate(0, 0));
   24 
   25       pos = new goog.math.Coordinate(25, 50);
   26       bot.window.setScroll(pos);
   27 
   28       // Yield to ensure all browsers apply the scrolling change.
   29       // Relying on the implicit tick in a promise resolution is enough.
   30       return goog.Promise.resolve().then(function() {
   31         // For some reason Android stock browser and webview do not apply
   32         // the full scroll.
   33         if (goog.userAgent.product.ANDROID) {
   34           pos = new goog.math.Coordinate(24, 48);
   35         }
   36         verifyScroll(pos);
   37       });
   38     }
   39 
   40     function testSetScrollUsingGetScroll() {
   41       var pos = bot.window.getScroll();
   42       bot.window.setScroll(pos);
   43       verifyScroll(pos);
   44     }
   45   </script>
   46 </head>
   47 <body style="width: 8000px; height: 8000px; padding: 0px;margin: 0px;">
   48   Hello
   49 </body>
   50 </html>