browser/base/content/test/newtab/browser_newtab_update.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 /* Any copyright is dedicated to the Public Domain.
     2    http://creativecommons.org/publicdomain/zero/1.0/ */
     4 /**
     5  * Checks that newtab is updated as its links change.
     6  */
     8 function runTests() {
     9   if (NewTabUtils.allPages.updateScheduledForHiddenPages) {
    10     // Wait for dynamic updates triggered by the previous test to finish.
    11     yield whenPagesUpdated(null, true);
    12   }
    14   // First, start with an empty page.  setLinks will trigger a hidden page
    15   // update because it calls clearHistory.  We need to wait for that update to
    16   // happen so that the next time we wait for a page update below, we catch the
    17   // right update and not the one triggered by setLinks.
    18   //
    19   // Why this weird way of yielding?  First, these two functions don't return
    20   // promises, they call TestRunner.next when done.  Second, the point at which
    21   // setLinks is done is independent of when the page update will happen, so
    22   // calling whenPagesUpdated cannot wait until that time.
    23   setLinks([]);
    24   whenPagesUpdated(null, true);
    25   yield null;
    26   yield null;
    28   // Strategy: Add some visits, open a new page, check the grid, repeat.
    29   fillHistory([link(1)]);
    30   yield whenPagesUpdated(null, true);
    31   yield addNewTabPageTab();
    32   checkGrid("1,,,,,,,,");
    34   fillHistory([link(2)]);
    35   yield whenPagesUpdated(null, true);
    36   yield addNewTabPageTab();
    37   checkGrid("2,1,,,,,,,");
    39   fillHistory([link(1)]);
    40   yield whenPagesUpdated(null, true);
    41   yield addNewTabPageTab();
    42   checkGrid("1,2,,,,,,,");
    44   // Wait for fillHistory to add all links before waiting for an update
    45   yield fillHistory([link(2), link(3), link(4)], TestRunner.next);
    46   yield whenPagesUpdated(null, true);
    47   yield addNewTabPageTab();
    48   checkGrid("2,1,3,4,,,,,");
    49 }
    51 function link(id) {
    52   return { url: "http://example.com/#" + id, title: "site#" + id };
    53 }

mercurial